//Add a TargetScript to the game //Without this, agents wouldn't be able to find a target public int AddTarget(int id, Transform transformToAdd, ParagonAI.TargetScript script) { currentID++; ParagonAI.Target agentToAdd = new ParagonAI.Target(currentID, id, transformToAdd, script); currentTargets.Add(agentToAdd); UpdateAllEnemiesEnemyLists(); return currentID; }
//Used to set variables once cover is found. void SetCover(Vector3 newCoverPos, Vector3 newCoverFiringSpot,bool isDynamicCover,ParagonAI.CoverNodeScript newCoverNodeScript) { baseScript.currentCoverNodePos = newCoverPos; baseScript.currentCoverNodeFiringPos = newCoverFiringSpot; agent.stoppingDistance = 0; if(isDynamicCover) { foundDynamicCover = true; ParagonAI.ControllerScript.currentController.AddACoverSpot(baseScript.currentCoverNodeFiringPos); } else { baseScript.currentCoverNodeScript = newCoverNodeScript; baseScript.currentCoverNodeScript.setOccupied(true); } }
public CoverData(bool f, Vector3 hp, Vector3 fP, bool d, ParagonAI.CoverNodeScript cns) { foundCover = f; hidingPosition = hp; firingPosition = fP; isDynamicCover = d; coverNodeScript = cns; }
public Target(int identity, int id, Transform transformToAdd, ParagonAI.TargetScript script) { uniqueIdentifier = identity; teamID = id; transform = transformToAdd; targetScript = script; }
void AttachHitboxes(Transform t, ParagonAI.HealthScript hs) { if (t.gameObject.GetComponent<Collider>()) { ParagonAI.HitBox hitboxNow = t.gameObject.AddComponent<ParagonAI.HitBox>() as ParagonAI.HitBox; if (t.gameObject.GetComponent<SphereCollider>()) hitboxNow.damageMultiplyer = headHitMultiplier; else hitboxNow.damageMultiplyer = defaultHitMultiplier; hitboxNow.myScript = hs; t.transform.tag = hitBoxTag; } for (int c = 0; c < t.childCount; c++) { AttachHitboxes(t.GetChild(c), hs); } }
//Setters public void SetTargetObj(ParagonAI.TargetScript x) { myTargetScript = x; }
public void SetEnemyBaseScript(ParagonAI.BaseScript x) { myAIBaseScript = x; }
//If a target is noticed, it is prioritized void NoticeATarget(ParagonAI.Target newTarget) { int IDToAdd = newTarget.uniqueIdentifier; //Make sure we haven't seen this target already for (int i = 0; i < targetIDs.Count; i++) { if (targetIDs[i] == IDToAdd) { return; } } lastKnownTargetPositions.Add(newTarget.transform.position); listOfCurrentlyNoticedTargets.Add(newTarget); targetIDs.Add(IDToAdd); ChooseTarget(); //If we aren't already engaging in combat, start engaging. if (!engaging) { myAIBaseScript.StartEngage(); engaging = true; } }
//Update the local lists of allies and enemies. public void UpdateEnemyAndAllyLists(ParagonAI.Target[] a, ParagonAI.Target[] e) { if (myAIBaseScript) { //allyTransforms = a; enemyTargets = e; //If we don't have any targets left, exit the engaging state if (enemyTargets.Length == 0) { myAIBaseScript.EndEngage(); engaging = false; } ParagonAI.Target[] lastTargets = listOfCurrentlyNoticedTargets.ToArray(); listOfCurrentlyNoticedTargets = new List<ParagonAI.Target>(); Vector3[] lastlastKnownTargetPositions = lastKnownTargetPositions.ToArray(); lastKnownTargetPositions = new List<Vector3>(); //Put all targets that still exist in new list for (int i = 0; i < lastTargets.Length; i++) { for (int x = 0; x < enemyTargets.Length; x++) { if (lastTargets[i].uniqueIdentifier == enemyTargets[x].uniqueIdentifier) { listOfCurrentlyNoticedTargets.Add(enemyTargets[x]); lastKnownTargetPositions.Add(lastlastKnownTargetPositions[i]); break; } } } //Check to see if we can see any targets. If engaging, we aren't limited by what direction we are looking in. if (engaging) { CheckForLOSAwareness(true); } else { CheckForLOSAwareness(false); } ChooseTarget(); } }