115 lines
3.4 KiB
C#
115 lines
3.4 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using DG.Tweening;
|
|||
|
|
|||
|
public class player : MonoBehaviour
|
|||
|
{
|
|||
|
[SerializeField] private GameObject m<EFBFBD>ndiEffekt;
|
|||
|
|
|||
|
public Transform m<EFBFBD>ndiMinekuAsukoht;
|
|||
|
|
|||
|
private bool lendab;
|
|||
|
|
|||
|
public ForceMode forcemode;
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
if (Input.GetKey(KeyCode.W))
|
|||
|
{
|
|||
|
transform.rotation = Quaternion.Euler(0, 360, 0);
|
|||
|
}
|
|||
|
if (Input.GetKey(KeyCode.S))
|
|||
|
{
|
|||
|
transform.rotation = Quaternion.Euler(0, 180, 0);
|
|||
|
}
|
|||
|
|
|||
|
if (Input.GetKeyDown(KeyCode.Space) & !lendab)
|
|||
|
{
|
|||
|
GetComponent<Rigidbody>().AddForce(new Vector3(0, 2000), forcemode);
|
|||
|
lendab = true;
|
|||
|
//transform.position += new Vector3(0, 20) * Time.deltaTime;
|
|||
|
}
|
|||
|
|
|||
|
if (Input.GetKey(KeyCode.D))
|
|||
|
{
|
|||
|
transform.position += new Vector3(20, 0) * Time.deltaTime;
|
|||
|
transform.rotation = Quaternion.Euler(0, 90, 0);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (Input.GetKey(KeyCode.A))
|
|||
|
{
|
|||
|
transform.position += new Vector3(-20, 0) * Time.deltaTime;
|
|||
|
transform.rotation = Quaternion.Euler(0, 270, 0);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
private bool kasLendab() {
|
|||
|
if (gameObject.transform.position.y <= 1143.05)
|
|||
|
return lendab = false;
|
|||
|
else
|
|||
|
return lendab = true;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
public void OnCollisionEnter(Collision collision)
|
|||
|
{
|
|||
|
if(collision.gameObject.tag == "Ground")
|
|||
|
{
|
|||
|
lendab = false;
|
|||
|
|
|||
|
}
|
|||
|
Debug.Log(collision);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnTriggerEnter(Collider other)
|
|||
|
{
|
|||
|
if (other.tag == "kast")
|
|||
|
{
|
|||
|
var targetFollower = GetComponent<TargetFollower>();
|
|||
|
targetFollower.kaesolevAsi = other.gameObject.transform;
|
|||
|
targetFollower.kaesolevAsi.DOScale(Vector3.one * 0.4f, 1f);
|
|||
|
targetFollower.kaesolevAsi.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
|
|||
|
}
|
|||
|
else if (other.tag == "npc")
|
|||
|
{
|
|||
|
var targetFollower = GetComponent<TargetFollower>();
|
|||
|
if (targetFollower.kaesolevAsi == null) return;
|
|||
|
var m<EFBFBD>ntideArv = targetFollower.kaesolevAsi.GetComponent<Kast>().m<EFBFBD>ntideArv;
|
|||
|
FindObjectOfType<M<EFBFBD>ntideLugeja>().AnnaM<EFBFBD>nte(m<EFBFBD>ntideArv);
|
|||
|
Destroy(targetFollower.kaesolevAsi.gameObject);
|
|||
|
|
|||
|
for (var i = 0; i < m<EFBFBD>ntideArv; i++)
|
|||
|
{
|
|||
|
var m<EFBFBD>nt = Instantiate(m<EFBFBD>ndiEffekt, transform.position, Quaternion.identity);
|
|||
|
//m<>nt.transform.localScale = Vector3.zero;
|
|||
|
var seq = DOTween.Sequence();
|
|||
|
seq.Append(m<EFBFBD>nt.transform.DOScale(Vector3.one, i).SetEase(Ease.InOutQuad));
|
|||
|
var tf = m<EFBFBD>nt.AddComponent<TargetFollower>();
|
|||
|
tf.kiirus = 5f - i * (0.5f);
|
|||
|
tf.kasi = m<EFBFBD>ndiMinekuAsukoht;
|
|||
|
tf.kaesolevAsi = m<EFBFBD>nt.transform;
|
|||
|
Destroy(m<EFBFBD>nt, 5f - i * (0.5f));
|
|||
|
//seq.Append(m<>nt.transform.DOScale(Vector3.one, i).SetEase(Ease.InOutQuad));
|
|||
|
//seq.Append(m<>nt.transform.DOScale(Vector3.zero, i).SetEase(Ease.InOutQuad)).OnComplete(() => { Destroy(m<>nt); });
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Surm()
|
|||
|
{
|
|||
|
|
|||
|
transform.position = new Vector3(-78, 1138, 0);
|
|||
|
}
|
|||
|
|
|||
|
}
|