Exemple #1
0
        private void Shoot()
        {
            var     bullet    = Instantiate(BulletPrefab);
            Vector2 direction = controller.GetDynamicDirection(Player.Instance.transform.position);

            if (direction == Vector2.zero)
            {
                direction = Player.Instance.IsFacingRight() ? Vector2.right : Vector2.left;
            }

            Vector2 origin = (Vector2)transform.position + direction.normalized * 0.5f;

            bullet.GetComponent <Bullet>().Fire(origin, direction, ShootSpeed);
        }
Exemple #2
0
        private void Update()
        {
            switch (state)
            {
            case States.Inactive:
                break;

            case States.Active:
                crosshair.Move(controller.GetDynamicDirection(crosshair.transform.position), MaxDistance);
                break;

            case States.Blinking:
                blinkTime     += Time.deltaTime;
                Time.timeScale = Mathf.Lerp(TimeScale, 1, blinkTime / BlinkDuration);
                if (blinkTime > BlinkDuration)
                {
                    Stop();
                }
                break;

            default:
                break;
            }
        }