예제 #1
0
        /// <summary>
        /// PowerUp Is used to run the commands of a palyer pressing 'Q' and using a poweer up,
        /// based on what time of powerup is used.
        /// </summary>
        /// <param name="id">The ID of the palyer using the power up</param>
        /// <param name="command"> The Command string that set off this action, see <see cref="Form1.RunCommands"/></param>
        /// <param name="powerupType">The enum of what powerup is being used, see <see cref="Player.PowerUpTypes"/></param>
        public void Powerup(int id, String command, Player.PowerUpTypes powerupType)
        {
            Debug.WriteLine(" PowerUpCommandReader Running");

            if (powerupType == Player.PowerUpTypes.GLOCK)
            {
                Debug.WriteLine(" Firing");

                Unit returnUnit = Globals.FindFirstUnit(players[id].GetX(), players[id].Gety(), players[id].GetDirection(), cellList);
                if (returnUnit != null && returnUnit.GetUnitType() != Globals.UnitType.Player)
                {
                    Debug.WriteLine(" Got a return Unit, adding damage");
                    this.f.commandStringsNew += "SHW" + String.Format("{0:000}{1:00}0020", returnUnit.GetId(), id) + "^";
                }
                else
                {
                    Debug.WriteLine(" No retun unit");
                }
            }
            else
            {
                Entity projReturn = Globals.FindFirstEntityInDistance(players[id].GetX(), players[id].Gety(), players[id].GetDirection(), cellList, 1, 2);
                if (projReturn != null)
                {
                    if (projReturn.type == Entity.EntityTypes.Projectile)

                    {
                        Debug.WriteLine(" Got a return Projectile " + projReturn.ToString() + ", Inverting");
                        Projectile projId = ((Projectile)projReturn);
                        projId.Invert();
                        this.f.commandStringsNew += "RPT001" + String.Format("{0:000}{1:000}", projId.sender.GetId(), projId.projectileId) + "^";
                    }
                    else if (projReturn.type == Entity.EntityTypes.Unit)
                    {
                        Debug.WriteLine(" Got a return Unit, adding damage");
                        Unit returUni = (Unit)projReturn;
                        this.f.commandStringsNew += "SHW" + String.Format("{0:000}{1:00}0020", returUni.GetId(), id) + "^";
                    }
                }
            }

            players[id].usingPowerUpFrame = false;
        }
예제 #2
0
 public Powerup(Bitmap baseImage, Player.PowerUpTypes p)
 {
     this.baseImage       = baseImage;
     this.animationImages = BuildPowerup();
     this.powerUpType     = p;
 }