void Start() { if (instance == null) { instance = this; } for (int i = 0; i < playerScore.Length; i++) { playerScore[i] = 0; } }
void OnCollisionEnter(Collision other) { if (other.gameObject.layer == LayerMask.NameToLayer("Item")) { if (other.gameObject.GetComponent <BS_Item>().IsTail() == false && isStunned == false) // Get items { tails.Add(other.gameObject); int index = tails.Count - 1; other.gameObject.GetComponent <BS_Item>().SetTail(playerNumber, index, tails.Count); Color playerColor = new Color(0, 0, 0); switch (playerNumber) { case 0: playerColor = new Color(1.0f, 0.08f, 0.08f, 1.0f); // Red break; case 1: playerColor = new Color(1.0f, 0.65f, 0.0f, 1.0f); // Orange break; case 2: playerColor = new Color(1.0f, 0.93f, 0.0f, 1.0f); // Yellow break; case 3: playerColor = new Color(0.27f, 0.95f, 1.0f, 1.0f); // Blue break; case 4: playerColor = new Color(0.85f, 0.19f, 1.0f, 1.0f); // Violet break; case 5: playerColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); // Black break; } if (isBonusItem == true) { BS_ScoreManager.Instance().PlusScore(playerNumber, 10); scoreHUD.gameObject.GetComponent <HUDText>().AddLocalized("10", playerColor, 0); GameObject bonusEffectClone = Instantiate(bonusEffect) as GameObject; bonusEffectClone.transform.position = other.transform.position; bonusEffectClone.transform.position += new Vector3(0, 1.0f, 0); } else { BS_ScoreManager.Instance().PlusScore(playerNumber, 5); scoreHUD.gameObject.GetComponent <HUDText>().AddLocalized("5", playerColor, 0); } int myScore = BS_ScoreManager.Instance().GetPlayerScore(playerNumber); switch (other.gameObject.GetComponent <BS_Item>().GetItemType()) { case ITEM_TYPE.ITEM_APPLE: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "AppleSound," + myScore); break; case ITEM_TYPE.ITEM_SILVER: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "SilverSound," + myScore); break; case ITEM_TYPE.ITEM_GOLD: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "GoldSound," + myScore); break; case ITEM_TYPE.ITEM_RING: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "RingSound," + myScore); break; case ITEM_TYPE.ITEM_DIAMOND: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "DiamondSound," + myScore); break; case ITEM_TYPE.ITEM_SPEED: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "SpeedSound," + myScore); break; case ITEM_TYPE.ITEM_MAGNET: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "MagnetSound," + myScore); break; case ITEM_TYPE.ITEM_BONUS: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "BonusSound," + myScore); break; } } else // Tail cutting, Take items { int enemyNumber = other.gameObject.GetComponent <BS_Item>().GetHeadPlayer(); if (enemyNumber != playerNumber) { if (enemyNumber < 0) //array index exception - enemyNumber가 -1로 추정됨 { return; } lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "StealEmojiSound"); lobbyHost.SendToCode(lobbyHost.GameUserList[enemyNumber], "AngryEmojiSound"); int enemyTailLength = this.transform.GetComponentInParent <BS_InGameManager>().character[enemyNumber].GetComponent <BS_Character>().tails.Count; int enemyTailCutPoint = other.gameObject.GetComponent <BS_Item>().GetTailIndex(); for (int i = enemyTailCutPoint; i < enemyTailLength; i++) { GameObject cutTail = (GameObject)this.transform.GetComponentInParent <BS_InGameManager>().character[enemyNumber].GetComponent <BS_Character>().tails[enemyTailCutPoint]; cutTail.GetComponent <BS_Item>().CutTail(); this.transform.GetComponentInParent <BS_InGameManager>().character[enemyNumber].GetComponent <BS_Character>().tails.RemoveAt(enemyTailCutPoint); tails.Add(cutTail.gameObject); int index = tails.Count - 1; cutTail.gameObject.GetComponent <BS_Item>().SetTail(playerNumber, index, tails.Count); } StartCoroutine(LaughEmozi()); StartCoroutine(this.transform.GetComponentInParent <BS_InGameManager>().character[enemyNumber].GetComponent <BS_Character>().AngryEmozi()); } } } }
public void MagnetCollision(Collider other) { tails.Add(other.gameObject); int index = tails.Count - 1; other.gameObject.GetComponent <BS_Item>().SetTail(playerNumber, index, tails.Count); Color playerColor = new Color(0, 0, 0); switch (playerNumber) { case 0: playerColor = new Color(1.0f, 0.08f, 0.08f, 1.0f); // Red break; case 1: playerColor = new Color(1.0f, 0.65f, 0.0f, 1.0f); // Orange break; case 2: playerColor = new Color(1.0f, 0.93f, 0.0f, 1.0f); // Yellow break; case 3: playerColor = new Color(0.27f, 0.95f, 1.0f, 1.0f); // Blue break; case 4: playerColor = new Color(0.85f, 0.19f, 1.0f, 1.0f); // Violet break; case 5: playerColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); // Black break; } if (isBonusItem == true) { BS_ScoreManager.Instance().PlusScore(playerNumber, 10); scoreHUD.gameObject.GetComponent <HUDText>().AddLocalized("10", playerColor, 0); GameObject bonusEffectClone = Instantiate(bonusEffect) as GameObject; bonusEffectClone.transform.position = other.transform.position; bonusEffectClone.transform.position += new Vector3(0, 1.0f, 0); } else { BS_ScoreManager.Instance().PlusScore(playerNumber, 5); scoreHUD.gameObject.GetComponent <HUDText>().AddLocalized("5", playerColor, 0); } int myScore = BS_ScoreManager.Instance().GetPlayerScore(playerNumber); switch (other.gameObject.GetComponent <BS_Item>().GetItemType()) { case ITEM_TYPE.ITEM_APPLE: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "AppleSound," + myScore); break; case ITEM_TYPE.ITEM_SILVER: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "SilverSound," + myScore); break; case ITEM_TYPE.ITEM_GOLD: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "GoldSound," + myScore); break; case ITEM_TYPE.ITEM_RING: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "RingSound," + myScore); break; case ITEM_TYPE.ITEM_DIAMOND: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "DiamondSound," + myScore); break; case ITEM_TYPE.ITEM_SPEED: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "SpeedSound," + myScore); break; case ITEM_TYPE.ITEM_MAGNET: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "MagnetSound," + myScore); break; case ITEM_TYPE.ITEM_BONUS: lobbyHost.SendToCode(lobbyHost.GameUserList[playerNumber], "BonusSound," + myScore); break; } }
void Update() { for (int i = 0; i < lobbyHost.GetPlayerCount(); i++) { if (lobbyHost.selectedPlayerCharacter[i] == (int)CHARACTER_TYPE.CHARACTER_DISCONNECTED) { scoreBoard[i].SetActive(false); character[i].SetActive(false); character[i].gameObject.GetComponent <BS_Character> ().LeavedTail(); // } } if (isGameStart == true && isGameSet == false) { gameTime -= Time.deltaTime; } string segmentTimeStirng; if (gameTime >= 0) { segmentTimeStirng = "0"; if ((int)gameTime / 60 == 1) { segmentTimeStirng += " "; } segmentTimeStirng += ((int)gameTime / 60); segmentTimeStirng += ":"; if (((int)gameTime % 60) / 10 == 1) { segmentTimeStirng += " "; } segmentTimeStirng += ((int)gameTime % 60) / 10; if (((int)gameTime % 60 % 10) == 1) { segmentTimeStirng += " "; } segmentTimeStirng += ((int)gameTime % 60) % 10; } else if (gameTime >= -3) { if (Time.frameCount % 30 > 15) { segmentTimeStirng = "00:00"; } else { segmentTimeStirng = " "; } } else { segmentTimeStirng = " E:ND"; } timeLabel.text = segmentTimeStirng; if (isFeverTime == true) { timeLabel.GetComponent <UILabel>().color = Color.red; } else { timeLabel.GetComponent <UILabel>().color = Color.yellow; } if (gameTime <= feverTime && isFeverTime == false) { isFeverTime = true; notification.GetComponent <BS_Notification>().HurryUp(); Camera.main.GetComponent <AudioSource>().Stop(); Camera.main.GetComponent <AudioSource>().PlayOneShot(feverSound); map.GetComponent <BS_Map>().ChangeNightTexture(); } if (gameTime <= 10 && isCountDown == false) { isCountDown = true; StartCoroutine(PlayCountDownSound()); } if (gameTime <= 0.0f && isGameSet == false) { isGameSet = true; notification.GetComponent <BS_Notification>().GameSet(); for (int i = 0; i < character.Length; i++) { character[i].GetComponent <BS_Character>().StopCharacter(); } for (int i = 0; i < lobbyHost.totalScore.Length; i++) { if (lobbyHost.selectedPlayerCharacter[i] == (int)CHARACTER_TYPE.CHARACTER_DISCONNECTED) { continue; } lobbyHost.totalScore[i] = BS_ScoreManager.Instance().GetPlayerScore(i); } for (int i = 0; i < lobbyHost.GetPlayerCount(); i++) //i = userindex { //lobbyHost.SendTo(i, "MyScore," + lobbyHost.totalScore[i]); lobbyHost.SendToCode(lobbyHost.GameUserList[i], "MyScore," + lobbyHost.totalScore[i]); } StartCoroutine(GameSet()); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("ScoredItem")) { if (other.gameObject.GetComponent <BS_Item>().IsScored() == true) { int headPlayer = other.gameObject.GetComponent <BS_Item>().GetHeadPlayer(); BS_ScoreManager.Instance().PlusScore(headPlayer, other.gameObject.GetComponent <BS_Item>().GetScore()); scoredTails.RemoveAt(0); Destroy(other.gameObject); int headPlayerScore = BS_ScoreManager.Instance().GetPlayerScore(headPlayer); iTween.PunchScale(scoreBoard.gameObject, Vector3.one * 1.05f, 0.05f); Color playerColor = Color.white; switch (headPlayer) { case 0: playerColor = new Color(1.0f, 0.08f, 0.08f, 1.0f); // Red break; case 1: playerColor = new Color(1.0f, 0.65f, 0.0f, 1.0f); // Orange break; case 2: playerColor = new Color(1.0f, 0.93f, 0.0f, 1.0f); // Yellow break; case 3: playerColor = new Color(0.27f, 0.95f, 1.0f, 1.0f); // Blue break; case 4: playerColor = new Color(0.85f, 0.19f, 1.0f, 1.0f); // Violet break; case 5: playerColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); // Black break; } switch (other.gameObject.GetComponent <BS_Item>().GetItemType()) { case ITEM_TYPE.ITEM_APPLE: lobbyHost.itemScore[headPlayer, (int)ITEM_TYPE.ITEM_APPLE]++; lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SellSound," + headPlayerScore); break; case ITEM_TYPE.ITEM_SILVER: lobbyHost.itemScore[headPlayer, (int)ITEM_TYPE.ITEM_SILVER]++; lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SellSound," + headPlayerScore); break; case ITEM_TYPE.ITEM_GOLD: lobbyHost.itemScore[headPlayer, (int)ITEM_TYPE.ITEM_GOLD]++; lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SellSound," + headPlayerScore); break; case ITEM_TYPE.ITEM_RING: lobbyHost.itemScore[headPlayer, (int)ITEM_TYPE.ITEM_RING]++; lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SellSound," + headPlayerScore); break; case ITEM_TYPE.ITEM_DIAMOND: lobbyHost.itemScore[headPlayer, (int)ITEM_TYPE.ITEM_DIAMOND]++; lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SellSound," + headPlayerScore); break; case ITEM_TYPE.ITEM_SPEED: case ITEM_TYPE.ITEM_MAGNET: case ITEM_TYPE.ITEM_BONUS: lobbyHost.SendToCode(lobbyHost.GameUserList[headPlayer], "SpecialSellSound," + headPlayerScore); break; } } } }