Example #1
0
        public void GameInit()
        {
            // take no prisoners
            foreach (Transform childTransform in transform)
            {
                Destroy(childTransform.gameObject);
            }
            // obj pooling
            pool   = new Dictionary <ID, Stack <Thing> >();
            fxPool = new Dictionary <FX.ID, Stack <FX> >();

            goodies.Clear();
            baddies.Clear();
            spawned.Clear();
            graveyard.Clear();
            logBox.Clear();
            rng = new System.Random();
            var size = 21;

            playerStart.x = size / 2;
            playerStart.y = size / 2;
            bounds.size   = new Vector3Int(size, size, 1);

            var floorSize = new Vector2(bounds.size.x * Thing.SCALE.x, bounds.size.y * Thing.SCALE.y);

            floor.size = floorSize;
            floor.transform.localPosition = new Vector3(floorSize.x * 0.5f, -floorSize.y * 0.5f);
            ids       = new Dictionary <Vector3Int, ID>();
            things    = new Dictionary <Vector3Int, Thing>();
            teamPaths = new Dictionary <ID, Dictionary <Vector3Int, int> > {
                { ID.GOOD, new Dictionary <Vector3Int, int>() },
                { ID.BAD, new Dictionary <Vector3Int, int>() }
            };
            triggers = new Dictionary <Vector3Int, List <Thing> >();

            // generate level
            Fill(bounds, ID.LOOT | ID.GOOD, 0.05f);
            //Fill(bounds, ID.MON | ID.BAD, 0.1f);
            Fill(bounds, ID.WALL, 0.2f);
            Fill(bounds, ID.HARD_WALL, 0.1f);
            ids[playerStart] = PLAYER_ID;
            // it's a monster, it's a baddie, and it's the spawner variant
            ids[playerStart + new Vector3Int(5, 0, 0)] = ID.MON | ID.BAD | (ID)Thing.Mon.SPAWNER;

            // convert
            foreach (var pos in ids.Keys)
            {
                GetMapThing(pos);
            }
            health.total = player.thing.hpTotal;
            health.value = player.thing.hp;
            score.value  = 0;
            power.Init(10, 5);
            camCtrl.SetTarget(playerStart);
            camCtrl.SkipPan();
            state = State.WAIT;

            logBox.Say("Welcome Rogue.");
        }