Example #1
0
    public void Execute(GameCmd.stBatchRemoveUserMapScreenUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemovePlayer(cmd.id[i]);

            IPlayer player = es.FindPlayer(cmd.id[i]);
            if (player != null)
            {
                if (!ClientGlobal.Instance().IsMainPlayer(player))
                {
                    Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                    removeEntiy.uid = player.GetUID();
                    Engine.Utility.Log.Info("remove :" + cmd.id[i]);
                    Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);

                    es.RemoveEntity(player);
                }
            }
        }
    }
Example #2
0
    public void Execute(stSendGoodNessDataUserCmd cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        IEntity en = es.FindPlayer(cmd.userid);

        if (en != null)
        {
            //// 时间(分钟) 大于0表示恶,否则表示善  暂时没用
            en.SetProp((int)PlayerProp.GoodNess, (int)cmd.goodstate);//GameCmd.enumGoodNess.GoodNess_Badman:
            stPropUpdate prop = new stPropUpdate();
            prop.uid        = en.GetUID();
            prop.nPropIndex = (int)PlayerProp.GoodNess;
            prop.oldValue   = en.GetProp((int)PlayerProp.GoodNess);
            prop.newValue   = (int)cmd.goodstate;
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_PROPUPDATE, prop);
        }
        else
        {
            Engine.Utility.Log.Error("找不到player :{0}", cmd.userid);
        }
    }
Example #3
0
    public void Execute(stMainUserDataUserCmd_S cmd)
    {
        //MainRole.Instance.MainData = cmd.data;

        // TODO: 后面再来处理
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        EntityCreateData data = new EntityCreateData();

        data.PropList = new EntityAttr[(int)PlayerProp.End - (int)EntityProp.Begin];
        data.ID       = cmd.data.dwUserID;
        RoleUtil.BuildPlayerPropList(cmd.data, ref data.PropList);
        IPlayer player = es.FindPlayer(cmd.data.dwUserID);

        if (player != null)
        {
            player.UpdateProp(data);
            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eSetRoleProperty, player);
        }
    }
Example #4
0
    public void Execute(stSetPKModePropertyUserCmd_CS cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        IEntity en = es.FindPlayer(cmd.userid);

        if (en != null)
        {
            en.SetProp((int)PlayerProp.PkMode, (int)cmd.pkmode);
            stPropUpdate prop = new stPropUpdate();
            prop.uid        = en.GetUID();
            prop.nPropIndex = (int)PlayerProp.PkMode;
            prop.oldValue   = en.GetProp((int)PlayerProp.PkMode);
            prop.newValue   = (int)cmd.pkmode;
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_PROPUPDATE, prop);
            //切换模式后刷新一下场景内的的血条
            RoleStateBarManager.RefreshAllRoleBarHeadStatus(HeadStatusType.Hp);
        }
        else
        {
            Engine.Utility.Log.Error("找不到player :{0}", cmd.userid);
        }
    }
Example #5
0
    public void Execute(stSetPKValuePropertyUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        IEntity en = es.FindPlayer(cmd.userid);

        if (en != null)
        {
            en.SetProp((int)PlayerProp.PKValue, (int)cmd.pkvalue);
            stPropUpdate prop = new stPropUpdate();
            prop.uid        = en.GetUID();
            prop.nPropIndex = (int)PlayerProp.PKValue;
            prop.oldValue   = en.GetProp((int)PlayerProp.PKValue);
            prop.newValue   = (int)cmd.pkvalue;
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_PROPUPDATE, prop);
        }
        else
        {
            Engine.Utility.Log.Error("找不到player :{0}", cmd.userid);
        }
    }
Example #6
0
    public void OnRemoveItems(GameCmd.stBatchRemoveItemMapScreenUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemovePlayer(cmd.id[i]);
            IBox box = es.FindBox(cmd.id[i]);
            if (box != null)
            {
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = box.GetUID();
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);
                es.RemoveEntity(box);
            }
            else
            {
                Engine.Utility.Log.Error("找不到box id{0}", cmd.id[i]);
            }
        }
    }
