Пример #1
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();
        }
Пример #2
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);
                }
            }
        }
Пример #3
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);
                    }
                }
            }