public Player(PlayerDefinition definition) { X = definition.X; Y = definition.Y; Name = definition.Name; ZoneKey = definition.ZoneKey; DebugGame.Log("Player", "Player", "Création du player " + Name + " en " + X + ", " + Y + " de la zone " + ZoneKey); }
// Use this for initialization public void Start() { StateManager.Instance.SetGameState(EnumGameState.MainMenu); StateManager.Instance.SetGameState(EnumGameState.Game); #if true //StateManager.Instance.SetGameState(EnumGameState.Game); DebugGame.ShowFps(); #else #endif }
// Update is called once per frame public void Update(GameTime gameTime) { StateManager.Instance.Update(gameTime); #if true DebugGame.Update(); //_fps.text = "FPS : " + DebugGame.GetFps(); #endif //if (Input.GetKeyDown(KeyCode.Escape)) //{ // Application.Quit(); //} }
public void GenerateZone() { DebugGame.Log("MapManager", "GetZone", "Création de la zone..."); var sw = new Stopwatch(); sw.Start(); _zone = new Zone(0, 0, Settings.ZoneWidth, Settings.ZoneHeight); _zone.Generate(); DebugGame.Log("MapManager", "GetZone", "Création de la zone (" + sw.ElapsedMilliseconds + " ms)"); if (OnNewZoneCreated != null) { OnNewZoneCreated(_zone); } }
public void SetGameState(EnumGameState gameState) { if (m_gameState.HasValue) { m_gameStates[m_gameState.Value].End(); } bool stateHasChanged = false; switch (gameState) { case EnumGameState.MainMenu: if (!m_gameState.HasValue || m_gameState.Value == EnumGameState.Pause) { m_gameStates.Clear(); m_gameStates[gameState] = new MainMenuState(); stateHasChanged = true; } break; case EnumGameState.Game: if (m_gameState.HasValue && (m_gameState.Value == EnumGameState.MainMenu || m_gameState.Value == EnumGameState.Pause)) { if (m_gameState.Value == EnumGameState.MainMenu) { m_gameStates[gameState] = new GameState(); m_gameStates[gameState].Start(); } else if (m_gameState.Value == EnumGameState.Pause) { m_gameStates[gameState].Resume(); } stateHasChanged = true; } break; case EnumGameState.Pause: if (m_gameState.HasValue && m_gameState.Value == EnumGameState.Game) { m_gameStates[m_gameState.Value].Pause(); m_gameStates[gameState] = new PauseState(); m_gameStates[gameState].Start(); stateHasChanged = true; } break; } if (stateHasChanged) { DebugGame.Log( "StateManager", "SetGameState", string.Format("L'état du jeu a été modifié ! ({0} => {1})", m_gameState, gameState)); this.m_gameState = gameState; } else { DebugGame.Log( "StateManager", "SetGameState", string.Format("L'état du jeu n'a pas pu être modifié ! ({0} => {1})", m_gameState, gameState)); } }
public void Generate() { DebugGame.Log("Zone", "Generate", "Génération de la zone"); //Perlin int width = Settings.ZoneWidth; int height = Settings.ZoneHeight; int octaveCount = 5; float[][] perlinNoise = PerlinNoise.GeneratePerlinNoise(width, height, octaveCount); //var simplex = new OpenSimplexNoise(); var terrainGrass = new Terrain(TypeTerrain.Grass); var terrainRock = new Terrain(TypeTerrain.Rock); var terrainDirt = new Terrain(TypeTerrain.Dirt); for (var line = 0; line < Height; line++) { for (var col = 0; col < Width; col++) { //var altitude = (simplex.Evaluate(line, col))* 4f; var altitude = (perlinNoise[line][col] - 0.5f) * 50f; //if (altitude < -6) //{ // layer.Tiles[line, col] = new Tile() // { // X = col, // Y = line, // Terrain = terrainDirt, // Water = 3, // Altitude = (int)altitude // }; //} //else if (altitude < -4) //{ // layer.Tiles[line, col] = new Tile() // { // X = col, // Y = line, // Terrain = terrainDirt, // Water = 2, // Altitude = (int)altitude // }; //} //else if (altitude < -2) //{ // layer.Tiles[line, col] = new Tile() // { // X = col, // Y = line, // Terrain = terrainDirt, // Water = 1, // Altitude = (int)altitude // }; //} //else if (altitude > 5) { LayerFloor.Tiles[line, col] = new Tile() { X = col, Y = line, Terrain = terrainRock, Water = 0, Altitude = (int)altitude }; } else if (altitude > 3) { LayerFloor.Tiles[line, col] = new Tile() { X = col, Y = line, Terrain = terrainDirt, Water = 0, Altitude = (int)altitude }; } else { LayerFloor.Tiles[line, col] = new Tile() { X = col, Y = line, Terrain = terrainGrass, Water = 0, Altitude = (int)altitude }; } } } }