Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            InputSystem.oldKeybordState = InputSystem.newKeybordState;
            InputSystem.newKeybordState = Keyboard.GetState();
            float delta = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000;

            IsMouseVisible = true;

            if (!hud.huntingSystem.active)
            {
                if (gameInMainMenu)
                {
                    //Resources.Meat = 0;
                    mainMenu.Update();

                    if (mainMenu.ExitButtonEvent())
                    {
                        Exit();
                    }
                    if (mainMenu.NewGameButtonEvent())
                    {
                        gameInMainMenu   = false;
                        IsMouseVisible   = false;
                        mainMenu.ifIntro = true;
                    }
                    if (mainMenu.LoadButtonEvent())
                    {
                        gameInMainMenu = false;
                        IsMouseVisible = false;
                        LoadContent();
                        LoadGame();
                    }
                }
                else if (mainMenu.ifIntro)
                {
                    mainMenu.intro.Update(gameTime);
                    if (mainMenu.intro.IntroEvent())
                    {
                        mainMenu.ifIntro = false;
                        this.LoadContent();
                    }

                    if (InputSystem.newKeybordState.IsKeyDown(Keys.Space))
                    {
                        mainMenu.ifIntro = false;
                        this.LoadContent();
                    }
                }
                else
                {
                    if (InputSystem.newKeybordState.IsKeyDown(Keys.Escape) && InputSystem.oldKeybordState.IsKeyUp(Keys.Escape) && !hud.ifPaused && !hud.ifGameOver)
                    {
                        IsMouseVisible = true;
                        hud.ifPaused   = true;
                        return;
                    }

                    if (!hud.ifPaused && !hud.ifGameOver && !hud.ifQuestPanel)
                    {
                        if (InputSystem.newKeybordState.IsKeyDown(Keys.E))
                        {
                            AudioSystem.playGrowl(2);
                        }

                        if (InputSystem.newKeybordState.IsKeyDown(Keys.F) && InputSystem.oldKeybordState.IsKeyUp(Keys.F) && QuestSystem.currentGiver != null && QuestSystem.currentGiver.actualQuest != QuestSystem.currentQuest)
                        {
                            hud.ifQuestPanel = true;
                        }

                        if (questSystem.ChceckNearestQuestGiver(wataha.wolves[0]))
                        {
                        }
                        else
                        {
                            hud.ifQuestPanel = false;
                        }

                        if (hud.marketPanel.CheckIfWolfIsClose(wataha.wolves[0], barrell))
                        {
                            hud.marketPanel.infoActive = true;
                        }
                        else
                        {
                            hud.marketPanel.infoActive = false;
                            hud.marketPanel.active     = false;
                        }

                        if (hud.marketPanel.infoActive && InputSystem.newKeybordState.IsKeyDown(Keys.F) && InputSystem.oldKeybordState.IsKeyUp(Keys.F))
                        {
                            hud.marketPanel.active = true;
                        }

                        foreach (Wolf w in wataha.wolves)
                        {
                            colisionSystem.IsEnvironmentCollision(w, trees, wataha);
                            if (!(QuestSystem.questGivers[1].actualQuest == null && QuestSystem.questGivers[1].questCompleted.Count == QuestSystem.questGivers[1].questsList.Count))
                            {
                                colisionSystem.IsEnvironmentCollision(w, blockade, wataha);
                            }
                            colisionSystem.IsEnvironmentCollision(w, blockade2, wataha);
                            colisionSystem.IsEnvironmentCollision(w, croft, wataha);
                            colisionSystem.IsEnvironmentCollision(w, barrell, wataha);
                        }
                        foreach (Animal rabit in rabits)
                        {
                            colisionSystem.IsEnvironmentCollision(rabit, trees);
                        }

                        if (QuestSystem.currentQuest is SheepQuest)
                        {
                            foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                            {
                                colisionSystem.IsEnvironmentCollision(sheep, trees);
                            }
                        }

                        wataha.Update(gameTime);
                        questSystem.Update(gameTime, wataha.wolves[0]);
                        foreach (Animal rabit in rabits)
                        {
                            rabit.Update(gameTime);
                        }

                        if (QuestSystem.currentQuest is SheepQuest)
                        {
                            foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                            {
                                sheep.Update(gameTime);
                            }
                        }



                        Vector3[] positions2 = new Vector3[QuestSystem.questGivers.Count];
                        int       i          = 0;
                        foreach (QuestGiver q in QuestSystem.questGivers)
                        {
                            if (QuestSystem.currentQuest == null && q.actualQuest != null && (q.questsGiverNeedToStart == null || (q.questsGiverNeedToStart != null && q.questsGiverNeedToStart.actualQuest == null)))
                            {
                                positions2[i] = new Vector3(QuestSystem.questGivers[i].position.X,
                                                            QuestSystem.questGivers[i].position.Y + 5.0f,
                                                            QuestSystem.questGivers[i].position.Z);
                            }
                            else
                            {
                                positions2[i] = new Vector3(QuestSystem.questGivers[i].position.X,
                                                            QuestSystem.questGivers[i].position.Y + 1000.0f,
                                                            QuestSystem.questGivers[i].position.Z);
                            }
                            i++;
                        }

                        billboardTest2 = new BillboardSystem(GraphicsDevice, Content, Content.Load <Texture2D>("Pictures/questionMark"), new Vector2(0.001f), positions2);
                        trees.Update(gameTime);
                        barrell.Update(gameTime);
                        blockade.Update(gameTime);
                        blockade2.Update(gameTime);
                    }
                    else
                    {
                        if (!hud.ifGameOver)
                        {
                            if (!hud.ifSaveInfo)
                            {
                                if (hud.ResumeButtonEvent())
                                {
                                    hud.ifPaused = false;
                                }
                                if (hud.SaveButtonEvent())
                                {
                                    SaveSystem saver = new SaveSystem(hud.wataha.wolves.ElementAt(0), hud.wataha.wolves.ElementAt(1), hud.wataha.wolves.ElementAt(2));
                                    saver.SaveGame();
                                    hud.ifSaveInfo = true;
                                }
                                if (hud.BackToMainMenuButtonEvent())
                                {
                                    hud.ifPaused   = false;
                                    gameInMainMenu = true;
                                }
                                if (hud.ExitButtonEvent())
                                {
                                    Exit();
                                }
                            }
                            else
                            {
                                hud.InfoSaveOkEvent();
                            }
                        }
                        else
                        {
                            if (hud.InfoGameOverOkEvent())
                            {
                                hud.ifPaused   = false;
                                hud.ifGameOver = false;
                                gameInMainMenu = true;
                            }
                        }
                    }

                    Vector3 offset       = new Vector3(MathHelper.ToRadians(2.0f));
                    Vector3 randAngle    = Vector3.Up + randVec3(-offset, offset);
                    Vector3 randPosition = randVec3(new Vector3(-1.5f), new Vector3(1.5f));
                    float   randSpeed    = (float)rand.NextDouble() * 2 + 10;

                    ps.AddParticle(randPosition, randAngle, randSpeed);
                    ps.Update();

                    hud.Update(gameTime);


                    GameObject.changeDay(gameTime);
                }
            }

            else
            {
                hud.huntingSystem.Update(gameTime);
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (InputSystem.newKeybordState.IsKeyDown(Keys.P))
            {
                ClearHunting();
                active = false;
            }
            if (hudHunting.okButtonEvent() && hudHunting.ifEndHuntingWindow)
            {
                ClearHunting();
                active = false;
            }



            if (time >= 3)
            {
                GenerateRabits(huntingWataha.wolves[0], rabitModel);
                time = 0;
            }
            else
            {
                time += gameTime.ElapsedGameTime.TotalMilliseconds / 1000;
            }

            if (timeS >= 4)
            {
                GenerateSheeps(huntingWataha.wolves[0], rabitModel);
                timeS = 0;
            }
            else
            {
                timeS += gameTime.ElapsedGameTime.TotalMilliseconds / 1000;
            }
            if (timeB >= 7)
            {
                GenerateBoars(huntingWataha.wolves[0], rabitModel);
                timeB = 0;
            }
            else
            {
                timeB += gameTime.ElapsedGameTime.TotalMilliseconds / 1000;
            }


            CheckKilledRabits();
            CheckKilledSheeps();
            CheckKilledBoars();

            if (!hudHunting.ifInfoHuntingWindow && !hudHunting.ifEndHuntingWindow)
            {
                foreach (Wolf w in huntingWataha.wolves)
                {
                    colisionSystem.IsEnvironmentCollision(w, trees, huntingWataha);
                }

                foreach (Animal a in rabits)
                {
                    if (a.active)
                    {
                        a.Update(gameTime);
                        colisionSystem.IsEnvironmentCollision(a, trees);
                    }
                }
                foreach (Animal a in sheeps)
                {
                    if (a.active)
                    {
                        a.Update(gameTime);
                        colisionSystem.IsEnvironmentCollision(a, trees);
                    }
                }
                foreach (Animal a in boars)
                {
                    if (a.active)
                    {
                        a.Update(gameTime);
                        colisionSystem.IsEnvironmentCollision(a, trees);
                    }
                }
                huntingWataha.Update(gameTime);
                GameObject.changeDay(gameTime);
            }

            hudHunting.Update(gameTime);
            trees.Update(gameTime);
        }