protected virtual void OnPickDrop(CEventBaseArgs data) { CEventObjectArgs args = (CEventObjectArgs)data; PkgDropGive dropInfo = (PkgDropGive)args.Value[0]; uint dropType = (uint)args.Value[1]; GameObject dropGameObject = (GameObject)args.Value[2]; if (dropType == 0) { GameDebug.LogError("Can not this drop " + dropInfo.oid + ", because it's drop type is zero!!!"); return; } C2SNwarPick msg = new C2SNwarPick(); msg.oid = dropInfo.oid; msg.drop_type = dropType; NetClient.GetBaseClient().SendData <C2SNwarPick>(NetMsg.MSG_NWAR_PICK, msg); //GameDebug.LogError("Send MSG_NWAR_PICK: " + msg.oid + ", " + msg.drop_type); //// 使碰撞体失效 //dropGameObject.transform.Find("Mesh").GetComponent<SphereCollider>().enabled = false; //int delayTime = 1000; //mTimerList.Add(new Utils.Timer(delayTime, false, delayTime, PickDropImpl, tfArgs)); }
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); } } }
void FinishPickImmediately() { if (mDropInfo == null) { return; } 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; }