示例#1
0
    void OnTriggerEnter(Collider other)
    {
        if (!isActive)
        {
            return;
        }
        if (attacked)
        {
            return;
        }
        switch (other.tag)
        {
        case "Player":
            characterBehavior = other.transform.GetComponent <CharacterBehavior> ();
            if (characterBehavior != null)
            {
                if (throwItem == null)
                {
                    return;
                }

                throwItem.SetActive(false);

                anim.Play("catapulta");
                attacked = true;
                characterBehavior.SuperJumpByBumped((int)2 * 100, 0.5f, false);
                Vector3 pos = transform.position;
                pos.y += 6;
                pos.z += 2;
                Shoot(pos, transform.localEulerAngles.y);
            }
            break;
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        switch (other.tag)
        {
        case "Player":
            CharacterBehavior ch = other.transform.parent.GetComponent <CharacterBehavior> ();

            if (lastCharacterJumped == ch)
            {
                return;
            }
            lastCharacterJumped = ch;

            ch.SuperJumpByBumped(force * 100, 0.5f, backwardJump);

            Invoke("Reset", 0.5f);
            break;
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (characterBehavior == null)
        {
            return;
        }
        if (state == states.ON_START_JUMPING)
        {
            return;
        }
        if (characterBehavior.state == CharacterBehavior.states.DEAD ||
            characterBehavior.state == CharacterBehavior.states.CRASH ||
            characterBehavior.state == CharacterBehavior.states.FALL)
        {
            return;
        }

        if (state == states.ON_FLY)
        {
            return;
        }

        if (other.tag == "destroyable")
        {
            if (other.GetComponent <CharacterAnimationForcer>())
            {
                switch (other.GetComponent <CharacterAnimationForcer>().characterAnimation)
                {
                case CharacterAnimationForcer.animate.SLIDE: characterBehavior.Slide(); break;
                }
            }
        }

        if (other.tag == "floor" && state != states.ON_FLOOR)
        {
            state = states.ON_FLOOR;
            characterBehavior.OnFloor();
        }
        else if (other.tag == "floor" && !other.GetComponent <SliderFloor>())
        {
            if (transform.parent.gameObject.GetComponent <SliderEffect>())
            {
                transform.parent.gameObject.GetComponent <SliderEffect>().speed = 0;
            }
        }
        else
        {
            if (other.tag == "enemy")
            {
                if (characterBehavior.state == CharacterBehavior.states.JUMP ||
                    characterBehavior.state == CharacterBehavior.states.DOUBLEJUMP ||
                    characterBehavior.state == CharacterBehavior.states.SHOOT)
                {
                    MmoCharacter mmoCharacter = other.GetComponent <MmoCharacter> ();
                    if (mmoCharacter != null)
                    {
                        other.GetComponent <MmoCharacter>().Die();
                    }
                    else
                    {
                        other.gameObject.SendMessage("breakOut", other.gameObject.transform.position, SendMessageOptions.DontRequireReceiver);
                    }

                    characterBehavior.SuperJumpByBumped(1200, 0.5f, false);
                }
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (characterBehavior == null)
        {
            return;
        }
        if (
            characterBehavior.state == CharacterBehavior.states.DEAD ||
            characterBehavior.state == CharacterBehavior.states.CRASH ||
            characterBehavior.state == CharacterBehavior.states.FALL
            )
        {
            return;
        }

        if (other.tag == "wall" || other.tag == "firewall")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.data.events.AddExplotion(transform.position, Color.red);
                characterBehavior.Hit();
            }
            //  else
            //   other.GetComponent<WeakPlatform>().breakOut(transform.position);
        }
        if (other.tag == "destroyable")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                Breakable breakable = other.GetComponent <Breakable> ();
                if (breakable != null)
                {
                    if (breakable.ifJumpingDontKill && characterBehavior.IsJumping() && breakable.transform.position.y < transform.position.y)
                    {
                        characterBehavior.SuperJumpByHittingSomething();
                    }
                    else if (!breakable.dontKillPlayers)
                    {
                        characterBehavior.HitWithObject(other.transform.position);
                    }
                }
            }
        }
        else if (other.tag == "floor")
        {
            CharacterAnimationForcer chanimF = other.GetComponent <CharacterAnimationForcer> ();
            if (chanimF != null)
            {
                switch (chanimF.characterAnimation)
                {
                case CharacterAnimationForcer.animate.SLIDE:
                    characterBehavior.Slide();
                    break;
                }
            }
            float difY = transform.position.y - other.transform.position.y;

            if (other.transform.eulerAngles.x == 0 && difY < 1.6f)
            {
                //si es una plataforma rotada se va:
                SceneObject so = other.transform.GetComponentInParent <SceneObject>();
                if (so != null && so.transform.localEulerAngles != Vector3.zero)
                {
                    return;
                }

                Vector3 pos = characterBehavior.transform.position;
                if (difY < -0.5f)
                {
                    characterBehavior.Hit();
                    return;
                }
                else if (difY < 0.15f)
                {
                    characterBehavior.SuperJumpByBumped(2600, 0.5f, false);
                }
                else if (difY < 0.5f)
                {
                    characterBehavior.SuperJumpByBumped(2000, 0.5f, false);
                }
                else
                {
                    characterBehavior.SuperJumpByBumped(1200, 0.5f, false);
                }

                pos.y += difY;
                characterBehavior.transform.position = pos;
            }
        }
        else if (other.tag == "enemy")
        {
            print("______________" + characterBehavior.state + characterBehavior.IsJumping());

            if (characterBehavior.IsJumping())
            {
                MmoCharacter mmoCharacter = other.GetComponent <MmoCharacter> ();
                if (mmoCharacter != null)
                {
                    other.GetComponent <MmoCharacter> ().Die();
                }
                characterBehavior.SuperJumpByBumped(920, 0.5f, false);
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.Hit();
            }
        }
        else if (
            other.tag == "fallingObject" &&
            characterBehavior.state != CharacterBehavior.states.FALL
            )
        {
            if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.Hit();
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (characterBehavior == null)
        {
            return;
        }
        if (characterBehavior.state == CharacterBehavior.states.DEAD)
        {
            return;
        }
        if (characterBehavior.state == CharacterBehavior.states.CRASH)
        {
            return;
        }
        if (characterBehavior.state == CharacterBehavior.states.FALL)
        {
            return;
        }
        if (other.tag == "Player")
        {
            if (characterBehavior.state == CharacterBehavior.states.JUMP)
            {
                if (other.GetComponent <CharacterCollisions>())
                {
                    CharacterBehavior cb = other.GetComponent <CharacterCollisions>().characterBehavior;

                    // if (cb.transform.localPosition.y > characterBehavior.transform.localPosition.y) return;
                    if (cb.state != CharacterBehavior.states.RUN)
                    {
                        return;
                    }
                    if (cb.isOver != null)
                    {
                        return;
                    }
                    if (characterBehavior.isOver != null)
                    {
                        return;
                    }

                    print("Player " + player.id + " con " + cb.player.id);
                    cb.OnAvatarStartCarringSomeone(characterBehavior);
                    characterBehavior.OnAvatarOverOther(cb);
                }
            }
        }
        else
        if (other.tag == "wall" || other.tag == "firewall")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.data.events.AddExplotion(transform.position, Color.red);
                characterBehavior.Hit();
            }
            else
            {
                other.GetComponent <WeakPlatform>().breakOut(transform.position);
            }
        }
        if (other.tag == "destroyable")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                if (!other.GetComponent <Breakable>().dontKillPlayers)
                {
                    characterBehavior.HitWithObject(other.transform.position);
                }
            }
        }
        else if (other.tag == "floor" && !hitted)
        {
            if (transform.position.y - other.transform.position.y < 0f)
            {
                //  characterBehavior.Hit();
            }
            else
            {
                hitted = true;
                characterBehavior.SuperJumpByBumped(1200, 0.5f, false);
                Invoke("resetHits", 1);
            }
            if (other.GetComponent <WeakPlatform>())
            {
                other.GetComponent <WeakPlatform>().breakOut(characterBehavior.transform.position);
            }
        }
        else if (
            other.tag == "enemy" &&
            characterBehavior.state != CharacterBehavior.states.JUMP &&
            characterBehavior.state != CharacterBehavior.states.DOUBLEJUMP &&
            characterBehavior.state != CharacterBehavior.states.SHOOT &&
            characterBehavior.state != CharacterBehavior.states.FALL
            )
        {
            if (player.fxState == Player.fxStates.NORMAL && characterBehavior.state != CharacterBehavior.states.JETPACK)
            {
                characterBehavior.Hit();
            }

            MmoCharacter mmoCharacter = other.GetComponent <MmoCharacter> ();
            if (mmoCharacter != null)
            {
                other.GetComponent <MmoCharacter>().Die();
            }
        }
        else if (
            other.tag == "fallingObject" &&
            characterBehavior.state != CharacterBehavior.states.FALL
            )
        {
            if (player.fxState == Player.fxStates.NORMAL && characterBehavior.state != CharacterBehavior.states.JETPACK)
            {
                characterBehavior.Hit();
            }
        }
    }
