Ejemplo n.º 1
0
    public void InitRoleCamera()
    {
        mRole = ObjectManager.mRole;
        if (mRole == null)
        {
            return;
        }

        mRoleTransform = mRole.mTransform;
        if (mRoleTransform == null)
        {
            return;
        }

        mCameraTransform = mRoleTransform.Find("AnimationCamera");
        if (mCameraTransform == null)
        {
            return;
        }

        mRoleCameraGo = mCameraTransform.gameObject;
        if (mRoleCameraGo == null)
        {
            return;
        }
    }
Ejemplo n.º 2
0
    static string GetLastRoleInfo()
    {
        string mstrRoleInfo = string.Empty;

        if (ObjectManager.mRole != null)
        {
            float x = 0, y = 0, z = 0, orient = 0;

            int iRegionID = GameSceneManager.mintRegionID;
            UnityEngine.Transform transform = ObjectManager.mRole.mGameObject.transform;

            if (transform != null)
            {
                x = transform.position.x;
                y = transform.position.y;
                z = transform.position.z;
                //orient = ObjectManager.mRole.Rotation.eulerAngles.y / UnityEngine.Mathf.Rad2Deg;
            }
            else
            {
                CRoleObject roleObject = ObjectManager.mRole;
                x      = roleObject.mGameSceneObj.GetPosiX();
                y      = roleObject.mGameSceneObj.GetPosiY();
                z      = roleObject.mGameSceneObj.GetPosiZ();
                orient = roleObject.mGameSceneObj.GetOrient();
            }

            mstrRoleInfo = iRegionID + "," + x + "," + y + "," + z + "," + orient;
        }

        return(mstrRoleInfo);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 启动前清空
    /// </summary>
    public static void Clear()
    {
        ///清空引用
        mRole = null;

        ObjAddOrRemoveChange.ClearCalls();

        // 对象添加等待队列
        mObjectsDic.Clear();
    }
Ejemplo n.º 4
0
    void Awake()
    {
        _Instance = this;

        DontDestroyOnLoad(gameObject);

        mRole = ObjectManager.mRole;

        // 注册服务端消息
        RegisterCallback();
    }
Ejemplo n.º 5
0
    public static void ClearObjects()
    {
        ///清空引用
        foreach (IObject obj in mObjectsDic.Values)
        {
            obj.OnRemoveObjectBefore(true);
            obj.OnRemoveObject();
        }

        mRole = null;

        // 对象添加等待队列
        mObjectsDic.Clear();
    }
Ejemplo n.º 6
0
    protected override void OnLeftClick()
    {
        CanSelect = false;
        CRoleObject ro = BindObject as CRoleObject;

        /*  if (ro == null || ro.cr == null)
         *    return;
         *
         * if (!Global.world.Ref.IsDungeon)
         * {
         *    PopupFuncContent menu = new PopupFuncContent();
         *    menu.data1 = ro.cr.SN;
         *    menu.funclist.Add(PopupFuncContent.PopupTag.GroupInvite);
         *    menu.funclist.Add(PopupFuncContent.PopupTag.TeamInvite);
         *    CPopupMenu.Create(menu);
         * }
         *
         * if (CClientRole.IsEnemyCamp(ro.cr, Global.MainPlayer))
         *    Global.MainPlayer.AttackTarget = ro.cr.SN;
         */
        CanSelect = true;
    }
Ejemplo n.º 7
0
    void OnTriggerExit(Collider other)
    {
        CRoleObject ro = BindObject as CRoleObject;

        if (!ro)
        {
            return;
        }
        CTrigger trigger = other.gameObject.GetComponent <CTrigger>();

        if (!trigger)
        {
            return;
        }
        switch (trigger.Eventtype)
        {
        case CTrigger.EventType.Auto:
        {
            // Global.world.OnCloseLevel(trigger);
        }
        break;
        }
    }
Ejemplo n.º 8
0
    public void CreateRole(int roleId)
    {
        // 添加角色相关数据
        //mRoleObject = ObjectManager.mRole;

        Vector3 pos = Vector3.zero;

        if (mRoleObject != null)
        {
            pos = mRoleObject.mPosition;
            ObjectManager.DestroyObject(mRoleObject);
        }

        if (mRoleObject == null)
        {
            mRoleObject = new CRoleObject();
        }

        ObjectManager.mRole        = mRoleObject;
        ObjectManager.mRole.mObjId = roleId;

        // 加载主角资源
        mRoleGo = ResourceManager.Instance.GetRolePrefab(roleId + "_Tpose");
        if (mRoleGo == null)
        {
            return;
        }

        mRoleGo.name = roleId.ToString();
        if (pos.Equals(Vector3.zero))
        {
            mRoleObject.mPosition = new Vector3(-95f, 4.78f, -84f);
        }

        mRoleGo.transform.localPosition = mRoleObject.mPosition;
        mRoleGo.transform.localScale    = new Vector3(1.2f, 1.2f, 1.2f);

        mRoleObject.mObjModel   = roleId;
        mRoleObject.mGameObject = mRoleGo;
        mRoleObject.mTransform  = mRoleGo.transform;

        // 创建主相机
        //mMainCamera = GameObject.Find("Main Camera");
        //if (mMainCamera == null)
        //{
        //    mMainCamera = new GameObject("Main Camera");
        //    Camera camera = mMainCamera.AddComponent<Camera>();
        //}

        // 相机跟随
        //mCameraMove = mMainCamera.GetComponent<CameraMove>();
        //if (mCameraMove == null)
        //{
        //    mCameraMove = mMainCamera.AddComponent<CameraMove>();
        //}
        //mCameraMove.SetRoleGameObject(mRoleGo.transform.Find("Bip01").gameObject);
        _mFreeCam = GameObject.Find("FreeLookCameraRig").GetComponent <FreeLookCam>();
        _mFreeCam.SetTarget(mRoleObject.mTransform);


        // 添加角色移动控制器
        PlayerCtrlManager mPlayerCtrlManager = mRoleGo.GetComponent <PlayerCtrlManager>();

        if (mPlayerCtrlManager == null)
        {
            mPlayerCtrlManager = mRoleGo.AddComponent <PlayerCtrlManager>();
        }

        if (mRoleObject.mGameObject.GetComponent <AudioListener>() == null)
        {
            mRoleObject.mGameObject.AddComponent <AudioListener>();
        }

        UIManager.Instance.OpenUI("UHUDUI");
        UIManager.Instance.mHUDUIPanel = GameObject.Find("UHUDUI").GetComponent <UHUDUI>();

        // 添加角色逻辑组件
        mRoleObject.AddComponent <FindingPathComponent>();
        mRoleObject.AddComponent <AnimatorComponent>();
        mRoleObject.AddComponent <SkillComponent>();
        mRoleObject.AddComponent <ViewComponent>();
        mRoleObject.AddComponent <MoveComponent>();

        mRoleObject.AddComponent <RestoreComponent>();
        mRoleObject.AddComponent <InjuredComponent>();

        mRoleObject.AddComponent <EffectComponent>();
    }
Ejemplo n.º 9
0
    public static void CallAddObject(string strIdent)
    {
        try
        {
            Game game = Game.Instance;
            if (game == null || game.mGameClient == null)
            {
                return;
            }

            IGameSceneObj sceneObj = game.mGameClient.GetSceneObj(strIdent);
            if (sceneObj == null)
            {
                return;
            }

            IObject cObj = null;
            int     type = 0;
            if (!sceneObj.QueryPropInt("ObjectType", ref type))
            {
                LogSystem.Log("could not find type : ", strIdent);

                return;
            }

            string strModel = string.Empty;
            if (!sceneObj.QueryPropString("ResourcePath", ref strModel))
            {
                LogSystem.Log("could not find ResourcePath : ", strIdent);

                return;
            }

            ObjectType ObjType = (ObjectType)type;

            switch (ObjType)
            {
            case ObjectType.ObjectType_Player:
                if (game.mGameClient.IsPlayer(strIdent))
                {
                    cObj = new CRoleObject();
                    ObjectManager.mRole = cObj as CRoleObject;
                }
                else
                {
                    cObj = new CPlayerObject();
                }
                break;

            case ObjectType.ObjectType_Npc:
                cObj = new CNpcObject();
                break;

            case ObjectType.ObjectType_Monster:
                cObj = new CMonsterObject();
                break;

            case ObjectType.ObjectType_Soldier:
            case ObjectType.ObjectType_Creeps:

                break;

            case ObjectType.ObjectType_Born:
                break;
            }

            if (cObj != null)
            {
                cObj.mObjectType   = ObjType;
                cObj.mGameSceneObj = sceneObj;
                cObj.mObjectRes    = strModel;
                cObj.mStrIdent     = strIdent;
                cObj.OnAddObject();
                ObjectManager.AddObject(strIdent, cObj);
                if (cObj is CRoleObject)
                {
                    //GUIManager.CacheView<CharacterPanel>();
                    //GUIManager.CacheView<PlayerMainViewPanel>();
                    //GUIManager.CacheView<PlayerControlPanel>();
                    //GUIManager.CacheView<PlayerStatePanel>();
                    //GUIManager.CacheView<PlayerMapControlPanel>();
                    //GUIManager.CacheView<MainChatPanel>();

                    // 添加到主角的AOI中
                }
                else
                {
                    RangeTools.MotifyObjectAoi(mRole, cObj);
                }
            }
        }
        catch (System.Exception ex)
        {
            LogSystem.LogError("on_add_object catch error", ex.ToString());
        }
    }