示例#1
0
        private IEnumerator Die()
        {
            _isDead = true;
            UnitEventManager.TriggerEvent("unitDeath", this);
            _animator.SetTrigger(Dead);

            var unitTransform = transform;

            // var startRotation = unitTransform.rotation;
            // var endRotation = Quaternion.Euler(new Vector3(0, 0, 90)) * startRotation;

            var startPosition = unitTransform.position;
            var endPosition   = startPosition - new Vector3(0, 3f, 0);

            // const int rotateDuration = 1;
            // const int sinkDuration = 4;

            // for (float t = 0; t < sinkDuration; t += Time.deltaTime)
            // {
            //     // if (t < rotateDuration)
            //     //     unitTransform.rotation = Quaternion.Lerp(startRotation, endRotation, t / rotateDuration);
            //     // else if (unitTransform.rotation != endRotation)
            //     //     unitTransform.rotation = endRotation;
            //
            //     unitTransform.position = Vector3.Lerp(startPosition, endPosition, t / sinkDuration);
            //     yield return null;
            // }

            // unitTransform.position = endPosition;

            yield return(new WaitForSeconds(1.7f));

            Destroy(gameObject);
        }
示例#2
0
 private void Start()
 {
     InstantiateHealthBar();
     _animator         = GetComponent <Animator>();
     _currentHitPoints = maxHitPoints;
     _agent            = GetComponent <NavMeshAgent>();
     UpdateAttackRange();
     UnitEventManager.TriggerEvent("unitSpawn", this);
 }