Ejemplo n.º 1
0
        // 根据服务器类型和id获取实体对象
        public static IEntity GetEntity(GameCmd.SceneEntryType type, uint id)
        {
            Client.EntityType t = GetEntityEtype(type);

            Client.IEntitySystem es = EntitySystem.m_ClientGlobal.GetEntitySystem();
            if (es == null)
            {
                return(null);
            }

            switch (t)
            {
            case EntityType.EntityType_Player:
            {
                return(es.FindPlayer(id));
            }

            case EntityType.EntityType_NPC:
            {
                IEntity en = es.FindNPC(id);
                if (en == null)
                {
                    en = es.FindRobot(id);
                }
                return(en);
            }

            case EntityType.EntityType_Monster:
            {
                return(es.FindMonster(id));
            }

            case EntityType.EntityType_Item:
            {
                return(es.FindItem(id));
            }
            }

            return(null);
        }
Ejemplo n.º 2
0
    public void Execute(GameCmd.stRobotLevelUpMagicUserCmd_S cmd)
    {
        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return;
        }
        Client.IRobot robot = es.FindRobot(cmd.npc_id);
        if (robot == null)
        {
            return;
        }
        uint             baseID     = (uint)robot.GetProp((int)Client.EntityProp.BaseID);
        uint             job        = (uint)robot.GetProp((int)Client.RobotProp.Job);
        uint             level      = (uint)robot.GetProp((int)Client.CreatureProp.Level);
        string           name       = robot.GetName();
        EntityCreateData createData = RoleUtil.BuildRobotEntityData(cmd.npc_id, baseID, job, level, name);

        stPropUpdate lvprop = new stPropUpdate();
        stPropUpdate prop   = new stPropUpdate();

        prop.uid   = robot.GetUID();
        lvprop.uid = robot.GetUID();

        prop.nPropIndex   = (int)CreatureProp.Hp;
        lvprop.nPropIndex = (int)CreatureProp.Level;

        prop.oldValue   = robot.GetProp((int)CreatureProp.Hp);
        lvprop.oldValue = robot.GetProp((int)CreatureProp.Level);

        robot.UpdateProp(createData);

        prop.newValue   = robot.GetProp((int)CreatureProp.Hp);
        lvprop.newValue = robot.GetProp((int)CreatureProp.Level);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_HPUPDATE, prop);
        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_PROPUPDATE, lvprop);
    }