void RPC_S2C_GetItemBack(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int objId = stream.Read <int>(); DragItemAgent obj = DragItemAgent.GetById(objId); DragItemAgent.Destory(obj); }
protected override void RPC_S2C_Turn(uLink.BitStream stream, uLink.NetworkMessageInfo info) { transform.rotation = stream.Read <Quaternion>(); //if (null != _viewTrans) // _viewTrans.rotation = transform.rotation; CSBuildingLogic csbl = Runner.GetComponent <CSBuildingLogic>(); if (csbl != null) { DragItemAgent dia = DragItemAgent.GetById(csbl.id); dia.rotation = transform.rotation; } if (null != Runner) { CSEntityObject ceo = Runner.GetComponentInChildren <CSEntityObject>(); if (ceo != null) { if (csbl != null) { ceo.Init(csbl, ceo.m_Creator, false); } } DragItemMousePickColony itemscript = Runner.GetComponentInChildren <DragItemMousePickColony>(); if (itemscript != null) { itemscript.OnItemOpGUIHide(); } } }
// HP 变化事件 protected virtual void OnHpChange(float deltaHp, bool isDead) { if (isDead) { DragItemAgent item = DragItemAgent.GetById(GetComponent <DragItemLogicCreation>().id); SceneMan.RemoveSceneObj(item); ItemAsset.ItemMgr.Instance.DestroyItem(itemObject); } }
public static void DestroyAllInDungeon() { List <ISceneObjAgent> allItem = SceneMan.FindAllDragItemInDungeon(); for (int i = allItem.Count - 1; i >= 0; i--) { DragItemAgent.Destory(allItem[i] as DragItemAgent); } }
protected Vector3 GetPos() { DragItemAgent agent = DragItemAgent.GetById(id); if (agent == null) { return(Vector3.zero); } return(agent.position); }
public static bool Destory(DragItemAgent item) { if (null == item) { return(false); } SceneMan.RemoveSceneObj(item); item.Destroy(); return(true); }
public override void DoGetItem() { ItemAsset.MaterialItem[] items = itemList.GetItems(); if (null == pkg || !pkg.CanAdd(items)) { PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning); return; } if (!GameConfig.IsMultiMode) { for (int i = 0; i < items.Length; ++i) { pkgCmpt.Add(items[i].protoId, items[i].count); } ItemAsset.ItemMgr.Instance.DestroyItem(itemObjectId); DragItemAgent agent = DragItemAgent.GetById(id); if (agent != null) { DragItemAgent.Destory(agent); } GameUI.Instance.mItemPackageCtrl.ResetItem(); } else { //CommonInterface target = GetComponentInChildren<CommonInterface>(); //if (null == target || null == target.Netlayer) // return; //if (null != target.OwnerView) // PlayerFactory.mMainPlayer.RPCServer(EPacketType.PT_InGame_GetItemListBack, m_ItemID, // itemObjectId, target.OwnerView.viewID, mItemIDList.ToArray(), mNumList.ToArray()); if (null != PlayerNetwork.mainPlayer) { var getItems = items.Select(iter => new ItemAsset.ItemSample(iter.protoId, iter.count)).ToArray(); PlayerNetwork.mainPlayer.RequestGetItemListBack(itemObjectId, getItems); } } GameUI.Instance.mItemOp.Hide(); }
/// <summary> /// 删除一个特定的OBJECT /// </summary> /// <param name="obj">删除的特定Object</param> /// <returns></returns> public static bool RemoveObject(OBJECT obj) { if (!obj.isSpecificEntity) { return(false); } if (obj.isNpoId) { SpawnDataSource ds = PeCustomScene.Self.spawnData; if (ds.ContainMonster(obj.Id)) { SpawnPoint sp = ds.GetMonster(obj.Id); PeCustomScene.Self.RemoveSpawnPoint(sp); } else if (ds.ContainNpc(obj.Id)) { SpawnPoint sp = ds.GetNpc(obj.Id); PeCustomScene.Self.RemoveSpawnPoint(sp); } else if (ds.ContainDoodad(obj.Id)) { SpawnPoint sp = ds.GetDoodad(obj.Id); PeCustomScene.Self.RemoveSpawnPoint(sp); } else if (ds.ContainItem(obj.Id)) { ItemSpwanPoint sp = ds.GetItem(obj.Id); List <ISceneObjAgent> agents = SceneMan.GetSceneObjs <DragItemAgent>(); for (int i = 0; i < agents.Count; i++) { DragItemAgent drag_agent = agents[i] as DragItemAgent; if (drag_agent.itemDrag.itemObj.protoId == sp.Prototype && drag_agent.itemDrag.itemObj.instanceId == sp.ItemObjId) { DragItemAgent.Destory(drag_agent); } } } } return(false); }
public virtual void DoGetItem() { if (null == itemObj) { return; } if (!GameConfig.IsMultiMode) { if (Pathea.PlayerPackageCmpt.LockStackCount && !ItemMgr.IsCreationItem(itemObj.protoId)) { ItemMgr.Instance.DestroyItem(itemObj.instanceId); } else if (null != pkg) { if (ItemPackage.InvalidIndex == pkg.AddItem(itemObj)) { PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning); return; } if (MissionManager.Instance != null && Pathea.PeCreature.Instance != null && Pathea.PeCreature.Instance.mainPlayer != null) { MissionManager.Instance.ProcessUseItemMissionByID(itemObj.protoId, Pathea.PeCreature.Instance.mainPlayer.position, -1); } } DragItemAgent agent = DragItemAgent.GetById(id); if (agent != null) { DragItemAgent.Destory(agent); } GameUI.Instance.mItemPackageCtrl.ResetItem(); } else { if (null != PlayerNetwork.mainPlayer) { PlayerNetwork.mainPlayer.RequestGetItemBack(itemObjectId); } } HideItemOpGui(); }
public virtual void Turn90Degree() { if (GameConfig.IsMultiMode) { if (null != PlayerNetwork.mainPlayer) { PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_InGame_Turn, itemObjectId); } } else { DragItemAgent agent = DragItemAgent.GetById(id); if (agent != null) { agent.Rotate(new Vector3(0, 90f, 0)); } } }
void RPC_S2C_Turn(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int objId = stream.Read <int>(); Quaternion rot = stream.Read <Quaternion>(); DragItemAgent dia = DragItemAgent.GetById(objId); dia.rotation = rot; ItemObject item = dia.itemDrag.itemObj; if (null == item) { return; } //ISceneObjAgent obj = SceneMan.GetSceneObjById(objId); //if (obj.Equals(null)) // return; }
public void DestroyDungeon() { GeneralSet(false); SceneMan.AddTerrainDependence(); if (generator != null && generator.CurrentDungeon != null && generator.CurrentDungeon.gameObject != null) { UnityUtil.Destroy(generator.CurrentDungeon.gameObject); } RandomDungenMgrData.Clear(); if (PeGameMgr.IsMulti) { ChangeOther(false); ResetPathFinding(); } if (dungeonWater != null) { GameObject.Destroy(dungeonWater); } FBSafePlane.instance.DeleteCol(); DragItemAgent.DestroyAllInDungeon(); }
public override void OnActivate() { base.OnActivate(); if (_entityBcn != null) { Debug.LogError("[MonsterBeaconItem]:MonsterBeacon has existed."); return; } //Put off aispawn tower defense int entityId = GameConfig.IsMultiMode ? id : -1; _entityBcn = EntityMonsterBeacon.CreateMonsterBeaconByTDID(m_monsterBeaconId, transform, new TowerInfoUIData(), entityId, null, -1, true); if (_entityBcn != null) { _entityBcn.handlerNewWave += OnNewWave; _agent = DragItemAgent.GetById(id); if (_agent != null) { SceneMan.RemoveSceneObj(_agent); // Not been managed by sceneMan } } }
/// <summary> /// 删除指定范围内Object /// </summary> /// <param name="proto">Object类型</param> /// <param name="range">删除范围</param> /// <returns></returns> public static bool RemoveObjects(OBJECT proto, RANGE range) { if (!proto.isPrototype) { return(false); } if (proto.isAnyPrototype) { SpawnDataSource data = PeCustomScene.Self.spawnData; if (proto.type == OBJECT.OBJECTTYPE.MonsterProto) { // Monster point _tempSPList.Clear(); foreach (var kvp in data.monsters) { if (range.Contains(kvp.Value.entityPos)) { _tempSPList.Add(kvp.Value); } } for (int i = 0; i < _tempSPList.Count; i++) { PeCustomScene.Self.RemoveSpawnPoint(_tempSPList[i]); } _tempSPList.Clear(); // Monster area foreach (var kvp in data.areas) { for (int i = 0; i < kvp.Value.Spawns.Count; i++) { for (int j = 0; j < kvp.Value.Spawns[i].spawnPoints.Count; j++) { MonsterSpawnPoint msp = kvp.Value.Spawns[i].spawnPoints[j]; if (range.Contains(msp.entityPos)) { if (msp.EntityID != -1) { CreatureMgr.Instance.Destory(msp.EntityID); } } } } } } else if (proto.type == OBJECT.OBJECTTYPE.ItemProto) { List <ISceneObjAgent> agents = SceneMan.GetSceneObjs <DragItemAgent>(); for (int i = 0; i < agents.Count; i++) { DragItemAgent drag_agent = agents[i] as DragItemAgent; if (range.Contains(drag_agent.position)) { DragItemAgent.Destory(drag_agent); } } } } else { SpawnDataSource data = PeCustomScene.Self.spawnData; if (proto.type == OBJECT.OBJECTTYPE.MonsterProto) { // Monster point _tempSPList.Clear(); foreach (var kvp in data.monsters) { if (kvp.Value.Prototype == proto.Id && range.Contains(kvp.Value.entityPos)) { _tempSPList.Add(kvp.Value); } } for (int i = 0; i < _tempSPList.Count; i++) { PeCustomScene.Self.RemoveSpawnPoint(_tempSPList[i]); } _tempSPList.Clear(); // Monster area foreach (var kvp in data.areas) { for (int i = 0; i < kvp.Value.Spawns.Count; i++) { for (int j = 0; j < kvp.Value.Spawns[i].spawnPoints.Count; j++) { MonsterSpawnPoint msp = kvp.Value.Spawns[i].spawnPoints[j]; if (kvp.Value.Prototype == proto.Id && range.Contains(msp.entityPos)) { if (msp.EntityID != -1) { CreatureMgr.Instance.Destory(msp.EntityID); } } } } } } else if (proto.type == OBJECT.OBJECTTYPE.ItemProto) { List <ISceneObjAgent> agents = SceneMan.GetSceneObjs <DragArticleAgent>(); for (int i = 0; i < agents.Count; i++) { DragArticleAgent drag_agent = agents[i] as DragArticleAgent; if (drag_agent.itemDrag.itemObj.protoId == proto.Id && range.Contains(drag_agent.position)) { DragItemAgent.Destory(drag_agent); } } } } return(true); }
private void DestroySelf() { DragItemAgent.Destory(_agent); }
public static bool Destory(int id) { DragItemAgent item = GetById(id); return(Destory(item)); }
protected override void FixPosByItemBounds(Ray cameraRay) { if (null == itemBounds) { mOverlaped = false; return; } if (!mRayHitTerrain) { itemBounds.activeState = false; return; } mHitPos.x = Mathf.RoundToInt(mHitPos.x); mHitPos.y -= 0.1f; mHitPos.z = Mathf.RoundToInt(mHitPos.z); SetPos(mHitPos); CloseItemBounds(); if (null == mFindBounds) { mFindBounds = new List <ItemDraggingBounds> (); } List <ISceneObjAgent> sceneObjs = SceneMan.GetActiveSceneObjs(typeof(DragItemAgent), true); float curDis; bool rayHitBounds = false; Bounds selfBounds = itemBounds.worldBounds; selfBounds.size -= 0.01f * Vector3.one; Bounds otherBounds; for (int i = 0; i < sceneObjs.Count; ++i) { DragItemAgent dragItem = sceneObjs[i] as DragItemAgent; if (null != dragItem.gameObject) { ItemDraggingBounds checkBounds = dragItem.gameObject.GetComponentInChildren <ItemDraggingBounds>(); if (null != checkBounds) { otherBounds = checkBounds.worldBounds; mFindBounds.Add(checkBounds); if (otherBounds.IntersectRay(cameraRay, out curDis) && curDis <= mMinDis + 0.05f && Vector3.Distance(playerPos, cameraRay.origin + curDis * cameraRay.direction.normalized) < DraggingDistance) { mTooFar = false; mMinDis = curDis; mAdsorbItemBounds = checkBounds; mHitPos = cameraRay.origin + curDis * cameraRay.direction.normalized; rayHitBounds = true; } if (mRayHitTerrain && otherBounds.Intersects(selfBounds)) { mAdsorbItemBounds = checkBounds; } } } } if (null != mAdsorbItemBounds) { SetPos(mHitPos); mFindBounds.Remove(mAdsorbItemBounds); mAdsorbItemBounds.showBounds = true; mAdsorbItemBounds.activeState = true; otherBounds = mAdsorbItemBounds.worldBounds; bool hitLeft = false, hitRight = false, hitFront = false, hitBack = false, hitTop = false, hitBottom = false; if (rayHitBounds) { rootGameObject.transform.position = mHitPos; selfBounds = itemBounds.worldBounds; if (Mathf.Abs(mHitPos.x - otherBounds.min.x) < 0.01f) { hitLeft = true; } else if (Mathf.Abs(mHitPos.x - otherBounds.max.x) < 0.01f) { hitRight = true; } else if (Mathf.Abs(mHitPos.z - otherBounds.max.z) < 0.01f) { hitBack = true; } else if (Mathf.Abs(mHitPos.z - otherBounds.min.z) < 0.01f) { hitFront = true; } else if (Mathf.Abs(mHitPos.y - otherBounds.min.y) < 0.01f) { hitBottom = true; } else if (Mathf.Abs(mHitPos.y - otherBounds.max.y) < 0.01f) { hitTop = true; } } else { float maxDS = 100f; if (Mathf.Abs(selfBounds.max.x - otherBounds.min.x) < maxDS) { hitLeft = true; maxDS = Mathf.Abs(selfBounds.max.x - otherBounds.min.x); } if (Mathf.Abs(selfBounds.min.x - otherBounds.max.x) < maxDS) { hitLeft = false; hitRight = true; maxDS = Mathf.Abs(selfBounds.min.x - otherBounds.max.x); } if (Mathf.Abs(selfBounds.min.z - otherBounds.max.z) < maxDS) { hitLeft = false; hitRight = false; hitBack = true; maxDS = Mathf.Abs(selfBounds.min.z - otherBounds.max.z); } if (Mathf.Abs(selfBounds.max.z - otherBounds.min.z) < maxDS) { hitLeft = false; hitRight = false; hitBack = false; hitFront = true; } } if (hitLeft) { mHitPos += (otherBounds.min.x - selfBounds.max.x) * Vector3.right; mHitPos.x = Mathf.FloorToInt(mHitPos.x); } else if (hitRight) { mHitPos += (otherBounds.max.x - selfBounds.min.x) * Vector3.right; mHitPos.x = Mathf.CeilToInt(mHitPos.x); } else if (hitFront) { mHitPos += (otherBounds.min.z - selfBounds.max.z) * Vector3.forward; mHitPos.z = Mathf.FloorToInt(mHitPos.z); } else if (hitBack) { mHitPos += (otherBounds.max.z - selfBounds.min.z) * Vector3.forward; mHitPos.z = Mathf.CeilToInt(mHitPos.z); } else if (hitTop) { mHitPos += (otherBounds.max.y - selfBounds.min.y) * Vector3.up; } else if (hitBottom) { mHitPos += (otherBounds.min.y - selfBounds.max.y) * Vector3.up; } mHitPos.x = Mathf.RoundToInt(mHitPos.x); mHitPos.y -= 0.1f; mHitPos.z = Mathf.RoundToInt(mHitPos.z); if (Physics.Raycast(mHitPos + Vector3.up, Vector3.down, out fhitInfo, 10f, layerMask)) { mHitPos.y = fhitInfo.point.y; } SetPos(mHitPos); if (hitTop || hitBottom) { mOverlaped = true; itemBounds.activeState = false; return; } selfBounds = itemBounds.worldBounds; selfBounds.size -= 0.01f * Vector3.one; for (int i = 0; i < mFindBounds.Count; ++i) { if (null != mFindBounds[i] && selfBounds.Intersects(mFindBounds[i].worldBounds)) { mOverlaped = true; itemBounds.activeState = false; mOverlapedItemBounds = mFindBounds[i]; mOverlapedItemBounds.showBounds = true; mOverlapedItemBounds.activeState = false; mFindBounds.Clear(); return; } } } if (!checkTerrain(mHitPos)) { mOverlaped = true; itemBounds.activeState = false; return; } mFindBounds.Clear(); mOverlaped = false; itemBounds.activeState = true; }