ENodeStates FetchHeat() { if (!haveTarget || targetType != EStatsTypes.Heat) { var heatPowerUp = GameObject.Find("HeatPowerUps"); var transformChildCount = heatPowerUp.transform.childCount; if (transformChildCount > 0) { // find closets Transform target = heatPowerUp.transform.GetChild(0); var ChildDistance = Vector3.Distance(transform.position, target.position); for (int i = 1; i < transformChildCount; ++i) { var child = heatPowerUp.transform.GetChild(i); var newDist = Vector3.Distance(transform.position, child.position); if (ChildDistance > newDist) { target = child; ChildDistance = newDist; } } // move to point haveTarget = true; targetPos = target.position; targetType = EStatsTypes.Heat; agent.SetDestination(targetPos); agent.isStopped = false; return(ENodeStates.RUNNING); } } else { if (Vector3.Distance(transform.position, targetPos) <= theta) { haveTarget = false; agent.isStopped = true; return(ENodeStates.SUCCESS); } else { return(ENodeStates.RUNNING); } } return(ENodeStates.FAILURE); }
public void AddPower(EStatsTypes powerType, int value) { m_Stats[(int)powerType, 0] += value; }