Ejemplo n.º 1
0
 private void CreatePowerup(String powerUpType = "PUGlock")
 {
     Globals.ReColorImage((Bitmap)Image.FromFile(String.Format("Resources/Images/PowerUp/{0}/{0}.png", powerUpType)), Color.FromArgb(255, 255, 0, 225), Globals.katanaColor, String.Format("Resources/Images/PowerUp/{0}/{0}1.png", powerUpType)).Save((String.Format("Resources/Images/PowerUp/{0}/{0}1.png", powerUpType)));
     this.power = new Powerup((Bitmap)Image.FromFile(String.Format("Resources/Images/PowerUp/{0}/{0}1.png", powerUpType)), this.powerUpType);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// setComponent take a string name and finds relevant image files that are compatible wih the current Gun instance.
        /// This is to Select a valid image for randomly generating Gun classes.
        /// </summary>
        /// <param name="gunPart"> One of the compatible images for this Gun instance from the 'Resources' folder</param>
        private void setComponent(String gunPart)
        {
            scope = Int32.Parse(this.sight_Code);
            Random rand        = new Random();
            String RunningPath = AppDomain.CurrentDomain.BaseDirectory;
            String imgPath     = RunningPath + "Resources\\Images\\Gun_Parts\\" + gunPart + "\\";

            String[]      possibleImgs = System.IO.Directory.GetFiles(imgPath, "*.png");
            List <String> relevantImgs = new List <String>();

            for (int i = 0; i < possibleImgs.Count(); i++)
            {
                String fileName       = possibleImgs[i].Substring(imgPath.Length, possibleImgs[i].Length - imgPath.Length);
                int    firstVarStart  = gunPart.Length + 1; // 1 '_' character before the first code
                int    secondVarStart = gunPart.Length + 5; //2 '_' characters plus 3 numbers
                switch (gunPart)
                {
                case "Barrel":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.bullet_Type))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.damage_Rate))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Muzzle_Flare":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.bullet_Type))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.damage_Rate))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Receiver":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.camo_Code))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.damage_Rate))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Ejection":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.bullet_Type))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.damage_Rate))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Front_Body":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.camo_Code))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.bullet_Type))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Magazine":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.bullet_Type))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.ammo_Cap))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Grip":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.camo_Code))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals(this.grip_Type))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Arm":
                    if (fileName.Substring(firstVarStart, 3).Equals("000"))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals(this.armour_Code))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Hand":
                    if (fileName.Substring(firstVarStart, 3).Equals(this.race_Code))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals(this.style_Code))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Rail":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.bullet_Type))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals("000") || fileName.Substring(secondVarStart, 3).Equals(this.damage_Rate))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                case "Sight":
                    if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.camo_Code))
                    {
                        if (fileName.Substring(secondVarStart, 3).Equals(this.sight_Code))
                        {
                            relevantImgs.Add(possibleImgs[i]);
                        }
                    }
                    break;

                /*
                 * case "Token":
                 *  if (fileName.Substring(firstVarStart, 3).Equals("000") || fileName.Substring(firstVarStart, 3).Equals(this.grip_Type))
                 *  {
                 *      if (fileName.Substring(secondVarStart, 3).Equals(this.style_Code))
                 *      {
                 *          relevantImgs.Add(possibleImgs[i]);
                 *      }
                 *  }
                 *  break;
                 */
                default:
                    break;
                }
            }
            int numberPicked = rand.Next(relevantImgs.Count());

            switch (gunPart)
            {
            case "Barrel":
                this.barrel = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Muzzle_Flare":
                this.muzzle_Flare = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Receiver":
                this.receiver = new Bitmap(relevantImgs[numberPicked]);
                this.receiver = Globals.ReColorImage(new Bitmap(relevantImgs[numberPicked]), Color.FromArgb(255, 0, 0, 255), newColor, "TestGun.png");
                this.receiver = Globals.ReColorImage(this.receiver, Color.FromArgb(255, 0, 0, 125), newAltColor, "TestGun1.png");

                break;

            case "Ejection":
                this.ejection = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Front_Body":

                this.front_Body = Globals.ReColorImage(new Bitmap(relevantImgs[numberPicked]), Color.FromArgb(255, 0, 0, 255), newColor, "TestGun.png");
                this.front_Body = Globals.ReColorImage(this.front_Body, Color.FromArgb(255, 0, 0, 125), newAltColor, "TestGun.png");

                break;

            case "Magazine":
                this.magazine = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Grip":
                this.grip = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Arm":
                this.arm = new Bitmap(relevantImgs[numberPicked]);
                this.arm = Globals.ReColorImage(new Bitmap(relevantImgs[numberPicked]), Color.FromArgb(255, 0, 0, 255), newColor, "TestGun.png");
                this.arm = Globals.ReColorImage(this.arm, Color.FromArgb(255, 0, 0, 125), newAltColor, "TestGun1.png");
                this.arm = Globals.ReColorImage(this.arm, Color.FromArgb(255, 0, 0, 25), newAltColor, "TestGun1.png");

                break;

            case "Hand":
                this.hand = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Rail":
                this.rail = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Sight":
                this.sight = new Bitmap(relevantImgs[numberPicked]);

                break;

            case "Token":
                this.token = new Bitmap(relevantImgs[numberPicked]);

                break;

            default:
                Debug.WriteLine("Unkown Switch " + gunPart);
                break;
            }
        }