Пример #1
0
 //强制设定坐标
 public void setPosition(long uid, Vector3 pos)
 {
     Debug.Log("set position:" + uid + " : " + pos);
     //强制设定坐标的情况是会包含自身的
     if (isSelf(uid))
     {
         if (selfPlayer.pc != null)
         {
             selfPlayer.pc.setPosition(pos);
         }
         else
         {
             selfPlayer.attr.position = pos;
         }
     }
     else
     {
         sEntityInfo tmp = getOrCreatePlayer(uid);
         if (tmp.pc != null)
         {
             tmp.pc.setPosition(pos);
         }
         else
         {
             tmp.attr.position = pos;
         }
     }
 }
Пример #2
0
    public void pushEntity(long uid, Vector3 startpos, string etype)
    {
        if (isSelf(uid))
        {
            return;
        }

        Debug.Log("push pid:" + uid);
        sEntityInfo tmp = getOrCreatePlayer(uid);

        tmp.playerCC = GameObject.Instantiate(sULoading.instance.playerCC, tmp.attr.position == Vector3.zero?startpos:tmp.attr.position, Quaternion.LookRotation(tmp.attr.direction)) as GameObject;
        tmp.playerCC.SetActive(true);
        tmp.playerCC.name  = sStringBuilder.combine(tmp.playerCC.name, "_", uid);
        tmp.playerCC.layer = LayerMask.NameToLayer(sConst.othersLayer);
        tmp.pc             = tmp.playerCC.GetComponent <sEntityControl>();
        tmp.uid            = uid;
        tmp.pm             = tmp.playerCC.GetComponent <sEntityModel>();
        tmp.pm.playerUID   = uid;
        tmp.pm.bone        = "FS_bone";
        tmp.pm.chestName   = "FS_chest_000";
        tmp.pm.footName    = "FS_foot_000";
        tmp.pm.handName    = "FS_hand_000";
        tmp.pm.headName    = "FS_head_000";
        tmp.pm.legName     = "FS_leg_000";
        tmp.pm.createAvatar(tmp.playerCC);

        tmp.delTime = 0;
    }
Пример #3
0
    public sEntityInfo getOrCreatePlayer(long uid)
    {
        if (s2cPlayers.ContainsKey(uid))
        {
            return(s2cPlayers[uid]);
        }
        sEntityInfo tmp = new sEntityInfo();

        tmp.uid = uid;
        s2cPlayers.Add(uid, tmp);
        return(tmp);
    }
Пример #4
0
    public void setDirection(long uid, Vector3 dir)
    {
        if (isSelf(uid))
        {
            Debug.LogError("move position can't be self");
            return;
        }

        sEntityInfo tmp = getOrCreatePlayer(uid);

        if (tmp.pc != null)
        {
            tmp.pc.setDirection(dir);
        }
        else
        {
            tmp.attr.direction = dir;
        }
    }
Пример #5
0
    //移动到某个坐标
    public void moveToPosition(long uid, Vector3 pos)
    {
        Debug.Log("move position:" + uid + " : " + pos);
        //自身是不允许服务器传递移动消息的
        if (isSelf(uid))
        {
            Debug.LogError("move position can't be self");
            return;
        }

        sEntityInfo tmp = getOrCreatePlayer(uid);

        if (tmp.pc != null)
        {
            tmp.pc.moveToPosition(pos);
        }
        else
        {
            tmp.attr.position = pos;
        }
    }
Пример #6
0
    public void pushEntity(long uid, Vector3 startpos, string modelName, string etype)
    {
        if (isSelf(uid))
        {
            return;
        }
        Debug.Log("push pid2:" + uid);

        sEntityInfo tmp = getOrCreatePlayer(uid);

        tmp.playerCC = GameObject.Instantiate(sULoading.instance.playerCC, tmp.attr.position == Vector3.zero ? startpos : tmp.attr.position, tmp.attr.direction == Vector3.zero?Quaternion.identity:Quaternion.LookRotation(tmp.attr.direction)) as GameObject;
        tmp.playerCC.SetActive(true);
        tmp.playerCC.name  = sStringBuilder.combine(tmp.playerCC.name, "_", uid);
        tmp.playerCC.layer = LayerMask.NameToLayer(sConst.othersLayer);
        tmp.pc             = tmp.playerCC.GetComponent <sEntityControl>();
        tmp.uid            = uid;
        tmp.pm             = tmp.playerCC.GetComponent <sEntityModel>();
        tmp.pm.playerUID   = uid;
        tmp.pm.createModel(modelName, tmp.playerCC);
        tmp.delTime = 0;
    }
Пример #7
0
    //set attr
    public void setAttr(long uid, sEntityAttrType paType, object value)
    {
        Debug.Log("set attr:" + uid + " - " + paType + " - " + value);
        sEntityInfo tmp = getOrCreatePlayer(uid);

        switch (paType)
        {
        case sEntityAttrType.Name:
            tmp.attr.name = (string)value;
            break;

        case sEntityAttrType.GuildName:
            tmp.attr.guildname = (string)value;
            break;

        case sEntityAttrType.Vip:
            tmp.attr.vip = (int)value;
            break;

        case sEntityAttrType.Lvl:
            tmp.attr.level = (ushort)value;
            break;

        case sEntityAttrType.Exp:
            tmp.attr.exp = (ulong)value;
            break;

        case sEntityAttrType.Hp:
            tmp.attr.hp = (int)value;
            break;

        case sEntityAttrType.HpMax:
            tmp.attr.hp_max = (int)value;
            break;

        case sEntityAttrType.Mp:
            tmp.attr.mp = (int)value;
            break;

        case sEntityAttrType.MpMax:
            tmp.attr.mp_max = (int)value;
            break;

        case sEntityAttrType.Strength:
            tmp.attr.strength = (int)value;
            break;

        case sEntityAttrType.Dexterity:
            tmp.attr.dexterity = (int)value;
            break;

        case sEntityAttrType.Intelligence:
            tmp.attr.intelligence = (int)value;
            break;

        case sEntityAttrType.Stamina:
            tmp.attr.stamina = (int)value;
            break;

        case sEntityAttrType.Equiplvl:
            tmp.attr.equiplvl = (int)value;
            break;

        case sEntityAttrType.DamageMin:
            tmp.attr.damageMin = (int)value;
            break;

        case sEntityAttrType.DamageMax:
            tmp.attr.damageMax = (int)value;
            break;

        case sEntityAttrType.Defence:
            tmp.attr.defence = (int)value;
            break;
        }
    }