예제 #1
0
        private void SpawnFire(GameSlot fireSlot)
        {
            if (fireDurration > 0)
            {
                if (fireSlot.Contents == GameSlotStatus.Fire)
                {
                    fireSlot.Child.facingDirection = playerSlot.Child.facingDirection;
                    fireSlot.Child.life            = fireDurration;
                }
                else
                {
                    GameObjectManager     manager = sSystemRegistry.GameObjectManager;
                    PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;

                    GameObject fireGameObject = factory.SpawnFire(0, 0, fireDurration);
                    manager.Add(fireGameObject);

                    fireSlot.Setup(GameSlotStatus.Fire, fireGameObject);

                    fireGameObject.SetPosition(GetSlotLocation(fireSlot.Position));
                    fireGameObject.facingDirection = playerSlot.Child.facingDirection;

                    fires.Add(fireSlot);
                }
            }
        }
예제 #2
0
        private void SpawnFuel()
        {
            const int maxRandomTries = 5;

            fuelSlot = GetRandomEmptySlot(maxRandomTries);
            if (fuelSlot == null)
            {
                //game has no empty tiles - shorted tail by 1 to allow space then try again
                AdjustFireDurration(-1);
                fuelSlot = GetRandomEmptySlot();

                Debug.Assert(fuelSlot != null, "Failed to spawn another fuel");
                //Need to test this
            }

            GameObjectManager     manager = sSystemRegistry.GameObjectManager;
            PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;

            GameObject fuelGameObject = factory.SpawnFuel(0, 0);

            manager.Add(fuelGameObject);

            //playerSlot.Setup(GameSlotStatus.Player, fireGameObject);
            fuelSlot.Setup(GameSlotStatus.Fuel, fuelGameObject);

            fuelGameObject.SetPosition(GetSlotLocation(fuelSlot.Position));

            //fires.Add(fireSlot);
        }
예제 #3
0
        private void SpawnBackground()
        {
            PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;
            GameObjectManager     manager = sSystemRegistry.GameObjectManager;

            manager.Add(factory.SpawnBackgroundPlate(0, 0));
        }
예제 #4
0
        public void SpawnLevelTiles()
        {
            foreach (GameSlot slot in tileSlots)
            {
                GameObjectManager     manager = sSystemRegistry.GameObjectManager;
                PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;

                GameObject tile = factory.SpawnTileEmpty(0, 0);
                manager.Add(tile);

                slot.Setup(GameSlotStatus.Empty, null);

                tile.SetPosition(GetSlotLocation(slot.Position));
            }
        }
예제 #5
0
        private void SpawnPlayer()
        {
            GameObjectManager     manager = sSystemRegistry.GameObjectManager;
            PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;

            GameObject playerGameObject = factory.SpawnPlayer(0, 0);

            manager.Add(playerGameObject);

            //spawn at center
            Point gameCenter = new Point(GameWidthInSlots / 2, GameHeightInSlots / 2);

            //gameCenter = new Point(19,19);//test wrap
            playerSlot.SetPosition(gameCenter.X, gameCenter.Y);
            playerSlot.Setup(GameSlotStatus.Player, playerGameObject);
            GetGameSlot(gameCenter).Setup(GameSlotStatus.Player, null);

            //spawn facing right
            playerSlot.Child.facingDirection.X = 1;
            playerSlot.Child.facingDirection.Y = 0;

            playerGameObject.SetPosition(GetSlotLocation(playerSlot.Position));
        }
예제 #6
0
        public FixedSizeArray <GameSlot> GenerateSlots()
        {
            int slotCount = GameWidthInSlots * (GameHeightInSlots);
            FixedSizeArray <GameSlot> result = new FixedSizeArray <GameSlot>(slotCount);

            GameObjectManager     manager = sSystemRegistry.GameObjectManager;
            PyroGameObjectFactory factory = (PyroGameObjectFactory)sSystemRegistry.GameObjectFactory;

            for (int xx = 0; xx < slotCount; xx++)
            {
                int xPos = xx / GameWidthInSlots;
                int yPos = xx % GameWidthInSlots;

                GameObject emptyTile = factory.SpawnTileEmpty(xPos, yPos);
                manager.Add(emptyTile);

                GameSlot slot = new GameSlot(xPos, yPos);

                result.Add(slot);
            }

            return(result);
        }