コード例 #1
0
    void Interakcija()
    {
        if (patrolinjo)
        {
            patrolinjo = false;
        }
        else if (flyinjo)
        {
            flyinjo = false;
        }
//		if(player.transform.position.y + 1.25f > reqHeight.position.y)
//		{
//
//		}
//		else
//		if(player.transform.position.y + 1.25f < reqHeight.position.y && player.activeShield)
        //	Debug.Log("Stiti: " + player.activeShield);
        if (player.activeShield || player.invincible || player.powerfullImpact)
        {
            if (runinjo)
            {
                runinjo = false;
            }
            reqHeight.GetComponent <KillTheBaboon>().turnOffColliders();
            if (parentRigidbody2D != null)
            {
                parentRigidbody2D.isKinematic = true;
            }

            anim.applyRootMotion = true;
            if (anim.GetBool("Land"))
            {
                anim.Play(death_state);
                //parentAnim.enabled = false;
            }
            else
            {
                //jump = false;
                anim.Play(deathJump_state);
                Invoke("UgasiBabunaPoslePada", 1f);
            }
            oblak.Play();
            //collider2D.enabled = false;
            colliders[0].enabled = false;
            colliders[1].enabled = false;
            //colliders[2].enabled = false;
            player.GetComponent <Rigidbody2D>().velocity = new Vector2(player.maxSpeedX, 0);
            //player.rigidbody2D.AddForce(new Vector2(0, player.jumpForce - rigidbody2D.velocity.y*player.doubleJumpForce));
            if (player.activeShield)
            {
                if (PlaySounds.soundOn)
                {
                    PlaySounds.Play_LooseShield();
                }
                player.activeShield = false;
                player.transform.Find("Particles/ShieldDestroyParticle").GetComponent <ParticleSystem>().Play();
                player.transform.Find("Particles/ShieldDestroyParticle").GetChild(0).GetComponent <ParticleSystem>().Play();
                GameObject.Find("_GameManager").SendMessage("ApplyPowerUp", -3);
                if (player.state != MonkeyController2D.State.running)
                {
                    //player.rigidbody2D.AddForce(new Vector2(0, 1500));
                    player.GetComponent <Rigidbody2D>().drag = 0;
                    player.canGlide = false;
                    player.animator.Play(player.jump_State);
                }
            }
            else if (!player.isSliding)
            {
                if (player.state != MonkeyController2D.State.running)
                {
                    player.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 1500));
                }
            }

            StartCoroutine(destroyBabun());
        }
        else if (!player.killed)
        {
            if (PlaySounds.soundOn)
            {
                PlaySounds.Play_SmashBaboon();
            }
            //anim.applyRootMotion = true;
            player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            player.killed = true;

            //if(runinjo)
            //	runinjo = false;
            if (run)
            {
                run          = false;
                runTurnedOff = true;
            }

            //collider2D.enabled = false;
            reqHeight.GetComponent <KillTheBaboon>().turnOffColliders();

            //collider2D.enabled = false;
            //if(!jump)
            //	parentAnim.enabled = false;

            colliders[0].enabled = false;
            colliders[1].enabled = false;
            //colliders[2].enabled = false;
            if (anim.GetBool("Land"))
            {
                if (!run)
                {
                    anim.Play(strike_state);
                    if (parentRigidbody2D != null)
                    {
                        parentRigidbody2D.isKinematic = true;
                    }

                    maxSpeedX = 0;
                }
            }
            else
            {
                Invoke("UkljuciCollidereOpet", 0.35f);
                //parentAnim.enabled = true;
            }
            oblak.Play();
            //collider2D.enabled = false;
            //colliders[0].enabled = false;
            //colliders[1].enabled = false;
            //transform.localScale = new Vector3(-transform.localScale.x,transform.localScale.y,transform.localScale.z);
            //Debug.Log("Utepan");
            if (player.state == MonkeyController2D.State.running)
            {
                player.majmunUtepan();
            }
            else
            {
                player.majmunUtepanULetu();
            }

            kontrolaZaBrzinuY = true;
            //smanjivac = parentRigidbody2D.velocity.y;
            //Invoke("resetujKontroluZaBrzinu",1.5f);
        }
    }
コード例 #2
0
ファイル: BabunDogadjaji.cs プロジェクト: bigstupidx/banana
    void Interakcija()
    {
//		if(player.transform.position.y + 1.25f > reqHeight.position.y)
//		{
//
//		}
//		else
//		if(player.transform.position.y + 1.25f < reqHeight.position.y && player.activeShield)
        //	Debug.Log("Stiti: " + player.activeShield);
        if (player.activeShield)
        {
            Debug.Log("Stitulj");
            reqHeight.GetComponent <KillTheBaboon>().turnOffColliders();
            GetComponent <Rigidbody2D>().isKinematic = true;
            if (PlaySounds.soundOn)
            {
                PlaySounds.Play_SmashBaboon();
            }

            anim.applyRootMotion = true;
            if (anim.GetBool("Land"))
            {
                anim.Play(death_state);
                //parentAnim.enabled = false;
            }
            else
            {
                jump = false;
                anim.Play(death_state);
            }
            oblak.Play();
            //collider2D.enabled = false;
            colliders[0].enabled = false;
            colliders[1].enabled = false;
            player.GetComponent <Rigidbody2D>().velocity = new Vector2(player.maxSpeedX, 0);;
            //player.rigidbody2D.AddForce(new Vector2(0, player.jumpForce - rigidbody2D.velocity.y*player.doubleJumpForce));
            if (player.activeShield)
            {
                player.activeShield = false;
                GameObject.Find("_GameManager").SendMessage("ApplyPowerUp", -3);
                if (player.state != MonkeyController2D.State.running)
                {
                    player.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 1500));
                    player.GetComponent <Rigidbody2D>().drag = 0;
                    player.canGlide = false;
                    player.animator.Play(player.jump_State);
                }
            }
            else
            {
                player.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 1500));
            }

            StartCoroutine(destroyBabun());
        }
        else if (!player.killed)
        {
            Debug.Log("nema stitulj");
            if (PlaySounds.soundOn)
            {
                PlaySounds.Play_SmashBaboon();
            }
            //anim.applyRootMotion = true;
            player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            player.killed = true;
            maxSpeedX     = 0;
            run           = false;
            //collider2D.enabled = false;
            //reqHeight.GetComponent<KillTheBaboon>().turnOffColliders();
            //colliders[0].enabled = false;
            //colliders[1].enabled = false;
            //if(!jump)
            //	parentAnim.enabled = false;
            GetComponent <Rigidbody2D>().isKinematic = true;
            if (anim.GetBool("Land"))
            {
                anim.Play(strike_state);
            }
            else
            {
                //parentAnim.enabled = true;
            }
            oblak.Play();
            //collider2D.enabled = false;
            //colliders[0].enabled = false;
            //colliders[1].enabled = false;
            //transform.localScale = new Vector3(-transform.localScale.x,transform.localScale.y,transform.localScale.z);
            //Debug.Log("Utepan");
            if (player.state == MonkeyController2D.State.running)
            {
                player.majmunUtepan();
            }
            else
            {
                player.majmunUtepanULetu();
            }
        }
    }