void SearchForFireballs() { if (fireballs.Length > 0) { foreach (Fireball f in fireballs) { float range = 1.0f; Survivor_AI sAI = FindClosestSurvivorToFireBall(f); float distance = Vector3.Distance(sAI.GetSurvivor().transform.position, f.transform.position); if (distance < range) { ResetSurvivorsBT(); sAI.GetBlackBoard().incomingFireball = f; sAI.GetBlackBoard().currentSurvivorPosition = sAI.GetSurvivor().transform.position; Task BT_Evade_Fireball = new Sequence_EvadeFireballs(); sAI.SetBehaviorTree(BT_Evade_Fireball); } } } }
void SurvivorFlee() { List <Enemy> enemies = GameManager.getAllEnemies(); if (enemies.Count > 0) { foreach (Enemy e in enemies) { float range = 5.0f; Survivor_AI sAI = FindClosestSurvivorToTarget(e); float distance = Vector3.Distance(sAI.GetSurvivor().transform.position, e.transform.position); if (distance < range) { ResetSurvivorsBT(); Task BT_Flee_Zombie = new Sequence_FleeZombie(); sAI.GetBlackBoard().target = e; sAI.GetBlackBoard().currentSurvivorPosition = sAI.GetSurvivor().transform.position; sAI.SetBehaviorTree(BT_Flee_Zombie); } } } }
Enemy FindClosestBunny(Survivor_AI sAI, List <Enemy> bunnies) { Enemy output = null; float closestSoFar = Mathf.Infinity; for (int i = 0; i < bunnies.Count; i++) { Enemy e = bunnies[i]; if (e.getState() != EnemyState.DEAD) { float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude; if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange()) { output = e; closestSoFar = dist; } } } if (output != null) //Debug.Log("Survivor " + sAI.GetSurvivor().name + //" is Targeting enemy position " + output.transform.position { } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.GRENADE_LAUNCHER).getAmmo() > 0) { if ((sAI.transform.position - sAI.GetBlackboard().enemyTarget.transform.position).magnitude <= 10) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.GRENADE_LAUNCHER); output = TASK_RETURN_STATUS.SUCCEED; } } return(output); }
public void MoveSurvivorBack(Survivor_AI sAI) { sAI.GetSurvivor().MoveTo(sAI.GetCurrDefensePoint().transform.position); sAI.mvmtTracker = Moving.NOT_MOVING_ON_ASTAR; SearchingForLoot = false; Invoke("SearchForLoot", 20.0f); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE; if (sAI.GetBlackBoard().target.state != EnemyState.DEAD) { Vector3 runTo = sAI.GetSurvivor().transform.position + ((sAI.GetSurvivor().transform.position - sAI.GetBlackBoard().target.gameObject.transform.position) * 5); sAI.GetSurvivor().MoveTo(runTo); output = TASK_RETURN_STATUS.SUCCESS; } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Blackboard bb = sAI.GetBlackboard(); if (bb.distFromTarget < 10.0f) { if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SHOTGUN).getAmmo() > 0) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SHOTGUN); output = TASK_RETURN_STATUS.SUCCEED; } } return(output); }
bool isTargetVisible(Survivor_AI sAI, Enemy e) { bool output = false; if (e != null) { Survivor survivor = sAI.GetSurvivor(); RaycastHit hit; Vector3 offset = (Vector3.up * 0.5f); Vector3 dir = e.transform.position - survivor.transform.position; dir += offset; dir.Normalize(); int layerMask = 1 << LayerMask.NameToLayer("Player"); layerMask = ~layerMask; if (Physics.Raycast(survivor.transform.position + offset, dir, out hit, 1000.0f, layerMask)) { if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Enemy")) { //if (hit.collider.gameObject.GetInstanceID () == e.gameObject.GetInstanceID ()) //{ output = true; //} } } } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; WEAPON_TYPE prevType = sAI.GetSurvivor().GetCurrentWeapon().type; sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.GRENADE_LAUNCHER); if (sAI.GetSurvivor().GetCurrentWeapon().getAmmo() > 0) { Enemy target = sAI.GetBlackboard().enemyTarget; sAI.GetSurvivor().Fire(target.transform.position + (sAI.GetEnemyHeightOffset() * Vector3.up)); sAI.GetSurvivor().SwitchWeapons(prevType); output = TASK_RETURN_STATUS.SUCCEED; } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS; sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL); return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS; FindPath(sAI, sAI.GetSurvivor().transform.position, targetPoint); return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE; if (GameManager.GetAmmo(WEAPON_TYPE.SNIPER) > 0) { BlackBoard bd = sAI.GetBlackBoard(); Weapon w = sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER); float distFromTarget = Vector3.Distance(bd.target.transform.position, sAI.transform.position); if (distFromTarget < w.getRange()) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER); output = TASK_RETURN_STATUS.SUCCESS; } } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Blackboard bb = sAI.GetBlackboard(); if (sAI.mvmtTracker == Moving.MOVING_ON_ASTAR) { return(output); } if (bb.distFromTarget < 35.0f && bb.distFromTarget > 25.0f) { if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.ASSAULT).getAmmo() > 0) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.ASSAULT); output = TASK_RETURN_STATUS.SUCCEED; } } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SHOTGUN).getAmmo() < 10) { //while (GameManager.GetCurrentGold() >= 25) //{ GameManager.PurchaseAmmo(WEAPON_TYPE.SHOTGUN); GameManager.PurchaseAmmo(WEAPON_TYPE.SHOTGUN); //} } return(TASK_RETURN_STATUS.SUCCEED); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Blackboard bb = sAI.GetBlackboard(); if (sAI.mvmtTracker == Moving.MOVING_ON_ASTAR) { return(output); } if (bb.distFromTarget > 25.0f && bb.distFromTarget < 37.0f && bb.enemyTarget.getEnemyType() == EnemyType.ZOMBEAR) { if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() > 0) //&& sAI.GetBlackboard().enemyTarget.getEnemyType() != EnemyType.ZOMBUNNY) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER); output = TASK_RETURN_STATUS.SUCCEED; } } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS; if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.ZOMBUNNY) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL); } if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.HELLEPHANT) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER); } if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.CLOWN) { sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL); } return(output); }
Enemy FindClosestHellephant(Survivor_AI sAI, List <Enemy> hellephant) { Enemy output = null; float closestSoFar = Mathf.Infinity; for (int i = 0; i < hellephant.Count; i++) { Enemy e = hellephant[i]; if (e.getState() != EnemyState.DEAD) { float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude; if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange()) { output = e; closestSoFar = dist; } } } //if (output != null) { Debug.Log("Enemy Type: " + output.name); } return(output); }
Enemy FindClosestClown(Survivor_AI sAI, List <Enemy> clowns) { Enemy output = null; float closestSoFar = Mathf.Infinity; for (int i = 0; i < clowns.Count; i++) { Enemy e = clowns[i]; if (e.getState() != EnemyState.DEAD) { float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude; if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange()) { output = e; closestSoFar = dist; } } } return(output); }
Enemy FindClosestTarget(Survivor_AI sAI) { Enemy output = null; float closestSoFar = Mathf.Infinity; List <Enemy> enemies = GameManager.getAllEnemies(); for (int i = 0; i < enemies.Count; i++) { Enemy e = enemies[i]; if (e.getState() != EnemyState.DEAD) { float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude; if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange()) { output = e; closestSoFar = dist; } } } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE; base.Run(sAI); if (sAI.GetBlackBoard().target.state == EnemyState.DEAD) { sAI.GetSurvivor().MoveTo(sAI.GetBlackBoard().currentSurvivorPosition); output = TASK_RETURN_STATUS.SUCCESS; } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE; BlackBoard blackBoard = sAI.GetBlackBoard(); Enemy target = blackBoard.target; if (target != null) { sAI.GetSurvivor().Fire(target.transform.position + (Vector3.up * sAI.enemyHeightOffset)); output = TASK_RETURN_STATUS.SUCCESS; } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { //TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; //if(sAI.transform.position != sAI.GetCurrDefensePoint().transform.position) //{ sAI.GetSurvivor().MoveTo(sAI.GetCurrDefensePoint().transform.position); // } //else //{ //output = TASK_RETURN_STATUS.SUCCEED; //} return(TASK_RETURN_STATUS.SUCCEED); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Blackboard bb = sAI.GetBlackboard(); if (bb.distFromTarget <= 25.0f) //&& bb.distFromTarget >= 10.0f) { //if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.PISTOL).getAmmo() > 0) //{ sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL); output = TASK_RETURN_STATUS.SUCCEED; //} } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Enemy target = sAI.GetBlackboard().enemyTarget; if (target != null) { sAI.GetSurvivor().Fire(target.transform.position + (sAI.GetEnemyHeightOffset() * Vector3.up)); output = TASK_RETURN_STATUS.SUCCEED; } return(output); }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED; Enemy e = FindClosestBearTarget(sAI); if (e != null) { if (sAI.GetBlackboard().distFromTarget < 40.0f && (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() > 0 || sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.ASSAULT).getAmmo() > 0)) { sAI.GetBlackboard().enemyTarget = e; output = TASK_RETURN_STATUS.SUCCEED; } } return(output); }
void FindPath(Survivor_AI sAI, Vector3 startPoint, Vector3 endPoint) { List <PathNode> path = pathfinder.CreatePath(startPoint, endPoint); if (path != null) { for (int i = 0; i < path.Count; i++) { if (sAI.transform.position != path[i].transform.position) { sAI.GetSurvivor().MoveTo(path[i].transform.position); } else { // pop the current node of the list path.Remove(path[i]); } } } }
public override TASK_RETURN_STATUS Run(Survivor_AI sAI) { if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() <= 12) { //while (GameManager.GetCurrentGold() > 50) if (GameManager.GetCurrentGold() > 160) { GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); } else if (GameManager.GetCurrentGold() > 80) { GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); } else if (GameManager.GetCurrentGold() > 40) { GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER); } } return(TASK_RETURN_STATUS.SUCCEED); }