Beispiel #1
0
        public void Update()
        {
            StopSound(Sounds.AMBIENT_CITYHUM);

            DrawTexture(gameOverScreen, 0, 0, WHITE);

            if (StaticPlayer.IsCityDead)
            {
                DrawTexture(gameOverScreenCityDead, 0, 0, WHITE);
            }

            DrawText("you survived for", 20, 540, 40, BLACK);
            DrawText(StaticPlayer.Days.ToString(), 20, 580, 72, BLACK);
            DrawText("days.", 20, 652, 40, BLACK);

            if (IsKeyReleased(KEY_SPACE))
            {
                MainClass.stateManager.SwitchState(new StateTitle());
                StaticPlayer.ResetStats();
            }
        }
Beispiel #2
0
        public void Update()
        {
            frames++;

            if ((frames % 10) == 0)
            {
                StaticPlayer.TimeMinute++;
                if (StaticPlayer.TimeMinute == 60)
                {
                    StaticPlayer.TimeHour++;
                    StaticPlayer.TimeMinute = 0;

                    if (StaticPlayer.TimeHour == 12)
                    {
                        StaticPlayer.TimeHour   = 0;
                        StaticPlayer.TimeMinute = 0;
                        StaticPlayer.Days++;
                    }
                }
                StaticPlayer.TurnsSinceLastAction++;
                city.Simulate(tiles);

                if (StaticPlayer.IsCityDead)
                {
                    MainClass.stateManager.SwitchState(new StateGameOver());
                }
                if (StaticPlayer.Heart < 0)
                {
                    MainClass.stateManager.SwitchState(new StateGameOver());
                }
                if (StaticPlayer.Soul < 0)
                {
                    MainClass.stateManager.SwitchState(new StateGameOver());
                }
            }

            if (StaticPlayer.TimeHour < 5)
            {
                DrawTileMap(tiles, GRAY, false, WIDTH, HEIGHT);
            }
            else if (StaticPlayer.TimeHour > 18)
            {
                DrawTileMap(tiles, GRAY, false, WIDTH, HEIGHT);
            }
            else
            {
                DrawTileMap(tiles, WHITE, false, WIDTH, HEIGHT);
            }

            mouse.UpdateMouse(GetMouseX(), GetMouseY());

            MakeTileMapBlank(ref cursorMap, WIDTH, HEIGHT, Tileset.NODRAW);
            cursorMap[mouse.CursorTileX, mouse.CursorTileY] = pallete[palleteIndex];
            DrawTileMap(cursorMap, BLUE, true, WIDTH, HEIGHT);

            ui.Update();
            ui.Render();

            DrawText("mouse x: " + GetMouseX() + " mouse y: " + GetMouseY(), 0, 0, 10, WHITE);
            DrawText("cursor x: " + mouse.CursorX + " cursor y: " + mouse.CursorY, 0, 10, 10, WHITE);
            DrawText("cursor tx: " + mouse.CursorTileX + " cursor ty: " + mouse.CursorTileY, 0, 20, 10, WHITE);
            DrawText("tile @ cursor: " + tiles[mouse.CursorTileX, mouse.CursorTileY].Name, 0, 30, 10, WHITE);
            DrawText("tile selected: " + pallete[palleteIndex].Name, 0, 40, 10, WHITE);

            if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
            {
                //Console.WriteLine("mouse click");
                if (!CheckCollisionPointRec(GetMousePosition(), ui.selfCareButton))
                {
                    if (StaticPlayer.Heart - pallete[palleteIndex].HeartCost > 0)
                    {
                        if (StaticPlayer.Soul - pallete[palleteIndex].SoulCost > 0)
                        {
                            StaticPlayer.Heart -= pallete[palleteIndex].HeartCost;
                            StaticPlayer.Soul  -= pallete[palleteIndex].SoulCost;
                            tiles[mouse.CursorTileX, mouse.CursorTileY] = pallete[palleteIndex];

                            if (pallete[palleteIndex].Name != "GRASS")
                            {
                                if (!pallete[palleteIndex].Name.Contains("ROAD"))
                                {
                                    StaticPlayer.AddToCityHealth(30);
                                }
                            }
                            StaticPlayer.TurnsSinceLastAction  = 0;
                            StaticPlayer.StagnationCoefficient = 1;
                            PlaySound(Sounds.PLACE);
                        }
                    }
                }
            }
            else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
            {
                tiles[mouse.CursorTileX, mouse.CursorTileY] = Tileset.GRASS;
            }

            if (GetMouseWheelMove() > 0)
            {
                IncreasePallete();
            }
            if (GetMouseWheelMove() < 0)
            {
                DecreasePallete();
            }
        }