Beispiel #1
0
    public void MouseUp()
    {
        if (Data.curPlayState != PlayerState.OnChain)
        {
            Vector3 hit = tool.RayPointBg();
            if (!Data.mouse_down.Equals(Vector3.zero) && !hit.Equals(Vector3.zero) && (hit - Data.mouse_down).magnitude > 1f)
            {
                Vector3 direction = (hit - Data.mouse_down).normalized;    //松开处与人物的角度方向
                float   angle     = tool.getAngle(direction, Vector3.right);
                if (direction.x >= 0 && direction.y >= 0 && direction.z >= 0)
                {
                    Data.angle = angle;

                    PastPlayerCompenetState past = new PastPlayerCompenetState();
                    past.isKinematic = true;
                    past.isTrigger   = true;
                    past.mass        = 8f;
                    SendNotification(NotificationConstant.playerMediator.ChangePlayerCompnentState, past);

                    Data.curPlayState = PlayerState.OnChain;
                    SendNotification(NotificationConstant.playerMediator.CreatRope, Data);
                }
            }
        }
        Data.mouse_down = Vector3.zero;
    }
    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;
        }
    }