Example #1
0
        /// <summary>
        /// Spawns the starting units of this player.
        /// </summary>
        public void SpawnStartUnits()
        {
            if (Game1.GetInstance().IsMultiplayerGame() &&
                Game1.CURRENT_PLAYER != this) return;

            if (!Game1.GetInstance().IsMultiplayerGame())
            {
                int unitCount = 25;

                CustomArrayList<Unit> temp_units = new CustomArrayList<Unit>();
                // +1 to compensate for the engineer
                for (int i = 0; i < unitCount + 1; i++)
                {
                    // Fill the list with dummy units
                    Unit u = null;
                    temp_units.AddLast(u);
                }

                UnitSelection selection = new UnitSelection(temp_units);
                UnitGroupPattern pattern = new CirclePattern(startLocation, selection, 90, 0);
                CustomArrayList<Point> points = pattern.ApplyPattern();

                for (int i = 0; i < unitCount; i++)
                {

                    Point p = points.ElementAt(i);
                    if (i % 2 == 0)
                    {
                        //temp_units.AddLast(fastStore.getUnit(Unit.Type.Fast, p.X, p.Y));
                    }
                    else
                    {
                        temp_units.AddLast(rangedStore.getUnit(Unit.Type.Ranged, p.X, p.Y));
                    }

                    // Point p = points.ElementAt(i);
                    //temp_units.AddLast(meleeStore.getUnit(Unit.Type.Melee, p.X, p.Y));
                }
            }

            meleeStore.getUnit(Unit.Type.Engineer, startLocation.X, startLocation.Y);
        }
Example #2
0
        /// <summary>
        /// Spawns the starting units of this player.
        /// </summary>
        /// <param name="location">The location to spawn them at.</param>
        public void SpawnStartUnits(Point location)
        {
            LinkedList<Unit> temp_units = new LinkedList<Unit>();
            for (int i = 0; i < 25; i++)
            {
                if( i % 2 == 0 ) temp_units.AddLast(new Engineer(this, 0, 0));
                else
                    temp_units.AddLast(new Bowman(this, 0, 0));
            }
            UnitSelection selection = new UnitSelection(temp_units);

            UnitGroupPattern pattern = new CirclePattern(location, selection, 90, 0);

            LinkedList<Point> points = pattern.ApplyPattern();

            for (int i = 0; i < temp_units.Count; i++)
            {
                temp_units.ElementAt(i).x = points.ElementAt(i).X;
                temp_units.ElementAt(i).y = points.ElementAt(i).Y;
            }
        }