Пример #1
0
        public void DisplayUnits(GroupBox groupBox)
        {
            //Num_Of_Rounds.Text = "Round : " + gE.round.ToString();

            //groupBox.Controls.Clear();

            foreach (Unit u in units)
            {
                Button newLabel = new Button();

                if (u is Melee_Unit)
                {
                    Melee_Unit mu = (Melee_Unit)u;
                    newLabel.Width    = 25;
                    newLabel.Height   = 25;
                    newLabel.Location = new Point(mu.Xpos * 20, mu.Ypos * 15);
                    newLabel.Text     = mu.Symbol;
                    if (mu.Team == "Blue")
                    {
                        newLabel.ForeColor = Color.Blue;
                    }
                    else
                    {
                        newLabel.ForeColor = Color.Red;
                    }
                }
                else if (u is Ranged_Unit)
                {
                    Ranged_Unit ru = (Ranged_Unit)u;
                    newLabel.Width    = 25;
                    newLabel.Height   = 25;
                    newLabel.Location = new Point(ru.Xpos * 20, ru.Ypos * 15);
                    newLabel.Text     = ru.Symbol;
                    if (ru.Team == "Blue")
                    {
                        newLabel.ForeColor = Color.Blue;
                    }
                    else
                    {
                        newLabel.ForeColor = Color.Red;
                    }
                }
                else if (u is Wizard_Unit)
                {
                    Wizard_Unit wU = (Wizard_Unit)u;
                    newLabel.Width     = 25;
                    newLabel.Height    = 25;
                    newLabel.Location  = new Point(wU.Xpos * 20, wU.Ypos * 15);
                    newLabel.Text      = wU.Symbol;
                    newLabel.ForeColor = Color.Purple;
                }

                groupBox.Controls.Add(newLabel);
            }



            foreach (Building bd in buildings)
            {
                Button newLabel = new Button();
                newLabel.Width    = 30;
                newLabel.Height   = 30;
                newLabel.Location = new Point(bd.xPosition * 20, bd.yPosition * 15);
                newLabel.Text     = bd.symbol;
                if (bd.team >= 3)
                {
                    newLabel.ForeColor = Color.Blue;
                }
                else
                {
                    newLabel.ForeColor = Color.Red;
                }

                groupBox.Controls.Add(newLabel);
            }

            //test = groupBox.Controls.Count;
        }
Пример #2
0
        public void SpawnUnitAtFactory()
        {
            //for(int i = 0; i < 20; i++)
            //{
            //    Melee_Unit m = new Melee_Unit(r.Next(0, 20), r.Next(0, 20) + 5, 200, 1, 20, 1, "{:}", "Red");
            //    units.Add(m);
            //}

            //for (int i = 0; i < 20; i++)
            //{
            //    Ranged_Unit rU = new Ranged_Unit(r.Next(0, 20), r.Next(0, 20) + 5, 100, 1, 20, 5, "[!]", "Blue");
            //    units.Add(rU);
            //}


            //Spawns Wizards
            Wizard_Unit wU = new Wizard_Unit(r.Next(0, xMapSize), r.Next(0, yMapSize), 150, 1, 30, 1, "(<|>)", "Wizard");

            units.Add(wU);


            foreach (Building bd in buildings)
            {
                if (bd is FactoryBuilding)
                {
                    if (bd.symbol == "F" && bd.team < 3)
                    {
                        Ranged_Unit rU = new Ranged_Unit(bd.xPosition, bd.yPosition + 5, 100, 1, 20, 5, "[!]", "Red");
                        //rU.Xpos = bd.xPosition;
                        //rU.Ypos = bd.yPosition + 5;
                        //rU.Symbol = "[!]";
                        //rU.Health = 100;
                        //rU.Attack = 20;
                        //rU.AttackRange = 5;
                        //rU.IsAttacking = false;
                        //rU.IsDead = false;
                        //rU.Team = "Red";

                        units.Add(rU);

                        Melee_Unit mU = new Melee_Unit(bd.xPosition, bd.yPosition + 5, 200, 1, 20, 1, "{:}", "Red");
                        //mU.Xpos = bd.xPosition;
                        //mU.Ypos = bd.xPosition + 5;
                        //mU.Symbol = "{:}";
                        //mU.Health = 200;
                        //mU.Attack = 20;
                        //mU.AttackRange = 1;
                        //mU.IsAttacking = false;
                        //mU.IsDead = false;
                        //mU.Team = "Red";

                        units.Add(mU);
                    }
                    else if (bd.symbol == "F" && bd.team >= 7)
                    {
                        Ranged_Unit rU = new Ranged_Unit(bd.xPosition, bd.yPosition + 5, 100, 1, 20, 5, "[!]", "Blue");
                        //rU.Xpos = bd.xPosition;
                        //rU.Ypos = bd.yPosition + 5;
                        //rU.Symbol = "[!]";
                        //rU.Health = 100;
                        //rU.Team = "Blue";

                        units.Add(rU);

                        Melee_Unit mU = new Melee_Unit(bd.xPosition, bd.yPosition + 5, 200, 1, 20, 1, "{:}", "Blue");
                        //mU.Xpos = bd.xPosition;
                        //mU.Ypos = bd.xPosition + 5;
                        //mU.Symbol = "{:}";
                        //mU.Health = 200;
                        //mU.Team = "Blue";

                        units.Add(mU);
                    }
                }
            }
        }