Example #7
0
    public void Excute(GameCmd.stMainUserRelivePropertyUserCmd_S cmd)
    {
        //  GameCmd.stReliveColdMagicUserCmd
        Engine.Utility.Log.Info("复活玩家 id: " + cmd.dwUserTempID);

        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        IPlayer player = es.FindPlayer(cmd.dwUserTempID);

        if (player == null)
        {
            return;
        }
        //  MapVector2 mapPos = MapVector2.FromCoordinate(cmd.x, cmd.y);
        Vector3 pos = new Vector3(cmd.x, 0, -cmd.y); // 服务器到客户端坐标转换

        player.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
        player.ChangeState(CreatureState.Normal);

        stEntityRelive stRelive = new stEntityRelive();

        stRelive.uid = player.GetUID();
        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_RELIVE, stRelive);
    }
Example #8
0
        void AddValues(IEntitySystem entity)
        {
            if (entity is SpiritSystem spirit)
            {
                for (int i = 0; i < spirit.Data.Get(Numeral.Level).Value; i++)
                {
                    IncreaseStatsPerLevel();
                }

                for (int i = 0; i < Data.NumeralAttributes.Count; i++)
                {
                    spirit.Data.Get(Data.NumeralAttributes[i].Type).AppliedValue += GetValue(Data.NumeralAttributes[i], spirit);
                }

                return;
            }

            if (entity is PlayerSystem player)
            {
                if (Data is Consumable item)
                {
                    if (item.Type == ConsumableType.MagicCrystals)
                    {
                        ConsumedMagicCrystals?.Invoke(item.NumeralAttributes[0].Value);
                    }
                    else if (item.Type == ConsumableType.SpiritVessel)
                    {
                        ConsumedSpiritVessels?.Invoke(item.NumeralAttributes[0].Value);
                    }
                }
            }
        }
Example #9
0
    public void OnRemoveMapObjectRes(stRemoveMapObjectMapScreenUserCmd_S cmd)
    {
        //Engine.Utility.Log.Info("OnRemoveMapObjectRes ID:" + cmd.qwThisID);

        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        {
            EntityCreator.Instance().RemovePlayer(cmd.qwThisID);
            IBox box = es.FindBox(cmd.qwThisID);
            if (box != null)
            {
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = box.GetUID();
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);
                es.RemoveEntity(box);
            }
            else
            {
                Engine.Utility.Log.Error("找不到box id{0}", cmd.qwThisID);
            }
        }
    }
Example #10
0
 public ItemSystem(Item data, IEntitySystem owner)
 {
     Owner       = owner;
     Data        = U.Instantiate(data);
     defaultData = data;
     Index       = (owner as PlayerSystem).ItemsCount;
 }
Example #11
0
    public void OnSetSkillState(stSendSkillStatusSkillUserCmd_S cmd)
    {
        if (MainPlayerHelper.IsMainPlayer(cmd.userid))
        {
            CurState = cmd.status == 0 ? SkillSettingState.StateOne : SkillSettingState.StateTwo;

            if (MainPlayerHelper.GetMainPlayer() != null)
            {
                MainPlayerHelper.GetMainPlayer().SetProp((int)PlayerProp.SkillStatus, (int)CurState);
            }
            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.eSkillChangeState, null);
        }
        else
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return;
            }
            IPlayer otherPlayer = es.FindEntity <IPlayer>(cmd.userid);
            if (otherPlayer != null)
            {
                otherPlayer.SetProp((int)PlayerProp.SkillStatus, (int)(cmd.status + 1));
            }
        }
    }
Example #12
0
 /// <summary>
 /// 设置家园实体状态通过实体id
 /// </summary>
 /// <param name="landIndex">实体id</param>
 /// <param name="state">状态</param>
 /// <param name="indexID">homeland.xlsx 模型配置表里对应的索引id</param>
 void SetHomeEntityState(long uid, int state, uint indexID)
 {
     if (entityStateDic.ContainsKey(uid))
     {
         HomeEntityInfo info = entityStateDic[uid];
         info.state          = state;
         entityStateDic[uid] = info;
         IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
         if (es != null)
         {
             IEntity en = es.FindEntity(uid);
             if (en != null)
             {
                 HomeLandViewDatabase db = GameTableManager.Instance.GetTableItem <HomeLandViewDatabase>((uint)indexID, state);
                 if (db != null)
                 {
                     ResourceDataBase rdb = GameTableManager.Instance.GetTableItem <ResourceDataBase>(db.dwModelID);
                     if (rdb != null)
                     {
                         ChangePart cp = new ChangePart();
                         cp.strPartName = "main";
                         cp.strResName  = rdb.strPath;
                         en.SendMessage(EntityMessage.EntityCommand_ChangePart, cp);
                     }
                 }
             }
         }
     }
     else
     {
         Log.Error("not cotain uid " + uid.ToString());
     }
 }
