Exemple #1
0
    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);
    }
Exemple #2
0
 // 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);
     }
 }
Exemple #3
0
 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));
         }
     }
 }
Exemple #4
0
    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));
        }
    }
Exemple #5
0
 public CreateNest(GameObject alienNestPrefab, NestInstance potentialNest, float protectionTimer, Entity entity) : base(entity)
 {
     this.alienNestPrefab = alienNestPrefab;
     this.timer           = protectionTimer;
     this.nestInstance    = potentialNest;
 }