コード例 #1
0
ファイル: IObject.cs プロジェクト: mengtest/actdemo
    /// <summary>
    /// IObject基础属性回调
    /// </summary>
    /// <param name="propName"></param>
    virtual public void OnObjectPropertyChange(string propName)
    {
        if (mGameSceneObj == null)
        {
            return;
        }

        switch (propName)
        {
        case "Name":
            mGameSceneObj.QueryPropStringW(propName, ref mObjName);
            break;

        case "HP":
            mGameSceneObj.QueryPropInt64(propName, ref mHP);
            break;

        case "MaxHP":
            mGameSceneObj.QueryPropInt64(propName, ref mMaxHP);
            break;

        case "Config":
            mGameSceneObj.QueryPropString(propName, ref mConfig);
            break;

        case "Script":
            mGameSceneObj.QueryPropString(propName, ref mScript);
            break;
        }
    }
コード例 #2
0
ファイル: ObjectManager.cs プロジェクト: mengtest/actdemo
    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());
        }
    }