private void Checks() { if (_agentInventory.HasItem(Names.HealthKit)) { if (_agentData.CurrentHitPoints <= 50) { _agentActions.UseItem(_agentInventory.GetItem(Names.HealthKit)); } } GameObject ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.HealthKit); if (ObjectToCheck != null) { if (!_agentInventory.HasItem(Names.HealthKit)) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { _agentActions.CollectItem(ObjectToCheck); Simulation((int)nodeOptions); } else if (Vector3.Distance(transform.position, ObjectToCheck.transform.position) < 7.0f) { _agentActions.MoveTo(ObjectToCheck); } } } ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.PowerUp); if (ObjectToCheck != null) { if (!_agentInventory.HasItem(Names.PowerUp)) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { _agentActions.CollectItem(ObjectToCheck); Simulation((int)nodeOptions); } else if (Vector3.Distance(transform.position, ObjectToCheck.transform.position) < 7.0f) { _agentActions.MoveTo(ObjectToCheck); } } } if (this.tag == Tags.BlueTeam) { ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.RedFlag); if (ObjectToCheck != null) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { _agentActions.CollectItem(ObjectToCheck); Simulation((int)nodeOptions); } } ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.BlueFlag); if (ObjectToCheck != null) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { ObjectToCheck.GetComponent <Flag>().ResetPositionBlue(); Simulation((int)nodeOptions); } } if (_agentData.HasEnemyFlag) { if (Vector3.Distance(transform.position, _agentData.FriendlyBase.transform.position) <= 5.0f) { _agentActions.DropItem(_agentInventory.GetItem(Names.RedFlag)); hasWon = true; ResetPosition(); hasWon = false; currentNode = rootNode; Debug.Log("win" + this.gameObject); } } } if (this.tag == Tags.RedTeam) { ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.BlueFlag); if (ObjectToCheck != null) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { _agentActions.CollectItem(ObjectToCheck); Simulation((int)nodeOptions); } } ObjectToCheck = _agentSenses.GetObjectInViewByName(Names.RedFlag); if (ObjectToCheck != null) { if (_agentSenses.IsItemInReach(ObjectToCheck)) { ObjectToCheck.GetComponent <Flag>().ResetPositionRed(); Simulation((int)nodeOptions); } } if (_agentData.HasEnemyFlag) { if (Vector3.Distance(transform.position, _agentData.FriendlyBase.transform.position) <= 5.0f) { _agentActions.DropItem(_agentInventory.GetItem(Names.BlueFlag)); hasWon = true; ResetPosition(); hasWon = false; Debug.Log("win" + this.gameObject); } } } }