void IfIsConsumable(Tile tile)
 {
     if (tile is Consumable)
     {
         bool freeSpace = false;
         int  i;
         for (i = 0; i < 6; i++)
         {
             if (equipment[i] == null)
             {
                 freeSpace = true;
                 break;
             }
         }
         if (freeSpace)
         {
             Consumable cons = (Consumable)tile;
             AddItem(i, cons);
             currentMap.SendLog("You picked up " + cons.name + "!");
             standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);
         }
         else
         {
             Consumable cons = (Consumable)tile;
             currentMap.SendLog("You have no room for " + cons.name + "!");
         }
     }
 }
        public Map(int[][] intMap, DisplayConsole display, GameHandler gm, int rowAmmount, int ColumnAmmount)
        {
            dontShow       = false;
            gameMaster     = gm;
            mapRowLimit    = rowAmmount;
            mapColumnLimit = ColumnAmmount;
            this.display   = display;
            this.tileMap   = new Tile[mapRowLimit][];
            int rowCounter = 0;

            foreach (int[] intRow in intMap)
            {
                this.tileMap[rowCounter] = new Tile[mapColumnLimit];
                int columnCounter = 0;
                foreach (int integer in intRow)
                {
                    if (integer == 2)
                    {
                        tileMap[rowCounter][columnCounter]     = gameMaster.hero;
                        gameMaster.hero.positionX              = columnCounter;
                        gameMaster.hero.positionY              = rowCounter;
                        gameMaster.hero.currentCenterPositionX = columnCounter;
                        gameMaster.hero.currentCenterPositionY = rowCounter;
                    }
                    else
                    {
                        this.tileMap[rowCounter][columnCounter] = TileFactory.Get(integer, columnCounter, rowCounter, this);
                    }

                    columnCounter++;
                }
                rowCounter++;
            }
            enemies = new EnemyIterator(tileMap);
        }
Esempio n. 3
0
 public Character(int id, int posX, int posY, Map mp) : base(id, mp)
 {
     positionX      = posX;
     positionY      = posY;
     standingOnTile = TileFactory.Get(0, posX, posY, mp);
     passable       = false;
 }
Esempio n. 4
0
        public Tile CreateTileAt(int x, int z, TileType type)
        {
            Tile tile          = tileFactory.Get(type);
            var  tileTransform = tile.transform;

            tileTransform.position = new Vector3(x * Tile.Size.x, -Tile.Size.y, z * Tile.Size.z);
            tileTransform.SetParent(gameObject.transform);
            tiles[x, z] = tile;
            tile.Pos    = new Vector2Int(x, z);
            return(tile);
        }
 void IfIsOther(Tile neighbor)
 {
     if (neighbor is Stairs)
     {
         currentMap.gameMaster.NextLevel();
         currentMap.gameMaster.GenerateRandom(currentMap.gameMaster.floorNumber);
         currentMap.SendLog("You went down the stairs");
         standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);
         currentMap.MoveFocus(this);
     }
     if (neighbor is Coin)
     {
         currentMap.GotGold();
         standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);
     }
     IfIsConsumable(neighbor);
 }
        public Map(int[][] intMap, DisplayScript display, GameHandler gm, int rowAmmount, int ColumnAmmount)
        {
            dontShow       = false;
            gameMaster     = gm;
            mapRowLimit    = rowAmmount;
            mapColumnLimit = ColumnAmmount;
            this.display   = display;
            this.tileMap   = new Tile[mapRowLimit][];
            int rowCounter = 0;

            foreach (int[] intRow in intMap)
            {
                this.tileMap[rowCounter] = new Tile[mapColumnLimit];
                int columnCounter = 0;
                foreach (int integer in intRow)
                {
                    if (integer == 2)
                    {
                        tileMap[rowCounter][columnCounter]     = gameMaster.hero;
                        gameMaster.hero.positionX              = columnCounter;
                        gameMaster.hero.positionY              = rowCounter;
                        gameMaster.hero.currentCenterPositionX = columnCounter;
                        gameMaster.hero.currentCenterPositionY = rowCounter;
                    }
                    else
                    {
                        this.tileMap[rowCounter][columnCounter] = TileFactory.Get(integer, columnCounter, rowCounter, this);
                    }
                    if (integer == 6 || integer == 3 || integer == 8 || integer == 9 || integer == 11)
                    {
                        gameMaster.AddEnemyToList((Enemy)this.tileMap[rowCounter][columnCounter]);
                    }

                    columnCounter++;
                }
                rowCounter++;
            }
            display.RandomizeDungeonColor();
        }
        void IfIsOther(Tile tile, int targetPositionX, int targetPositionY)
        {
            if (tile.passable)
            {
                currentMap.StepOnElement(positionX, positionY, targetPositionX, targetPositionY);
                if (isNearBorder())
                {
                    currentMap.MoveFocus(this);
                }
                positionX = targetPositionX;
                positionY = targetPositionY;

                if (tile is Stairs)
                {
                    currentMap.gameMaster.NextLevel();
                    currentMap.SendLog("You went down the stairs");
                    standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);

                    currentMap.MoveFocus(this);
                }
                if (tile is Coin)
                {
                    currentMap.GotGold();
                    standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);
                }
                IfIsConsumable(tile);
            }
            else
            {
                if (tile is Enemy)
                {
                    Enemy enm = (Enemy)tile;
                    enm.GetDmg(attack);
                    currentMap.SendLog("You hit " + enm.name + " for " + attack.ToString() + " damage!");
                }
            }
        }
Esempio n. 8
0
 public Character(int id, int posX, int posY, Map mp) : base(id, posX, posY, mp)
 {
     standingOnTile = TileFactory.Get(0, posX, posY, mp);
     passable       = false;
 }
 public Consumable(int id, int posX, int posY, Map mp) : base(id, mp)
 {
     standingOnTile = TileFactory.Get(0, posX, posY, mp);
     passable       = true;
 }