コード例 #1
0
ファイル: Enemy.cs プロジェクト: Ramzawulf/Endless-Dungeon
 // Use this for initialization
 void Start()
 {
     this.lastShoot = Time.time;
             this.shootingSpeed = 1f;
             this.shootingDirection = ShootingDirection.front;
             this.transform.Rotate (new Vector3 (90, 0, 0));
 }
コード例 #2
0
 public void setUp(PlayerIndex playerIndex)
 {
     shootingDirection = ShootingDirection.up;
     updateShootingDirectionSprite();
     if (playerIndex == PlayerIndex.first)
     {
         setUpAsFirst();
         controls = new Controls(PlayerIndex.first);
     }
     else if (playerIndex == PlayerIndex.second)
     {
         setUpAsSecond();
         controls = new Controls(PlayerIndex.second);
     }
     else
     {
         setUpAsSecond();
         controls = new Controls(PlayerIndex.auto);
     }
 }
コード例 #3
0
    void updateShootingDirection()
    {
        var oldShootingDirection = shootingDirection;

        if (controls.up)
        {
            shootingDirection = ShootingDirection.up;
        }
        else if (controls.down)
        {
            shootingDirection = ShootingDirection.down;
        }
        else
        {
            shootingDirection = ShootingDirection.normal;
        }

        if (oldShootingDirection != shootingDirection)
        {
            updateShootingDirectionSprite();
        }
    }
コード例 #4
0
        /// <summary>
        /// Shoots same balloons in a direction.
        /// </summary>
        /// <param name="direction">The direction to shoot - left, right, up or down.</param>
        /// <param name="startingPoint">The starting coordinates.</param>
        /// <param name="balloonToShoot">The type of the balloon.</param>
        private void ShootSameBalloonsInDirection(ShootingDirection direction, ICoordinates startingPoint, char balloonToShoot)
        {
            ICoordinates nextCoordinates = new Coordinates();
            nextCoordinates.X = startingPoint.X;
            nextCoordinates.Y = startingPoint.Y;

            switch (direction)
            {
                case ShootingDirection.Left:
                    {
                        nextCoordinates.X--;
                        break;
                    }

                case ShootingDirection.Right:
                    {
                        nextCoordinates.X++;
                        break;
                    }

                case ShootingDirection.Up:
                    {
                        nextCoordinates.Y--;
                        break;
                    }

                case ShootingDirection.Down:
                    {
                        nextCoordinates.Y++;
                        break;
                    }
            }

            while (balloonToShoot == this.GetBaloonTypeFromPosition(nextCoordinates))
            {
                this.Game.Field.UpdateField(nextCoordinates, '.');
                this.Game.RemainingBalloons--;

                switch (direction)
                {
                    case ShootingDirection.Left:
                        {
                            nextCoordinates.X--;
                            break;
                        }

                    case ShootingDirection.Right:
                        {
                            nextCoordinates.X++;
                            break;
                        }

                    case ShootingDirection.Up:
                        {
                            nextCoordinates.Y--;
                            break;
                        }

                    case ShootingDirection.Down:
                        {
                            nextCoordinates.Y++;
                            break;
                        }
                }
            }
        }