public void TankHasDied(NPCTankController self) { if (AllTanks.Contains(self))//Only tanks on the roster should be tracked. AKA, no ninja tanks { DeadTanks.Add(self); } }
public ChaseState(NPCTankController tank) { stateID = FSMStateID.Chasing; this.tank = tank; curRotSpeed = 2.0f; curSpeed = 200.0f; }
public AttackState(NPCTankController tank) { stateID = FSMStateID.Attacking; curRotSpeed = 1.5f; curSpeed = 100.0f; this.tank = tank; }
public override void Act(Transform player, Transform npc) { NPCTankController npcScript = npc.GetComponent <NPCTankController>(); if (npcScript.findPointCounter == 0) { if (npcScript.pathing == PathingMode.Random) { FindNextRandPoint(); npcScript.agent.SetDestination(destPos); } else if (npcScript.pathing == PathingMode.Order) { if (waypointCounter < waypoints.Length - 1) { waypointCounter += 1; npcScript.agent.SetDestination(waypoints[waypointCounter].position); } else { waypointCounter = 0; npcScript.agent.SetDestination(waypoints[waypointCounter].position); } } npcScript.findPointCounter++; } //Rotate to the target point //Quaternion targetRotation = Quaternion.LookRotation(destPos - npc.position); //npc.rotation = Quaternion.Slerp(npc.rotation, targetRotation, Time.deltaTime * npcScript.curRotSpeed); }
public PatrolState(NPCTankController npcTankController, Transform[] wp) { waypoints = wp; stateID = FSMStateID.Patrolling; _npcTankController = npcTankController; curRotSpeed = 1.0f; curSpeed = 100.0f; }
public RageState(NPCTankController npcController, MeshRenderer meshRenderer, Transform[] wp) { waypoints = wp; stateID = FSMStateID.Rage; _npcController = npcController; curRotSpeed = 1.0f; _meshRenderer = meshRenderer; }
void Start() { agentScript = GetComponent <NPCTankController>(); viewMesh = new Mesh(); viewMesh.name = "View Mesh"; viewMeshFilter.mesh = viewMesh; StartCoroutine("FindTargetsWithDelay", .2f); }
public BoredState(Transform[] wp, NPCTankController brain) { waypoints = wp; stateID = FSMStateID.Bored; curRotSpeed = 1.0f; curSpeed = 100.0f; npcBrain = brain; }
public PatrolState(NPCTankController tank) { stateID = FSMStateID.Patrolling; this.tank = tank; curRotSpeed = 1.8f; curSpeed = 130.0f; waitTimer = waitconst; destPos = tank.transform.position; startingRotation = tank.transform.rotation; }
// Start is called before the first frame update void Start() { npcScript = GetComponentInParent <NPCTankController>(); playerScript = GameObject.FindWithTag("Player").GetComponent <PlayerScript>(); if (npcScript.aggroType.ToString() != "Touch") { this.gameObject.SetActive(false); } }
public RepairState(NPCTankController tank) { curRotSpeed = 12; curSpeed = 250; stateID = FSMStateID.Repairing; this.tank = tank; Transform repairarea = GameObject.FindGameObjectWithTag("Repair Area").transform; destination = repairarea.GetComponent <Waypoint>(); }
public override void Act(Transform player, Transform npc) { NPCTankController npcScript = npc.gameObject.GetComponent <NPCTankController>(); if (npcScript.targetSardine != null) { distToSardine = Vector3.Distance(npc.position, npcScript.targetSardine.transform.position); npcScript.agent.SetDestination(npcScript.targetSardine.transform.position); } }
public PatrolState(Transform[] wp, NPCTankController controller) { waypoints = wp; stateID = FSMStateID.Patrolling; curSpeed = 200f; curRotSpeed = 2f; attackDistance = 200f; chaseDistance = 450f; this.controller = controller; }
public AttackState(NPCTankController npcController, Transform[] wp) { waypoints = wp; stateID = FSMStateID.Attacking; _npcController = npcController; curRotSpeed = 1.0f; curSpeed = 100.0f; //find next Waypoint position FindNextPoint(); }
public RageState(NPCTankController controller) { stateID = FSMStateID.Rage; attackDistance = 200f; chaseDistance = 450f; shootRate = 4f; bonusSpeed = 300f; this.controller = controller; }
public AttackState(Transform[] wp, NPCTankController brain) { waypoints = wp; stateID = FSMStateID.Attacking; curRotSpeed = 1.0f; curSpeed = 100.0f; npcBrain = brain; //find next Waypoint position FindNextPoint(); }
public OffDutyState(Transform npc, NPCTankController tank) { curRotSpeed = 1.3f; curSpeed = 100.0f; stateID = FSMStateID.OffDuty; waitTimer = 20.0f; Transform offdutyArea = GameObject.FindGameObjectWithTag("Offduty Area").transform; destination = offdutyArea.GetComponent <Waypoint>(); this.tank = tank; tank.destPath = null; }
public ChaseState(Transform[] wp, NPCTankController controller) { waypoints = wp; stateID = FSMStateID.Chasing; attackDistance = 200f; chaseDistance = 450f; this.controller = controller; //find next Waypoint position FindNextPoint(); }
public bool canGoOnDuty(NPCTankController self) { if (!AllTanks.Contains(self))//Only tanks on the roster can go off duty { return(false); } if ((float)OnDuty.Count / (float)AllTanks.Count < .2f && AllTanks.Count > 1) { OnDuty.Add(self); return(true); } return(false); }
public AttackState(Transform[] wp, NPCTankController controller) { waypoints = wp; stateID = FSMStateID.Attacking; curRotSpeed = 1.0f; curSpeed = 100.0f; attackDistance = 200f; chaseDistance = 450f; this.controller = controller; //find next Waypoint position FindNextPoint(); }
public override void Reason(Transform player, Transform npc) { npcController = npc.GetComponent <NPCTankController>(); //Set the target position as the player position destPos = player.position; //Check the distance with player tank //When the distance is near, transition to attack state float dist = Vector3.Distance(npc.position, destPos); if (npcController.GetCurrentHealth() >= (npcController.GetMaxHealth() / 1.5) && dist < 200f) { Debug.Log(npcController.GetCurrentHealth() + "Current health " + npcController.GetMaxHealth() + " Max health"); Debug.Log("Switch to attack state"); npcController.SetTransition(Transition.ReachPlayer); } else if (dist > 800f) { npcController.SetTransition(Transition.LostPlayer); } }
public bool returnToDuty(NPCTankController self) { return(OnDuty.Remove(self)); }
public DeadState(NPCTankController controller) { stateID = FSMStateID.Dead; this.controller = controller; }
public override void Reason(Transform player, Transform npc) { NPCTankController npcScript = npc.GetComponent <NPCTankController>(); npcScript.detectionTimer += Time.deltaTime; if (npcScript.detectionTimer >= npcScript.detectionRate) { if (npcScript.aggroType.ToString() == "LineOfSight") { //RaycastHit hit; //npcScript.rayDirection = player.position - npc.position; //if ((Vector3.Angle(npcScript.rayDirection, npc.forward)) < npcScript.FieldOfView) //{ // // Detect if player is within the field of view // if (Physics.Raycast(npc.position, npcScript.rayDirection, out hit, npcScript.ViewDistance)) // { // //get aspect on the hit // Aspect aspect = hit.collider.GetComponent<Aspect>(); // if (aspect != null) // { // //Debug.Log("Hit something"); // if(aspect.aspectName == Aspect.aspect.Enemy) // { // Debug.Log("Enemy Seen"); // GameObject.FindWithTag("Player").GetComponent<PlayerScript>().isSeen = true; // npcScript.SetTransition(Transition.SawPlayer); // } // } // else // { // if (npcScript.CurrentStateID != FSMStateID.Patrolling) // npcScript.SetTransition(Transition.LostPlayer); // } // } //} } else if (npcScript.aggroType.ToString() == "Sound") { //if palyer is in list and is moving, else invoke transidtion to patorl after if (npcScript.canHearObjects.Contains(player.gameObject)) { if (npcScript.canHearObjects.Count < 2) { //100% chance npcScript.cantHearDebug = true; GameObject.FindWithTag("Player").GetComponent <PlayerScript>().isHeard = true; //npcScript.SetTransition(Transition.SawPlayer); } else { //Cuts chance in half depending on the amount of tanks in the list int randNum; randNum = Random.Range(1, 100); Debug.Log("testRand"); if (randNum < (100 / (npcScript.canHearObjects.Count * 5))) { npcScript.cantHearDebug = true; GameObject.FindWithTag("Player").GetComponent <PlayerScript>().isHeard = true; // npcScript.SetTransition(Transition.SawPlayer); } } } } else if (npcScript.aggroType.ToString() == "Touch") { } else if (npcScript.aggroType.ToString() == "Investigate") { if (npcScript.canHearObjects.Contains(player.gameObject)) { Debug.Log("Investigating"); npcScript.SetTransition(Transition.SmelledSardine); } } else { } npcScript.detectionTimer = 0; } if (Vector3.Distance(npc.position, player.position) <= 3.5f) { Debug.Log("Touched Player"); player.GetComponent <PlayerScript>().FoundPlayer(); npcScript.GetComponent <FieldOfView>().CatFoundPlayer(player); npcScript.agent.velocity = Vector3.zero; npcScript.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; npcScript.agent.isStopped = true; } if (Vector3.Distance(npc.position, waypoints[waypointCounter].position) <= 2.0f) { npcScript.agent.velocity = Vector3.zero; npcScript.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; npcScript.agent.isStopped = true; npcScript.pathingBuffer += Time.deltaTime; if (npcScript.pathingBuffer > 1f) { npcScript.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; npcScript.agent.isStopped = false; if (npcScript.pathing == PathingMode.Random) { Debug.Log("findnextrand"); FindNextRandPoint(); npcScript.agent.SetDestination(destPos); } else if (npcScript.pathing == PathingMode.Order) { if (waypointCounter < waypoints.Length - 1) { waypointCounter += 1; npcScript.agent.SetDestination(waypoints[waypointCounter].position); } else { waypointCounter = 0; npcScript.agent.SetDestination(waypoints[waypointCounter].position); } } npcScript.pathingBuffer = 0; } } }
public HideState(NPCTankController tank) { stateID = FSMStateID.Hiding; this.tank = tank; }
public override void Reason(Transform player, Transform npc) { NPCTankController npcScript = npc.gameObject.GetComponent <NPCTankController>(); if (npcScript.targetSardine == null) { npcScript.agent.isStopped = false; investigateTime = 0; npcScript.findPointCounter = 0; Debug.Log("Waypoint count is" + waypointCounter); Debug.Log("Waypoing Length is" + waypoints.Length); //if (waypointCounter < waypoints.Length - 1) //{ // Debug.Log("+1"); // waypointCounter++; // npcScript.agent.SetDestination(waypoints[waypointCounter].position); //} //else //{ // Debug.Log("0"); // waypointCounter = 0; // npcScript.agent.SetDestination(waypoints[waypointCounter].position); //} npcScript.isEatingSardines = false; npcScript.SetTransition(Transition.LostPlayer); } else { distToSardine = Vector3.Distance(npc.position, npcScript.targetSardine.transform.position); investigateTime += Time.deltaTime; if (distToSardine <= 3.5f) { npcScript.agent.velocity = Vector3.zero; npcScript.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; npcScript.agent.isStopped = true; } if (investigateTime >= 6f) { investigateTime = 0; npcScript.findPointCounter = 0; //if (waypointCounter < waypoints.Length - 1) //{ // waypointCounter += 1; // npcScript.agent.SetDestination(waypoints[waypointCounter].position); //} //else //{ // waypointCounter = 0; // npcScript.agent.SetDestination(waypoints[waypointCounter].position); //} npcScript.agent.isStopped = false; npcScript.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; npcScript.isEatingSardines = false; npcScript.SetTransition(Transition.LostPlayer); } } }
// Start is called before the first frame update void Start() { player = GameObject.FindWithTag("Player"); npcScript = GetComponentInParent <NPCTankController>(); }