// Use this for initialization void Start() { animator = GetComponent<AgentAnimationController> (); animalAgent = GetComponent<AnimalAgent> (); navAgent = GetComponent<NavMeshAgent> (); Debug.Assert (Camera.main != null); cameraTransform = Camera.main.transform; }
public override void Enter(AnimalAgent agent) //Do Upon Start of Action { _target = agent.GetTarget(); if (_target) { _supply = _target.GetComponent <ResourceManager>(); } }
void Start() { agent = gameObject.GetComponentInChildren <AnimalAgent>(); agent.EpisodeReset += EnvironmentReset; agent.TaskDone += UpdateTask; targets = gameObject.GetComponentsInChildren <BaseTarget>().ToList(); obstacles = gameObject.GetComponentsInChildren <Obstacle>().ToList(); }
public override void UpdateAction(AnimalAgent agents) { if (_target != null && _supply.GetSupply()) { agents.NavMeshAgent.SetDestination(_target.transform.position); } else if (_supply.GetSupply() == false) { _target = agents.GetTarget(); _supply = _target.GetComponent <ResourceManager>(); } if (_target.transform.position.magnitude - agents.transform.position.magnitude < 1f) { _supply.SetSupply(false); agents.Hunger = 0; } }
public float FightCalculator(AnimalAgent attacker, AnimalAgent defenser) { return attacker.dna.GetAttackValue() - defenser.dna.GetDefenseValue(); }
public abstract void Exit(AnimalAgent agent);
public abstract void Enter(AnimalAgent agent);
public abstract void UpdateAction(AnimalAgent agents);
public abstract float Evaluate(AnimalAgent agent);
public Search(AnimalAgent searchingAgent) { _previousTick = DateTime.Now; _searchingAgent = searchingAgent; }
void Start() { agent = GetComponent<AnimalAgent> (); }
public override void Exit(AnimalAgent agent) //Do Upon End of Action { }
public EvolutionAgent SeekBush(AnimalAgent agent, List<EvolutionAgent> percepts) { EvolutionAgent foundTarget = null; foreach (EvolutionAgent a in percepts) { if (a != null && a.GetComponent<IODA.IODAAgent>().agentName == "Bush" && a.GetComponent<Bush>() != null && a.GetComponent<Bush>().IsMature()) { if (!foundTarget) { foundTarget = a; } //compares distances if (Vector3.Distance(agent.transform.position, a.transform.position) <= Vector3.Distance(agent.transform.position, foundTarget.transform.position)) { foundTarget = a; } } } return foundTarget; }
private EvolutionAgent SeekAnimal(AnimalAgent agent, List<EvolutionAgent> percepts) { EvolutionAgent foundTarget = null; foreach (EvolutionAgent a in percepts) { if (a != null && a.GetComponent<IODA.IODAAgent>().agentName == "Animal" && a.GetComponent<AnimalAgent>() != null && a.GetComponent<SimpleGenome>().id != agent.genome.id) { if (!foundTarget) { foundTarget = a; } //compares distances if (Vector3.Distance(agent.transform.position, a.transform.position) <= Vector3.Distance(agent.transform.position, foundTarget.transform.position)) { foundTarget = a; } } } return foundTarget; }
public override void Enter(AnimalAgent agent) //Do Upon Start of Action { }
public override void UpdateAction(AnimalAgent agents) { //agents.NavMeshAgent.SetDestination(agents.WaterSource.transform.position); }
public Approach(AnimalAgent agent, string targetTagName) { _agent = agent; _targetTagName = targetTagName; }
public override float Evaluate(AnimalAgent agent) { float evaluation = agent.Hunger; return(evaluation); }
public Flee(AnimalAgent fleeingAgent, string targetTagName) { _fleeingAgent = fleeingAgent; _targetTagName = targetTagName; }