Example #1
0
 void Awake()
 {
     //This is ugly.
     //This is in awake so it won't lose to the start in LevelSetup.
     //Rethink!
     dFactory = new DungeonFactory();
 }
Example #2
0
        public Encounter GetEncounter(int ownerIndex)
        {
            var valid    = new List <DungeonEncounter>();
            int priority = 0;

            foreach (var dungeonMonster in dungeon.monsters)
            {
                if (dungeonMonster.min <= dungeon.currentLevel &&
                    dungeonMonster.max >= dungeon.currentLevel &&
                    dungeonMonster.priority >= priority)
                {
                    if (dungeonMonster.priority > priority)
                    {
                        priority = dungeonMonster.priority;
                        valid.Clear();
                    }
                    valid.Add(dungeonMonster);
                }
            }

            var choosen   = valid.Random();
            var encounter = DungeonFactory.CreateEncounter(choosen.monsters, ownerIndex);

            return(encounter);
        }
Example #3
0
    public static DungeonRoom GetRoomForPosition(Vector3 position)
    {
        //position += WorldInfo.Instance.WorldOffset;

        int x = (int)(position.x / TILES_WIDE_WITH_HALLS);
        int z = (int)(position.z / TILES_LONG_WITH_HALLS);

        DungeonFactory df = CommonObjects.CurrentDungeonFactory;

        return(df.GetRoomAtGridPosition(x, z));
    }
Example #4
0
    void InstantiateInvisibleBlock()
    {
        GameObject     block = Instantiate(CommonObjects.Instance.invisibleBlockStatuePrefab) as GameObject;
        DungeonFactory df    = CommonObjects.CurrentDungeonFactory;

        if (df != null)
        {
            block.transform.SetParent(df.blocksContainer);
        }

        Vector3 pos = transform.position;

        pos.y = transform.localScale.y * 0.5f;
        block.transform.position = pos;
    }
        void Awake()
        {
            if (!_dDrawer || !_dFactory)
            {
                _dDrawer = GetComponent<DungeonDrawer>();
                _dFactory = GetComponent<DungeonFactory>();
            }
            _dFactory.onGenerationEnd.AddListener((dungeon) =>
            {
                GameManager.Instance.ClearedDungeons++;
                _currentDungeon = dungeon;

                dungeon.OnGoalCleared.AddListener(() =>
                {
                    if (dungeon.RemainingGoals <= 0)
                    {
                        Exit e = FindObjectOfType<Exit>();
                        e.Unlock();
                    }
                });
            });
        }
Example #6
0
 public void StartNewDungeon(string id)
 {
     dungeon = DungeonFactory.CreateDungeon(id);
 }
 public DungeonFactoryTest()
 {
     _dungeonFactory = new DungeonFactory(new RoomFactory(), new HallwayFactory(new MonsterFactory()));
 }