示例#1
0
 void FixedUpdate()
 {
     if (clickedOn)
     {
         if (lastPlace == Vector3.zero)
         {
             lastPlace = startingPosition;
         }
         if (Mathf.Abs(transform.position.x - mixContainer.transform.position.x) < tolerance)
         {
             if (Mathf.Abs(transform.position.x - mixContainer.transform.position.x) < Mathf.Epsilon)
             {
                 // do nothing
             }
             else if (wentLeft && transform.position.x > lastPlace.x)
             {
                 Debug.Log("Shook right");
                 shakes++;
                 wentLeft = false;
                 if (shakes == enoughShakes)
                 {
                     Debug.Log("You shook it!");
                     mixContainer.Action(Element.Earth);
                 }
             }
             else if (!wentLeft && transform.position.x < lastPlace.x)
             {
                 Debug.Log("Shook left");
                 shakes++;
                 wentLeft = true;
                 if (shakes == enoughShakes)
                 {
                     Debug.Log("You shook it!");
                     mixContainer.Action(Element.Earth);
                 }
             }
         }
         else if (shakes > 0)
         {
             spillBuffer += Time.fixedDeltaTime;
             if (spillBuffer >= 1f)
             {
                 spillBuffer = 0f;
                 shakes--;
             }
         }
         lastPlace = transform.position;
     }
 }
示例#2
0
 protected override void OnMouseUp()
 {
     clickedOn = false;
     if (distanceTraveled > howFarToShake)
     {
         Debug.Log("Shook enough: " + (int)distanceTraveled);
         mixingBowl.Action(Element.Air);
     }
     distanceTraveled = 0f;
     lastPlace        = Vector3.zero;
     ResetPosition();
 }
示例#3
0
    void OnMouseDown()
    {
        counter++;
        Debug.Log("hit " + counter);

        if (counter < breakingIce.Length)
        {
            GetComponent <SpriteRenderer>().sprite = breakingIce [counter];            // Resources.Load<Sprite>("ice" + counter);
        }
        else if (counter >= 5)
        {
            Debug.Log("Added Ice");
            mixingBowl.Action(Element.Ice);
            counter = 0;
            draggingIce.GetComponent <IceDragger>().ResetPosition();
            draggingIce.SetActive(true);
            this.gameObject.SetActive(false);
        }
    }
示例#4
0
 // Update is called once per frame
 void Update()
 {
     if (flaming)
     {
         if (counter <= 4)
         {
             counter += Time.deltaTime;
             Debug.Log("mouse is being held" + counter);
         }
         else if (counter > 4)
         {
             counter += Time.deltaTime;
             if (counter < 4.5)
             {
                 counter += Time.deltaTime;
                 GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> ("fire" + 1);
                 Debug.Log("mouse is being held" + counter);
             }
             else if (counter < 5)
             {
                 counter += Time.deltaTime;
                 GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> ("fire" + 2);
                 Debug.Log("mouse is being held" + counter);
             }
             else if (counter < 5.5)
             {
                 counter += Time.deltaTime;
                 GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> ("fire" + 3);
                 Debug.Log("mouse is being held" + counter);
             }
         }
         else if (counter >= 6)
         {
             counter += Time.deltaTime;
             Debug.Log("Done Heating");
             mix.Action(Element.Fire);
         }
     }
 }