Example #1
0
 public void HarvestWorker(WorkerEgg victim)
 {
     if (SelectedWorker != null)
     {
         SelectedWorker.BeginEggHarvest(victim);
     }
 }
Example #2
0
 public override void WorkerInteraction(WorkerEgg worker)
 {
     // If touched by the assigned workstation, process state changes
     if (worker.Destination == this)
     {
         worker.TouchedWorkstation();
     }
 }
Example #3
0
 public override void WorkerInteraction(WorkerEgg worker)
 {
     // If touched by the worker harvesting from it, complete the harvest action
     if (worker.Source == this && worker.CurrentState == WorkerEgg.WorkerEggState.HarvestingPantry)
     {
         worker.HarvestingComplete();
     }
 }
Example #4
0
 public override void WorkerInteraction(WorkerEgg worker)
 {
     if (worker == Victim)
     {
         SoundBoard.Current.PlayEggDie();
         Victim.Killed();
         EndEggHarvest();
     }
 }
Example #5
0
    public void DeselectWorker()
    {
        if (SelectedWorker == null)
        {
            return;
        }

        SelectedWorker.DeselectWorker();
        SelectedWorker = null;
    }
Example #6
0
 public override void ResetState()
 {
     Source              = null;
     Destination         = null;
     CurrentState        = WorkerEggState.Unassigned;
     Victim              = null;
     selectingForHarvest = false;
     Longtouch.gameObject.SetActive(false);
     DeselectWorker();
     UpdateUI();
 }
Example #7
0
 public bool PotentiallyHarvestingEgg(WorkerEgg newTarget)
 {
     // If the selected worker can be reassigned,
     // and is not the same as the new target,
     // and is not targeting or being targeted by the target,
     // have the new target process as a potential kill
     return(SelectedWorker != null &&
            SelectedWorker != newTarget &&
            (SelectedWorker.Victim == null || SelectedWorker.Victim != newTarget) &&
            (newTarget.Victim == null || newTarget.Victim != SelectedWorker) &&
            SelectedWorker.CanAssignToResource());
 }
Example #8
0
    public bool SelectWorker(WorkerEgg egg)
    {
        if (egg == SelectedWorker)
        {
            return(false);
        }

        if (SelectedWorker != null)
        {
            SelectedWorker.DeselectWorker();
        }

        Debug.Log(string.Format("Selecting worker {0}", egg.gameObject.name));
        SelectedWorker = egg;
        egg.SelectWorker();
        return(true);
    }
Example #9
0
    public bool AssignResource(MaterialSource mats)
    {
        // If we assign to a new resource, go from any state to Harvesting
        if (CanAssignToResource() && mats != Source)
        {
            Debug.Log(string.Format("Worker {0} assigned to resource {1}", gameObject.name, mats.gameObject.name));
            if (Victim != null)
            {
                Victim = null;
            }
            Source = mats;
            DoPantryHarvest();
            return(true);
        }

        return(false);
    }
Example #10
0
    void Update()
    {
        if (!GameEngine.Current.IsPlaying() || !CanSpawn())
        {
            return;
        }

        Timer -= Time.deltaTime;
        if (Timer < 0)
        {
            Timer = (SpawnTime + Timer);
            SoundBoard.Current.PlayEggSpawn();
            LastSpawned = ObjectPooler.Current.Spawn <WorkerEgg>("WorkerEgg", x => {
                x.transform.position = transform.position;
                x.UpdateUI();
            });
        }
    }
 void Awake()
 {
     egg = GetComponentInParent <WorkerEgg>();
 }
Example #12
0
 public void EndEggHarvest()
 {
     WalkTarget = Destination.GetWalkPoint();
     ChangeState(WorkerEggState.RetrievingEgg);
     Victim = null;
 }
Example #13
0
 public void BeginEggHarvest(WorkerEgg egg)
 {
     WalkTarget = egg.transform.position;
     ChangeState(WorkerEggState.HarvestingEgg);
     Victim = egg;
 }
Example #14
0
 public void ResetState()
 {
     Timer       = SpawnTime + SpawnOffset;
     LastSpawned = null;
 }
 public abstract void WorkerInteraction(WorkerEgg worker);