void Start() { master = FindObjectOfType <GameMaster>(); team = transform.parent.parent.GetComponent <Team>(); bot_object = transform.parent.gameObject; bot = bot_object.GetComponent <Bot>(); agent = bot_object.GetComponent <UnityEngine.AI.NavMeshAgent>(); collider = bot_object.GetComponent <Collider>(); renderer = bot_object.GetComponent <Renderer>(); behaviour = GetComponent <BotBehaviourDeusVult> (); teamController = transform.parent.parent.GetComponentInChildren <TeamBehaviourDeusVult> (); }
/*public void GetNewFlagDefenser(){ * * * float distance = float.MaxValue; * BotBehaviourDeusVult closer = teamMates[0]; * * * foreach (BotBehaviourDeusVult bot in teamMates) { * * * float newDist = Vector3.Distance (bot.transform.position, team.team_flag.transform.position); * * if (newDist < distance) { * * distance = newDist; * closer = bot; * * } * * * * } * * closer.SwitchState (BotBehaviourDeusVult.BotState.DefenseProtectBase); * * flagDefenser = closer.gameObject; * * * * * }*/ public GameObject GetCloser(Vector3 pos) { float distance = float.MaxValue; BotBehaviourDeusVult closer = teamMates[0]; foreach (BotBehaviourDeusVult bot in teamMates) { if (bot.state != BotBehaviourDeusVult.BotState.DefenseProtectBase && bot.state != BotBehaviourDeusVult.BotState.DefensePlantATent) { float newDist = Vector3.Distance(bot.transform.position, pos); if (newDist < distance) { distance = newDist; closer = bot; } } } return(closer.gameObject); }