Beispiel #1
0
    static public void CreateDrop(uint eid, int x, int y, int gold, int itemId, int belongAvatar)
    {
        if (belongAvatar == thePlayer.ID)
        {
            EntityDrop entity = new EntityDrop();
            CellAttachedInfo info = new CellAttachedInfo();
            info.x = (short)x;
            info.y = (short)y;
            info.id = eid;

            Vector3 newPosi = MogoWorld.FindEmptyDropPoint(info.position);
            entity.SetTweenTarget(newPosi);
            entity.ID = info.id;
            entity.entity = info.entity;
            entity.SetEntityCellInfo(info);
            entity.gold = gold;
            entity.itemId = itemId;
            entity.belongAvatar = belongAvatar;
            entity.OnEnterWorld();

            if (!isLoadingScene)
                entity.CreateModel();

            OnEnterWorld(entity);
        }
    }
Beispiel #2
0
    // 协议处理函数, 新的 entity 进入视野
    static private void AOINewEntity(CellAttachedInfo info)
    {
        // todo:  先硬编码, 以后改成 从 def 中 自动化
        EntityParent entity;
        LoggerHelper.Debug(info.entity.Name);
        if (isReConnect && !mainCameraCompleted)
        {//断线重连场景没加载完,缓存起来
            others.Add(info);
            return;
        }
        if (Entities.ContainsKey(info.id) || (thePlayer != null && thePlayer.ID == info.id))
        {
            LoggerHelper.Debug("has same id entity in world");
            return;
        }
        if ((info.entity.Name == "Monster" ||
            info.entity.Name == "Mercenary" ||
            info.entity.Name == "Drop") && inCity)
        {
            //主城不出现Monster Mercenary,用于切场景的瞬间收到创建协议
            return;
        }
        switch (info.entity.Name)
        {
            case "Avatar"://对应Avatar.def
                if (SystemConfig.Instance.PlayerCountInScreen <= playerCount
                    || (MogoWorld.thePlayer != null && MogoWorld.thePlayer.IsNewPlayer))
                {
                    LoggerHelper.Debug("EntityPlayer over count: " + playerCount);
                    return;
                }
                if (MogoWorld.IsClientMission)
                {
                    return;
                }
                entity = new EntityPlayer();
                entity.vocation = Vocation.Warrior;
                break;
            case "NPC"://对应NPC.def
                // entity = new EntityNPC();
                entity = new EntityParent();
                break;
            case "Monster": //对应Monster.def
                entity = new EntityMonster();
                break;
            case "Mercenary": //对应Monster.def
                entity = new EntityMercenary();
                break;
            case "Drop": //对应Drop.def
                entity = new EntityDrop();
                Vector3 newPosi = MogoWorld.FindEmptyDropPoint(info.position);
                (entity as EntityDrop).SetTweenTarget(newPosi);
                //LoggerHelper.Error("f**k end " + info.id + " n " + newPosi.x + " " + newPosi.y + " " + newPosi.z);
                break;
            case "TeleportPointSrc": //对应TeleportPointSrc.def
                entity = new EntityTeleportSrc();
                break;
            case "Dummy": //CMonster.def
                entity = new EntityDummy();
                break;
            default:
                entity = new EntityParent();
                break;
        }
        entity.ID = info.id;
        entity.entity = info.entity;
        entity.SetEntityCellInfo(info);
        entity.OnEnterWorld();
        if (!isLoadingScene)
            entity.CreateModel();
        //LoggerHelper.Error("AOINewEntity: etype: " + info.entity.Name + " eid: " + entity.ID + " pos: " + entity.position);
        OnEnterWorld(entity);

        EventDispatcher.TriggerEvent(Events.CampaignEvent.SetPlayerMessage, entity);
    }