2023-04-29 20:13:37 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using DG.Tweening;
|
2023-04-29 21:50:24 +00:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2023-04-29 20:13:37 +00:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2023-04-30 11:23:57 +00:00
|
|
|
|
Sounds.PlaySound(0);
|
2023-04-29 20:13:37 +00:00
|
|
|
|
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")
|
|
|
|
|
{
|
2023-04-30 11:23:57 +00:00
|
|
|
|
Sounds.PlaySound(1);
|
2023-04-29 20:13:37 +00:00
|
|
|
|
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;
|
2023-04-29 21:50:24 +00:00
|
|
|
|
//FindObjectOfType<M<>ntideLugeja>().AnnaM<61>nte(m<>ntideArv);
|
2023-04-29 20:13:37 +00:00
|
|
|
|
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();
|
2023-04-29 21:50:24 +00:00
|
|
|
|
seq.Append(m<EFBFBD>nt.transform.DOMove(m<EFBFBD>ndiMinekuAsukoht.position, 0.3f + (i * 0.1f)).SetEase(Ease.InOutQuad));
|
2023-04-29 20:13:37 +00:00
|
|
|
|
var tf = m<EFBFBD>nt.AddComponent<TargetFollower>();
|
2023-04-29 21:50:24 +00:00
|
|
|
|
//tf.kiirus = 2f + i * (1f);
|
|
|
|
|
//tf.kasi = m<>ndiMinekuAsukoht;
|
|
|
|
|
//tf.kaesolevAsi = m<>nt.transform;
|
2023-04-29 20:13:37 +00:00
|
|
|
|
//seq.Append(m<>nt.transform.DOScale(Vector3.one, i).SetEase(Ease.InOutQuad));
|
2023-04-29 21:50:24 +00:00
|
|
|
|
seq.Append(m<EFBFBD>nt.transform.DOShakeRotation(0.2f).SetEase(Ease.InOutQuad).OnStart(() => {
|
|
|
|
|
tf.kiirus = 10f;
|
|
|
|
|
tf.kasi = m<EFBFBD>ndiMinekuAsukoht;
|
|
|
|
|
tf.kaesolevAsi = m<EFBFBD>nt.transform;
|
|
|
|
|
}));
|
2023-04-30 11:23:57 +00:00
|
|
|
|
seq.OnComplete(() => { Destroy(m<EFBFBD>nt); FindObjectOfType<M<EFBFBD>ntideLugeja>().AnnaM<EFBFBD>nte(1); Sounds.PlaySound(1); });
|
2023-04-29 20:13:37 +00:00
|
|
|
|
}
|
2023-04-30 11:23:57 +00:00
|
|
|
|
}
|
|
|
|
|
else if (other.tag == "win")
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.SceneManagement.SceneManager.LoadScene(3);
|
2023-04-29 20:13:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Surm()
|
|
|
|
|
{
|
2023-04-29 21:50:24 +00:00
|
|
|
|
FindObjectOfType<M<EFBFBD>ntideLugeja>().Nulli();
|
2023-04-30 11:23:57 +00:00
|
|
|
|
SceneManager.LoadScene(2);
|
2023-04-29 20:13:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|