Example #1
0
        public override void Update()
        {
            base.Update();

            if (IsShooting)
            {
                SetHeadDirection(_shootKey);
                return;
            }

            if (InputHelpers.IsAnyKey(KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.LeftArrow, KeyCode.RightArrow))
            {
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    _shootDirection = new Vector2(0, _bulletSpeed);
                    _shootKey       = KeyCode.UpArrow;
                }
                else if (Input.GetKey(KeyCode.DownArrow))
                {
                    _shootDirection = new Vector2(0, -_bulletSpeed);
                    _shootKey       = KeyCode.DownArrow;
                }
                else if (Input.GetKey(KeyCode.LeftArrow))
                {
                    _shootDirection = new Vector2(-_bulletSpeed, 0);
                    _shootKey       = KeyCode.LeftArrow;
                }
                else if (Input.GetKey(KeyCode.RightArrow))
                {
                    _shootDirection = new Vector2(_bulletSpeed, 0);
                    _shootKey       = KeyCode.RightArrow;
                }
                StartCoroutine(Shoot());
            }
        }
Example #2
0
        public override void Update()
        {
            base.Update();

            if (IsShooting)
            {
                SetHeadDirection(_shootKey);
                return;
            }

            if (InputHelpers.IsAnyKey(KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.LeftArrow, KeyCode.RightArrow))
            {
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    _shootDirection = new Vector2(0, BulletSpeed);
                    _shootKey       = KeyCode.UpArrow;
                }
                else if (Input.GetKey(KeyCode.DownArrow))
                {
                    _shootDirection = new Vector2(0, -BulletSpeed);
                    _shootKey       = KeyCode.DownArrow;
                }
                else if (Input.GetKey(KeyCode.LeftArrow))
                {
                    _shootDirection = new Vector2(-BulletSpeed, 0);
                    _shootKey       = KeyCode.LeftArrow;
                }
                else if (Input.GetKey(KeyCode.RightArrow))
                {
                    _shootDirection = new Vector2(BulletSpeed, 0);
                    _shootKey       = KeyCode.RightArrow;
                }
                StartCoroutine(Shoot());
            }
            if (NumberofBombs > 0 && InputHelpers.IsAnyKeyDown(KeyCode.LeftShift, KeyCode.RightShift, KeyCode.E))
            {
                var bomb = (Bomb)Instantiate(BombPrefab);
                bomb.transform.position = transform.position;
                NumberofBombs--;
            }
        }