Ejemplo n.º 1
0
    public static bool CanWalkTo(Vector3 dst)
    {
        Actor localPlayer = Game.GetInstance().GetLocalPlayer();

        if (localPlayer != null)
        {
            var     path      = new XNavMeshPath();
            Vector3 playerPos = localPlayer.transform.position;
            dst = PhysicsHelp.GetPosition(dst.x, dst.z);
            XNavMesh.CalculatePath(playerPos, dst, LevelManager.GetInstance().AreaExclude, path);
//            GameDebug.LogWarning("NavMesh.CalculatePath src: " + playerPos);
//            GameDebug.LogWarning("NavMesh.CalculatePath dst: " + dst);
//            GameDebug.LogWarning("NavMesh.CalculatePath status: " + path.status);
//            string str = "NavMesh.CalculatePath corners:";
//            for (int i = 0; i < path.corners.Length; ++i)
//            {
//                str += " " + path.corners[i];
//            }
//            GameDebug.LogWarning(str);
            if (path.status == XNavMeshPathStatus.PathComplete)
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 2
0
        void OnLoadDropObjectFinished(GameObject dropGameObject, PkgDropGive dropInfo, DropComponent.EDropType dropType)
        {
#if UNITY_EDITOR
            dropGameObject.name = string.Format("Drop_{0}_{1}", dropInfo.oid, dropInfo.gid);
#endif
            if (dropType == DropComponent.EDropType.Noncompetitive || dropInfo.pos == null)
            {
                dropGameObject.transform.position = InstanceDropManager.GetInstance().GenerateDropPosition(mDropPosition, 0);
            }
            else
            {
                //GameDebug.LogError("Create drop1 " + dropInfo.oid + ", pos " + dropInfo.pos.px * GlobalConst.UnitScale + " " + dropInfo.pos.py * GlobalConst.UnitScale);

                Vector3 pos = new Vector3((float)dropInfo.pos.px * GlobalConst.UnitScale, 0, (float)dropInfo.pos.py * GlobalConst.UnitScale);
                //pos.y = PhysicsHelp.GetHeight(pos.x, pos.z);
                //pos = InstanceHelper.ClampInWalkableRange(pos);
                pos.y = PhysicsHelp.GetHeight(pos.x, pos.z);
                dropGameObject.transform.position = pos;

                //GameDebug.LogError("Create drop2 " + dropInfo.oid + ", pos " + pos.ToString());
            }
            var dropComponent = dropGameObject.transform.Find("Mesh").GetComponent <DropComponent>();
            dropComponent.DropType = dropType;
            dropComponent.DropInfo = dropInfo;
            dropComponent.Init();
        }
Ejemplo n.º 3
0
        public void CreateDrops(List <PkgDropGive> drops, DropComponent.EDropType dropType, uint emId)
        {
            for (int i = 0; i < drops.Count; ++i)
            {
                var dropInfo = drops[i];

                // 经验直接拾取
                if (dropInfo.type == GameConst.GIVE_TYPE_EXP)
                {
                    C2SNwarPick msg = new C2SNwarPick();
                    msg.oid       = dropInfo.oid;
                    msg.drop_type = (uint)dropType;
                    NetClient.GetBaseClient().SendData <C2SNwarPick>(NetMsg.MSG_NWAR_PICK, msg);

                    continue;
                }

                if (dropType == DropComponent.EDropType.Noncompetitive && dropInfo.pos != null)
                {
                    Vector3 pos = new Vector3((float)dropInfo.pos.px * GlobalConst.UnitScale, 0, (float)dropInfo.pos.py * GlobalConst.UnitScale);
                    pos.y         = PhysicsHelp.GetHeight(pos.x, pos.z);
                    pos           = InstanceHelper.ClampInWalkableRange(pos);
                    mDropPosition = pos;
                }

                // 是否超过最大掉落数
                if (InstanceDropManager.Instance.DropNum < InstanceDropManager.Instance.MaxDropNum)
                {
                    //mLoadDropPrefabCoroutine.Add(SGameEngine.ResourceLoader.Instance.StartCoroutine(LoadDropObject(dropInfo, dropType)));

                    GameObject dropGameObject = (GameObject)xc.ObjCachePoolMgr.Instance.LoadFromCache(DropBehaviour.DropPrefabPoolType, DropBehaviour.DropObjectPrefabPoolKey);
                    if (dropGameObject == null)
                    {
                        dropGameObject = (GameObject)GameObject.Instantiate(InstanceDropManager.Instance.DropObjectTemplate);
                        if (dropGameObject != null)
                        {
                            PoolGameObject pg = dropGameObject.AddComponent <PoolGameObject>();
                            pg.poolType = DropBehaviour.DropPrefabPoolType;
                            pg.key      = DropBehaviour.DropObjectPrefabPoolKey;
                        }
                    }
                    if (dropGameObject != null)
                    {
                        dropGameObject.SetActive(true);
                        OnLoadDropObjectFinished(dropGameObject, dropInfo, dropType);
                    }
                    else
                    {
                        GameDebug.LogError("Create drop object error, is null!!!");
                    }
                }
                else
                {
                    GameDebug.LogError("Can not create drop" + dropInfo.oid + ", reach max num, current num is " + InstanceDropManager.Instance.DropNum + ", max num is " + InstanceDropManager.Instance.MaxDropNum);
                }
            }
        }
Ejemplo n.º 4
0
        public CollectionObject CreateCollectionObject(int id)
        {
            if (GetCollectionObject(id) != null)
            {
                RemoveCollectionObject(id);
            }
            Neptune.Collection collection = Neptune.DataManager.Instance.Data.GetNode <Neptune.Collection>(id);
            if (collection != null)
            {
                collection.Position = PhysicsHelp.GetPosition(collection.Position.x, collection.Position.z);
                return(CreateCollectionObject(collection));
            }

            return(null);
        }
Ejemplo n.º 5
0
        void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_NWAR_BAR_APPEAR:
            {
                S2CNwarBarAppear pack = S2CPackBase.DeserializePack <S2CNwarBarAppear>(data);

                foreach (PkgNwarBarPos barPos in pack.poss)
                {
                    if (GetCollectionObject((int)(barPos.bar_id)) != null)
                    {
                        RemoveCollectionObject((int)(barPos.bar_id));
                    }
                    Neptune.Collection collection = Neptune.DataManager.Instance.Data.GetNode <Neptune.Collection>((int)(barPos.bar_id));
                    if (collection != null)
                    {
                        collection.ExcelId  = barPos.type;
                        collection.Position = PhysicsHelp.GetPosition(barPos.pos.px * GlobalConst.UnitScale, barPos.pos.py * GlobalConst.UnitScale);
                        CreateCollectionObject(collection);
                    }
                    else
                    {
                        CreateCollectionObject((int)barPos.bar_id, barPos.type, PhysicsHelp.GetPosition(barPos.pos.px * GlobalConst.UnitScale, barPos.pos.py * GlobalConst.UnitScale));
                    }
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_COLLECTION_OBJECTS_COUNT_CHANGED, null);

                break;
            }

            case NetMsg.MSG_NWAR_BAR_DISAPPEAR:
            {
                S2CNwarBarDisappear pack = S2CPackBase.DeserializePack <S2CNwarBarDisappear>(data);

                RemoveCollectionObject((int)(pack.bar_id));

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_COLLECTION_OBJECTS_COUNT_CHANGED, null);

                break;
            }

            default:
                break;
            }
        }
