48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UIElements;
|
||
|
|
|
||
|
|
public class SimpleNiddleMove : MonoBehaviour
|
||
|
|
{
|
||
|
|
public float speed = 1f;
|
||
|
|
public float direction = -1;
|
||
|
|
public float isup = 0;
|
||
|
|
public float rotate = 0f;
|
||
|
|
[SerializeField] private GameObject sprite;
|
||
|
|
[SerializeField] private GameObject player;
|
||
|
|
[SerializeField] private GameObject line;
|
||
|
|
[SerializeField] private GameObject exmark;
|
||
|
|
|
||
|
|
private void Start()
|
||
|
|
{
|
||
|
|
if (isup == 0)
|
||
|
|
{
|
||
|
|
rotate = -90 + (direction * 90);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
rotate = -90 + (direction * -45);
|
||
|
|
}
|
||
|
|
gameObject.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, rotate));
|
||
|
|
}
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
gameObject.transform.position += new Vector3(speed * Time.deltaTime * direction, speed * isup * Time.deltaTime, 0f);
|
||
|
|
}
|
||
|
|
void OnTriggerEnter2D(Collider2D collider)
|
||
|
|
{
|
||
|
|
if (collider.CompareTag("Enemy"))
|
||
|
|
{
|
||
|
|
//collider.GetComponent<SimpleExActive>().isex = true;
|
||
|
|
GameObject niddle = Instantiate(sprite, collider.transform);
|
||
|
|
player.gameObject.GetComponent<SimpleExcution>().gbs.Add(collider.gameObject);
|
||
|
|
GameObject Line = Instantiate(line);
|
||
|
|
Line.GetComponent<SimpleLineRender>().player = player.transform;
|
||
|
|
Line.GetComponent<SimpleLineRender>().target = collider.transform;
|
||
|
|
collider.transform.GetComponent<SpriteRenderer>().color = Color.red;
|
||
|
|
GameObject mark = Instantiate(exmark, collider.transform);
|
||
|
|
mark.transform.position = collider.transform.position + new Vector3(0f, 0.5f, 0f);
|
||
|
|
Destroy(gameObject);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|