示例#6
0
    void OnTriggerEnter(Collider other)
    {
        if (characterBehavior == null)
        {
            return;
        }
        if (
            characterBehavior.state == CharacterBehavior.states.DEAD ||
            characterBehavior.state == CharacterBehavior.states.CRASH ||
            characterBehavior.state == CharacterBehavior.states.FALL
            )
        {
            return;
        }

        if (other.tag == "wall" || other.tag == "firewall")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                Data.Instance.events.AddExplotion(transform.position, Color.red);
                characterBehavior.Hit();
            }
        }
        if (other.tag == "destroyable")
        {
            if (characterBehavior.state == CharacterBehavior.states.SHOOT)
            {
                return;
            }
            if (player.fxState == Player.fxStates.NORMAL)
            {
                Breakable breakable = other.GetComponent <Breakable> ();
                if (breakable != null)
                {
                    if (breakable.ifJumpingDontKill && characterBehavior.IsJumping() && breakable.transform.position.y < transform.position.y)
                    {
                        characterBehavior.SuperJumpByHittingSomething();
                    }
                    else if (!breakable.dontKillPlayers)
                    {
                        characterBehavior.HitWithObject(other.transform.position, false);//breakable.killAtHit);
                    }
                }
            }
        }
        else if (other.tag == "floor")
        {
            CharacterAnimationForcer chanimF = other.GetComponent <CharacterAnimationForcer> ();
            if (chanimF != null)
            {
                switch (chanimF.characterAnimation)
                {
                case CharacterAnimationForcer.animate.SLIDE:
                    characterBehavior.Slide();
                    break;
                }
            }
            float difY = transform.position.y - other.transform.position.y;

            if (other.transform.localEulerAngles.z > -0.9f && other.transform.localEulerAngles.z < 0.9f)
            {
                if (other.transform.eulerAngles.x == 0 && difY < 0.8f)
                {
                    Vector3 pos = characterBehavior.transform.position;
                    if (difY < -1.55f)
                    {
                        characterBehavior.Hit();
                        return;
                    }
                    else if (difY < -0.5f)
                    {
                        characterBehavior.SuperJumpByBumped(2400, 0.5f, false);
                    }
                    else if (difY < 0)
                    {
                        characterBehavior.SuperJumpByBumped(2000, 0.5f, false);
                    }
                    else
                    {
                        characterBehavior.SuperJumpByBumped(1200, 0.5f, false);
                    }

                    pos.y += difY;
                    characterBehavior.transform.position = pos;
                }
            }
        }
        else if (other.tag == "enemy")
        {
            MmoCharacter mmoCharacter = other.GetComponent <MmoCharacter> ();
            if (mmoCharacter != null)
            {
                other.GetComponent <MmoCharacter> ().Die();
            }
            if (characterBehavior.IsJumping())
            {
                characterBehavior.SuperJumpByBumped(920, 0.5f, false);
                return;
            }
            else if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.HitWithObject(other.transform.position, false);
            }
        }
        else if (
            other.tag == "fallingObject" &&
            characterBehavior.state != CharacterBehavior.states.FALL
            )
        {
            if (player.fxState == Player.fxStates.NORMAL)
            {
                characterBehavior.HitWithObject(other.transform.position, false);
            }
        }
    }