public void CheckEtatsOnAction(CombatActionData newCombat, GameObject newLauncher, int newDamage, int newActionState) //action state sert a savoir si je lance l'attaque ou si j'attaque { for (int i = 0; i < this.summonerScript.L_etats.Count; i++) { if (this.summonerScript.L_etats [i].id == 15 && newActionState == 1) // c'est la riposte { float damage = (float)newDamage; int intDamage = Mathf.CeilToInt((damage * 30) / 100); CombatActionData combatActionTemp = new CombatActionData(); combatActionTemp.colorDmg = newCombat.colorDmg; combatActionTemp.damage = intDamage; combatActionTemp.idAnim = "1"; combatActionTemp.modulateur = "-"; combatActionTemp.target = 2; combatActionTemp.typeDmg = 1; newLauncher.GetComponent <ActionManager> ().ApplyCombatAction(combatActionTemp, this.gameObject); } else if (this.summonerScript.L_etats [i].id == 20 && newActionState == 2) // c'est le lien vampirique { float damage = (float)newDamage; int intDamage = Mathf.CeilToInt((damage * 30) / 100); CombatActionData combatActionTemp = new CombatActionData(); combatActionTemp.colorDmg = newCombat.colorDmg; combatActionTemp.damage = intDamage; combatActionTemp.idAnim = "3"; combatActionTemp.modulateur = "+"; combatActionTemp.target = 1; combatActionTemp.typeDmg = 1; this.ApplyCombatAction(combatActionTemp, this.gameObject); this.summonerScript.charactersInfosPanel.GetComponent <CombatEffectsText> ().GenerateDamageText(2, intDamage); } } }
private int UpdateDefense(CombatActionData newCombatAction) { if (this.summonerScript.defense >= newCombatAction.damage) { int defenseTemp = this.summonerScript.defense; defenseTemp -= newCombatAction.damage; this.summonerScript.defense = defenseTemp; if (this.summonerScript.defense > 0) { this.summonerScript.charactersInfosPanel.GetComponent <CharacterInfosPanel> ().BumpDefense(); } return(0); } else { int damageTemp = newCombatAction.damage; damageTemp -= this.summonerScript.defense; this.summonerScript.defense = 0; this.GetDamageBegin(); this.summonerScript.charactersInfosPanel.GetComponent <CombatEffectsText> ().GenerateDamageText(1, damageTemp); return(damageTemp); } }
public void ApplyCombatAction(CombatActionData newCombatAction, GameObject newLauncher) { if (newCombatAction.typeDmg == 1) // c'est une attaque { if (newCombatAction.modulateur == "+") { this.summonerScript.pv += newCombatAction.damage; this.CheckPv(); //print (this.summonerName + " : je me suis soigné de : " + newCombatAction.damage + " pv"); } else { int damage = this.UpdateDefense(newCombatAction); this.summonerScript.pv -= damage; this.CheckPv(); this.CheckEtatsOnAction(newCombatAction, newLauncher, damage, 1); //print (this.summonerName + " : je me suis mangé : " + damage + " degats"); } } else if (newCombatAction.typeDmg == 2) { if (newCombatAction.modulateur == "+") // c'est une défense { this.summonerScript.defense += newCombatAction.damage; //print (this.summonerName + " : jai gagne : " + newCombatAction.damage + " defense"); } else { this.summonerScript.defense -= newCombatAction.damage; //print (this.summonerName + " : jai perdu : " + newCombatAction.damage + " defense"); } } this.summonerScript.CallUpdateUIInfos(); }
public void AddSpecialEtat(Card newCard, EtatsData newEtat, CombatEtatData newCombatEtat) { if (newEtat.id == 14) // relance { this.summonerScript.LaunchSpecificDice(newCard); } else if (newEtat.id == 16) // defausse { if (this.summonerScript.L_Cards.Count > 1) { int randomCardId; do { randomCardId = Random.Range(0, this.summonerScript.L_Cards.Count); } while (this.summonerScript.L_Cards [randomCardId].tempAction.id == newCard.tempAction.id); Card cardToBan = this.summonerScript.L_Cards [randomCardId]; //print ("la carte a virer est la " + randomCardId + " / " + this.summonerScript.L_Cards [randomCardId].tempAction.name); this.summonerScript.RemoveCardFromList(cardToBan); this.summonerScript.CardBanEvent(cardToBan); for (int i = 0; i < this.summonerScript.L_CardsToApply.Count; i++) { if (this.summonerScript.L_CardsToApply [i].card.tempAction.id == cardToBan.tempAction.id) { this.cardLauncherScript.L_CardsToApply.RemoveAt(i); } } } } else if (newEtat.id == 18) // c'est le permanent armure { CombatActionData combatActionTemp = new CombatActionData(); combatActionTemp.colorDmg = 0; combatActionTemp.damage = newEtat.value; combatActionTemp.idAnim = "2"; combatActionTemp.modulateur = "+"; combatActionTemp.target = 1; combatActionTemp.typeDmg = 2; GameObject actionAnimation = Instantiate(this.animationManagerPrefab, this.transform.position, this.transform.rotation, this.transform) as GameObject; AnimationManager actionAnimationScript = actionAnimation.GetComponent <AnimationManager> (); actionAnimationScript.GenerateAnimation(this.gameObject, this.gameObject, combatActionTemp.idAnim); this.ApplyCombatAction(combatActionTemp, this.gameObject); } else if (newEtat.id == 19) // c'est le permanent déflagration { CombatActionData combatActionTemp = new CombatActionData(); combatActionTemp.colorDmg = 4; combatActionTemp.damage = 1; combatActionTemp.idAnim = "1"; combatActionTemp.modulateur = "-"; combatActionTemp.target = 1; combatActionTemp.typeDmg = 1; this.ApplyCombatAction(combatActionTemp, this.gameObject); GameObject actionAnimation1 = Instantiate(this.animationManagerPrefab, this.transform.position, this.transform.rotation, this.transform) as GameObject; AnimationManager actionAnimationScript1 = actionAnimation1.GetComponent <AnimationManager> (); actionAnimationScript1.GenerateAnimation(this.gameObject, this.gameObject, combatActionTemp.idAnim); CombatActionData combatActionTemp2 = new CombatActionData(); combatActionTemp2.colorDmg = 4; combatActionTemp2.damage = newEtat.value; combatActionTemp2.idAnim = "1"; combatActionTemp2.modulateur = "-"; combatActionTemp2.target = 3; combatActionTemp2.typeDmg = 1; for (int j = 0; j < CombatManager.L_Enemies.Count; j++) { GameObject enemyTemp = CombatManager.L_Enemies [j]; if (enemyTemp.GetComponent <Summoner> ().isKo == false) { GameObject actionAnimation = Instantiate(this.animationManagerPrefab, this.transform.position, this.transform.rotation, this.transform) as GameObject; AnimationManager actionAnimationScript = actionAnimation.GetComponent <AnimationManager> (); actionAnimationScript.GenerateAnimation(this.gameObject, enemyTemp, combatActionTemp2.idAnim); enemyTemp.GetComponent <ActionManager> ().ApplyCombatAction(combatActionTemp2, this.gameObject); } } } else if (newEtat.id == 21) // c'est l'entrave { int randomDice; bool isAlreadyOnEntrave = false; List <Dice> diceList = new List <Dice> (); for (int i = 0; i < this.summonerScript.L_dices.Count; i++) { if (this.summonerScript.L_dices [i].isBlocked == false) { diceList.Add(this.summonerScript.L_dices [i]); } else { isAlreadyOnEntrave = true; } } for (int i = 0; i < this.summonerScript.L_supports.Count; i++) { Support supportScript = this.summonerScript.L_supports [i].GetComponent <Support> (); for (int j = 0; j < supportScript.L_dices.Count; j++) { if (supportScript.L_dices [j].isBlocked == false) { diceList.Add(supportScript.L_dices [j]); } else { isAlreadyOnEntrave = true; } } } if (diceList.Count > 0) { randomDice = Random.Range(0, diceList.Count); diceList [randomDice].isBlocked = true; if (diceList [randomDice].characterType == 1 || diceList [randomDice].characterType == 3) { diceList [randomDice].parentSummonerScript.charactersInfosPanel.GetComponent <CharacterInfosPanel> ().ShowBlockedDice(diceList [randomDice].diceId); } else { diceList [randomDice].parentSupportScript.charactersInfosPanel.GetComponent <CharacterInfosPanel> ().ShowBlockedDice(diceList [randomDice].diceId); } if (isAlreadyOnEntrave) { newCombatEtat.duration = 0; } this.AddEtat(newEtat, newCombatEtat); } } }
public bool IsConditionOk(CombatActionData newCombatAction) { Summoner targetTemp; if (newCombatAction.conditions.Length == 0) // si je ne specifie pas de conditions je peux la lancer { return(true); } if (newCombatAction.conditions [0].target == 1) { targetTemp = this.cardLauncher.GetComponent <Summoner> (); } else if (newCombatAction.conditions [0].target == 2) { targetTemp = this.cardTarget.GetComponent <Summoner> (); } else { targetTemp = this.cardLauncher.GetComponent <Summoner> (); } if (newCombatAction.conditions [0].type == 2) // je check l'armure { if (newCombatAction.conditions [0].mod == 1) // si c'est inférieur { if (targetTemp.defense < newCombatAction.conditions [0].value) { return(true); } else { return(false); } } else if (newCombatAction.conditions [0].mod == 2) // si c'est égal { if (targetTemp.defense == newCombatAction.conditions [0].value) { return(true); } else { return(false); } } else { if (targetTemp.defense > newCombatAction.conditions [0].value) // si c'est supérieur { return(true); } else { return(false); } } } else if (newCombatAction.conditions [0].type == 3) // je check la previous card { if (newCombatAction.conditions [0].mod == 2) // je check le type de la previous card { if (this.lastCardPlayed.tempAction.type == newCombatAction.conditions [0].value) { return(true); } else { return(false); } } } return(false); }
public IEnumerator ApplyClassicAction() { if (this.cardLauncherScript.characterType == 3) { this.cardLauncherScript.charactersInfosPanel.GetComponent <CharacterInfosPanel> ().EndBumpDice(this.cardToApply.diceId); } this.cardLauncherScript.CallDroppedCardEvent(this.cardToApply, true); // je dis a la carte d'aller a la bonne position yield return(new WaitForSeconds(0.5f)); //print (this.summonerName + ": je lance lattaque sur: " + targetTemp + " / " + cardTemp.uId); for (int i = 0; i < this.cardToApply.tempAction.combatActions.Length; i++) { if (this.IsConditionOk(this.cardToApply.tempAction.combatActions [i])) { CombatActionData combatAction = this.cardToApply.tempAction.combatActions [i]; GameObject actionAnimation = Instantiate(this.animationManagerPrefab, this.transform.position, this.transform.rotation, this.transform) as GameObject; AnimationManager actionAnimationScript = actionAnimation.GetComponent <AnimationManager> (); if (combatAction.target == 1) // je me cible moi { this.animationIsPlaying = true; actionAnimationScript.GenerateAnimation(this.cardLauncher, this.cardLauncher, this.cardToApply.tempAction.combatActions [i].idAnim); while (this.animationIsPlaying) { yield return(null); } this.ApplyCombatAction(combatAction, this.cardLauncher); } else if (combatAction.target == 2) // je cible un ennemi { this.animationIsPlaying = true; actionAnimationScript.GenerateAnimation(this.cardLauncher, this.cardTarget, this.cardToApply.tempAction.combatActions [i].idAnim); while (this.animationIsPlaying) { yield return(null); } this.cardTarget.GetComponent <ActionManager> ().ApplyCombatAction(combatAction, this.cardLauncher); this.CheckEtatsOnAction(combatAction, this.cardLauncher, this.cardToApply.tempAction.combatActions [i].damage, 2); } else // je cible tous les enemies { this.animationIsPlaying = true; for (int j = 0; j < CombatManager.L_Enemies.Count; j++) { GameObject enemyTemp = CombatManager.L_Enemies [j]; if (enemyTemp.GetComponent <Summoner> ().isKo == false) { actionAnimationScript.GenerateAnimation(this.cardLauncher, enemyTemp, this.cardToApply.tempAction.combatActions [i].idAnim); while (this.animationIsPlaying) { yield return(null); } enemyTemp.GetComponent <ActionManager> ().ApplyCombatAction(combatAction, this.cardLauncher); } } } if (combatAction.etats.Length != 0) { for (int j = 0; j < combatAction.etats.Length; j++) { CombatEtatData combatEtatTemp = combatAction.etats [j]; EtatsData etatTemp = DictionaryManager.GetEtat(combatEtatTemp.idEtat); if (etatTemp.id == 14 || etatTemp.id == 16 || etatTemp.id == 21) { if (combatEtatTemp.target == 1) { this.AddSpecialEtat(this.cardToApply, etatTemp, combatEtatTemp); } else if (combatEtatTemp.target == 2) { this.cardTarget.GetComponent <ActionManager>().AddSpecialEtat(this.cardToApply, etatTemp, combatEtatTemp); } else if (combatEtatTemp.target == 3) { // je l'applique a tous } } else { if (combatEtatTemp.target == 1) { etatTemp.turnStateApply = 1; this.AddEtat(etatTemp, combatEtatTemp); } else if (combatEtatTemp.target == 2) { etatTemp.turnStateApply = 2; this.cardTarget.GetComponent <ActionManager>().AddEtat(etatTemp, combatEtatTemp); } else if (combatEtatTemp.target == 3) { // je l'applique a tous } } } } yield return(new WaitForSeconds(0.3f)); } } if (this.cardLauncherScript.characterType == 1) //si c'est un player j'update les cartes, si c'est un enemy on s'en fout { this.cardLauncherScript.RemoveCardFromList(this.cardToApply); this.cardLauncherScript.L_CardsToApply.RemoveAt(0); //print ("je apply lattaque: " + newCard.tempAction.name + " / il me reste : " + this.L_Cards.Count); this.cardLauncherScript.CardPlayedEvent(this.cardToApply); this.cardLauncherScript.cardIsPlaying = false; this.ResetCardVariable(); this.summonerScript.CheckCardsToApplyList(); } else { this.cardLauncherScript.charactersInfosPanel.GetComponent <CharacterInfosPanel> ().HideDice(this.cardToApply.diceId); yield return(new WaitForSeconds(0.5f)); // je mets en un temps de pause avant de lancer la next expres pour les monstres this.cardLauncherScript.RemoveCardFromList(this.cardToApply); this.cardLauncherScript.L_CardsToApply.RemoveAt(0); this.cardLauncherScript.cardIsPlaying = false; this.ResetCardVariable(); this.summonerScript.CheckCardsToApplyList(); } }