private void Update() { if (Time.timeScale == 0.0f || Fade.instance.IsFade) { return; } if (!IsPlayGame()) { return; } UpdateTimeText(); int alivePlayerCount = 0; for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (!PlayerJoinManager.IsJoin(i)) { continue; } if (PointManager.GetPoint(i) != 0) { ++alivePlayerCount; } } if (alivePlayerCount <= 1) { playTimeCount = 0.0f; } }
/// <summary> /// 順位を出す /// </summary> static public void ApplyRank() { for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (!PlayerJoinManager.IsJoin(i)) { continue; } if (playerRanks[i] != 0) { continue; } int rank = 1; for (int j = 0; j < PlayerCount.MaxValue; ++j) { if (!PlayerJoinManager.IsJoin(j)) { continue; } if (playerPoints[i] < playerPoints[j]) { ++rank; } } playerRanks[i] = rank; } }
public override void OnCollisionEnter(Collision other) { switch (other.gameObject.tag) { case "Goal": { //入れたゴールの番号を取得 int goalNumber = other.gameObject.GetComponent <GoalController>().GetGoalNumber(); if (!PlayerJoinManager.IsJoin(goalNumber) || PointManager.GetPoint(goalNumber) <= 0) { return; } other.gameObject.GetComponent <GoalController>().goalAudioPlay(); if (ballBehaviour.isColor && ballBehaviour.playerNumberByColor == goalNumber) { PointManager.ByColorGoalCalculate(goalNumber); } else { PointManager.GoalCalculate(goalNumber); } GameObject.Destroy(ballBehaviour.gameObject); } break; } }
/// <summary> /// 参加するプレイヤーを生成 /// </summary> void GenerateAllJoinPlayer() { for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (PlayerJoinManager.IsJoin(i)) { GeneratePlayer(i); } } }
private void Start() { fade = Fade.instance; fade.StartFadeIn(); BgmManager.GetInstance().Play(BgmEnum.Select); viewportMin = Camera.main.ViewportToWorldPoint(Vector2.zero); viewportMax = Camera.main.ViewportToWorldPoint(Vector2.one); for (int i = 0; i < PlayerCount.MaxValue; ++i) { PlayerJoinManager.SetJoinInfo(i, false); } for (int i = 0; i < playerNum; ++i) { playerUI[i] = new PlayerUI(); foreach (Transform child in playerUIList[i].transform) { if (child.name == "Cursor") { playerUI[i].cursor = child.gameObject; } else if (child.name == "Capsule") { playerUI[i].capusuleTransform = child.transform; } else if (child.name == "OK") { playerUI[i].okObj = child.gameObject; playerUI[i].startOkScale = child.gameObject.transform.localScale; child.gameObject.SetActive(false); } } } for (int i = 0; i < animalNum; ++i) { startAnimal[i] = animalArray[i].transform.localPosition; foreach (Transform child in animalArray[i].transform) { if (child.tag == "Animal") { animalMoveObj[i] = child; animalAnimation[i] = child.gameObject.GetComponent <PlayerAnimationController>(); } else { message[i] = child.gameObject; message[i].SetActive(false); } } PlayerType type = animalArray[i].GetComponent <CharaType>().type; animalIndex.Add(type, i); } }
/// <summary> /// 決定のキャンセル /// </summary> void Cancel(int playerId) { if (SwitchInput.GetButtonDown(playerId, SwitchButton.Cancel)) { PlayerType type = playerUI[playerId].decisionInfo.decisionInfoType; animalArray[animalIndex[type]].GetComponent <BoxCollider>().enabled = true; animalArray[animalIndex[type]].transform.localPosition = startAnimal[animalIndex[type]]; playerUI[playerId].Cancel(); PlayerJoinManager.SetJoinInfo(playerId, false); } }
IEnumerator ResultStart() { while (fade.IsFade) { yield return(null); } //各順位ごとにプレイヤーの番号を格納 List <int>[] counts = new List <int> [PlayerCount.MaxValue]; for (int i = 0; i < PlayerCount.MaxValue; ++i) { counts[i] = new List <int>(); } for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (!PlayerJoinManager.IsJoin(i)) { continue; } counts[PointManager.GetRank(i) - 1].Add(i); } yield return(new WaitForSeconds(0.5f)); // くす玉を開く間隔 const float intervalTime = 1.0f; int index = PlayerCount.MaxValue - 1; for (int i = PlayerCount.MaxValue - 1; i >= 0; --i) { for (int j = 0; j < counts[i].Count; ++j) { KusudamaAnimationPlay(counts[i][j]); if (i == 0) { Instantiate( kamifubukiPrefab, playerPosArray[counts[i][j]].transform.position + new Vector3(0, 2, 0), kamifubukiPrefab.transform.rotation); } --index; } if (counts[i].Count != 0) { aud.Play(); yield return(new WaitForSeconds(intervalTime)); } } yield return(new WaitForSeconds(1.0f)); BgmManager.GetInstance().Play(BgmEnum.Result, false); animEnd = true; }
/// <summary> /// 決定 /// </summary> void Decision(int playerId, PlayerType type) { SeManager.GetInstance().Play(SeEnum.Decision); animalArray[animalIndex[type]].GetComponent <BoxCollider>().enabled = false; animalArray[animalIndex[type]].transform.position = new Vector3( playerUI[playerId].capusuleTransform.position.x - 0.01f, playerUI[playerId].capusuleTransform.position.y - 0.15f, animalArray[animalIndex[type]].transform.position.z); playerUI[playerId].Decision(type); PlayerJoinManager.SetJoinInfo(playerId, true); PlayerTypeManager.SetPlayerType(playerId, type); }
void Start() { goalAudio = GetComponent <AudioSource>(); childTransform = transform.GetChild(0); var mat = childTransform.GetComponent <MeshRenderer>().material; mat.color = PlayerColor.GetColor(goalNumber); childTransform.GetComponent <MeshRenderer>().material = mat; if (!PlayerJoinManager.IsJoin(goalNumber)) { Zeropoint(); } }
// 動物とくす玉を生成 void Generate() { for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (!PlayerJoinManager.IsJoin(i)) { continue; } // 動物生成 GameObject player = PlayerTypeManager.GetInstance().GeneratePlayer(i, PlayerTypeManager.SceneType.Object); player.transform.position = playerPosArray[i].transform.position; player.transform.rotation = playerPosArray[i].transform.rotation; player.transform.localScale = playerPosArray[i].transform.localScale; var pos = player.transform.GetChild(0).transform.localPosition; pos.y = 0; player.transform.GetChild(0).transform.localPosition = pos; // くす玉生成 GameObject kusudama = Instantiate( kusudamaPrefab[i], playerPosArray[i].transform.position + kusudamaOffset, playerPosArray[i].transform.rotation); kusudamaArray[i] = kusudama; // RankTextを取得 foreach (Transform child in kusudama.transform) { if (child.name != "Canvas") { continue; } foreach (Transform grandchild in child) { if (grandchild.name != "RankImage") { continue; } rankTextArray[i] = grandchild.GetComponent <Image>(); rankTextArray[i].sprite = rankSprites[PointManager.GetRank(i) - 1]; break; } break; } } }
// The onSceneLoaded function is where you are going to do most of the data pushing from scene to scene. void onSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode) { if (instance == this) { currentSceneName = scene.name; if (scene.name == mainMenuSceneName) { if (playerJoinManager == null) { playerJoinManager = GameObject.FindGameObjectWithTag("player-join-manager").GetComponent <PlayerJoinManager>(); } } else if (scene.name != mainMenuSceneName) // WE ARE ASSUMING ANYTHING THAT ISN'T THE MAIN MENU IS A LEVEL. THIS IS CLEARLY NOT GOING TO BE THE CASE AT ALL TIMES, SO UPDATE THIS AS NEEDED. { if (players == null) { Debug.LogWarning("GameManager did not recieve players from main menu, defaulting to 4 players on, This is correct if starting editor from game scene"); SetUpPlayers(new bool[] { true, true, true, true }, new int[] { 0, 1, 2, 3 }); // Set up players if game is not started in main menu StartCoroutine(UpdateGame()); } } if (countdownText == null) { countdownText = GameObject.FindGameObjectWithTag("countdown"); } if (audioManager == null) { audioManager = Instantiate(audioManagerPrefab).GetComponent <AudioManager>(); audioManager.gameObject.name = "AudioManager"; //I don't like it being named "Clone" DontDestroyOnLoad(audioManager); if (scene.name == mainMenuSceneName) { GameManager.instance.audioManager.Play("Main Menu"); } } if (curveManager == null && scene.name != mainMenuSceneName && scene.name != winnerSceneName) { curveManager = GameObject.FindGameObjectWithTag("ghost-curve").GetComponent <CurveManager>(); //This will be destroyed on load because a different scene might have a different curve manager } } }
private void Update() { if (fade.IsFade) { return; } // 各プレイヤー実行 //---------------------- for (int i = 0; i < playerUI.Length; ++i) { // 未決定 if (!playerUI[i].decisionInfo.isDecision) { CursorMove(i); } else { playerUI[i].OkObjAnimation(); Cancel(i); } } //---------------------- AnimalRote(); if (SwitchInput.GetButtonDown(0, SwitchButton.Pause)) { int count = 0; for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (PlayerJoinManager.IsJoin(i)) { ++count; } } if (count >= PlayerCount.MinValue) { fade.StartFadeOut("GameScene"); } } }
static void GoalCalculateImpl(int n) { //ポイントが0になったら if (playerPoints[n] <= 0) { playerPoints[n] = 0; int currentRank = 0; for (int i = 0; i < PlayerCount.MaxValue; ++i) { if (!PlayerJoinManager.IsJoin(i)) { continue; } if (playerRanks[i] == 0) { ++currentRank; } } playerRanks[n] = currentRank; } }
public override void OnCollisionEnter(Collision other) { switch (other.gameObject.tag) { case "Ball": { var otherballBehaviour = other.gameObject.GetComponent <BallBehaviour>(); //入っていて、力が一定以上なら入力不可時間を与える if (otherballBehaviour.IsInPlayer() && other.relativeVelocity.sqrMagnitude > ballBehaviour.ballScriptableObject.CantInputHitPower) { ballBehaviour.SetCantInputTime( other.relativeVelocity.sqrMagnitude * ballBehaviour.ballScriptableObject.HitPowerPercenage); } } break; case "Goal": { //入れたゴールの番号を取得 int goalNumber = other.gameObject.GetComponent <GoalController>().GetGoalNumber(); if (!PlayerJoinManager.IsJoin(goalNumber) || PointManager.GetPoint(goalNumber) <= 0) { return; } other.gameObject.GetComponent <GoalController>().goalAudioPlay(); if (goalNumber == ballBehaviour.playerIndex) { PointManager.OwnGoalCalculate(goalNumber); } ballStateManager.TranslationState(new RespawnState()); } break; } }