Exemplo n.º 1
0
        void Start()
        {
            GM = FindObjectOfType <GameManager>();

            if ((Elly == Ellyments.BlackPlayerHealth) || (Elly == Ellyments.BlackPlayerShields) || (Elly == Ellyments.WhitePlayerHealth) || (Elly == Ellyments.WhitePlayerShields))
            {
                White = GameObject.FindGameObjectWithTag("WhitePlayer").GetComponent <PlayerController>();
                Black = GameObject.FindGameObjectWithTag("BlackPlayer").GetComponent <PlayerController>();
            }

            if ((Elly == Ellyments.Player1ShipSelection) || (Elly == Ellyments.Player2ShipSelection))
            {
                SS = FindObjectOfType <ShipSelection>();

                for (int i = 0; i < transform.childCount; i++)
                {
                    ShipSelectionOptions.Add(transform.GetChild(i).gameObject);
                }

                SS.Player1MaxPos = transform.childCount;
                SS.Player2MaxPos = transform.childCount;
            }

            if ((Elly == Ellyments.LeaderboardP1Value) || (Elly == Ellyments.LeaderboardP2Value))
            {
                Data = SaveManager.LoadOperationStarshine();
            }

            SSLBS = FindObjectOfType <StarshineLeaderboardsSend>();

            UIUNeedsUpdating = true;
        }
Exemplo n.º 2
0
        private void Awake()
        {
            PlayersAlive = 2;

            _data = SaveManager.LoadOperationStarshine();
            Player1ShipPrefabs[_data.LastPlayer1ShipSelection].SetActive(true);
            Player2ShipPrefabs[_data.LastPlayer2ShipSelection].SetActive(true);
        }
Exemplo n.º 3
0
        IEnumerator WaitToChangeScene()
        {
            IsCoRunning = true;
            //Trans.SetFloat("Multi", 2f);
            Trans.SetBool("ChangeScene", true);
            yield return(new WaitForSeconds(1f));

            _data = SaveManager.LoadOperationStarshine();
            _data.LastPlayer1ShipSelection = (int)Player1ShipChoice;
            _data.LastPlayer2ShipSelection = (int)Player2ShipChoice;
            SaveManager.SaveOperationStarshine(_data);
            SceneManager.LoadSceneAsync("Operation-Starshine-Level");
            IsCoRunning = false;
        }
Exemplo n.º 4
0
        private void Update()
        {
            if (IsGameOver())
            {
                // need the get both players stuff here somehow....
                _data              = SaveManager.LoadOperationStarshine();
                _Player1Stats      = Player1ShipPrefabs[_data.LastPlayer1ShipSelection].GetComponent <ShipManagement>().PlayerStats;
                _Player2Stats      = Player2ShipPrefabs[_data.LastPlayer2ShipSelection].GetComponent <ShipManagement>().PlayerStats;
                _data.player1Stats = _Player1Stats;
                _data.player2Stats = _Player2Stats;
                _data.Player1Score = Player1Score;
                _data.Player2Score = Player2Score;
                SaveManager.SaveStarshinePlayerStats(_data);

                if (OverlayCG.alpha > 0)
                {
                    OverlayCG.alpha = -1f * Time.deltaTime;
                }

                StartCoroutine(ChangeToLoseScene());
            }


            if (IsGameVictory)
            {
                _data              = SaveManager.LoadOperationStarshine();
                _Player1Stats      = Player1ShipPrefabs[_data.LastPlayer1ShipSelection].GetComponent <ShipManagement>().PlayerStats;
                _Player2Stats      = Player2ShipPrefabs[_data.LastPlayer2ShipSelection].GetComponent <ShipManagement>().PlayerStats;
                _data.player1Stats = _Player1Stats;
                _data.player2Stats = _Player2Stats;
                _data.Player1Score = Player1Score;
                _data.Player2Score = Player2Score;
                SaveManager.SaveStarshinePlayerStats(_data);

                for (int i = 0; i < FindObjectsOfType <PlayerController>().Length; i++)
                {
                    FindObjectsOfType <PlayerController>()[i].enabled = false;
                }

                StartCoroutine(ChangeToVictoryScene());
            }
        }
Exemplo n.º 5
0
        private new void Update()
        {
            if (currentScreen == Screens.Input)
            {
                if (P1Ready && P2Ready /*&& (!string.IsNullOrEmpty(keyboards[0].InputtedValue)) && (!string.IsNullOrEmpty(keyboards[1].InputtedValue))*/)
                {
                    if (Confirm())
                    {
                        loadedData          = SaveManager.LoadOperationStarshine();
                        changeToLeaderboard = true;
                    }
                }

                // Keyboard backlights and confirming
                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    // Player 1
                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    // Player 1
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Return) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    // Player 1
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    // Player 1
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    // Player 1
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Return) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                default:
                    break;
                }

                // if move screen - do canvas grouip fades
                if ((changeToLeaderboard) && (canvasGroups[0].alpha != 0) && (canvasGroups[1].alpha != 1))
                {
                    canvasGroups[0].alpha -= 2 * Time.deltaTime;
                    canvasGroups[1].alpha += 2 * Time.deltaTime;

                    if (canvasGroups[0].alpha == 0 && canvasGroups[1].alpha == 1)
                    {
                        if (keyboards[0].GetFinalValue() != null)
                        {
                            leaderboardData.Player1Name = keyboards[0].GetFinalValue();
                        }
                        else
                        {
                            leaderboardData.Player1Name = "Unknown";
                        }

                        if (keyboards[1].GetFinalValue() != null)
                        {
                            leaderboardData.Player2Name = keyboards[1].GetFinalValue();
                        }
                        else
                        {
                            leaderboardData.Player2Name = "Unknown";
                        }

                        leaderboardData.Player1Score    = loadedData.Player1Score;
                        leaderboardData.Player2Score    = loadedData.Player2Score;
                        leaderboardData.Player1ShipName = ConvertToShipName(loadedData.LastPlayer1ShipSelection);
                        leaderboardData.Player2ShipName = ConvertToShipName(loadedData.LastPlayer2ShipSelection);

                        if (ControllerType == SupportedControllers.ArcadeBoard)
                        {
                            leaderboardData.Platform = "Arcade";
                        }
                        else
                        {
                            leaderboardData.Platform = "PC";
                        }

                        isLeaderboardScreen = true;
                        currentScreen       = Screens.Leaderboard;
                        sendScript.SendDataToBoard(leaderboardData);
                        UpdateStatsScreen();
                    }
                }
            }
            else
            {
                MoveUD();
                UpdateMenuOptions();
                UpdateStatsScreen();

                if (isLeaderboardScreen)
                {
                    UpdateLeaderboardRow();
                    isLeaderboardScreen = false;
                }

                if (Confirm())
                {
                    switch (pos)
                    {
                    case 0:
                        animator.SetBool("ChangeScene", true);
                        ChangeScene("Operation-Starshine-Level", 1.1f);
                        break;

                    case 1:
                        animator.SetBool("ChangeScene", true);
                        ChangeScene("Operation-Starshine-Menu", 1.1f);
                        break;

                    default:
                        break;
                    }
                }
            }
        }