Example #13
0
    public void Execute(GameCmd.stUserStopMoveUserCmd_S cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        IPlayer player = es.FindPlayer(cmd.charid);

        if (player == null)
        {
            return;
        }

        if (ClientGlobal.Instance().IsMainPlayer(player))
        {
            return;
        }

        Vector3 pos = new Vector3(cmd.stop_pos_x * 0.01f, 0, -cmd.stop_pos_y * 0.01f);

        Engine.Utility.Log.LogGroup("ZDY", "stop move ==============================!");
        player.SendMessage(EntityMessage.EntityCommand_ForceStopMove, pos);
    }
Example #14
0
    public void OnSendNineSuitMsg(stSendSuitToNinePropertyUserCmd_S cmd)
    {
        uint          userID = cmd.userid;
        IEntitySystem es     = ClientGlobal.Instance().GetEntitySystem();

        if (es != null)
        {
            if (cmd.type == EquipSuitType.Magic_Pet_Type)
            {
                ChangePetBody(cmd.suitid, cmd.petid);
                SendChangeRenderObj(cmd.suitid, (int)cmd.type, userID);
            }
            else
            {
                IPlayer player = es.FindEntity <IPlayer>(userID);
                if (player == null)
                {
                    return;
                }

                //if(ClientGlobal.Instance().IsMainPlayer(player))
                //{
                //    return;
                //}

                if (player != null)
                {
                    SendChangeBody((int)cmd.type, cmd.suitid, player);
                    SendChangeRenderObj(cmd.suitid, (int)cmd.type, userID);
                }
            }
        }
    }
Example #15
0
        /// <exception cref="InvalidOperationException">Thrown if the specified type is already registered by another system.</exception>
        /// <exception cref="InvalidEntitySystemException">Thrown if the entity system instance is not registered with this <see cref="EntitySystemManager"/></exception>
        /// <exception cref="ArgumentNullException">Thrown if the provided system is null.</exception>
        public void RegisterMessageType <T>(IEntitySystem regSystem)
            where T : EntitySystemMessage
        {
            if (regSystem == null)
            {
                throw new ArgumentNullException(nameof(regSystem));
            }

            Type type = typeof(T);

            if (!Systems.ContainsValue(regSystem))
            {
                throw new InvalidEntitySystemException();
            }

            if (SystemMessageTypes.ContainsKey(type))
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Duplicate EntitySystemMessage registration: {0} is already registered by {1}.",
                              type,
                              SystemMessageTypes[type].GetType()));
            }

            SystemMessageTypes.Add(type, regSystem);
        }
Example #16
0
    public void ShowPlantSceneUI()
    {
        gameObject.SetActive(true);
        uiCamera   = Util.UICameraObj.GetComponent <Camera>();
        mainCamera = Util.MainCameraObj.GetComponent <Camera>();
        es         = ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return;
        }

        foreach (var info in homeDM.EntityStateDic)
        {
            IEntity en = es.FindEntity(info.Key);
            if (en != null)
            {
                Vector3 enpos = en.GetPos();
                enpos.y = 0;
                enpos   = mainCamera.WorldToViewportPoint(enpos);
                enpos   = uiCamera.ViewportToWorldPoint(enpos);

                ShowFarmUI(info, enpos);
                ShowAnimalUI(info, enpos);
                ShowTreeUI(info, enpos);
            }
        }
    }
Example #17
0
    public void Excute(GameCmd.stBatchRemoveNpcMapScreenUserCmd_S cmd)
    {
        Profiler.BeginSample("stBatchRemoveNpcMapScreenUserCmd_S");
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        for (int i = 0; i < cmd.id.Count; ++i)
        {
            EntityCreator.Instance().RemoveNPC(cmd.id[i]);
            //  Engine.Utility.Log.LogGroup( "ZDY" , "stBatchRemoveNpcMapScreenUserCmd_S remove entity ----------------" + cmd.id[i] );
            IEntity npc = es.FindNPC(cmd.id[i]);
            if (npc == null)
            {
                npc = es.FindRobot(cmd.id[i]);
            }

            if (npc != null)
            {
                long uid = npc.GetUID();
                Client.stRemoveEntity removeEntiy = new Client.stRemoveEntity();
                removeEntiy.uid = uid;
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_REMOVEENTITY, removeEntiy);

                NpcAscription.Instance.OnRemoveBelongData(uid);
            }

            es.RemoveEntity(npc);
        }
        Profiler.EndSample();
    }
