protected override void ProcessStates() { // base.ProcessStates(); GameObject g = GameObject.FindGameObjectWithTag("ProtoManager"); if (g == null) { hasBeenClicked = false; } if (bMouseClicking && bMouseOver && bIsActive) { bMouseClicking = false; bMouseOver = false; combatManager.PlayerClickedAction(ActionType.GetActionTypeWithID((int)action)); hasBeenClicked = true; GetComponentInChildren <SpriteRenderer>().sprite = clickSprite; } else if (bIsActive && !remainHighlighted) { GetComponentInChildren <SpriteRenderer>().sprite = normalSprite; } else if (remainHighlighted && combatManager.bTargetChoosed) { GetComponentInChildren <SpriteRenderer>().sprite = clickSprite; } }
// Update is called once per frame void Update() { if (combatManager.currentFighter.eCreatureType == CreatureType.Monster) { if (scriptedCombat != null) { ScriptTurnInfo turnInfo = scriptedCombat.currentTurn; if (turnInfo != null) { OnlyAction(ActionType.GetActionTypeWithID(turnInfo.ActionCode)); } } else { if (!combatManager.currentFighter.bHasTookDamage) { BlockOneAction(ActionType.ATTACK); } } } }
void ProcessCombat() { if (!bCombatStarted) { } else { if (bActionInProgress && bFighterInInitialPosition) { if (!waitedOneFrame) { waitedOneFrame = true; } else { ActionEnded(); waitedOneFrame = false; } } if (!bTurnInProgress && !fighterMouvementManager.bMoveFighterJoiningToPosition) { if (protoScript != null) { if (protoScript.combat != null) { protoScript.combat.NextTurn(); } } currentFighter = GetNextFighter(); actionLaunched = false; actionWheel.SetFighter(currentFighter); if (currentFighter.eCreatureType == CreatureType.Monster) { // actionWheel.SetAction(ActionType.FEAR, ((GroupHumanFighter)humanGroupFighter).bCanBeFeared); // actionWheel.SetAction(ActionType.TALK, ((GroupHumanFighter)humanGroupFighter).bCanListen); } currentGroupLogic = GetGroupLogicOfFighter(currentFighter); bTurnInProgress = true; targetChoosed = null; PutFighterInFightPosition(); } else if (!bActionInProgress && bFighterInFightPosition) { if (currentGroupLogic.GetLogicType() == LogicType.IA) { if (!bActionChoosed) { if (protoScript != null && protoScript.combat != null && protoScript.combat.currentTurn != null) { actionChoosed = ActionType.GetActionTypeWithID(protoScript.combat.currentTurn.ActionCode); } else { actionChoosed = ((GroupIA)currentGroupLogic).SelectAction(monsterGroupFighter.lFighters, humanGroupFighter.lFighters); } bActionChoosed = true; if (actionChoosed.GetTargetType() == ActionType.ActionTargetType.OneTarget) { bActionRequireTarget = true; } else { bActionRequireTarget = false; } } else if (bActionRequireTarget && !bTargetChoosed) { targetChoosed = ((GroupIA)currentGroupLogic).SelectTarget(monsterGroupFighter.lFighters, humanGroupFighter.lFighters); bTargetChoosed = true; } else { // Current Fighter perform action on target PerformAction(); } } else // If LogicType = Player { if (!bActionChoosed) { if (currentFighter.eCreatureType == CreatureType.Monster) { if (((Monster)currentFighter).isBoss) { actionChoosed = ActionType.FEAR; bActionChoosed = true; AkSoundEngine.PostEvent("Play_" + currentFighter.sName + "Fear", gameObject); } } // Choose action } else if (bActionRequireTarget && !bTargetChoosed) { // Chose Target } else { // Current Fighter perform action on target // Debug.Log("Action in progress player"); PerformAction(); } } } } }
public virtual ActionType SelectAction(List <Fighter> Enemies, List <Fighter> Allies) { GameObject g = GameObject.FindGameObjectWithTag("ProtoManager"); if (g != null) { ProtoScript protoScript = g.GetComponent <ProtoScript>(); if (protoScript.combat.iteration == 1) { return(ActionType.TALK); } else { return(ActionType.ATTACK); } } if (groupHumanFighter.bWantsToAttack) { return(ActionType.ATTACK); } if (groupHumanFighter.bInConversation) { return(ActionType.TALK); } if (!groupHumanFighter.bCanBeFeared || !groupHumanFighter.bCanListen) { groupHumanFighter.bWantsToAttack = true; return(ActionType.ATTACK); } if (bIsFirstLogicTurn) { bIsFirstLogicTurn = false; CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>(); if (combatManager.isBossCombat) { groupHumanFighter.bWantsToAttack = true; groupHumanFighter.bInConversation = false; return(ActionType.ATTACK); } float rand = Random.Range(0.0f, 1.0f); ActionType.ActionEnum enumAction = GameObject.FindGameObjectWithTag("CombatTerrain").GetComponent <CombatTerrainInfo>().modComportement.action; ActionType acType = ActionType.GetActionTypeWithID((int)enumAction); if ((acType == ActionType.ATTACK && rand > rollProbaManager.humanComp.discussion - 0.1)) { groupHumanFighter.bWantsToAttack = true; groupHumanFighter.bInConversation = false; return(ActionType.ATTACK); } if (rand < rollProbaManager.humanComp.escape || (acType == ActionType.ESCAPE && rand < rollProbaManager.humanComp.escape + 0.1)) { groupHumanFighter.bIsFeared = true; return(ActionType.ESCAPE); } if (rand < rollProbaManager.humanComp.discussion || (acType == ActionType.TALK && rand < rollProbaManager.humanComp.discussion + 0.1)) { groupHumanFighter.bInConversation = true; groupHumanFighter.bWantsToAttack = false; return(ActionType.TALK); } else { groupHumanFighter.bWantsToAttack = true; groupHumanFighter.bInConversation = false; return(ActionType.ATTACK); } } float random = Random.Range(0.0f, 1.0f); if (random < 0.6) { groupHumanFighter.bWantsToAttack = true; groupHumanFighter.bInConversation = false; return(ActionType.ATTACK); } else { groupHumanFighter.bInConversation = true; groupHumanFighter.bWantsToAttack = false; return(ActionType.TALK); } }