Example #1
0
 public void AddTower(int id)
 {
     if (GetTower(id) == null)
     {
         Towers.Add(new Tower(this, id));
     }
 }
Example #2
0
        public Castle AddTower()
        {
            var tower = new Tower();

            Destructables.Add(tower);
            Towers.Add(tower);
            return(this);
        }
        /// <summary>
        /// Buys given tower and places it on the map. Buying a tower resets the SelectedShopTower.
        /// If the player does not have enough money, no tower will be placed and SelectedShopTower
        /// will still be reset.
        /// </summary>
        /// <param name="tower">Instance of a tower to be placed</param>
        public void BuyTower(ITower tower)
        {
            if (Money >= tower.Price)
            {
                Towers.Add(tower);
                Money -= tower.Price;
            }

            DeselectShopTower();
        }
Example #4
0
 public static void Add(string name, Tower tower)
 {
     if (!Towers.ContainsKey(name))
     {
         Towers.Add(name, tower);
         if (DefaultTower == null)
         {
             DefaultTower = tower;
         }
     }
 }
Example #5
0
        public override void BuildTower(Rectangle towerBase, string buildType)
        {
            switch (buildType)
            {
            case "Rocket":
                Towers.Add(new RocketTower(towerBase));
                break;

            case "MG":
                Towers.Add(new MGTower(towerBase));
                break;

            case "Artillery":
                Towers.Add(new ArtilleryTower(towerBase));
                break;

            case "Flame":
                Towers.Add(new FlameTower(towerBase));
                break;

            case "Pulse":
                Towers.Add(new PulseTower(towerBase));
                break;

            case "Concussion":
                Towers.Add(new SlowingTower(towerBase));
                break;

            case "Command":
                Towers.Add(new CommandCenter(towerBase));
                break;

            case "Rifle":
                Towers.Add(new RifleTower(towerBase));
                break;

            case "Gamma":
                Towers.Add(new GammaRayTower(towerBase));
                break;
            }

            Map.AddTower(towerBase);

            for (int i = Towers.Count - 1; i > 0; i--)
            {
                if (((Tower)Towers[i]).TowerBase.Y < ((Tower)Towers[i - 1]).TowerBase.Y)
                {
                    Towers.Reverse(i - 1, 2);
                }
            }

            PlaySound("tick", Interface.Camera.Position);
        }
Example #6
0
 public W2()
 {
     Name           = "W2";
     Default_towers = 6;
     Towers.Add(new Tower());
     Towers.Add(new Tower());
     Towers.Add(new Tower());
     Towers.Add(new Tower());
     Towers.Add(new Tower());
     Timer    = 60;
     Finished = false;
 }
Example #7
0
 public Sector(IVirtualWorld world, string name, int towers) : base(world, name)
 {
     /*if (!world.Sectors.Contains(this))
      * {
      *  world.Sectors.Add(this);
      * }
      */
     for (int i = 1; i < towers + 1; i++)
     {
         Towers.Add(new Tower(i, this));
     }
 }
Example #8
0
 public Sector(IVirtualWorld virtualworld, string sectorName, int towers = 0) : base(virtualworld, sectorName)
 {
     //we want to add our own Tower implementation to the list, not APITower (which is what happens if you add the tower variable to the base() )
     if (towers < 1)
     {
         return;
     }
     Towers.Add(new Tower(this, 1, true)); //create a waytower
     for (int i = 2; i < towers; i++)
     {
         Towers.Add(new Tower(this, i));        //not a waytower
     }
     Towers.Add(new Tower(this, towers, true)); //waytower on the last number
 }
Example #9
0
 public EnemyAttacker this[int index]
 {
     get { return(Towers[index]); }
     set
     {
         if (Count > index && Count > 0)
         {
             Towers[index] = value;
         }
         else
         {
             Towers.Add(value);
         }
     }
 }