Example #18
0
    private System.Collections.IEnumerator BuildEntityBarsCor()
    {
        yield return(0);

        IEntitySystem entitySystem = ClientGlobal.Instance().GetEntitySystem();

        if (null != entitySystem)
        {
            List <long> entityUids = entitySystem.GetEntityUids();

            if (null != entityUids)
            {
                UIRoleStateBar bar = null;
                int            successCreateCount = 0;
                int            modSeed            = (entityUids.Count % 30);
                modSeed = Mathf.Max(0, modSeed);
                for (int i = 0, max = entityUids.Count; i < max; i++)
                {
                    bar = AddRoleBar(entityUids[i]);
                    if (null != bar)
                    {
                        successCreateCount++;
                        if (modSeed != 0)
                        {
                            if (successCreateCount % modSeed == 0)
                            {
                                //等待下一帧
                                yield return(null);
                            }
                        }
                    }
                }
            }
        }
    }
Example #19
0
    public void Execute(GameCmd.stNpcMoveMoveUserCmd cmd)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }

        MapVector2 mapPos = MapVector2.FromCoordinate(cmd.dst_x, cmd.dst_y);
        Vector3    pos    = new Vector3(mapPos.x, 0, -mapPos.y); // 服务器到客户端坐标转换
        IEntity    en     = null;

        en = es.FindNPC(cmd.dwNpcTempID);
        if (en == null)
        {
            //Engine.Utility.Log.Info("机器人 移动pos {0}", pos);
            en = es.FindRobot(cmd.dwNpcTempID);
        }
        if (en != null)
        {
            Engine.Utility.Log.LogGroup("XXF", "{0}Move to{1},{2}", en.GetName(), pos.x, pos.z);

            Move move = new Move();
            //move.m_dir = Global.S2CDirection(cmd.dir);
            move.strRunAct = EntityAction.Run; // 动作名需要统一处理
            move.m_target  = pos;
            move.m_speed   = en.GetProp((int)WorldObjProp.MoveSpeed) * EntityConst.MOVE_SPEED_RATE;
            // Log.Error( "npc pos is" + pos.ToString() );
            en.SendMessage(EntityMessage.EntityCommand_MoveTo, (object)move);
        }
    }
Example #20
0
    public void Execute(GameCmd.stAddMapNpcAndPosMapScreenUserCmd_S cmd)
    {
        //AddNPC(cmd.data);
        Profiler.BeginSample("stAddMapNpcAndPosMapScreenUserCmd_S");
        EntityCreator.Instance().AddNPC(cmd.data, cmd.master_id);
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
            return;
        }
        uint userUID = ClientGlobal.Instance().MainPlayer.GetID();

        if (userUID == cmd.master_id && cmd.pet_id != 0)
        {
            DataManager.Manager <PetDataManager>().AddPetToNpc(cmd.pet_id, cmd.data.mapnpcdata.npcdata.dwTempID);
        }

        GameCmd.stNpcBelongListMapScreenUserCmd_S belongcmd = new GameCmd.stNpcBelongListMapScreenUserCmd_S();
        belongcmd.teamid = cmd.data.mapnpcdata.npcdata.owernteamid;
        belongcmd.userid = cmd.master_id;
        belongcmd.npcid  = cmd.data.mapnpcdata.npcdata.dwTempID;
        Execute(belongcmd);
        RoleStateBarManager.RefreshAllRoleBarHeadStatus(HeadStatusType.Hp);
        Profiler.EndSample();
    }
