Ejemplo n.º 1
0
 public override void Interact(Action action, Clickable target)
 {
     if (action == Action.MAKE_POTION)
     {
         AudioSource audioS = GetComponent <AudioSource>();
         if (!bucketAtCauldron.activeSelf)
         {
             // NO WATER
             NextState   = Gal02State.IDLE;
             audioS.clip = angryTrack;
             audioS.Play();
             return;
         }
         Cauldron c = (Cauldron)target;
         if (!c.IsFull())
         {
             // NOT FULL
             audioS.clip = angryTrack;
             audioS.Play();
             NextState = Gal02State.IDLE;
             return;
         }
         audioS.clip = yesTrack;
         audioS.Play();
         NextState = Gal02State.APROACHING_CAULDRON;
     }
     else if (action == Action.GIVE_POTION && potionIsReady)
     {
         happyKid.SetActive(true);
         dyingKid.SetActive(false);
         GoToNextLevel();
     }
 }
Ejemplo n.º 2
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (CurrentState == Gal02State.APROACHING_CAULDRON && collision.gameObject.GetInstanceID() == cauldronTarget.GetInstanceID())
     {
         NextState = Gal02State.CHECKING_POTION;
     }
 }
Ejemplo n.º 3
0
    private void Update()
    {
        if (NextState == Gal02State.APROACHING_CAULDRON)
        {
            RandomMovement rm = GetComponent <RandomMovement>();
            if (rm)
            {
                rm.StopAllCoroutines();
            }
        }

        if (NextState != Gal02State.NONE && NextState != CurrentState)
        {
            CurrentState = NextState;
            NextState    = Gal02State.NONE;
        }

        if (CurrentState == Gal02State.APROACHING_CAULDRON)
        {
            MoveTowardsTarget(cauldronTarget.transform.position);
        }

        if (CurrentState == Gal02State.CHECKING_POTION)
        {
            AudioSource audioS = GetComponent <AudioSource>();
            Cauldron    c      = FindObjectOfType <Cauldron>();
            if (!bucketAtCauldron.activeSelf)
            {
                // NO WATER
                NextState   = Gal02State.IDLE;
                audioS.clip = angryTrack;
            }
            else if (!c.CheckPotion())
            {
                popupWrong.SetActive(true);
                popupWrong.GetComponentInChildren <Animator>().SetTrigger("play");
                NextState   = Gal02State.IDLE;
                audioS.clip = angryTrack;
            }
            else
            {
                popupOk.SetActive(true);
                popupOk.GetComponentInChildren <Animator>().SetTrigger("play");
                potionIsReady = true;
                NextState     = Gal02State.DONE;
                audioS.clip   = yesTrack;
            }
        }

        WalkAnimation();
        previousPosition = transform.position;
    }