Esempio n. 1
0
        public Game()
        {
            _bgm      = new Music("../SFX/bgm.ogg");
            _bgm.Loop = true;
            _bgm.Play();
            // Predefine game state to menu
            _gameState = State.Menu;
            _menuState = eMenuState.MS_START;

            //TODO  Default values, replace with correct ones !
            SmartSprite._scaleVector = new Vector2f(2.0f, 2.0f);
            ScreenEffects.Init(new Vector2u(800, 600));
            ParticleManager.SetPositionRect(new FloatRect(-500, 0, 1400, 600));
            //ParticleManager.Gravity = GameProperties.GravitationalAcceleration;


            ResetCreationParameters();


            try
            {
                SmartText._font = new Font("../GFX/font.ttf");

                SmartText._lineLengthInChars = 18;
                SmartText._lineSpread        = 1.2f;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    public void OnLoadLobby()
    {
        LoadMenu(LobbyGroup);
        State = eMenuState.LOBBY;

        if (LobbyManagerWrapper.Instance.bIsHost)
        {
            ShowIPText();
        }
    }
Esempio n. 3
0
    public void OnMenuUITransition(eMenuState newState)
    {
        if (menuState == newState)
        {
            return;
        }

        TransitionMenu(menuState, newState);
        menuState = newState;
    }
Esempio n. 4
0
    void SetTarget(eMenuState state)
    {
        if (TargetState != CurrentState)
        {
            return;
        }

        TargetState = state;
        TimeInState = 0;
    }
Esempio n. 5
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     instance  = this;
     loaded    = false;
     menuState = eMenuState.NONE;
     DontDestroyOnLoad(gameObject);
 }
Esempio n. 6
0
    protected override void Update()
    {
        base.Update();

        TimeInState += Time.deltaTime;

        if (CurrentState != TargetState)
        {
            var progress = FadeDown.Evaluate(TimeInState);
            SetAllButtonFade(progress);

            if (progress <= 0f)
            {
                CurrentState = TargetState;
                RemoveAllButtons();
                switch (TargetState)
                {
                case eMenuState.Main:
                    MainMenu();
                    break;

                case eMenuState.Settings:
                    SettingsMenu();
                    break;

                case eMenuState.Credits:
                    CreditsMenu();
                    break;

                case eMenuState.DebugSettings:
                    DebugSettingsMenu();
                    break;

                case eMenuState.LevelSelect:
                    LevelPickerMenu();
                    break;

                case eMenuState.ExitConfirm:
                    ExitConfirm();
                    break;

                default:
                    Logger.LogError($"unexpected state: {TargetState}");
                    break;
                }
                TimeInState = 0;
            }
        }
        else
        {
            var progress = FadeUp.Evaluate(TimeInState);
            SetAllButtonFade(progress);
        }
    }
    // Use this for initialization
    void Awake()
    {
        if (Instance)
        {
            DestroyImmediate(Instance);
            Instance = null;
        }

        Instance = this;

        State       = eMenuState.TITLE;
        currentMenu = TitleGroup;
    }
Esempio n. 8
0
    private void TransitionMenu(eMenuState prevState, eMenuState newState)
    {
        switch (newState)
        {
        case eMenuState.HOME:
            panelMenuHome.Enable(true);
            break;

        case eMenuState.GAME:
            panelGameHud.Enable(true);
            break;

        case eMenuState.RESULTS:
            panelGameResult.Enable(true);
            break;
        }
    }
Esempio n. 9
0
        public void Update(Cursor oCursor, Camera oCamera, Stats oStats, Hex[,] oHexes, Robber oRobber)
        {
            Random oRandom = new Random();

            oKeyState = Keyboard.GetState();

            //XNACS1Base.EchoToTopStatus("HUD:" + oPickedUpCard);

            #region Year of Plenty Menu (test) (F3)
            if (oYearOfPlentymenu == null && oKeyState.IsKeyDown(Keys.F3))
            {
                oYearOfPlentymenu = new YearOfPlentyMenu();
                RedrawCards(oStats, oCamera);
            }
            if (oYearOfPlentymenu != null)
            {
                oYearOfPlentymenu.Update(oCursor, oCamera, this, oStats.oPlayers[0]);

                if (oYearOfPlentymenu.bFinished == true)
                {
                    oYearOfPlentymenu.Clear();
                    oYearOfPlentymenu = null;
                }
            }
            #endregion

            #region Monopoly Menu (test) (F4)
            if (oMonopolyMenu == null && oKeyState.IsKeyDown(Keys.F4))
            {
                oMonopolyMenu = new MonopolyMenu();
                RedrawCards(oStats, oCamera);
            }
            if (oMonopolyMenu != null)
            {
                oMonopolyMenu.Update(oCursor, oCamera, this, oStats.oPlayers);

                if (oMonopolyMenu.bFinished == true)
                {
                    oMonopolyMenu.Clear();
                    oMonopolyMenu = null;
                }
            }
            #endregion

            #region Road Building Menu (test) (F5)
            if (oRoadBuildingMenu == null && oKeyState.IsKeyDown(Keys.F5))
            {
                oRoadBuildingMenu = new RoadBuildingMenu();
                RedrawCards(oStats, oCamera);
            }
            if (oRoadBuildingMenu != null)
            {
                oRoadBuildingMenu.Update(oCursor, oCamera, this, oStats.oPlayers);

                if (oRoadBuildingMenu.bFinished == true)
                {
                    oRoadBuildingMenu.Clear();
                    oRoadBuildingMenu = null;
                }
            }
            #endregion

            #region Knight Menu (test) (F6)
            if (oKnightMenu == null && oKeyState.IsKeyDown(Keys.F6))
            {
                oKnightMenu = new KnightMenu();
                RedrawCards(oStats, oCamera);
            }
            if (oKnightMenu != null)
            {
                oKnightMenu.Update(oCursor, oCamera, this, oStats.oPlayers, oRobber);

                if (oKnightMenu.bFinished == true)
                {
                    oKnightMenu.Clear();
                    oKnightMenu = null;
                }
            }
            #endregion

            #region Statistics Menues (F7-F9)
            // button press
            if (MenuState == eMenuState.NONE)
            {
                if (oKeyState.IsKeyDown(Keys.F7))
                {
                    MenuState = eMenuState.TURN_RECORDS;
                }
                else if (oKeyState.IsKeyDown(Keys.F8))
                {
                    MenuState = eMenuState.RESOURCE_GRAPHS;
                }
                else if (oKeyState.IsKeyDown(Keys.F9))
                {
                    MenuState = eMenuState.TABLE;
                }
            }

            // update
            if (oStatisticsMenu1 != null)
            {
                eMenuState oCurrent = oStatisticsMenu1.Update(oCamera, oCursor);

                if (oCurrent != eMenuState.NO_CHANGE)
                {
                    oStatisticsMenu1.Clear();
                    oStatisticsMenu1 = null;
                    MenuState        = oCurrent;
                }
            }
            else if (oStatisticsMenu2 != null)
            {
                eMenuState oCurrent = oStatisticsMenu2.Update(oCamera, oCursor);

                if (oCurrent != eMenuState.NO_CHANGE)
                {
                    oStatisticsMenu2.Clear();
                    oStatisticsMenu2 = null;
                    MenuState        = oCurrent;
                }
            }
            else if (oStatisticsMenu3 != null)
            {
                eMenuState oCurrent = oStatisticsMenu3.Update(oCamera, oCursor);

                if (oCurrent != eMenuState.NO_CHANGE)
                {
                    oStatisticsMenu3.Clear();
                    oStatisticsMenu3 = null;
                    MenuState        = oCurrent;
                }
            }

            // create
            if (MenuState == eMenuState.TURN_RECORDS && oStatisticsMenu1 == null)
            {
                oStatisticsMenu1 = new StatisticsMenu1(oStats, oCamera);
            }
            else if (MenuState == eMenuState.RESOURCE_GRAPHS && oStatisticsMenu2 == null)
            {
                oStatisticsMenu2 = new StatisticsMenu2(oStats, oCamera);
            }
            else if (MenuState == eMenuState.TABLE && oStatisticsMenu3 == null)
            {
                oStatisticsMenu3 = new StatisticsMenu3(oStats, oCamera);
            }
            #endregion

            #region HUD Follow Camera
            // hud
            this.Center = oCamera.oCenter + oHUDDisplacement;

            // cards
            for (int x = 0; x < oCards.Count(); x++)
            {
                for (int y = 0; y < oCards[x].Count(); y++)
                {
                    oCards[x][y].Center = oCardDisplacements[x][y] + oCamera.oCenter;
                }
            }

            // buttons
            for (int x = 0; x < oButtons.Count(); x++)
            {
                oButtons[x].Center = oButtonDisplacement[x] + oCamera.oCenter;
            }
            #endregion

            #region Update Small HUDs
            for (int x = 0; x < oSmallHUDs.Count(); x++)
            {
                oSmallHUDs[x].Update(oCamera, oCursor, oStats, this);
                oSmallHUDs[x].nScores[0] = oStats.oPlayers[x + 1].nVictoryPoints;
                oSmallHUDs[x].nScores[1] = oStats.oPlayers[x + 1].nArmyCount;
                oSmallHUDs[x].nScores[2] = oStats.oPlayers[x + 1].nLongestRoad;
                oSmallHUDs[x].nScores[3] = oStats.oPlayers[x + 1].nDevelopmentCardCount;
                oSmallHUDs[x].nScores[4] = oStats.oPlayers[x + 1].nResourceCardCount;
            }
            #endregion

            #region Road Button (Left Click), Cancel Building (Right Click)
            if (oCursor.LeftClick() == true && oButtons[0].Collided(oCursor.oHitbox))
            {
                XNACS1Base.PlayACue("ButtonClick");

                if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildRoad() || oStats.oPlayers[oStats.nCurrentPlayer].nFreeRoads > 0)
                {
                    oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.ROAD;
                    ChangeSelectedButton(oStats);
                }
            }
            else if (oCursor.RightClick())
            {
                oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.NONE;
                ChangeSelectedButton(oStats);
            }
            #endregion

            #region Settlement Button Click
            if (oCursor.LeftClick() == true && oButtons[1].Collided(oCursor.oHitbox))
            {
                XNACS1Base.PlayACue("ButtonClick");

                if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildSettlement())
                {
                    oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.SETTLEMENT;
                    ChangeSelectedButton(oStats);
                }
            }
            #endregion

            #region City Button Click
            if (oCursor.LeftClick() == true && oButtons[2].Collided(oCursor.oHitbox))
            {
                XNACS1Base.PlayACue("ButtonClick");

                if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildCity())
                {
                    oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.CITY;
                    ChangeSelectedButton(oStats);
                }
            }
            #endregion

            #region Development Card Button Click
            if (oCursor.LeftClick() == true && oButtons[3].Collided(oCursor.oHitbox))
            {
                XNACS1Base.PlayACue("ButtonClick");

                if (oStats.oPlayers[oStats.nCurrentPlayer].CanGetDevelopment(oStats.nResourceCardsLeft))
                {
                    oStats.oPlayers[oStats.nCurrentPlayer].GetDevelopment(oStats.nResourceCardsLeft, this);
                    oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.NONE;
                    ChangeSelectedButton(oStats);
                    ShowCards(oStats.oPlayers[oStats.nCurrentPlayer].nCards, oCamera);
                }
            }
            #endregion

            #region Dice Button Click
            if (oCursor.LeftClick() == true && oButtons[4].Collided(oCursor.oHitbox) && bRollMade == false)
            {
                XNACS1Base.PlayACue("ButtonClick");
                oButtons[4].TextureTintColor = oUnselectedColor;
                //bRollMade = true;
                int nRoll1 = oRandom.Next() % 6 + 1;
                int nRoll2 = oRandom.Next() % 6 + 1;
                nCurrentRoll = nRoll1 + nRoll2;
                oDice[0].SetTextureSpriteAnimationFrames(nRoll1, 0, nRoll1, 0, 1, SpriteSheetAnimationMode.AnimateForward);
                oDice[1].SetTextureSpriteAnimationFrames(nRoll2, 1, nRoll2, 1, 1, SpriteSheetAnimationMode.AnimateForward);
                oStats.AddRollRecord(nCurrentRoll - 2);

                if (nCurrentRoll == 7 && bRobberEnabled == true)
                {
                    oRobber.ShowMessage();
                    oRobber.bMoveRobber = true;
                    oStats.oPlayers[0].UpdateCardCount();

                    if (oStats.oPlayers[0].nResourceCardCount > 7)
                    {
                        oRobberMenu = new RobberMenu(oStats.oPlayers[0].nResourceCardCount);
                        RedrawCards(oStats, oCamera);
                    }
                }

                int[] nResourceRecord = new int[22];
                nResourceRecord[20] = nCurrentRoll;
                nResourceRecord[21] = oStats.nCurrentTurn;

                for (int x = 0; x < 5; x++) // give resources to players
                {
                    for (int y = 0; y < 5; y++)
                    {
                        if (oHexes[x, y] != null)
                        {
                            oHexes[x, y].GiveResources(nCurrentRoll, oStats, nResourceRecord);
                        }
                    }
                }

                oStats.AddTurnRecord(nResourceRecord);
                ShowCards(oStats.oPlayers[0].nCards, oCamera);
            }
            #endregion

            #region Trade Button Click
            if (oCursor.LeftClick() == true && oButtons[5].Collided(oCursor.oHitbox))
            {
                XNACS1Base.PlayACue("ButtonClick");
                oTradeMenu = new TradeMenu();
                RedrawCards(oStats, oCamera);
            }
            #endregion

            #region End Turn Button Click
            if (CanEndTurn(oRobber))
            {
                oButtons[6].TextureTintColor = oOriginalColor;
                if (oCursor.LeftClick() == true && oButtons[6].Collided(oCursor.oHitbox) && bRollMade == true)
                {
                    XNACS1Base.PlayACue("ButtonClick");
                    oButtons[4].TextureTintColor = oOriginalColor;
                    bRollMade = false;
                    oStats.PassTurn();
                    oTurnNumber.Label    = "" + oStats.nCurrentTurn;
                    oCurrentPlayer.Label = "" + oStats.oPlayers[oStats.nCurrentPlayer].sName;
                }
            }
            else
            {
                oButtons[6].TextureTintColor = oUnselectedColor;
            }
            #endregion

            #region Trade Menu
            if (oTradeMenu != null)
            {
                oTradeMenu.Update(oCamera, oCursor, this, oStats);

                if (oTradeMenu.bFinished == true)
                {
                    oTradeMenu.Clear();
                    oTradeMenu = null;
                }
            }
            #endregion

            #region Robber Menu
            if (oRobberMenu != null)
            {
                oRobberMenu.Update(oCamera, oCursor, this);

                if (oRobberMenu.bFinished == true)
                {
                    oRobberMenu.Clear();
                    oRobberMenu = null;
                }
            }
            #endregion

            #region Pick Up Card/Card Follow Cursor
            // move picked up card
            if (oPickedUpCard != null)
            {
                oPickedUpCard.Center = oCursor.oHitbox.Center;

                if (oCursor.IsLeftMouseDown() == false)
                {
                    if (oTradeMenu != null && oCursor.oHitbox.Collided(oTradeMenu) ||
                        oRobberMenu != null && oCursor.oHitbox.Collided(oRobberMenu))
                    {
                        oStats.oPlayers[0].nCards[nPickedUpCard]--;
                    }

                    oPickedUpCard = null;
                    nPickedUpCard = -1;
                    ShowCards(oStats.oPlayers[0].nCards, oCamera);
                }
            }

            // pick up the card
            if (oCursor.LeftClick() == true && oPickedUpCard == null)
            {
                for (int x = 0; x < oCards.Count(); x++)
                {
                    if (oCards[x].Count > 0 && oCursor.oHitbox.Collided(oCards[x][oCards[x].Count - 1]) == true)
                    {
                        oPickedUpCard = oCards[x][oCards[x].Count - 1];
                        nPickedUpCard = x;

                        if (oPickedUpCard.Visible == false)
                        {
                            oPickedUpCard.Visible = true;
                            oCards[x][0].Label    = "" + (oCards[x].Count - 1);
                        }
                    }
                }
            }
            #endregion

            for (int x = 0; x < oDice.Count(); x++)
            {
                oDice[x].Center = oCamera.oCenter + oDiceDisplacement[x];
            }
            oTurnNumber.Center    = oCamera.oCenter + oTurnNumberDisplacement;
            oCurrentPlayer.Center = oCamera.oCenter + oCurrentPlayerDisplacement;
        }