Example #21
0
        public void AddRobot(t_MapNpcDataPos data, uint master_id)
        {
            if (data == null)
            {
                return;
            }

            Engine.Utility.Log.Trace("添加ROBOT:{0}", data.mapnpcdata.npcdata.dwBaseID);

            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
                return;
            }

            if (es.FindRobot(data.mapnpcdata.npcdata.dwTempID) != null)
            {
                CreateNPC(data, master_id); // 更新数据
                return;
            }

            if (m_dicNPCData.ContainsKey(data.mapnpcdata.npcdata.dwTempID))
            {
                return;
            }

            CreateNPC(data, master_id);
        }
Example #22
0
    public void CancleBuffState(stCancelStateIcoListMagicUserCmd_S cmd)
    {
        BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(cmd.wdState);

        if (db != null)
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                Engine.Utility.Log.Error("GetEntitySystem failed!");
            }

            IEntity entity = EntitySystem.EntityHelper.GetEntity(cmd.byType, cmd.dwTempID);

            if (entity == null)
            {
                Engine.Utility.Log.Error("es.FindEntity  useid is !" + cmd.dwTempID.ToString());
            }
            else
            {
                Log.LogGroup("ZDY", "取消{0}身上的buff {1}===========", db.strName, entity.GetName());
            }
        }
        else
        {
            Log.Error("找不到buff ===========" + cmd.wdState);
        }
        IBuffPart bp = GetBuffPart((GameCmd.SceneEntryType)cmd.byType, cmd.dwTempID);

        if (bp != null)
        {
            bp.CancleBuffState(cmd);
        }
    }
Example #23
0
    /// <summary>
    /// 通过玩家id获取所属的npc
    /// </summary>
    /// <param name="playerID"></param>
    /// <returns></returns>
    public void GetOwnNpcByPlayerID(uint playerID, ref List <INPC> lstNPC)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            return;
        }

        if (lstNPC == null)
        {
            return;
        }

        lstNPC.Clear();
        es.FindAllEntity <INPC>(ref m_npcList);
        for (int i = 0; i < m_npcList.Count; i++)
        {
            INPC npc = m_npcList[i];
            if (npc != null)
            {
                int masterID = npc.GetProp((int)NPCProp.Masterid);
                if (masterID == playerID)
                {
                    lstNPC.Add(npc);
                }
            }
        }
        m_npcList.Clear();
    }
Example #24
0
    public int SetDisplayData(uint uID)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(uID);
        if (npctable == null)
        {
            return(0);
        }

        GameCmd.t_MapNpcDataPos npcdata = new GameCmd.t_MapNpcDataPos();
        npcdata.mapnpcdata         = new GameCmd.t_MapNpcData();
        npcdata.mapnpcdata.npcdata = new GameCmd.t_NpcData();

        npcdata.mapnpcdata.npcdata.dwBaseID = uID;

        npcdata.mapnpcdata.npcdata.dwTempID  = this.m_dwID;
        npcdata.mapnpcdata.npcdata.movespeed = 600;

        EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityType_NPC, npcdata, 0);

        IEntity npc = es.CreateEntity(EntityType.EntityType_NPC, data, true) as INPC;

        //ISkillPart skillPart = npc.GetPart(EntityPart.Skill) as ISkillPart;
        //skillPart.ReqNpcUseSkill(208);

        m_pEntity = npc;

        return(1);
    }
Example #25
0
    public override bool OnTogglePanel(int tabType, int pageid)
    {
        if (pageid == (int)PropPanelPageEnum.Page_Prop)
        {
            SetPanelMode(PropPanelMode.Prop, true);
            uint          showUID = ClientGlobal.Instance().MainPlayer.GetID();
            IEntitySystem es      = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return(false);
            }
            IPlayer player = es.FindPlayer(showUID);
            if (player == null)
            {
                return(false);
            }
            m_currShowUID = showUID;
            ShowByPlayer(player);
            m_label_fight.gameObject.SetActive(true);
        }
        else if (pageid == (int)PropPanelPageEnum.Page_Title)
        {
            SetPanelMode(PropPanelMode.Title, true);
        }
        else if (pageid == (int)PropPanelPageEnum.Page_Fashion)
        {
            SetPanelMode(PropPanelMode.Fashion, true);
            m_label_fight.gameObject.SetActive(false);
        }

        // 页签红点提示
        UpdateRedPoint();
        return(base.OnTogglePanel(tabType, pageid));
    }
