private void InventoryUIToggle() { if (Input.GetButtonDown("Inventory")) { if (inventoryUI.activeSelf) //if already active go to idle { psm.RequestChangeState(StateMachine.States.Idle); } else { psm.RequestChangeState(StateMachine.States.InvOpen); } ScriptToolbox.GetInstance().GetWindowCloser().DestroyPopupMenus(); } }
void TriggerAttack() { Debug.Log("Player is attacking " + gameObject.name); UnitStateMachine u = ScriptToolbox.GetInstance().GetPlayerManager().player.GetComponent <UnitStateMachine>(); u.currentThreat = transform; u.RequestChangeState(StateMachine.States.Fight); }
void TriggerTrade() { if (myShop != null) { UnitStateMachine u = GetComponent <UnitStateMachine>(); u.RequestChangeState(StateMachine.States.Shopping); } else { Debug.Log("This NPC cannot trade"); } }
private IEnumerator Flee() { Vector3 closestExit = GetClosestExit(); float z = transform.position.z; PathfindingManager.RequestPath(new PathRequest(transform.position, closestExit, usm.unitController.OnPathFound)); while (Vector3.Distance(transform.position, closestExit) > 0.5f) { yield return(null); } usm.RequestChangeState(StateMachine.States.Routed); }
public virtual void RecieveAttack(AttackInfo recievedAttack, Transform myAttacker) { //don't keep reacting to the same attack if (stateMachine.currentState != StateMachine.States.Fight || stateMachine.currentState != StateMachine.States.Flight || stateMachine.currentState != StateMachine.States.FightOrFlight) { stateMachine.currentThreat = myAttacker; stateMachine.RequestChangeState(StateMachine.States.FightOrFlight); } if (Hit()) { BodyPart bodyPart = GetRandomPart(); bodyPart.TakeDamage(recievedAttack); } if (PartTooInjured(vitalParts)) { stateMachine.RequestChangeState(StateMachine.States.Dead); string line = "<color=red>" + gameObject.name + " has been mortally wounded!</color>"; BattleReport.AddToBattleReport(line); } }
private IEnumerator Engage(Transform _targetTransform) { //Debug.LogError(gameObject.name + " is engaging " + _targetTransform.name); bool inRange; targetTransform = _targetTransform; targetBody = targetTransform.GetComponent <BodyPartController>(); attack1Parts = usm.attack1Parts; attack2Parts = usm.attack2Parts; UnitController uc = usm.unitController; BodyPartController opponent = targetTransform.GetComponent <BodyPartController>(); Collider2D col = GetComponent <Collider2D>(); usm.unitAnim.FaceDirection(transform.position, targetTransform.position); while (!opponent.Incapacitated()) { //eventually this will be a function that will check if ranged or melee, then decide if in range or not //for ranged we can use a raycast of some sort to check for obstabcles inRange = col.IsTouching(targetTransform.GetComponent <Collider2D>()); if (!inRange) { PathfindingManager.RequestPath(new PathRequest(transform.position, targetTransform.position, uc.OnPathFound)); yield return(new WaitForSeconds(.1f)); } else if (!usm.attackTimer.coolingDown) { Attack(); } yield return(null); } usm.RequestChangeState(StateMachine.States.Idle); yield break; }
//can be used for descriptions and observations as well void TriggerDialogue() { UnitStateMachine u = GetComponent <UnitStateMachine>(); u.RequestChangeState(StateMachine.States.Talking); }
//dialogue ended via continue button private void SoftDialogueExit() { unitTalking.RequestChangeState(StateMachine.States.Idle); ScriptToolbox.GetInstance().GetPlayerManager().playerStateMachine.RequestChangeState(StateMachine.States.Idle); CloseDialogueWindow(); }