Exemplo n.º 1
0
        private void init(bool fullRegen = false)
        {
            Vector3 min = new Vector3(0, Constants.HUD_OFFSET, 0f);
            Vector3 max = new Vector3(Constants.RESOLUTION_X, Constants.RESOLUTION_Y, 0f);

            this.boundary = new BoundingBox(min, max);
            this.rand     = new Random();
            PositionGenerator.getInstance().init(this.rand);
            SpawnGenerator.getInstance().SpawnRequests.Clear();
            if (StateManager.getInstance().GameMode == GameMode.OnePlayer)
            {
                this.playerOne = new Snake(this.content, Constants.HEADING_UP, 0f, ConfigurationManager.getInstance().PlayerOnesControls);
            }
            else
            {
                this.playerOne = new Snake(this.content, Constants.HEADING_UP, 100f, ConfigurationManager.getInstance().PlayerOnesControls);
                this.playerTwo = new Snake(this.content, Constants.HEADING_UP, -100f, ConfigurationManager.getInstance().PlayerTwosControls);
            }

            if (fullRegen)
            {
                this.backGround  = new BackGround(this.content);
                this.hud         = new HUD(this.content);
                this.foodManager = new FoodManager(content, this.rand);
                this.portals     = new PortalManager(content, this.rand);
                this.walls       = new WallManager(content, this.rand);
            }

#if DEBUG
            this.debugLine = LoadingUtils.load <Texture2D>(this.content, "Chip");
#endif
        }
Exemplo n.º 2
0
 protected virtual void create()
 {
     this.elapsed = 0f;
     if (this.spawnHandler != null)
     {
         SpawnGenerator.getInstance().SpawnRequests.Enqueue(this.spawnHandler);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
#if DEBUG
            base.Window.Title = GAME_NAME + "...FPS: " + FrameRate.getInstance().calculateFrameRate(gameTime) + "    X:" +
                                InputManager.getInstance().MouseX + " Y:" + InputManager.getInstance().MouseY;

            if (InputManager.getInstance().wasKeyPressed(Keys.R))
            {
                SoundManager.getInstance().removeAllEmitters();
                this.gameDisplay = new GameDisplay(GraphicsDevice, Content);
            }
            if (InputManager.getInstance().wasKeyPressed(Keys.Escape) ||
                InputManager.getInstance().wasButtonPressed(PlayerIndex.One, Buttons.B))
            {
                //SpawnGenerator.getInstance().Running = false;
                //this.Exit();
            }
#endif
            // start the transitions
            handleNewTransition();

            if (StateManager.getInstance().CurrentGameState == GameState.Exit)
            {
                SpawnGenerator.getInstance().Running = false;
                this.Exit();
            }


            base.IsMouseVisible = false;
            if (StateManager.getInstance().CurrentGameState == GameState.Options)
            {
                if (!InputManager.getInstance().isLeftButtonDown())
                {
                    base.IsMouseVisible = true;
                }
            }

            float elapsed = gameTime.ElapsedGameTime.Milliseconds;
            handleTransitionState(elapsed);
            SoundManager.getInstance().update();

            this.activeDisplay.update(elapsed);
            this.transitionItem.update(elapsed);
            base.Update(gameTime);
        }
Exemplo n.º 4
0
    public void SpawnSpawnables(TrainingRoom room, System.Random rand)
    {
        var roomType = roomTypes.GetRandom(rand);
        HashSet <Vector2Int> floorTiles = new HashSet <Vector2Int>(room.unitSpaceFloors);
        HashSet <Vector2Int> wallTiles  = new HashSet <Vector2Int>(room.unitSpaceWalls);

        Debug.Log("LEVEL SPAWNED AT: " + transform.position);

        Vector2Int pos = new Vector2Int(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z)) + room.Position;

        Debug.Log($"LEVEL SPAWN: {pos}");
        RoomType.RoomSet roomSet = roomType.roomSets.GetRandom(rand);
        var spawned = SpawnGenerator.SpawnItemsInRoom(rand, roomType, roomType.roomSets.GetRandom(rand), floorTiles, wallTiles, pos);

        foreach (var item in spawned)
        {
            item.transform.SetParent(room.transform);
        }
    }