Example #26
0
    void OnClickMsg(GameObject o)
    {
        // 发送事件

        //显示切换目标
        es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es != null)
        {
            IPlayer m_curTarget = es.FindPlayer(this.teamMemberInfo.id);
            if (m_curTarget != null)
            {
                Client.stTargetChange targetChange = new Client.stTargetChange();
                targetChange.target = m_curTarget;
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_TARGETCHANGE, targetChange);
            }
        }

        //左侧最远操作界面
        if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MissionAndTeamPanel))
        {
            stTeamMemberBtn teamMemberBtn = new stTeamMemberBtn();
            teamMemberBtn.id    = this.teamMemberInfo.id;
            teamMemberBtn.name  = this.teamMemberInfo.name;
            teamMemberBtn.pos_y = this.transform.position.y;

            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MissionAndTeamPanel, UIMsgID.eTeamMemberBtn, teamMemberBtn);
        }
    }
Example #27
0
    public void RebackWeaponSuitAndCleanData(uint uid)
    {
        IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            return;
        }

        IPlayer player = es.FindPlayer(uid);

        if (player == null)
        {
            return;
        }

        uint suitId;

        if (m_playerSuitDic.TryGetValue(player.GetID(), out suitId))
        {
            SendChangeBody(2, suitId, player);
            SendChangeRenderObj(suitId, 2, player.GetID());
            m_playerSuitDic.Remove(player.GetID());
            m_playerFishingDic.Remove(player.GetID());
        }
    }
Example #28
0
    void ChangePetBody(uint suitID, uint petID)
    {
        PetDataManager pm = DataManager.Manager <PetDataManager>();

        if (pm != null)
        {
            //if (pm.CurFightingPet != 0)
            {
                IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
                if (es != null)
                {
                    INPC npc = es.FindNPC(petID);
                    if (npc != null)
                    {
                        if (suitID != 0)
                        {
                            SuitDataBase sdb = GameTableManager.Instance.GetTableItem <SuitDataBase>(suitID, 1);
                            if (sdb != null)
                            {
                                Client.ChangeBody cb = new Client.ChangeBody();
                                cb.resId      = (int)sdb.resid;
                                cb.modleScale = sdb.sceneModleScale;
                                npc.SendMessage(EntityMessage.EntityCommand_Change, cb);
                            }
                        }
                        else
                        {
                            npc.SendMessage(EntityMessage.EntityCommand_Restore);
                        }
                    }
                }
            }
        }
    }
Example #29
0
    /// <summary>
    /// 移除npc身上特效
    /// </summary>
    /// <param name="npcId"></param>
    public bool RemoveCollectNpcEffectByNpcId(uint npcId)
    {
        List <int> linkIdList;

        if (m_dicCollectNpcEffectLinkId.TryGetValue(npcId, out linkIdList))
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return(false);
            }

            INPC npc = es.FindNPC(npcId);
            if (npc == null)
            {
                return(false);
            }

            for (int i = 0; i < linkIdList.Count; i++)
            {
                EntitySystem.EntityHelper.RemoveEffect(npc, linkIdList[i]);
            }
            return(true);
        }

        return(false);
    }
Example #30
0
        // 根据ID获取技能部件
        public static ISkillPart GetSkillPart(uint uid, EntityType type)
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                Engine.Utility.Log.Error("GetEntitySystem failed!");
                return(null);
            }
            if (type == EntityType.EntityType_NPC)
            {
                IRobot robot = es.FindEntity <IRobot>(uid);
                if (robot != null)
                {
                    type = EntityType.EntityTYpe_Robot;
                }
            }
            long    id     = EntitySystem.EntityHelper.MakeUID(type, uid);
            IEntity player = es.FindEntity(id);

            if (player == null)
            {
                Engine.Utility.Log.Error("GetAttack failed!");
                return(null);
            }

            ISkillPart skillPart = player.GetPart(EntityPart.Skill) as ISkillPart;

            return(skillPart);
        }
        /// <summary>
        /// Gets a system bit for the specified <see cref="IEntitySystem"/>.
        /// </summary>
        /// <param name="entitySystem">The <see cref="IEntitySystem"/> to use.</param>
        /// <returns>Either the system bit flag assigned to the provided <see cref="IEntitySystem"/>, or a new
        /// system bit flag.</returns>
        public static long GetBitFor(IEntitySystem entitySystem)
        {
            long bit;
            if (!_systemBits.TryGetValue(entitySystem, out bit))
            {
                bit = 1L << _position;
                ++_position;
                _systemBits.Add(entitySystem, bit);
            }

            return bit;
        }