Ejemplo n.º 6
0
            public void UpdateInfo(List <PkgBossInfo> boss_list)
            {
                if (m_bossArray == null)
                {
                    m_bossArray = new List <BossInfoItem>();
                }

                foreach (var boss_info in boss_list)
                {
                    if (mBossInfoAll != null)
                    {
                        var find_item = mBossInfoAll.Find((a) =>
                        {
                            if (a.id == boss_info.id)
                            {
                                return(true);
                            }
                            return(false);
                        });
                        if (find_item != null)
                        {
                            mBossInfoAll.Remove(find_item);
                        }
                        var protocol_info = RedefineBossInfo.GetInfo(boss_info);
                        mBossInfoAll.Add(protocol_info);
                    }

                    var data_mon_attr = DBManager.Instance.GetDB <DBSpecialMon>().GetData(boss_info.id);
                    if (data_mon_attr == null)
                    {
                        GameDebug.LogError("Cannot find special monster info,id:" + boss_info.id);
                        continue;
                    }

                    if (xc.SceneHelp.Instance.CurSceneID != data_mon_attr.DungeonId)
                    {
                        continue;
                    }

                    BossInfoItem tmp_item = new BossInfoItem();
                    tmp_item.m_pkgBossInfo = boss_info;
                    tmp_item.m_need_update_exchange_model = true;
                    tmp_item.m_uid = new InterObjectUnitID(InterObjectType.TOMB_STONE, tmp_item.m_pkgBossInfo.id);
                    if (tmp_item.m_pkgBossInfo.pos != null)
                    {
                        tmp_item.m_pos.x = tmp_item.m_pkgBossInfo.pos.px * 0.01f;
                        tmp_item.m_pos.z = tmp_item.m_pkgBossInfo.pos.py * 0.01f;
                    }
                    tmp_item.m_pos.y = PhysicsHelp.GetHeight(tmp_item.m_pos.x, tmp_item.m_pos.z);
                    if (tmp_item.m_pos.y < -500)
                    {
                        GameDebug.LogError(string.Format("[MSG_BOSS_INFO] boss_actor pos maybe is error new_pos = {0}, {1}, {2}",
                                                         tmp_item.m_pos.x, tmp_item.m_pos.y, tmp_item.m_pos.z));
                        tmp_item.m_pos.y = 0;
                        var local_player = Game.Instance.GetLocalPlayer();
                        if (local_player != null && local_player.transform != null)
                        {
                            tmp_item.m_pos.y = local_player.transform.position.y;
                        }
                    }
                    tmp_item.m_model_Quaternion = Quaternion.identity;
                    bool can_add_new_monster = true;
                    for (int index = 0; index < m_bossArray.Count; ++index)
                    {
                        BossInfoItem find_item = m_bossArray[index];
                        if (find_item.m_uid != null && find_item.m_uid.m_Idx == tmp_item.m_uid.m_Idx)
                        {
                            if (find_item.m_pkgBossInfo != null &&
                                find_item.m_pkgBossInfo.state == tmp_item.m_pkgBossInfo.state)
                            {
                                can_add_new_monster = false;
                            }
                            else
                            {
                                InterObjectManager.Instance.DestroyObject(find_item.m_uid);
                                m_bossArray.Remove(find_item);
                            }
                            break;
                        }
                    }
                    if (can_add_new_monster)
                    {
                        m_bossArray.Add(tmp_item);
                    }
                }
            }
