Ejemplo n.º 1
0
    public void SetState(string State)
    {
        this.State = State;

        switch (this.State)
        {
        case "init":
            GetComponent <Entity>().PlayAnimation("idle");
            break;

        case "move_to_checkpoint":
            GetComponent <Entity> ().PlayAnimation("walk");
            EntityQueueSlot Slot = this.Checkpoints [0].GetFreeSlot();
            if (Slot != null)
            {
                MoveToSlot(Slot);
            }
            else
            {
                this.SetState("move_to_exit");
            }
            break;

        case "process_checkpoint":
            GetComponent <Entity> ().PlayAnimation("idle");
            StartCoroutine(ProcessCheckpoint());
            break;

        case "move_to_exit":
            GetComponent <Entity> ().PlayAnimation("walk");
            gameObject.transform.localScale = new Vector3(-Mathf.Abs(gameObject.transform.localScale.x), gameObject.transform.localScale.y, gameObject.transform.localScale.z);
            this.MoveTo(this.ExitPoint);
            break;
        }
    }
Ejemplo n.º 2
0
    IEnumerator ProcessCheckpoint()
    {
        // first slot, processing
        if (this.CurrentSlot.IsFirstSlot())
        {
            yield return(new WaitForSeconds(2.0f));

            SetSlot(null);
            SetState("move_to_exit");
        }
        else
        {
            // check for better slot
            EntityQueueSlot BetterSlot = this.Checkpoints [0].GetBetterFreeSlot(GetComponent <Entity> ());
            if (BetterSlot != null)
            {
                MoveToSlot(BetterSlot);
            }
            else
            {
                yield return(new WaitForSeconds(0.5f));

                SetState("process_checkpoint");
            }
        }
    }
Ejemplo n.º 3
0
 void SetSlot(EntityQueueSlot Slot)
 {
     if (this.CurrentSlot != null)
     {
         this.CurrentSlot.SetEntity(null);
     }
     this.CurrentSlot = Slot;
     if (this.CurrentSlot != null)
     {
         this.CurrentSlot.SetEntity(GetComponent <Entity> ());
     }
 }
Ejemplo n.º 4
0
 void MoveToSlot(EntityQueueSlot Slot)
 {
     SetSlot(Slot);
     this.MoveTo(this.CurrentSlot.gameObject);
 }