예제 #1
0
        private void Awake()
        {
            setup = FindObjectOfType <GameSetup>();

            LevelLoader levelLoader = FindObjectOfType <LevelLoader>();

            if (levelLoader != null)
            {
                levelLoader.InitializeLevel();
            }
        }
예제 #2
0
        private void Awake()
        {
            if (instance == null)
            {
                DontDestroyOnLoad(gameObject);
                instance = this;

                rankings = new Dictionary <int, MatchStats>();
            }
            else
            {
                Destroy(gameObject);
            }
        }
예제 #3
0
        public void SetMatchResults()
        {
            GameManager gm = FindObjectOfType <GameManager>();

            if (gm != null)
            {
                GameSetup gs = FindObjectOfType <GameSetup>();
                if (gs != null)
                {
                    foreach (GameObject player in gm.players)
                    {
                        if (player.GetComponent <UserCharacterController>() != null)
                        {
                            int playerIndex = player.GetComponent <UserCharacterController>().playerId;

                            if (gs.rankings.ContainsKey(playerIndex))
                            {
                                TimerScript ts = FindObjectOfType <TimerScript>();
                                if (ts != null)
                                {
                                    gs.rankings[playerIndex].deathTime = ts.GetElapsedTime();
                                }
                                gs.rankings[playerIndex].coinReward = 0;
                                gs.rankings[playerIndex].tie        = true;
                            }
                            else
                            {
                                MatchStats  ms = new MatchStats();
                                TimerScript ts = FindObjectOfType <TimerScript>();
                                if (ts != null)
                                {
                                    gs.rankings[playerIndex].deathTime = ts.GetElapsedTime();
                                }
                                ms.coinReward = 0;
                                ms.coinTotal  = 0;
                                ms.tie        = true;
                                gs.rankings.Add(playerIndex, ms);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        void Start()
        {
            if ((setup = FindObjectOfType <GameSetup>()) == null)
            {
                GameObject gameSetupObj = Instantiate(gameSetupPrefab);
                setup = gameSetupObj.GetComponent <GameSetup>();
                setup.selectedCharacterPrefabs = new GameObject[ReInput.players.playerCount];
            }
            else
            {
                int activePanels = 0;
                for (int i = 0; i < ReInput.players.playerCount; i++)
                {
                    if (i < panels.Length && setup.selectedCharacterPrefabs[i] != null)
                    {
                        panels[i].SetActive(true);
                        activePanels++;
                    }
                }
                if (activePanels > 3)
                {
                    placeHolder.SetActive(false);
                }

                for (int i = 0; i < panels.Length; i++)
                {
                    if (panels[i] != null)
                    {
                        panels[i].transform.SetParent(null);
                        panels[i].transform.SetParent(grid);
                    }
                }

                if (placeHolder.activeSelf)
                {
                    placeHolder.transform.SetParent(null);
                    placeHolder.transform.SetParent(grid);
                }
            }
        }
예제 #5
0
        public void Start()
        {
            setup = FindObjectOfType <GameSetup>();

            if (setup != null)
            {
                List <MatchStats> l = new List <MatchStats>();

                for (int i = 0; i < ReInput.players.playerCount; i++)
                {
                    if (setup.selectedCharacterPrefabs[i] != null && setup.rankings.ContainsKey(i))
                    {
                        GameObject        matchResultObject = Instantiate(matchResultPanelPrefab, horizontalLayout);
                        MatchResultsPanel matchResultPanel  = matchResultObject.GetComponent <MatchResultsPanel>();

                        MatchStats m = setup.rankings[i];
                        matchResultPanel.rankText.text      = GetRankString(m) + " - P" + i;
                        matchResultPanel.rewardText.text    = m.coinReward + " Points";
                        matchResultPanel.playerImage.sprite = setup.selectedCharacterPrefabs[i].GetComponentInChildren <SpriteRenderer>().sprite;
                    }
                }
            }
        }
예제 #6
0
 private void Awake()
 {
     setup = FindObjectOfType <GameSetup>();
 }
예제 #7
0
파일: Character.cs 프로젝트: jkaba/Game-Dev
        void TestOneStack()
        {
            // Test 1 stack remaining

            bool onlyOneStack = true;

            List <GameObject> stack = new List <GameObject>();

            foreach (GameObject player in players)
            {
                if (!player.GetComponent <Character>().stationary)
                {
                    stack = player.GetComponent <Character>().m_CharacterStack;
                    break;
                }
            }

            foreach (GameObject player in players)
            {
                if (!player.GetComponent <Character>().stationary)
                {
                    foreach (GameObject player0 in players)
                    {
                        if (!player0.GetComponent <Character>().stationary)
                        {
                            if (!player.GetComponent <Character>().m_CharacterStack.Contains(player0))
                            {
                                onlyOneStack = false;
                                break;
                            }
                        }
                    }
                }

                if (!onlyOneStack)
                {
                    break;
                }
            }

            // if only 1 stack remains, all win.
            if (onlyOneStack)
            {
                GameSetup gs = FindObjectOfType <GameSetup>();

                if (gs != null)
                {
                    foreach (GameObject winner in stack)
                    {
                        // AI don't get points
                        if (winner.GetComponent <UserCharacterController>() != null)
                        {
                            int playerIndex = winner.GetComponent <UserCharacterController>().playerId;

                            if (gs.rankings.ContainsKey(playerIndex))
                            {
                                gs.rankings[playerIndex].deathTime  = -1;
                                gs.rankings[playerIndex].coinReward = gs.matchPoints / stack.Count;
                                gs.rankings[playerIndex].coinTotal += gs.rankings[playerIndex].coinReward;
                            }
                            else
                            {
                                MatchStats ms = new MatchStats();
                                ms.deathTime  = -1; // winner didn't die
                                ms.coinReward = gs.matchPoints / stack.Count;
                                ms.coinTotal  = ms.coinReward;
                                gs.rankings.Add(playerIndex, ms);
                            }
                        }
                    }
                }

                LevelLoader.initialized = false;
                LevelLoader levelLoader = FindObjectOfType <LevelLoader>();
                if (levelLoader != null)
                {
                    Destroy(levelLoader.gameObject);
                }

                SceneManager.LoadScene("MatchResults");
            }
        }