示例#1
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        BladeController b = collider.GetComponent <BladeController>();

        if (b)
        {
            FindObjectOfType <GameManager>().GameOver();
        }
        else
        {
            return;
        }
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        BladeController b = collider.GetComponent <BladeController>();

        if (b)
        {
            CreateSlicedFruit();
            FindObjectOfType <GameManager>().IncreaseScore(points);
        }
        else
        {
            return;
        }
    }
示例#3
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Acertei uma: " + this.gameObject.name);
        BladeController blade = collision.GetComponent <BladeController>();

        if (!blade)
        {
            return;
        }

        gameController.AddScore(1);

        SlicingSound();
        FruitSlicedVFX();
        CreateSlicedFruit();
    }
示例#4
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        BladeController blade          = collision.GetComponent <BladeController>();
        GameController  gameController = FindObjectOfType <GameController>();

        if (!blade)
        {
            return;
        }

        bombMeshRenderer.enabled = false;
        bombFuseVFXObject.SetActive(false);

        bombAudioSource.PlayOneShot(bombExplosionSFX);
        FruitSlicedVFX();
        StartCoroutine(gameController.EndGame());
        //Destroy(this.gameObject, 6f);
    }
示例#5
0
    //-----------------------------------------END UPDATE----------------------------------------------//
    void Update()
    {
        isgrounded = Physics2D.OverlapBox(gc.position, gcsize, 90, whatisground);
        if (isgrounded)
        {
            jumpcount = 1;
        }

        //*********************************if isanimated or not**************************************//
        if (!isanimated)
        {
            if (!whoami)              //player1 control axis
            {
                if (Input.GetAxisRaw("p1Horizontal") == -1 && CheckAnimState(1, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(-movespeed * mytimescale, rb.velocity.y * mytimescale);
                }
                else if (Input.GetAxisRaw("p1Horizontal") == 1 && CheckAnimState(1, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(movespeed * mytimescale, rb.velocity.y * mytimescale);
                }
                else
                {
                    anim.SetBool("Run", false);
                    if (CheckAnimState(1, 1, 0, 1, 1, 1, 1, 1, 1))
                    {
                        rb.velocity = new Vector2(rb.velocity.x * dragfactor, rb.velocity.y);
                    }
                }
            }
            else                //player2 control axis
            {
                if (Input.GetAxisRaw("p2Horizontal") == -1 && CheckAnimState(1, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(-movespeed * mytimescale, rb.velocity.y * mytimescale);
                }
                else if (Input.GetAxisRaw("p2Horizontal") == 1 && CheckAnimState(1, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(movespeed * mytimescale, rb.velocity.y * mytimescale);
                }
                else
                {
                    anim.SetBool("Run", false);
                    if (CheckAnimState(1, 1, 0, 1, 1, 1, 1, 1, 1))
                    {
                        rb.velocity = new Vector2(rb.velocity.x * dragfactor, rb.velocity.y);
                    }
                }
            }

            if (rb.velocity.x < 0)
            {
                if (CheckAnimState(0, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    transform.localScale = new Vector3(-1, 1, 1);
                }
                else if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Hurt"))
                {
                    transform.localScale = new Vector3(1, 1, 1);
                }
            }
            else if (rb.velocity.x > 0)
            {
                if (CheckAnimState(0, 1, 1, 0, 0, 1, 0, 0, 0))
                {
                    transform.localScale = new Vector3(1, 1, 1);
                }
                else if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Hurt"))
                {
                    transform.localScale = new Vector3(-1, 1, 1);
                }
            }

            if (Input.GetKeyDown(jump) && jumpcount > 0 && CheckAnimState(1, 1, 1, 0, 1, 0, 0, 0, 1))
            {
                rb.velocity = new Vector2(rb.velocity.x * mytimescale, jumpforce * mytimescale);
                jumpcount--;
            }
            if (Input.GetKeyDown(attack) && !delayattack && CheckAnimState(1, 1, 1, 0, 0, 0, 0, 0, 0))
            {
                anim.SetTrigger("Attack");
                delayattack      = true;
                timerdelayattack = 0f;
            }

            if (Input.GetKeyUp(parry))
            {
                anim.SetBool("HoldParry", false);

                /*
                 * if (!delayparry) {
                 *      delayparry = true;
                 *      timerdelayparry = 0f;
                 * }
                 */
            }
            if (Input.GetKeyDown(parry) && CheckAnimState(1, 1, 1, 0, 0, 0, 0, 0, 0))
            {
                anim.SetBool("HoldParry", true);
            }


            if (Input.GetKeyDown(slide) && !delayslide && CheckAnimState(0, 1, 1, 0, 0, 0, 0, 0, 0))
            {
                anim.SetTrigger("Slide");
                rb.velocity     = new Vector2(transform.localScale.x * slideforce * mytimescale, rb.velocity.y * mytimescale);
                delayslide      = true;
                timerdelayslide = 0f;
            }

            if (Input.GetKeyDown(throwblade) && CheckAnimState(1, 1, 1, 0, 0, 0, 0, 0, 0))
            {
                if (mgm.GetKnife(whoami) > 0)
                {
                    Vector3 blrottemp = transform.rotation.eulerAngles;
                    if (transform.localScale.x == 1)
                    {
                        blrottemp.z = -90f;
                    }
                    else if (transform.localScale.x == -1)
                    {
                        blrottemp.z = 90f;
                    }
                    GameObject bladetemp = (GameObject)Instantiate(blade, throwbladepoint.position, Quaternion.Euler(blrottemp));
                    bladetemp.transform.localScale = transform.localScale;
                    BladeController bladecon = bladetemp.GetComponent <BladeController> ();
                    if (!whoami)
                    {
                        bladecon.owner = 1;
                    }
                    else if (whoami)
                    {
                        bladecon.owner = 2;
                    }
                    anim.SetTrigger("Throw");
                    mgm.SetKnife(whoami, -1);
                }
            }

            if (hurt)
            {
                timerhurt += (Time.deltaTime * mytimescale);
                if (sr.color.a == 1.0f)
                {
                    sr.color -= new Color(0, 0, 0, 0.7f);
                }
                else if (sr.color.a == 0.3f)
                {
                    sr.color += new Color(0, 0, 0, 0.7f);
                }
                if (timerhurt >= 2.0f)
                {
                    hurt = false;
                    if (sr.color.a != 1.0f)
                    {
                        sr.color += new Color(0, 0, 0, 0.7f);
                    }
                }
            }

            if (dead)
            {
                timerdead += (Time.deltaTime * mytimescale);
                if (timerdead >= 0.5f)
                {
                    if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Idle"))
                    {
                        dead = false;
                        mgm.SetKnife(whoami, 3, false);
                        if (!whoami)
                        {
                            mgm.SetRevival(1);
                        }
                        else
                        {
                            mgm.SetRevival(2);
                        }

                        hurt      = true;
                        timerhurt = 0f;
                    }
                }
            }

            if (invincible)
            {
                timerinvincible += (Time.deltaTime * mytimescale);
                if (timerinvincible >= 2.5f)
                {
                    invincible = false;
                }
            }

            if (delayattack)
            {
                timerdelayattack += (Time.deltaTime * mytimescale);
                if (timerdelayattack >= limitdelayattack)
                {
                    delayattack = false;
                }
            }

            /*
             * if (delayparry) {
             *      timerdelayparry += (Time.deltaTime * mytimescale);
             *      if (timerdelayparry >= limitdelayparry) {
             *              delayparry = false;
             *      }
             * }
             */
            if (delayslide)
            {
                timerdelayslide += (Time.deltaTime * mytimescale);
                if (timerdelayslide >= limitdelayslide)
                {
                    delayslide = false;
                }
            }

            if (transform.position.y <= -9f && !invincible)
            {
                Hit();
                if (!whoami)
                {
                    mgm.whosesimonsays = 2;
                    mgm.mgmSetFocus(2);
                }
                else if (whoami)
                {
                    mgm.whosesimonsays = 1;
                    mgm.mgmSetFocus(1);
                }
            }
        }
        else            //elsenya ifanimated

        {
            if (!whoami)
            {
                if (transform.position.x < playerdestination)
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(movespeed * mytimescale, rb.velocity.y * mytimescale);
                    if (transform.position.x >= playerfirstpoint && !reachedfirstpoint)
                    {
                        mgm.score1++;
                        SpawnScoreUI();
                        reachedfirstpoint = true;
                    }
                }
                else if (callsimonsaysactivated == false && transform.position.x >= playerdestination)
                {
                    anim.SetBool("Run", false);
                    rb.velocity = new Vector2(rb.velocity.x * dragfactor, rb.velocity.y);
                    mgm.CallSimonSays();
                    callsimonsaysactivated = true;
                }
            }
            else
            {
                if (transform.position.x > playerdestination)
                {
                    anim.SetBool("Run", true);
                    rb.velocity = new Vector2(-movespeed * mytimescale, rb.velocity.y * mytimescale);
                    if (transform.position.x <= playerfirstpoint && !reachedfirstpoint)
                    {
                        mgm.score2++;
                        SpawnScoreUI();
                        reachedfirstpoint = true;
                    }
                }
                else if (callsimonsaysactivated == false && transform.position.x <= playerdestination)
                {
                    anim.SetBool("Run", false);
                    rb.velocity = new Vector2(rb.velocity.x * dragfactor, rb.velocity.y);
                    mgm.CallSimonSays();
                    callsimonsaysactivated = true;
                }
            }
        }
        //*****************************************END if isanimated or not************************************************//

        anim.SetBool("Grounded", isgrounded);
    }
示例#6
0
 void Start()
 {
     mBlade = GetComponentInChildren <BladeController>();
 }