Esempio n. 10
0
 void LoadJoinState()
 {
     LoadMenu(JoinGroup);
     State = eMenuState.JOIN;
 }
Esempio n. 11
0
 void LoadHostState()
 {
     LoadMenu(HostGroup);
     State = eMenuState.HOST;
 }
Esempio n. 12
0
 void LoadMenuState()
 {
     LoadMenu(MenuGroup);
     State = eMenuState.MENU;
 }
Esempio n. 13
0
        private void GetInputMenu()
        {
            if (Keyboard.IsKeyPressed(Keyboard.Key.Return))
            {
                if (_menuState == eMenuState.MS_START)
                {
                    _menuState        = eMenuState.MS_WORLD;
                    _timeTilNextInput = 0.5f;
                }
                else if (_menuState == eMenuState.MS_WORLD)
                {
                    if (EvolutionPoints >= GameProperties.EvolutionPointsStart - GameProperties.EvolutionPointsWorldMax)
                    {
                        _menuState        = eMenuState.MS_TRIBE;
                        _timeTilNextInput = 0.5f;
                    }
                }
                else if (_menuState == eMenuState.MS_TRIBE)
                {
                    if (EvolutionPoints >= 0)
                    {
                        StartGame();
                    }
                }
            }
            else if (Keyboard.IsKeyPressed(Keyboard.Key.Back))
            {
                if (_menuState == eMenuState.MS_START)
                {
                    // Nothingness
                }
                else if (_menuState == eMenuState.MS_WORLD)
                {
                    //Nothingness squared
                }
                else if (_menuState == eMenuState.MS_TRIBE)
                {
                    _menuState        = eMenuState.MS_WORLD;
                    _timeTilNextInput = 0.5f;
                }
            }


            if (_menuState == eMenuState.MS_WORLD)
            {
                GetInputWorldCreation();
            }
            else if (_menuState == eMenuState.MS_TRIBE)
            {
                GetInputTribeCreation();
            }
            else if (_menuState == eMenuState.MS_START)
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.A))
                {
                    _menuState        = eMenuState.MS_ABOUT;
                    _timeTilNextInput = 0.5f;
                }
            }
            else if (_menuState == eMenuState.MS_ABOUT)
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.A) || Keyboard.IsKeyPressed(Keyboard.Key.Escape) || Keyboard.IsKeyPressed(Keyboard.Key.Return))
                {
                    _menuState        = eMenuState.MS_START;
                    _timeTilNextInput = 0.25f;
                }
            }


            if (Keyboard.IsKeyPressed(Keyboard.Key.C))
            {
                ChangeGameState(State.Credits);
            }
        }