Exemplo n.º 1
0
    void OnCollisionEnter(Collision other)
    {
        ConnectPoint = other.contacts [0].point;
        if (other.collider.tag.Equals(Tags.tag.top))
        {
            CharacterJoint cj = this.gameObject.AddComponent <CharacterJoint>();
            cj.connectedBody = other.collider.GetComponent <Rigidbody>();

            for (int i = chain.transform.childCount - 1; i >= 0; i--)
            {
                if (chain.transform.GetChild(i).GetChild(0).GetComponent <BoxCollider>().isTrigger)
                {
                    chain.transform.GetChild(i).gameObject.SetActive(false);
                    if (!isConnect)
                    {
                        pastAdd = new PastAddJointCompnent("FixedJoint", chain.transform.GetChild(i + 1).GetComponent <Rigidbody>());
                        RunFacade.getInstance.SendNotification(NotificationConstant.playerMediator.AddPlayerJointCompnent, pastAdd);

                        past.isKinematic = false;
                        past.isTrigger   = false;
                        past.mass        = 8f;
                        RunFacade.getInstance.SendNotification(NotificationConstant.playerMediator.ChangePlayerCompnentState, past);
                        RunFacade.getInstance.SendNotification(NotificationConstant.playerCommand.ResetJumpData);

                        isConnect = true;
                    }
                }

                else
                {
                    chain.transform.GetChild(i).GetComponent <Rigidbody>().velocity = Vector3.zero;
                    chain.transform.GetChild(i).GetComponent <Rigidbody>().AddForce(Vector3.right * 500f);
                    chain.transform.GetChild(i).GetComponent <Rigidbody>().useGravity = true;
                }
            }
        }
    }
Exemplo n.º 2
0
    public override void HandleNotification(PureMVC.Interfaces.INotification notification)
    {
        PlayerBasic pb = notification.Body as PlayerBasic;

        switch (notification.Name)
        {
        //执行和显示有关的命令
        case NotificationConstant.playerMediator.PlayerRunMove:
        {
            player.transform.Translate(Vector3.right * pb.run_speed * Time.deltaTime, Space.World);
        } break;


        case NotificationConstant.playerMediator.JumpMediator:
        {
            if (player_ac.GetBool(Tags.animator_player.Jump) == false)
            {
                player_rigidboy.velocity = new Vector3(0, pb.jump_Velocity, 0);
                player_ac.SetBool(Tags.animator_player.Jump, true);
            }
            else if (player_ac.GetBool(Tags.animator_player.Jump2) == false)                    //二段跳
            {
                player_rigidboy.velocity = new Vector3(0, pb.jump_Velocity, 0);
                player_ac.SetBool(Tags.animator_player.Jump2, true);
                player_ac.SetBool(Tags.animator_player.Jump, false);
            }
        } break;

        case NotificationConstant.playerMediator.AtkMediator:
        {
            player_ac.SetTrigger(Tags.animator_player.isAtk);
        }
        break;

        case NotificationConstant.playerMediator.HitMediator:
        {
            player_ac.SetTrigger(Tags.animator_player.isHit);
        }
        break;

        case NotificationConstant.playerMediator.ResetJumpAnimator:
        {
            player_ac.SetBool(Tags.animator_player.Jump, false);
            player_ac.SetBool(Tags.animator_player.Jump2, false);
        } break;

        case NotificationConstant.playerMediator.ReStart:
        {
            Application.LoadLevel(Application.loadedLevel);
        } break;


        case NotificationConstant.playerMediator.CreatRope:
        {
            GameObject obj = Resources.Load(Tags.prb_path.Rope) as GameObject;
            obj.transform.position    = player.transform.GetChild(Tags.PlayerChilds.Send_target).position;
            obj.transform.eulerAngles = new Vector3(0, 0, pb.angle - 90f);
            player.GetComponent <Player>().InstantiateGameOjbect(obj);
        } break;

        case NotificationConstant.playerMediator.ChangePlayerCompnentState:
        {
            PastPlayerCompenetState recive = notification.Body as PastPlayerCompenetState;
            player.GetComponent <Rigidbody>().isKinematic      = recive.isKinematic;
            player.GetComponent <Rigidbody>().mass             = recive.mass;
            player.GetComponent <CapsuleCollider> ().isTrigger = recive.isTrigger;
        } break;

        case NotificationConstant.playerMediator.AddPlayerJointCompnent:
        {
            PastAddJointCompnent recive = notification.Body as PastAddJointCompnent;
            if (recive.Compnent_type.Equals("FixedJoint"))
            {
                FixedJoint fiexd = player.AddComponent <FixedJoint>();
                fiexd.connectedBody = recive.connect;
            }
        } break;

        case NotificationConstant.playerMediator.DeletePlayerCompnent:
        {
            if (player.GetComponent <FixedJoint> ())
            {
                player.GetComponent <Player>().DestroyObject(player.GetComponent <FixedJoint> ());
            }
        } break;
        }
    }