Ejemplo n.º 7
0
        protected virtual void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_NWAR_PICK_BOSS_CHIP_START:
            {        //开始拾取
                //GameDebug.LogError("recv MSG_NWAR_PICK_BOSS_CHIP_START");
                var pack = S2CPackBase.DeserializePack <S2CNwarPickBossChipStart>(data);
                if (pack.action.uuid == Game.Instance.LocalPlayerTypeID)
                {
                    return;
                }
                if (SceneHelp.Instance.IsInWorldBossExperienceInstance)
                {
                    return;        //世界BOSS体验副本,不显示其他人的拾取操作
                }
                Actor actor = ActorManager.Instance.GetPlayer(pack.action.uuid);
                if (actor == null || actor.IsPlayer() == false)
                {
                    return;
                }
                Player player            = actor as Player;
                UnityEngine.Vector3 kPos = UnityEngine.Vector3.zero;
                kPos = PhysicsHelp.GetPosition(pack.action.pos.px / 100.0f, pack.action.pos.py / 100.0f);
                DropComponent drop_com = InstanceDropManager.Instance.GetDrop(pack.action.oid);
                if (drop_com != null && drop_com.transform.parent != null)
                {
                    kPos = drop_com.transform.position;
                }
                player.StartPickUpBossChipEffect(kPos);
            }
                return;

            case NetMsg.MSG_NWAR_PICK_BOSS_CHIP_STOP:
            {
                var pack = S2CPackBase.DeserializePack <S2CNwarPickBossChipStop>(data);

                Actor actor = ActorManager.Instance.GetPlayer(pack.uuid);
                if (actor == null || actor.IsPlayer() == false)
                {
                    return;
                }
                if (SceneHelp.Instance.IsInWorldBossExperienceInstance && actor.IsLocalPlayer == false)
                {
                    return;        //世界BOSS体验副本,不显示其他人的拾取操作
                }
                Player player = actor as Player;
                player.FinishPickUpEffect();
                if (pack.type == 0 && player.IsLocalPlayer)
                {        //如果是主角完成,需要发送拾取协议给后端 2017/12/28
                    FinishPickImmediately();
                    //if ((mDropInfo.type == GameConst.GIVE_TYPE_GOODS || mDropInfo.type == GameConst.GIVE_TYPE_EQUIP) && ItemManager.Instance.BagIsFull(1) == true)
                    //{
                    //    UINotice.Instance.ShowMessage(DBConstText.GetText("BAG_IS_FULL"));
                    //    return;
                    //}
                    //C2SNwarPick msg = new C2SNwarPick();
                    //msg.oid = mDropInfo.oid;
                    //msg.drop_type = mDropType;
                    //NetClient.GetBaseClient().SendData<C2SNwarPick>(NetMsg.MSG_NWAR_PICK, msg);
                    //mHasSendPickPackage = true;
                    //mSendPickPackageTime = Time.realtimeSinceStartup;
                    //xc.ui.ugui.UIManager.Instance.ShowWindow("UIBossFragmentsWindow", mDropInfo.gid, mDropInfo.num);
                }
            }
                return;

            default:
                break;
            }
        }