public NestInstance OccupiedNests() { List <NestInstance> availableNests = nests.FindAll(nest => nest.occupied); if (availableNests.Count > 0) { NestInstance randomNest = availableNests[Random.Range(0, availableNests.Count - 1)]; return(randomNest); } return(null); }
// Use this for initialization void Awake() { nests = new List <NestInstance>(); //Transform listOfPointObjects = transform.Find("PointNest"); foreach (Transform childTransform in transform) { NestInstance nest = new NestInstance(); nest.occupied = false; nest.nestPosition = childTransform.transform.position; nests.Add(nest); } }
protected void Start() { nestManager = GameObject.FindObjectOfType <NestManager>(); if (CurrentOrder == null) { NestInstance potentialNest = nestManager.RandomNest(); if (potentialNest != null) { CurrentInstruction = new Goto(potentialNest.nestPosition + Vector3.forward, 0, this); Instructions.Push(new CreateNest(nestPrefab, potentialNest, protectionTimer, this)); } } }
protected override void RanOutOfInstructions() { NestInstance potentialNest = nestManager.RandomNest(); if (potentialNest != null) { Instructions.Push(new CreateNest(nestPrefab, potentialNest, protectionTimer, this)); CurrentInstruction = new Goto(potentialNest.nestPosition + Vector3.forward, 0, this); } else { CurrentInstruction = new Goto(homeNest.transform.position + Vector3.forward, 0, this); Instructions.Push(new Goto(nestManager.OccupiedNests().nestPosition, protectionTimer, this)); } }
public CreateNest(GameObject alienNestPrefab, NestInstance potentialNest, float protectionTimer, Entity entity) : base(entity) { this.alienNestPrefab = alienNestPrefab; this.timer = protectionTimer; this.nestInstance = potentialNest; }