예제 #1
0
        private IEnumerator SnapCrossHairToEnemy(GameObject enemy)
        {
            _state = HunterState.CROSSHAIR_LOCKED_ON_ENEMY;

            int time     = 0;
            int duration = 300;

            var     crossStartPos = TransformPoint(_crossHair.Pos.x, _crossHair.Pos.y);
            Vector2 localPos;

            while (time < duration)
            {
                float pointX = Easing.Ease(Easing.Equation.QuadEaseOut, time, crossStartPos.x,
                                           enemy.x - crossStartPos.x, duration);
                float pointY = Easing.Ease(Easing.Equation.QuadEaseOut, time, crossStartPos.y,
                                           enemy.y - crossStartPos.y, duration);

                localPos = InverseTransformPoint(pointX, pointY);

                _crossHair.SetXY(localPos.x, localPos.y);

                time += Time.deltaTime;
                yield return(null);
            }

            SpriteTweener.TweenColor(_crossHair, _crossHair.StartColor, ColorTools.ColorToUInt(Color.Red), 300);

            //After Snap, follow target while distance less than range
            //Countdown to Shoot
            _countDownToShootRoutine = CoroutineManager.StartCoroutine(CountDownToShootRoutine(enemy), this);

            do
            {
                _distanceToTarget = enemy.Pos - _pos;
                float distanceMag = _distanceToTarget.Magnitude;

                localPos = InverseTransformPoint(enemy.x, enemy.y);
                _crossHair.SetXY(localPos.x, localPos.y);

                //Lost lock on enemy, out of range
                if (distanceMag > _scanEnemyRange)
                {
                    CoroutineManager.StopCoroutine(_countDownToShootRoutine);

                    _lostLockOnEnemyOutOfRangeRoutine =
                        CoroutineManager.StartCoroutine(LostLockOnEnemyOutOfRangeRoutine(enemy), this);
                }

                yield return(null);
            } while (_state == HunterState.CROSSHAIR_LOCKED_ON_ENEMY);
        }
        public HudArrowToObjective() : base("data/Hud Arrow.png", false, false)
        {
            SetOrigin(width, height * 0.5f);

            color = ColorTools.ColorToUInt(Color.Red);
        }