Beispiel #1
0
        } //update things based on game state

        void UpdateGame(float es_)
        {
            ParticleSystem.UpdateAll(es_);

            EntityCollection.UpdateAll(es_);
            gameTick.Update(es_);
            if (gameTick.Complete())
            {
                GameData.Tick();
                gameTick.Reset();
            }

            villagerTick.Update(es_);
            if (villagerTick.Complete())
            {
                if (GameData.citizensOutside < GameData.MaxVillagers)
                {
                    CreateVillager("c**t");
                }

                villagerTick.time = (float)rng.Next(3, 15);
                villagerTick.Reset();
            }

            UpdateHoveredLocation();

            if (GameData.madness >= 90 && !GameData.cultExists)
            {
                GameData.cultExists = true;
                Building cult = new Building(
                    new DrawerCollection(
                        new List <TextureDrawer>()
                {
                    SpriteSheetCollection.GetTex("idle", "defBuildings", "cult"),
                    SpriteSheetCollection.GetTex("idle", "defBuildings", "cult"),
                    SpriteSheetCollection.GetTex("idle", "defBuildings", "cult")
                },
                        "cult"),
                    new PositionManager(new Vector2(46, 24)),
                    new List <Property>(),
                    5,
                    "cult",
                    ""
                    );
                EntityCollection.AddEntity(cult);
            }

            changeTooltipText = true;
            bool x = false;

            foreach (Building building in EntityCollection.GetGroup("buildings"))
            {
                if (building.Name == "cult")
                {
                    building.hoveredText = "";
                }
                else if (building.Name == "bridge")
                {
                    building.hoveredText = "the god's anger is at " + GameData.godAnger.ToString() + " and his hunger is at " + GameData.godHunger.ToString() + ". you currently have " + GameData.TotalCitizens.ToString() + " villagers. Appease the god?";
                }
                else
                {
                    building.hoveredText = GameData.UpgradeCost(building.Name) + ". Level:" + GameData.LevelOfBuilding(building.Name).ToString();
                }
                if (!x && new Rectangle(building.posman.pos.ToPoint(), building.GetBounds().Size).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos())))
                {
                    if (cursor.GetClicked() && GameData.CanUpgrade(building.Name))
                    {
                        if (!building.wasClicked)
                        {
                            switch (building.Name)
                            {
                            case "field":
                                //CreateVillager("farmer");
                                if (GameData.CanUpgrade("field"))
                                {
                                    GameData.Upgrade("field");
                                }
                                SoundManager.PlayEffect("build");
                                break;

                            case "mine":
                                //CreateVillager("miner");
                                if (GameData.CanUpgrade("mine"))
                                {
                                    GameData.Upgrade("mine");
                                }
                                SoundManager.PlayEffect("build");
                                break;

                            case "forest":
                                //CreateVillager("lumberjack");
                                if (GameData.CanUpgrade("forest"))
                                {
                                    GameData.Upgrade("forest");
                                }
                                SoundManager.PlayEffect("build");
                                break;

                            case "city":
                                if (GameData.CanUpgrade("city"))
                                {
                                    GameData.Upgrade("city");
                                }
                                SoundManager.PlayEffect("build");
                                break;

                            case "church":
                                if (GameData.CanUpgrade("church"))
                                {
                                    GameData.Upgrade("church");
                                }
                                SoundManager.PlayEffect("build");
                                break;

                            case "bridge":
                                foreach (God god in EntityCollection.GetGroup("god"))
                                {
                                    god.Attack();
                                }
                                break;
                            }
                        }
                        building.Click();
                    }
                    else
                    {
                        if (building.hoveredText != null)
                        {
                            tooltipText = building.hoveredText; changeTooltipText = false;
                        }
                        if (GameData.CanUpgrade(building.Name))
                        {
                            building.isHovered = true;
                        }
                    }
                    x = true;
                }
                else
                {
                    building.isHovered = false;
                }
            }

            if (new Rectangle(10, 165, 100, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos())))
            {
                tooltipText       = "The village's madness is at " + GameData.madness.ToString() + "/100";
                changeTooltipText = false;
            }
            else if (new Rectangle(135, 165, 50, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos())) && GameData.cultExists)
            {
                tooltipText       = GameData.daysUntilDoom.ToString() + " days until doom.";
                changeTooltipText = false;
            }
            else if (new Rectangle(260, 165, 100, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos())))
            {
                tooltipText       = "Next day in " + Math.Ceiling(gameTick.timer).ToString() + " s";
                changeTooltipText = false;
            }
        } //update the movey things