Example #1
0
        public void WizardLogic(Wizzard wizzard)
        {
            bool   action        = false;
            double healthPercent = wizzard.Health / wizzard.MaxHealth * 100;

            if (healthPercent <= 50)//if the wizard is a tad low on health then they must flee for their lives
            {
                wizzard.RandomMove(world.MapWidth, world.MapHeight);
                action = true;
            }
            else if (!action)                        //if the wizard didnt do anything already then they must see if they can attack anything in its AOE of DOOM
            {
                foreach (Unit unit in world.players) //if anyone of these poor suckers are within attack distance, the wizard must attck them
                {
                    if (wizzard.WithinRange(unit) & unit.Team != "C")
                    {
                        wizzard.Attack(unit);
                        action = true;
                    }
                }
            }

            if (!action)//if the wizard still has not done anything then the wizard must move to a neerby unit
            {
                wizzard.Move(wizzard.ClosestUnit);
            }
        }
Example #2
0
        public void WorldBuild()
        {
            for (int i = 0; i < players.Length; i++)//creates the player types and randomizes their positions
            {
                int unitType = r.Next(3);
                if (unitType == 0)
                {
                    players[i] = new Ranged(r.Next(1, mapWidth), r.Next(0, mapHeight), teams[r.Next(2)]);   // make a Ranged Boi
                }
                else if (unitType == 1)
                {
                    players[i] = new Melee(r.Next(1, mapWidth), r.Next(0, mapHeight), teams[r.Next(2)]);   // make a melee Boi
                }
                else
                {
                    players[i] = new Wizzard(r.Next(1, mapWidth), r.Next(0, mapHeight), teams[2]);  // make a wizard Boi
                }
            }

            for (int i = 0; i < buildings.Length; i++)//creates the building types and randomizes their positions
            {
                if (r.Next(2) == 0)
                {
                    int yValue = r.Next(1, mapHeight);
                    int SpawnVal;
                    if (yValue == 0)
                    {
                        SpawnVal = -1;
                    }
                    else
                    {
                        SpawnVal = 1;
                    }

                    buildings[i] = new FactoryBuilding(r.Next(1, mapWidth), yValue, teams[r.Next(2)], SpawnVal);//make a factory
                }
                else
                {
                    buildings[i] = new ResourceBuilding(r.Next(1, mapWidth), r.Next(0, mapHeight), teams[r.Next(2)]);//make a recource building
                }
            }

            UpdateWorld();
        }