private void Start() { globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); maxAttackDamage = (float)globalBlackboard.GetValue("maxAttackDamage"); minAttackDamage = (float)globalBlackboard.GetValue("minAttackDamage"); maxFood = (int)globalBlackboard.GetValue("maxFood"); }
public override NodeState Evaluate() { int nAnts = (int)globalBlackboard.GetValue("totalNumberOfCharacters"); int nAntsDefending = (int)globalBlackboard.GetValue("antsDefending"); if (nAntsDefending < nAnts / 2) { return(NodeState.SUCCESS); } else { return(NodeState.FAIL); } }
protected override void Awake() { base.Awake(); agent = (NavMeshAgent)blackboard.GetValue("navMeshAgent"); globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); }
public override NodeState Evaluate() { if ((Vector3)blackboard.GetValue("currentFoodLocation") == Vector3.zero) { return(NodeState.SUCCESS); } if (isEating) { if (timer >= eatAnimationLength) { ObjectDestroyer.DestroyObjectAtGivenPosition((Vector3)blackboard.GetValue("currentFoodLocation"), LayerMask.GetMask("Food")); int foodEaten = (int)globalBlackboard.GetValue("foodEaten") + 1; globalBlackboard.UpdateValue("foodEaten", foodEaten); return(NodeState.SUCCESS); } else { timer += Time.deltaTime; } } else { anim.SetTrigger("Attack"); agent.isStopped = true; isEating = true; } return(NodeState.RUNNING); }
public override NodeState Evaluate() { if (((int)globalBlackboard.GetValue("foodEaten") >= foodRequiredToBeStrong) == desiredBool) { return(NodeState.SUCCESS); } return(NodeState.FAIL); }
public override bool EvaluateCondition() { nAllies = (int)globalBlackboard.GetValue("totalNumberOfCharacters"); minEnemies = nAllies + (int)(nAllies * fewEnemiesMultiplier); int nTotalCharacters = (int)gameGlobalBlackboard.GetValue("totalNumberOfCharacters"); return((nTotalCharacters <= minEnemies) == desiredBool); }
public override void OnStateEnter() { base.OnStateEnter(); Vector3 currentEnemyBase = (Vector3)globalBlackboard.GetValue("currentEnemyBase"); Vector3 positionToGo = NavMeshUtilities.SamplePositionNearMe(transform.position, currentEnemyBase); agent.SetDestination(positionToGo); }
protected void Start() { anim = (Animator)blackboard.GetValue("animator"); agent = (NavMeshAgent)blackboard.GetValue("navMeshAgent"); attackAnimationLength = AnimatorUtilities.GetClipLength(anim, "Attack"); globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); attackDamage = (float)globalBlackboard.GetValue("attackDamage"); }
public override NodeState Evaluate() { int foodEaten = (int)globalBlackboard.GetValue("foodEaten"); float t = Mathf.InverseLerp(0, maxFood, foodEaten); float attackDamage = Mathf.Lerp(minAttackDamage, maxAttackDamage, t); globalBlackboard.UpdateValue("attackDamage", attackDamage); return(NodeState.SUCCESS); }
public override bool EvaluateCondition() { if (baseManager.isBaseAlive((Vector3)globalBlackboard.GetValue("currentEnemyBase"))) { return(false); } globalBlackboard.UpdateValue("enemyBaseFound", false); return(true); }
public override void OnStateEnter() { agent.isStopped = false; anim.SetBool("isMoving", true); Vector3 homeLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); Vector3 positionToGo = NavMeshUtilities.SamplePositionNearMe(transform.position, homeLocation); agent.SetDestination(positionToGo); base.OnStateEnter(); }
public override NodeState Evaluate() { nAllies = (int)globalBlackboard.GetValue("totalNumberOfCharacters"); minEnemies = nAllies * 2; if (((int)gameGlobalBlackboard.GetValue("totalNumberOfCharacters") <= minEnemies) == desiredBool) { return(NodeState.SUCCESS); } return(NodeState.FAIL); }
public override NodeState Evaluate() { Vector3 baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); if (Vector3.Distance(transform.position, baseLocation) <= distance) { return(NodeState.SUCCESS); } return(NodeState.FAIL); }
public override NodeState Evaluate() { if ((bool)globalBlackboard.GetValue("baseIsInDanger") == desiredBool) { return(NodeState.SUCCESS); } else { return(NodeState.FAIL); } }
public override NodeState Evaluate() { Vector3 baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); if (baseLocation != agent.destination) { agent.SetDestination(NavMeshUtilities.SamplePositionNearMe(transform.position, baseLocation)); agent.isStopped = false; anim.SetBool("isMoving", true); } if (agent.remainingDistance <= distanceHome && !agent.pathPending) { agent.isStopped = true; anim.SetBool("isMoving", false); return(NodeState.SUCCESS); } return(NodeState.RUNNING); }
void setDestinationToBase() { Vector3 baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); Vector3 dirToBase = (baseLocation - transform.position).normalized; NavMeshHit hit; Vector3 posToMove = (dirToBase * deltaMovement) + transform.position; if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas)) { agent.SetDestination(hit.position); agent.isStopped = false; anim.SetBool("isMoving", true); } else { print("I could not flee"); } }
void setDestination() { Vector3 basePos = (Vector3)globalBlackboard.GetValue("baseLocation"); Vector3 dirToMe = (transform.position - basePos).normalized * baseOffset; Vector3 directionToMove = Quaternion.Euler(0, deltaAngle, 0) * dirToMe; Vector3 posToMove = basePos + directionToMove; NavMeshHit hit; if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas)) { agent.SetDestination(hit.position); } else { posToMove = basePos - directionToMove; if (NavMesh.SamplePosition(posToMove, out hit, 3f, NavMesh.AllAreas)) { agent.SetDestination(hit.position); } } }
private void Start() { baseManager = (BaseManager)GameGlobalBlackboard.Instance.GetValue("baseManager"); globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); baseLocation = (Vector3)globalBlackboard.GetValue("baseLocation"); }
private void Awake() { blackboard = GetComponent <Blackboard>(); globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); maxHealth = (float)globalBlackboard.GetValue("maxHealth"); }
private void Start() { globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); maxHealth = (float)globalBlackboard.GetValue("maxHealth"); }
public override NodeState Evaluate() { globalBlackboard.UpdateValue("antsDefending", (int)globalBlackboard.GetValue("antsDefending") - 1); return(NodeState.SUCCESS); }
public override bool EvaluateCondition() { return(Vector3.Distance((Vector3)globalBlackboard.GetValue("baseLocation"), transform.position) <= distanceNear); }
public override bool EvaluateCondition() { return((bool)globalBlackboard.GetValue("enemyBaseFound")); }
public override void OnStateEnter() { base.OnStateEnter(); globalBlackboard.UpdateValue("antsDefending", (int)globalBlackboard.GetValue("antsDefending") + 1); }
private void Start() { globalBlackboard = (GlobalBlackboard)blackboard.GetValue("globalBlackboard"); foodRequiredToBeStrong = (int)globalBlackboard.GetValue("maxFood"); }
private void RemoveCharacterFromBase() { BaseManager baseManager = (BaseManager)GameGlobalBlackboard.Instance.GetValue("baseManager"); baseManager.RemoveCharacterFromBase(GetComponentInParent <IDamageable>(), (Vector3)globalBlackboard.GetValue("baseLocation")); }