Example #32
0
 public void Add(IEntitySystem system)
 {
     foreach (var entity in Entities)
         system.Add(entity);
     entitySystems.Add(system);
 }
Example #33
0
        public void Initialize(IServiceRegistry registry, string effectFilename = null, string[] optionalFeatures = null)
        {
            // Missing features compared to before: ZInverse support, Picking/Wireframe, Heat Shimmering and light shafts bounding boxes.
            // Other stuff to implement: Enable features by RenderPipeline, reloading, access of plugins through a flexible interface, yebis config.
            renderSystem = registry.GetSafeServiceAs<IRenderSystem>();
            graphicsDeviceService = registry.GetSafeServiceAs<IGraphicsDeviceService>();
            this.effectSystemOld = registry.GetSafeServiceAs<IEffectSystemOld>();
            entitySystem = registry.GetSafeServiceAs<IEntitySystem>();
            
            var rootRenderPass = renderSystem.RootRenderPass;
            var dataContext = RenderConfigContext = renderSystem.ConfigContext;
            var graphicsDevice = graphicsDeviceService.GraphicsDevice;

            if (effectFilename == null)
                effectFilename = Path.Combine("/shaders/effects.xml");

            var context = new XenkoXamlSchemaContext(dataContext);
            var xamlObjectWriter = new XamlObjectWriter(context);

            using (var fileStream = VirtualFileSystem.OpenStream(effectFilename, VirtualFileMode.Open, VirtualFileAccess.Read))
                XamlServices.Transform(new XamlXmlReader(fileStream, context), xamlObjectWriter);

            var effectConfig = (RenderConfig)xamlObjectWriter.Result;

            foreach (var renderPass in effectConfig.Content.OfType<RenderPass>())
            {
                dataContext.RenderPasses.Add(renderPass.Name, renderPass);
                rootRenderPass.AddPass(renderPass);
            }

            foreach (var item in effectConfig.Content)
            {
                var plugin = item as RenderPassPlugin;
                if (plugin != null)
                {
                    dataContext.RenderPassPlugins.Add(plugin.Name, plugin);
                }

                var setter = item as Setter;
                if (setter != null)
                {
                    PropertyPath.SetNextValue(setter.Target, setter.Property, setter.Value);
                }
            }

            MainPlugin = dataContext.RenderPassPlugins.Select(x => x.Value).OfType<MainPlugin>().First();
            MainTargetPlugin = dataContext.RenderPassPlugins.Select(x => x.Value).OfType<RenderTargetsPlugin>().FirstOrDefault(x => x.Name == "MainTargetPlugin");

            var mainBackBuffer = graphicsDevice.BackBuffer;
            MainPlugin.RenderTarget = graphicsDevice.BackBuffer;
            
            // Depth Stencil target needs to be shader resource only if Yebis or GBuffer is active (need more robust way to decide)
            var depthStencilTexture = Texture.New2D(graphicsDevice, mainBackBuffer.Width, mainBackBuffer.Height, PixelFormat.D32_Float,
                (RenderConfigContext.RenderPassPlugins.Any(x => x.Value is YebisPlugin || x.Value is GBufferPlugin) ? TextureFlags.ShaderResource : 0) | TextureFlags.DepthStencil);
            MainPlugin.DepthStencil = depthStencilTexture.ToDepthStencilBuffer(false);

            if (DepthStencilBuffer.IsReadOnlySupported(graphicsDevice))
                MainPlugin.DepthStencilReadOnly = depthStencilTexture.ToDepthStencilBuffer(true);

            // TODO: Temporary setup (should be done through an Entity and its Manager)
            HeatShimmerPlugin heatShimmerPlugin;
            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("HeatShimmerPlugin", out heatShimmerPlugin))
            {
                throw new NotImplementedException();
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(8200, 3000, 1500) * Matrix.Translation(2700, 0, 300) } } });
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(2000, 2000, 3500) * Matrix.RotationZ(0.5f) * Matrix.Translation(-7000, -4000, 1500) } } });
                //heatShimmerPlugin.BoundingBoxes.Add(new MeshData { MeshData = MeshDataHelper.CreateBox(1, 1, 1, Color.White, true), Parameters = new ParameterCollectionData { { TransformationKeys.World, Matrix.Scaling(2000, 3000, 3500) * Matrix.Translation(-7800, 900, 1500) } } });
            }
            
            // Generates intermediate render targets
            var plugins = dataContext.RenderPassPlugins
                .OrderBy(x => rootRenderPass.Passes.IndexOf(x.Value.RenderPass)).ToArray();

            // Weave render targets from last to first plugin.
            // TODO: Instead of guessing through interface and non-null/null values, it would be better if plugin had flags to inform of its intentions.
            var currentTarget = mainBackBuffer;
            for (int i = plugins.Length - 1; i >= 0; --i)
            {
                var plugin = plugins[i];

                var targetPlugin = plugin.Value as IRenderPassPluginTarget;
                if (targetPlugin != null)
                {
                    if (targetPlugin.RenderTarget == null)
                        targetPlugin.RenderTarget = currentTarget;

                    currentTarget = targetPlugin.RenderTarget;
                }

                var sourcePlugin = plugin.Value as IRenderPassPluginSource;
                if (sourcePlugin != null)
                {
                    if (sourcePlugin.RenderSource == null)
                    {
                        sourcePlugin.RenderSource = Texture.New2D(graphicsDevice, mainBackBuffer.Width, mainBackBuffer.Height, PixelFormat.R16G16B16A16_Float, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
                    }

                    currentTarget = sourcePlugin.RenderSource.ToRenderTarget();
                }
            }

            foreach (var plugin in dataContext.RenderPassPlugins)
            {
                renderSystem.RenderPassPlugins.Add(plugin.Value);
            }

            foreach (var effectBuilder in effectConfig.Content.OfType<EffectBuilder>())
            {
                foreach (var plugin in effectBuilder.Plugins)
                {
                    plugin.Services = registry;
                }
                this.effectSystemOld.Effects.Add(effectBuilder);
            }

#if XENKO_YEBIS
            YebisPlugin yebisPlugin;
            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("YebisPlugin", out yebisPlugin))
            {
                yebisPlugin.AntiAlias = true;

                yebisPlugin.ToneMap.Gamma = 2.2f;
                yebisPlugin.ToneMap.Type = ToneMapType.SensiToMetric;
                yebisPlugin.ToneMap.AutoExposure.Enable = true;
                yebisPlugin.ToneMap.AutoExposure.MiddleGray = 0.25f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationSensitivity = 0.5f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationScale = 0.8f;
                yebisPlugin.ToneMap.AutoExposure.AdaptationSpeedLimit = 4.0f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationSensitivity = 0.9f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationScale = 0.6f;
                yebisPlugin.ToneMap.AutoExposure.DarkAdaptationSpeedLimit = 4.0f;
                yebisPlugin.ToneMap.AutoExposure.LightDarkExposureBorder = 1.0f;

                yebisPlugin.Glare.Enable = true;
                //yebisPlugin.Glare.RemapFactor = 1.0f;
                //yebisPlugin.Glare.Threshold = 0.0f;

                yebisPlugin.Lens.Vignette.Enable = true;

                yebisPlugin.Lens.Distortion.Enable = false;
                yebisPlugin.Lens.Distortion.Power = 0.2f;
                yebisPlugin.Lens.Distortion.EdgeSmoothness = 0.2f;

                yebisPlugin.DepthOfField.Enable = true;
                yebisPlugin.DepthOfField.AutoFocus = true;
                yebisPlugin.DepthOfField.Aperture = 2.0f;
                yebisPlugin.DepthOfField.ImageSensorHeight = 40.0f;

                //yebisPlugin.ColorCorrection.ColorTemperature = 4500;

                yebisPlugin.HeatShimmer.Enable = false;
                //YebisPlugin.LightShaft.Enable = true;
                //YebisPlugin.LightShaft.ScreenPosition = new Vector2(0.5f, 0.1f);
            }
#endif

            // Adds the particle system if the ParticlePlugin is used in the config
            ParticlePlugin particlePlugin;
            if (RenderConfigContext.RenderPassPlugins.TryGetValueCast("ParticlePlugin", out particlePlugin))
            {
                var particleSystem = new ParticleProcessor(particlePlugin);
                entitySystem.Processors.Add(particleSystem);
            }
        }