Esempio n. 1
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);
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
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));
        }