private void playerDies(Global.typeOfPlayer player) { Debug.Log("Executando o OnHealthGoesToZero no LevelManager"); if (OnRespaw != null) { foreach (PlayerControl scriptPlayer in listOfPlayers) { if (scriptPlayer.tipo.Equals(player)) { if (canRespaw) { OnRespaw(player); } else { InputController.instance.changePlayer(true); OnKillPlayer(player); qtdMortos++; Debug.Log("Jogador Morreu--> " + player.ToString() + " Posicao->" + qtdMortos); if (qtdMortos == listOfPlayers.Count) { Debug.Log("GAME OVER"); } } } } } }
void OnTriggerEnter2D(Collider2D other) { if (OnItemActivedByPlayer != null) { Global.typeOfPlayer player = Global.getTypeOfPlayerByTag(other.tag); if (!Global.typeOfPlayer.Player_None.Equals(player) && checkWhoCanIterateWithItem(player)) { if (CanBeDesactived) { isItemActive = !isItemActive; animacao.SetBool("ativo", isItemActive); //Trocar esses dois Enum por um bool OnItemActivedByPlayer(isItemActive, Global.getTypeOfPlayerByTag(other.tag), typeOfPlayerCanActived, typeOfInteractiveItem, transform.position); } else { if (isItemActive == false) { isItemActive = true; animacao.SetBool("ativo", true); //Trocar esses dois Enum por um bool OnItemActivedByPlayer(true, Global.getTypeOfPlayerByTag(other.tag), typeOfPlayerCanActived, typeOfInteractiveItem, transform.position); } } } } }
private void whoToRespawn(Global.typeOfPlayer player) { if (tipo.Equals(player)) { Respawn(); } }
private void whoToKill(Global.typeOfPlayer player) { if (tipo.Equals(player)) { killPlayer(); } }
private void soundPlayerHurt(int damage, Global.typeOfPlayer player) { Debug.Log("Executando o OnHurt no SoundController"); switch (player) { case Global.typeOfPlayer.Player_Bege: hurtBege.Play(); break; case Global.typeOfPlayer.Player_Blue: hurtBlue.Play(); break; case Global.typeOfPlayer.Player_Green: hurtGreen.Play(); break; case Global.typeOfPlayer.Player_Pink: hurtPink.Play(); break; case Global.typeOfPlayer.Player_Yellow: hurtYellow.Play(); break; default: break; } }
private void soundItemCatch(int valueOfItem, Global.typeOfPlayer player, CollectiablesController item) { switch (item.typeOfItem) { case Global.typeOfItem.Gem_Blue: case Global.typeOfItem.Gem_Green: case Global.typeOfItem.Gem_Red: case Global.typeOfItem.Gem_Yellow: catchGem.Play(); break; case Global.typeOfItem.Key_Blue: case Global.typeOfItem.Key_Green: case Global.typeOfItem.Key_Red: case Global.typeOfItem.Key_Yellow: catchKey.Play(); break; case Global.typeOfItem.Gold_Coin: catchGoldCoin.Play(); break; default: break; } }
private void respawPlayer(Global.typeOfPlayer type) { hearths = ScoreController.instance.getCurrentHealthFromPlayer(type); currentHealth = ScoreController.instance.getHearthsFromPlayer(type); setQuantidadeCoracao(hearths); updateHealthShow(); }
void OnTriggerExit2D(Collider2D outro) { Global.typeOfPlayer tipo = Global.getTypeOfPlayerByTag(outro.tag); if (!tipo.Equals(Global.typeOfPlayer.Player_None)) { StartCoroutine("PararEm2Segudos"); } }
void OnTriggerStay2D(Collider2D outro) { Global.typeOfPlayer tipo = Global.getTypeOfPlayerByTag(outro.tag); if (!tipo.Equals(Global.typeOfPlayer.Player_None)) { startMovimento(); } }
private void changedPlayer(IPlayerAction action, Global.typeOfPlayer type) { action.changedPlayer(LevelManager.instance.listOfPlayers, botaoMudarJogador, playerAtivo); hearths = ScoreController.instance.getHearthsFromPlayer(type); currentHealth = ScoreController.instance.getCurrentHealthFromPlayer(type); setQuantidadeCoracao(hearths); //updateHealthShow(); }
private void respawCollectibles(Global.typeOfPlayer player) { if (!this.gameObject.activeSelf && canRespaw && typeOfPlayerThatCanCatchItem.Equals(player)) { this.gameObject.SetActive(true); this.ResetObject(); } }
private void itemActived(bool actived, Global.typeOfPlayer player, Global.typeOfPlayer playerThatCanActived, Global.InteractiveItem item, Vector3 positionOfItem) { if (tipo.Equals(playerThatCanActived) && actived && Global.InteractiveItem.CheckPoint.Equals(item)) { respawnPosition = positionOfItem; } }
private bool checkWhoCanIterateWithItem(Global.typeOfPlayer player) { if (allPlayersCanCatch) { return(true); } else { return(typeOfPlayerCanActived.Equals(player)); } }
private bool checkWhoCanCatchItem(Global.typeOfPlayer player) { if (allPlayersCanCatch) { return(true); } else { return(typeOfPlayerThatCanCatchItem.Equals(player)); } }
private void itemCatch(int valueOfItem, Global.typeOfPlayer player, CollectiablesController item) { if (Global.typeOfItem.Star.Equals(item.typeOfItem) && tipo.Equals(player)) { Debug.Log("Pegou Estrela-->" + valueOfItem); contadorInvencibilidade = valueOfItem; Invoke("ContadorInvencibilidade", valueOfItem); invencivel = true; StartCoroutine(flashSprites(sprites, valueOfItem)); } }
public void carregarValoresInicias(Global.typeOfPlayer tipo) { setQuantidadeChaves(quantidadeChaves); setQuantidadeInicialMoedas(quantidadeMoeda); if (!Global.typeOfPlayer.Player_None.Equals(tipo)) { currentHealth = ScoreController.instance.getCurrentHealthFromPlayer(tipo); setQuantidadeCoracao(ScoreController.instance.getHearthsFromPlayer(tipo)); } }
private void soundItemActived(bool actived, Global.typeOfPlayer player, Global.typeOfPlayer playerThatCanActived, Global.InteractiveItem item, Vector3 position) { if (player.Equals(playerThatCanActived)) { if (actived) { interactiveItemOn.Play(); } else { interactiveItemOff.Play(); } } }
private void respawPlayer(Global.typeOfPlayer player) { //TODO arrumar isso aqui, nao pode ter inicializacao de tudo qdo der respaw //initializeHealthCoins(); totalCurrentCoins -= currentCoinsByPlayer[player]; currentCoinsByPlayer[player] = 0; foreach (CollectiablesController collectiable in listItensCatch) { if (collectiable.canRespaw) { collectiable.ResetObject(); } } }
private void upadateItemCatch(int valueOfItem, Global.typeOfPlayer player, CollectiablesController item) { if (!Global.typeOfItem.Item_None.Equals(item)) { if (item.canRespaw) { listItensCatch.Add(item); } } switch (item.typeOfItem) { case Global.typeOfItem.Gem_Blue: case Global.typeOfItem.Gem_Green: case Global.typeOfItem.Gem_Red: case Global.typeOfItem.Gem_Yellow: case Global.typeOfItem.Key_Blue: case Global.typeOfItem.Key_Green: case Global.typeOfItem.Key_Red: case Global.typeOfItem.Key_Yellow: itens[item.typeOfItem] = true; break; case Global.typeOfItem.Health_empty: maxHealth[player] += valueOfItem; break; case Global.typeOfItem.Health_full: currentHealth[player] = maxHealth[player]; break; case Global.typeOfItem.Health_half: currentHealth[player] += valueOfItem; break; case Global.typeOfItem.Gold_Coin: currentCoinsByPlayer[player] += valueOfItem; totalCurrentCoins += valueOfItem; return; default: return; } }
void OnTriggerEnter2D(Collider2D other) { if (OnItemCollect != null) { Global.typeOfPlayer player = Global.getTypeOfPlayerByTag(other.tag); //Qualquer tag nao encontrada sera definida como Player_None //Tem q ser um Player e tem que estar apto a pegar o item if (!Global.typeOfPlayer.Player_None.Equals(player) && checkWhoCanCatchItem(player)) { typeOfPlayerThatCanCatchItem = player; OnItemCollect(valueOfItem, player, this); //TODO verificar se como fica o delagate das classes pressas a ele //Destroy (gameObject); gameObject.SetActive(false); } } }
private void actionController(IPlayerAction action) { if (action.changePlayer(listOfPlayers)) { Global.typeOfPlayer type = Global.typeOfPlayer.Player_None; foreach (PlayerControl player in listOfPlayers) { if (player.isAtivo) { type = player.tipo; break; } } if (OnLevelAction != null) { OnLevelAction(action, type); } } }
private void actionController(IPlayerAction action) { if (action.GetType() == typeof(ActionJump)) { PlayerControl player = LevelManager.instance.getActivePlayer(); Global.typeOfPlayer tipoPlayer = Global.typeOfPlayer.Player_None; if (player != null) { tipoPlayer = player.tipo; } switch (tipoPlayer) { case Global.typeOfPlayer.Player_Bege: action.playSound(playerJumpBege, player.isGrounded && player.isAtivo); break; case Global.typeOfPlayer.Player_Blue: action.playSound(playerJumpBlue, player.isGrounded && player.isAtivo); break; case Global.typeOfPlayer.Player_Green: action.playSound(playerJumpGreen, player.isGrounded && player.isAtivo); break; case Global.typeOfPlayer.Player_Pink: action.playSound(playerJumpPink, player.isGrounded && player.isAtivo); break; case Global.typeOfPlayer.Player_Yellow: action.playSound(playerJumpYellow, player.isGrounded && player.isAtivo); break; default: break; } } }
private void updateHealth(int damage, Global.typeOfPlayer player) { Debug.Log("Executando o OnHurt no ScoreController"); switch (player) { case Global.typeOfPlayer.Player_None: return; default: currentHealth[player] -= damage; Debug.Log("Life " + player.ToString() + " ->" + currentHealth[player]); if (currentHealth[player] <= 0) { if (OnHealthGoesToZero != null) { Debug.Log("Player->" + player.ToString() + " morreu executando OnHealthGoesToZero"); OnHealthGoesToZero(player); } } return; } }
private void executarFerimento(Collider2D outro) { Global.typeOfPlayer tipo = Global.getTypeOfPlayerByTag(outro.tag); if (OnHurtPlayer != null) { //Qualquer tag nao encontrada sera definida como Player_None //Assim qualquer outro tipo de jogador ira sofre dano switch (tipo) { case Global.typeOfPlayer.Player_None: break; default: //Será que isso eh perfomatico? if (canHurt(outro.GetComponent <PlayerControl>())) { Debug.Log("Executando Dano, Chamando todos os Eventos"); OnHurtPlayer(damage, tipo); } break; } } }
public int getCurrentHealthFromPlayer(Global.typeOfPlayer typeOfPlayer) { return(currentHealth[typeOfPlayer]); }
private void updateHearthDamage(int dano, Global.typeOfPlayer type) { Debug.Log("Executando o OnHurt no UIControl"); currentHealth -= dano; updateHealthShow(); }
//Metodos Privados private void catchItem(int add, Global.typeOfPlayer player, CollectiablesController item) { switch (item.typeOfItem) { case Global.typeOfItem.Gem_Blue: gema_azul.gameObject.SetActive(true); gema_azul.sprite = s_gema_azul; break; case Global.typeOfItem.Gem_Green: gema_verde.gameObject.SetActive(true); gema_verde.sprite = s_gema_verde; break; case Global.typeOfItem.Gem_Red: gema_vermelho.gameObject.SetActive(true); gema_vermelho.sprite = s_gema_laranja; break; case Global.typeOfItem.Gem_Yellow: gema_amarelo.gameObject.SetActive(true); gema_amarelo.sprite = s_gema_amarela; break; case Global.typeOfItem.Key_Blue: chave_azul.sprite = s_key_azul_enable; break; case Global.typeOfItem.Key_Green: chave_verde.sprite = s_key_verde_enable; break; case Global.typeOfItem.Key_Red: chave_vermelho.sprite = s_key_vermelho_enable; break; case Global.typeOfItem.Key_Yellow: chave_amarelo.sprite = s_key_amarelo_enable; break; case Global.typeOfItem.Health_empty: setQuantidadeCoracao(hearths + add); break; case Global.typeOfItem.Health_half: currentHealth += add; updateHealthShow(); break; case Global.typeOfItem.Health_full: currentHealth = hearths * 2; updateHealthShow(); break; case Global.typeOfItem.Gold_Coin: currentCoin += add; updateCurrentCoins(); break; default: break; } }
public int getHearthsFromPlayer(Global.typeOfPlayer typeOfPlayer) { return(maxHealth[typeOfPlayer] / 2); }
public void machucarJogador(int dano, Global.typeOfPlayer type) { Debug.Log("Executando o OnHurt no PlayerControl"); // startKnockbackAction(); }