コード例 #1
0
    //Causes spark of electricty to come from the sky.
    IEnumerator spark()
    {
        sparking = true;
        int choices = Random.Range(1, 7);
        int r       = 1;

        for (int i = 1; i <= 4; i = i << 1)
        {
            if ((choices & i) != 0)
            {
                animator.SetLayerWeight(r, 1);
                animator.SetTrigger("Cloud" + r.ToString() + "Shock");

                yield return(new WaitForSeconds(1f));

                for (int y = 0; y < 5; y++)
                {
                    Instantiate(lightning, new Vector3(bottomLayerClouds[r - 1].transform.position.x - 5 + (3 * y), bottomLayerClouds[r - 1].transform.position.y), Quaternion.identity);
                    yield return(new WaitForSeconds(0.1f));

                    StartCoroutine(cam.shakeScreen(0.3f));
                }
                //yield return new WaitForSeconds(0.5f);
                animator.SetLayerWeight(r, 0);
            }
            r++;
        }
        sparking = false;
        //Step 2: Shock em' boy!
    }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "gate")
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     }
     if (other.gameObject.tag == "enemy" && !animator.GetBool("dodge") && !animator.GetBool("Hurt") && !dead)
     {
         bool enemyHurt = false;
         if (other.gameObject.transform.root.gameObject.GetComponent <Animator>())
         {
             enemyHurt = other.gameObject.transform.root.gameObject.GetComponent <Animator>().GetBool("Hurt");
         }
         else
         {
             enemyHurt = false;
         }
         if (!enemyHurt)
         {
             if (!cam.getShaking())
             {
                 StartCoroutine(cam.shakeScreen());
             }
             animator.SetBool("Hurt", true);
             heart.SetTrigger("Hurt");
             health -= 10;
             manager.resetMult();
             if (health > 0)
             {
                 rig.velocity = new Vector2(Mathf.Sign(transform.position.x - other.transform.position.x) * 40, rig.velocity.y);
             }
         }
     }
 }
コード例 #3
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D other)
    {
        float   dir         = Mathf.Sign(other.transform.root.localScale.x);
        Vector2 impactPoint = other.bounds.ClosestPoint(transform.position);

        SwordBehaviour sword = other.gameObject.GetComponent <SwordBehaviour>();

        if (animator)
        {
            isVunerable = !animator.GetBool("Hurt");
        }

        if (other.gameObject.tag == "sword" && sword.activated && isVunerable)
        {
            if (impactEffect)
            {
                Instantiate(impactEffect, impactPoint, Quaternion.identity);
            }
            if (knockback && rig != null)
            {
                rig.velocity = new Vector2(-dir * 20, rig.velocity.y);
            }


            if (animator)
            {
                animator.SetBool("Hurt", true);
            }

            if (animator && !animator.GetBool("Death"))
            {
                if (manager)
                {
                    manager.addScore(10);
                    manager.addMult();
                }
            }
            if (cam && !cam.getShaking())
            {
                StartCoroutine(cam.shakeScreen());
            }
            if (hurtEvent != null)
            {
                hurtEvent.Invoke();
            }
        }
    }
コード例 #4
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D other)
    {
        float   dir         = Mathf.Sign(other.transform.root.localScale.x);
        Vector2 impactPoint = other.bounds.ClosestPoint(transform.position);

        SwordBehaviour sword = other.gameObject.GetComponent <SwordBehaviour>();

        if (animator)
        {
            isVunerable = !animator.GetBool("Hurt");
        }

        if (other.gameObject.tag == "sword" && sword.activated && isVunerable)
        {
            int vert = 0;
            if (verticalKnockback)
            {
                vert = 10;
            }
            if (produceOrbs && Random.Range(1, 3) == 1)
            {
                Instantiate(memOrbs, transform.position, transform.rotation);
            }
            if (impactEffect)
            {
                Instantiate(impactEffect, impactPoint, Quaternion.identity);
            }
            if (knockback && rig != null)
            {
                rig.velocity = new Vector2(-dir * 20, rig.velocity.y + vert);
            }
            if (verticalKnockback)
            {
                rig.AddTorque(90 * Mathf.Sign(rig.velocity.x));
            }
            //Vector2 impactDir = new Vector2(transform.position.x, transform.position.y) - impactPoint;
            //if (knockback && rig != null) rig.velocity = impactDir.normalized * 20;


            if (animator)
            {
                animator.SetBool("Hurt", true);
            }

            if (animator && !animator.GetBool("Death"))
            {
                if (manager)
                {
                    //manager.addScore(10);
                    //manager.addMult();
                }
            }
            if (cam && !cam.getShaking())
            {
                StartCoroutine(cam.shakeScreen());
            }
            if (hurtEvent != null)
            {
                hurtEvent.Invoke();
            }
        }
    }
コード例 #5
0
 public void createField()
 {
     //Instantiate(downwardDust, GameObject.FindGameObjectWithTag("sword").GetComponent<Transform>().position, Quaternion.identity);
     Instantiate(downwardDust, transform.position + (Vector3.down * 2), Quaternion.identity);
     StartCoroutine(cam.shakeScreen(0.4f));
 }