104 lines
2.2 KiB
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "Dun_Snake" company="Kimch"></copyright>
// <summary></summary>
// ***********************************************************************
namespace G
{
using UnityEngine;
public class Dun_Snake : MonoBehaviour
{
private Animation _animation;
private Vector3 _startPos;
private Vector3 _targetPos;
private float _delay = 3f;
private float _speed;
public Transform holes;
public Transform trap1;
public Transform trap2;
private EntityTrap script_trap1;
private EntityTrap script_trap2;
private void Awake()
{
_animation = this.GetComponent<Animation>();
_animation["snake_move"].speed = 0.3f;
script_trap1 = trap1.GetComponent<EntityTrap>();
script_trap2 = trap2.GetComponent<EntityTrap>();
}
private void OnEnable()
{
}
private void Start()
{
transform.position = Vector3.up * 25f;
_delay = 2f;
}
public void FisnishShoot()
{
_animation.Stop();
}
public void SetDamage(int _damage)
{
script_trap1.SetDamage(_damage);
script_trap2.SetDamage(_damage);
}
public void StartShoot()
{
_delay = Random.Range(2f, 3.6f);
int num = Random.Range(0, 7);
_startPos = holes.GetChild(num).position;
int num2 = 0;
if (num == 0)
{
num2 = Random.Range(1, 7);
}
else
{
int num3 = Random.Range(0, 5);
num2 = ((num3 != 0) ? ((num3 % 2 != 0) ? ((num - 1) % 7) : ((num + 1) % 7)) : 0);
}
_targetPos = holes.GetChild(num2).position;
Vector3 forward = _startPos - _targetPos;
transform.position = _startPos;
transform.forward = forward;
_animation.Play("snake_move");
script_trap1.DirectFire(_startPos);
trap1.GetChild(0).particleEmitter().emit = true;
Invoke(nameof(PtOn2), 0.6f);
}
private void PtOn2()
{
script_trap2.DirectFire(_targetPos);
trap2.GetChild(0).particleEmitter().emit = true;
}
private void Update()
{
}
}
}