// Use this for initialization void Start() { _agentControllers = _plane.GetComponents <AIAgentController>(); _playerController = _player.GetComponent <PlayerController>(); _playerAgentController = GetPlayerAgentController(); }
public void GotHit(AIAgentController attacker, GameObject ball) { // check to see if they catch the ball bool tempCatch = isACatch(); if (attacker != this) { // if they catch if (tempCatch) { _currentBallTarget = ball; PickUpBall(); if (!attacker) { gameManager.PlayerEliminated(); } } // if not else { Eliminate(this); } } else { ball.GetComponent <BallProjectile>()._lastThrower = this; } }
public void SetController(AIAgentController controller) { Controller = controller; foreach (AgentAction action in Actions) { (action).AgentSensor = (AgentSensor)controller.GetSensor(); } }
// Use this for initialization void Start() { m_rb = GetComponent <Rigidbody>(); DetermineAgentColour(); linearSpeed = 6.0f; angularSpeed = 3.0f; _agentController = FindAgentController(); }
public void Eliminate(AIAgentController playerEliminated) { // eliminate player from the game Debug.Log(playerEliminated.m_agent.gameObject + " is eliminated"); Destroy(playerEliminated.m_agent.gameObject); playerEliminated.enabled = false; gameManager.CheckPlayers(playerEliminated); this.enabled = false; }
public void OnThingSelectionChanged() { AIAgentController agent = (AIAgentController)director.AgentWithFocus; if (thingOfInterestDropdown.value == 0) { agent.Target = null; } else { agent.Target = thingsManager.allTheThings[thingOfInterestDropdown.value - 1].transform; } }
private void LateUpdate() { AIAgentController agent = (AIAgentController)director.AgentWithFocus; Thing thing = agent.Target ? agent.Target.GetComponentInParent <Thing>() : null; if (thing) { thingOfInterestDropdown.value = thingsManager.allTheThings.FindIndex(x => x == thing) + 1; } else { thingOfInterestDropdown.value = 0; } }
private AIAgentController GetPlayerAgentController() { AIAgentController[] players = _plane.GetComponents <AIAgentController>(); AIAgentController playerAgent = null; for (int i = 0; i < players.Length; i++) { if (players[i].m_agent.gameObject == _player) { playerAgent = players[i]; } } return(playerAgent); }
private void Update() { PopulateInterestingThingsDropdown(); AIAgentController agent = (AIAgentController)director.AgentWithFocus; Thing thing = agent.Target ? agent.Target.GetComponentInParent <Thing>() : null; if (thing) { distanceToThingOfInterestText.text = "Distance: " + Vector3.Distance(agent.transform.position, thing.AgentViewingTransform.position).ToString(); } else { distanceToThingOfInterestText.text = "Wandering"; } }
public void CheckPlayers(AIAgentController mostRecentElimination) { Debug.Log("checking players to see if alive"); int blueTeam = 0; int redTeam = 0; Agent[] players = FindObjectsOfType <Agent>(); Debug.Log("found " + players.Length + " players"); foreach (Agent player in players) { if (player.gameObject == mostRecentElimination.m_agent.gameObject) { continue; } Debug.Log("player " + player.gameObject.name + " is still alive"); if (player._isBlue) { blueTeam++; Debug.Log("adding one to blue team"); } else { redTeam++; Debug.Log("adding one to red team"); } } _blueScore.text = blueTeam.ToString(); _redScore.text = redTeam.ToString(); if (blueTeam == 0) { Debug.Log("red team wins"); string winner = "Red Team Wins"; GameOver(winner); } else if (redTeam == 0) { Debug.Log("blue team wins"); string winner = "Blue Team Wins"; GameOver(winner); } }
private AIAgentController FindAgentController() { AIAgentController[] controllers = _plane.GetComponents <AIAgentController>(); AIAgentController thisAgentController = null; if (controllers.Length > 0) { for (int i = 0; i < controllers.Length; i++) { if (controllers[i].m_agent == this) { thisAgentController = controllers[i]; } } } return(thisAgentController); }
public void OnAddThingClicked() { AIAgentController agent = (AIAgentController)director.AgentWithFocus; Thing newThing = GameObject.Instantiate <Thing>(addableThings[0]); newThing.name = "This is " + transform.position.ToString(); Vector3 position = agent.transform.position; position.y = Terrain.activeTerrain.SampleHeight(position) - 0.1f; position.x -= 0.1f; position.z -= 0.1f; newThing.transform.position = position; Vector3 lookAt = Camera.main.transform.position; newThing.transform.LookAt(new Vector3(lookAt.x, newThing.transform.position.y, lookAt.z)); thingsManager.allTheThings.Add(newThing); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Ground") { _isThrown = false; _lastThrower = null; _isHeld = false; } if (collision.gameObject.tag == "Agent") { if (_isThrown) { Debug.Log(collision.gameObject.name + " got Hit"); collision.gameObject.GetComponent <Agent>()._agentController.GotHit(_lastThrower, gameObject); _isThrown = false; _lastThrower = null; _isHeld = false; } } }
public override void OnEnter() { agent.Mood = Agent.EMood.Angry; m_agentController = agent.GetComponent <AIAgentController>(); Debug.Assert(m_agentController != null, "MISSING AGENT CONTROLLER"); }