Example #10
0
 public W1()
 {
     Name           = "W1";
     Default_towers = 5;
     Towers.Add(new Tower());
     Towers.Add(new Tower(750, 792, 2, "Tower"));
     Towers.Add(new Tower());
     Towers.Add(new Tower(834, 261, 4, "Tower"));
     Towers.Add(new Tower(1171, 233, 5, "Tower"));
     //Towers.Add(new Trap());
     Timer        = 20;     //40
     Finished     = true;
     LoadTime     = 11;
     Map_location = new int[] { 960, 540 };
 }
Example #11
0
        public bool PlaceTower(int row, int col, int index)
        {
            if (Grid.Tiles[row, col].Placeable)
            {
                ITower tower = PlaceholderTowers[index].Clone();
                tower.Tile = Grid.Tiles[row, col];

                foreach (var tile in Grid.Tiles[row, col].Node)
                {
                    tile.IsOccupied = true;
                }

                Towers.Add(tower);

                return(true);
            }
            return(false);
        }
Example #12
0
    public void towerInstantiate(int i, int x, int y, int type)
    {
        Towers.Add(PhotonNetwork.Instantiate(Path.Combine("Prefabs", "NewPlayer"), new Vector3(0, 0, 1), Quaternion.identity, 0).GetComponent <Unit>());
        Towers[i].isTower = true;
        switch (type)
        {
        case 0:
            Towers[i].setUnitSprite("sprite/unit/blue/CBcastle");
            Towers[i].SpritePath = "sprite/unit/red/CRcastle";
            break;

        case 1:
            Towers[i].setUnitSprite("sprite/unit/blue/CBnexus");
            Towers[i].SpritePath = "sprite/unit/red/CRnexus";
            break;
        }

        Vector3 position = HexCoordinates.cubeToOffset(HexCoordinates.FromOffsetCoordinates(x, y));

        Towers[i].setUnitPosition(position);
        Towers[i].transform.SetParent(transform);

        print("create tower");
    }
        private void AskToPlaceTowers()
        {
            /* Finalize and refactor once PrintMapToScreen() has been re-written/fixed
             * 
             */

            int towerPoints = _amountTowers[(int)Difficulty] * CurrentLevel;
            bool error = false;

            while (towerPoints > 0)
            {
                PrintMapToScreen();

                if (error)
                {
                    Console.WriteLine("!!Error while analyzing coordinates!!");
                    error = false;
                }

                Console.WriteLine("Please choose a tower to place:");
                Console.WriteLine("1 - Basic Tower ({0})", (towerPoints / 1));
                Console.WriteLine("2 - Advanced Tower ({0})", (towerPoints / 2));
                Console.WriteLine("3 - Precise Tower ({0})", (towerPoints / 2));
                Console.WriteLine("4 - Power Tower ({0})", (towerPoints / 4));
                Console.Write(": ");
                var input = Console.ReadKey();

                Console.WriteLine();
                Console.WriteLine("Enter the coordinates (x,y) to place the tower");
                Console.WriteLine("You can place towers beside the path (X)");
                Console.Write(": ");
                string inputCoordinates = Console.ReadLine();
                try
                {
                    string[] placedTower = inputCoordinates.Split(',');
                    int x = Int32.Parse(placedTower[0]);
                    int y = Int32.Parse(placedTower[1]);

                    if (input.Key == ConsoleKey.D1)
                    {
                        Towers.Add(new Tower(new MapLocation(x, y, GameMap)));
                        towerPoints -= 1;
                    }
                    else if (input.Key == ConsoleKey.D2)
                    {
                        Towers.Add(new AdvancedTower(new MapLocation(x, y, GameMap)));
                        towerPoints -= 2;
                    }
                    else if (input.Key == ConsoleKey.D3)
                    {
                        Towers.Add(new PreciseTower(new MapLocation(x, y, GameMap)));
                        towerPoints -= 2;
                    }
                    else if (input.Key == ConsoleKey.D4)
                    {
                        Towers.Add(new PowerTower(new MapLocation(x, y, GameMap)));
                        towerPoints -= 4;
                    }
                    else
                        throw new Exception();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.ReadKey();
                    error = true;
                    continue;
                }
            }
            PrintMapToScreen();
        }