Example #1
0
 /// <summary>
 /// Creates instance of Unit and sets all objects that it is dependent on
 /// </summary>
 /// <param name="owner">Player that owns this unit</param>
 /// <param name="at">At which field is unit located</param>
 /// <param name="pf">Initialized PathFinder used for movement and printing position</param>
 /// <param name="tm">Initialized TurnManager used for removing unit from the game</param>
 /// <param name="rng">Seeded Random used for attacking</param>
 public Unit(Player owner, Field at, Pathfinder pf, TurnManager tm, Random rng)
 {
     this.tm        = tm;
     this.pf        = pf;
     attackPower    = 200;
     range          = 1;
     hitPoints      = 1000;
     maxHitPoints   = hitPoints;
     unitName       = "unknown";
     attackPriority = 100;
     movement       = 15;
     flying         = false;
     at.setOccupant(this);
     this.at    = at;
     this.owner = owner;
     owner.addUnit(this);
     this.rng = rng;
 }
Example #2
0
        /// <summary>
        /// Initializes data objects before first run
        /// </summary>
        static void init()
        {
            rng = new Random();
            List <Player> players = new List <Player>();

            for (int i = 0; i < 2; i++)
            {
                players.Add(new Player(i + 1));
            }

            map = new Map(25, 36);
            pf  = new Pathfinder(map);
            tm  = new TurnManager(players);

            for (int i = 25; i < 36; i++)
            {
                map.changeFields(map.allFields[4][i], new Wall(4, i));
                map.changeFields(map.allFields[20][i], new Wall(20, i));
            }
            for (int i = 5; i < 20; i++)
            {
                if (i != 12)
                {
                    map.changeFields(map.allFields[i][25], new Wall(i, 25));
                }
            }
            for (int i = 0; i < 5; i++)
            {
                new Archer(players[0], map.allFields[8 + i * 2][30], pf, tm, rng);
            }

            for (int i = 0; i < 5; i++)
            {
                new Archer(players[1], map.allFields[8 + i * 2][10], pf, tm, rng);
            }

            tm.createAttackPriorityList();
        }
Example #3
0
 public Soldier(Player owner, Field at, Pathfinder pf, TurnManager tm, Random rng) : base(owner, at, pf, tm, rng)
 {
 }