예제 #1
0
        public void Update(ShipCommands commands)
        {
            if (commands.TurnLeft)
            {
                TurnLeft(Direction.FromRadian(ShipParameters.RotationSpeed));
            }
            if (commands.TurnRight)
            {
                TurnRight(Direction.FromRadian(ShipParameters.RotationSpeed));
            }
            if (commands.Accelerate)
            {
                AccelerateAlongHeading(ShipParameters.AccelerationSpeed);
            }
            if (commands.Decelerate)
            {
                DecelerateAlongHeading(ShipParameters.AccelerationSpeed);
            }
            if (commands.Fire)
            {
                Fire();
                commands.Fire = false;
            }

            this.Energy += ShipParameters.EnergyRegen;
            if (Energy > ShipParameters.Energy)
            {
                Energy = ShipParameters.Energy;
            }

            var newLocation = new WrappingLocation(this.Location, Movement);

            this.Location = newLocation;
        }
예제 #2
0
        public Player()
        {
            Id = playerIdCounter++;

            Commands = new ShipCommands();

            ship = new Ship(
                new WrappingLocation(random.Next(Game.MaxX * 100), random.Next(Game.MaxY * 100)),
                System.Drawing.Color.FromArgb(128 + random.Next(127), 128 + random.Next(127), 128 + random.Next(127)));
        }