Esempio n. 1
0
        public bool AddMonster(LevelObject.Monster monster)
        {
            var cell            = GetCellAt(monster.Location.x, monster.Location.y);
            var existingMonster = GetMonsterAt(monster.Location.x, monster.Location.y);

            if (cell != null && existingMonster == null)
            {
                try
                {
                    Monsters.Add(monster.Location.x, monster.Location.y, monster);
                    return(true);
                }
                catch (IndexOutOfRangeException)
                {
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public bool MoveMonster(LevelObject.Monster monster, Vector2Int to)
        {
            var cell = GetCellAt(to.x, to.y);

            if (cell == null)
            {
                return(false);
            }

            var other = GetMonsterAt(to.x, to.y);

            if (other != null)
            {
                return(false);
            }

            Monsters.Remove(monster.Location.x, monster.Location.y);
            Monsters.AddExisting(to.x, to.y, monster);
            monster.Location = to;
            return(true);
        }
Esempio n. 3
0
 public void RemoveMonster(LevelObject.Monster monster)
 {
     Monsters.Remove(monster.Location.x, monster.Location.y, monster);
     Destroy(monster.gameObject);
     Destroy(monster);
 }