示例#1
0
    void mpFunc()
    {
        //check if mp should regen

        GameObject mpBar    = GameObject.Find("MpBar");
        MpScript   mpSprite = mpBar.GetComponent <MpScript>();

        mpSprite.changeMp(mp);
    }
示例#2
0
 void Update()
 {
     posAndRotation();
     if (GameObject.Find("Shield(Clone)") != null && counter >= mpCounter)
     {
         PlayerScript.mp -= mpInc;
         GameObject mpBar    = GameObject.Find("MpBar");
         MpScript   mpSprite = mpBar.GetComponent <MpScript>();
         mpSprite.changeMp(PlayerScript.mp);
         counter = 0;
     }
     if (GameObject.Find("Shield(Clone)") != null)
     {
         counter++;
     }
     if (PlayerScript.mp <= 0)
     {
         Destroy(this.gameObject);
         GameObject mpBar    = GameObject.Find("MpBar");
         MpScript   mpSprite = mpBar.GetComponent <MpScript>();
         mpSprite.changeMp(PlayerScript.mp);
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        //	Debug.Log ("test2");

        if (Dead == true)
        {
            if (isFading == true)
            {
                Fade += 0.02f;
                rend.GetComponent <SpriteRenderer> ().color  = new Color(0.0f, 0.0f, 0.0f, Fade);
                rend2.GetComponent <SpriteRenderer> ().color = new Color(0.0f, 0.0f, 0.0f, Fade);
                if (Fade >= 1.0f)
                {
                    Portal.SetActive(true);
                    Portal.GetComponent <SpriteRenderer> ().enabled = false;

                    isFading = false;
                    Portal.GetComponent <PortalScript> ().CutsceneFadeIn("Black");
                }
            }
        }
        else
        {
            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
            {
                rb.AddForce(Vector2.up * speed);
            }
            if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
            {
                rb.AddForce(Vector2.down * speed);
            }
            if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
            {
                rb.AddForce(Vector2.left * speed);
            }
            if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
            {
                rb.AddForce(Vector2.right * speed);
            }
            if (Input.GetMouseButtonDown(0))
            {
                if (mp >= shieldMp)
                {
                    createShield();
                    mpFunc();
                }
                else
                {
                    Debug.Log("No MP");
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                Debug.Log("Bye shield.");
                destroyShield();
            }
            if (GameObject.Find("Shield(Clone)") == null && mp < maxMp && counter >= mpCounter)
            {
                mp += mpRegen;
                GameObject mpBar    = GameObject.Find("MpBar");
                MpScript   mpSprite = mpBar.GetComponent <MpScript> ();
                counter = 0;
                mpSprite.changeMp(mp);
            }
            if (mp < maxMp)
            {
                counter++;
            }
            if (GameObject.Find("Shield(Clone)") != null)
            {
                counter = 0;
            }
        }
    }