public static void OnMonsterAdd(int id, AiNetwork ai, Pathea.PeEntity entity) { EntityMonsterBeacon mbEntity = Pathea.EntityMgr.Instance.Get(id) as EntityMonsterBeacon; if (null != mbEntity) { mbEntity.OnMonsterCreated(entity); } else { if (null != entity) { Pathea.CommonCmpt cc = entity.GetCmpt <Pathea.CommonCmpt>(); if (cc != null) { AiTowerDefense td = AiTowerDefense.Get <AiTowerDefense>(id); if (null != td) { cc.TDpos = td._pos; } } Pathea.SkAliveEntity sae = entity.GetCmpt <Pathea.SkAliveEntity>(); if (sae != null) { sae.SetAttribute(Pathea.AttribType.DefaultPlayerID, 8); sae.SetAttribute(Pathea.AttribType.CampID, 26); } } } }
void CreateDroppableItemList() { if (_itemListsUpdated) { return; } _itemListsUpdated = true; //_itemLists.Add(this); // this will be added at the end of this method(foreach) Pathea.PeEntity entity = GetComponent <Pathea.PeEntity>(); if (null == entity) { return; } _skAlive = entity.GetCmpt <Pathea.SkAliveEntity>(); if (_skAlive == null || !_skAlive.isDead) { return; } if (Pathea.PeGameMgr.IsMulti) { return; } Pathea.CommonCmpt common = entity.GetCmpt <Pathea.CommonCmpt>(); if (common != null) { List <ItemSample> items = ItemDropData.GetDropItems(common.ItemDropId); if (common.entityProto.proto == Pathea.EEntityProto.Monster) { if (items == null) { items = GetSpecialItem.MonsterItemAdd(common.entityProto.protoId); } else { items.AddRange(GetSpecialItem.MonsterItemAdd(common.entityProto.protoId)); //特殊道具添加 } } if (items != null) { foreach (ItemSample item in items) { AddDroppableItem(item); } } } return; }
void OnOkBtn() { // if (DoSleep)//mDoSleep != null // { // mDoSleep((int)(((int)11 * mSleepSlider.scrollValue) + 1)); // ShowSleepWnd(false); // } // else // Hide(); if (m_PeSleep == null || mEntity == null) { return; } if (!m_PeSleep.CanOperateMask(Pathea.Operate.EOperationMask.Sleep)) { return; } Pathea.MotionMgrCmpt mmc = mEntity.GetCmpt <Pathea.MotionMgrCmpt>(); if (null != mmc && (mmc.IsActionRunning(Pathea.PEActionType.Sleep) || !mmc.CanDoAction(Pathea.PEActionType.Sleep))) { return; } SleepController.StartSleep(m_PeSleep, mEntity, GetCurSleepTime()); ShowSleepWnd(false); }
public bool RequestGetOnTrain(int routeId, int entityId) { if (!GameConfig.IsMultiMode) { return(DoGetOnTrain(entityId, routeId)); } else { Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(entityId); if (null == entity) { Debug.LogError("cant find entity:" + entityId); return(false); } Pathea.MotionMgrCmpt mmc = entity.GetCmpt <Pathea.MotionMgrCmpt>(); if (null == mmc) { Debug.LogError("no Pathea.RailPassengerCmpt"); return(false); } if (mmc.CanDoAction(Pathea.PEActionType.GetOnTrain)) { if (null != PlayerNetwork.mainPlayer) { PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_InGame_Railway_GetOnTrain, routeId, entityId); } } return(true); } }
public static Pathea.Replicator GetReplicator() { Pathea.PeEntity e = Pathea.PeCreature.Instance.mainPlayer; if (null == e) { return(null); } Pathea.ReplicatorCmpt c = e.GetCmpt <Pathea.ReplicatorCmpt>(); if (null == c) { return(null); } return(c.replicator); }
Vector2 GetPlayerPos() { if (mTrans == null) { Pathea.PeEntity entity = Pathea.PeCreature.Instance.mainPlayer; if (null != entity) { mTrans = entity.GetCmpt <Pathea.PeTrans>(); } } if (null != mTrans) { return(new Vector2(mTrans.position.x, mTrans.position.z)); } return(Vector2.zero); }
public bool DoGetOnTrain(int entityId, int routeId, bool checkState = true) { Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(entityId); if (null == entity) { Debug.LogError("cant find entity:" + entityId); return(false); } Pathea.PassengerCmpt passenger = entity.GetCmpt <Pathea.PassengerCmpt>(); if (null == passenger) { Debug.LogError("no Pathea.RailPassengerCmpt"); return(false); } return(passenger.GetOn(routeId, checkState)); }
void RPC_SO_InitData(uLink.BitStream stream, uLink.NetworkMessageInfo info) { ItemAsset.ItemObject itemObj = stream.Read <ItemAsset.ItemObject>(); _pos = transform.position = stream.Read <Vector3>(); rot = transform.rotation = stream.Read <Quaternion>(); if (null == itemObj) { return; } ItemAsset.Drag drag = itemObj.GetCmpt <ItemAsset.Drag>(); if (null == drag) { return; } DragArticleAgent item = DragArticleAgent.Create(drag, _pos, transform.localScale, rot, Id, this); if (item.itemLogic != null) { DragItemLogicFlag flag = item.itemLogic as DragItemLogicFlag; if (flag != null) { OnSpawned(flag.gameObject); Pathea.PeEntity FlagEntity = flag.gameObject.GetComponent <Pathea.PeEntity>(); if (null != FlagEntity) { Pathea.NetCmpt net = FlagEntity.GetCmpt <Pathea.NetCmpt>(); if (null == net) { net = FlagEntity.Add <Pathea.NetCmpt>(); } net.network = this; } } } OnResetFlag(); }
public bool DoGetOffTrain(int routeId, int entityId, Vector3 pos) { Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(entityId); if (null == entity) { Debug.LogError("cant find entity:" + entityId); return(false); } Pathea.PassengerCmpt passenger = entity.GetCmpt <Pathea.PassengerCmpt>(); if (null == passenger) { Debug.LogError("no Pathea.RailPassengerCmpt"); return(false); } if (passenger.railRouteId != routeId) { return(false); } return(passenger.GetOff(pos)); }
void UpdateMiniMap() { if (null == mView) { Pathea.PeEntity e = Pathea.PeCreature.Instance.mainPlayer; if (null != e) { mView = e.GetCmpt <Pathea.PeTrans>(); } } if (null != mView && GameUI.Instance.bVoxelComplete) { if (!GameConfig.IsInVCE) { if (!mMiniMapCam.targetTexture.IsCreated()) { mMiniMapCam.targetTexture.Create(); ReFlashMap(); } Vector3 pos = mView.position + 1000 * Vector3.up; pos.y = 0; //if (true) if (Vector3.Distance(pos, mMapCenterPos) > 62f || (GameTime.Timer.Second - mMapReFlashTime > 600.0)) // disable camera would cause unreasonable memory allocation { mMiniMapCam.enabled = true; mMapCenterPos = pos; mMiniMapCam.transform.position = mView.position + 300 * Vector3.up; mMapReFlashTime = GameTime.Timer.Second; } else { if (mMiniMapCam.enabled) { mMiniMapCam.enabled = false; } } mMiniMapTex.uvRect = new Rect((pos.x - mMapCenterPos.x) / 248f / mMiniMapCam.aspect + 0.25f, (pos.z - mMapCenterPos.z) / 248f + 0.25f, 0.5f / mMiniMapCam.aspect, 0.5f); float mCenter_x = Convert.ToSingle(0.5 + (pos.x - mMapCenterPos.x) / 248f); float mCenter_y = Convert.ToSingle(0.5 + (pos.z - mMapCenterPos.z) / 248f); mMiniMapTex.material.SetFloat("_Center_x", mCenter_x); mMiniMapTex.material.SetFloat("_Center_y", mCenter_y); mMiniMapTex.material.SetFloat("_Alpha", mMapAlpha); mMiniMapTex.material.SetFloat("_Bright", mMapBright); //float xfactor = (mMapSize.x - mMinSize.x)/(mMaxSize.x - mMinSize.x); //float yfactor = (mMapSize.y - mMinSize.y) / (mMaxSize.y - mMinSize.y); //mMiniMapTex.uvRect = new Rect((pos.x - mMapCenterPos.x) / 248f + ((1 - xfactor) * 0.5f), (pos.z - mMapCenterPos.z) / 248f + ((1 - xfactor) * 0.5f), xfactor, yfactor); //float mCenter_x = Convert.ToSingle(xfactor + (pos.x - mMapCenterPos.x) / 248f); //float mCenter_y = Convert.ToSingle(yfactor + (pos.z - mMapCenterPos.z) / 248f); //mMiniMapTex.material.SetFloat("_Center_x", mCenter_x); //mMiniMapTex.material.SetFloat("_Center_y", mCenter_y); //mMiniMapTex.material.SetFloat("_Alpha", mMapAlpha); //mMiniMapTex.material.SetFloat("_Bright", mMapBright); } } }
string DoEntityCmd(int id, string funcName, string[] args) { Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(id); if (null == entity) { return("can't find entity by id:" + id); } switch (funcName) { case "servant": Pathea.NpcCmpt npcCmpt = entity.GetCmpt <Pathea.NpcCmpt>(); if (npcCmpt == null) { return("no NpcCmpt."); } Pathea.ServantLeaderCmpt leader = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.ServantLeaderCmpt>(); if (leader == null) { return("no ServantLeaderCmpt"); } leader.AddServant(npcCmpt); npcCmpt.SetServantLeader(leader); return("ok"); case "start_skill": int targetId; if (!int.TryParse(args[0], out targetId)) { return("get target id failed"); } Pathea.PeEntity targetEntity = Pathea.EntityMgr.Instance.Get(targetId); Pathea.SkAliveEntity skillCmpt = targetEntity.GetCmpt <Pathea.SkAliveEntity>(); if (null == skillCmpt) { return("target have no SkillCmpt"); } int skillId; if (!int.TryParse(args[1], out skillId)) { return("get skill id failed"); } skillCmpt.StartSkill(skillCmpt, skillId); return("ok"); case "Kill": Pathea.PeEntity killEntity = Pathea.EntityMgr.Instance.Get(id); if (killEntity == null) { return("get entity failed with id : " + id); } killEntity.SetAttribute(Pathea.AttribType.Hp, 0.0f, false); return("ok"); //case "SetBool": // string animationName = args[0]; // bool value; // if (!bool.TryParse(args[1], out value)) // { // return "get value failed"; // } // entity.SetBool(animationName, value); // return "ok"; default: return("not implementd cmd"); } }
public void StartLoadScene() { for (int i = 0; i < 100; i++) { PeLauncher.Instance.Add(new GameLoader.Dummy()); } bFirstRun = true; PeLauncher.Instance.endLaunch = delegate() { if (PeGameMgr.IsMulti && !NetworkInterface.IsClient) { return(true); } if (bFirstRun) { bFirstRun = false; VFVoxelTerrain.TerrainVoxelComplete = false; return(false); } if (!VFVoxelTerrain.TerrainVoxelComplete) { return(false); } PeEntity mainPlayer = MainPlayer.Instance.entity; if (null == mainPlayer) { return(false); } MotionMgrCmpt motion = mainPlayer.GetCmpt <MotionMgrCmpt>(); if (motion == null) { return(false); } Vector3 safePos; if (PeGameMgr.IsMulti) { if (PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId == (int)Pathea.SingleGameStory.StoryScene.MainLand) { if (PETools.PE.FindHumanSafePos(mainPlayer.position, out safePos, 10)) { mainPlayer.position = safePos; motion.FreezePhySteateForSystem(false); } else { mainPlayer.position += 10 * Vector3.up; motion.FreezePhySteateForSystem(true); return(false); } } } else { if (PETools.PE.FindHumanSafePos(mainPlayer.position, out safePos, 10)) { mainPlayer.position = safePos; motion.FreezePhySteateForSystem(false); } else { mainPlayer.position += 10 * Vector3.up; motion.FreezePhySteateForSystem(true); return(false); } } Object.Destroy(gameObject); Resources.UnloadUnusedAssets(); System.GC.Collect(); return(true); }; PeLauncher.Instance.StartLoad(); }
public static void Update() { if (inited) { // System Settings SetGlobalFloat("Rotate Sensitivity", SystemSettingData.Instance.CameraSensitivity * 3.5f); SetGlobalFloat("Original Fov", SystemSettingData.Instance.CameraFov); SetGlobalBool("Inverse X", SystemSettingData.Instance.CameraHorizontalInverse); SetGlobalBool("Inverse Y", SystemSettingData.Instance.CameraVerticalInverse); // Character if (Pathea.MainPlayerCmpt.gMainPlayer != null) { Pathea.PeEntity entity = Pathea.MainPlayerCmpt.gMainPlayer.Entity; Pathea.BiologyViewCmpt vcmpt = entity.viewCmpt as Pathea.BiologyViewCmpt; Pathea.PeTrans trans = entity.peTrans; Pathea.PassengerCmpt psgr = entity.GetCmpt <Pathea.PassengerCmpt>(); SetTransform("Anchor", trans.camAnchor); if (vcmpt.monoModelCtrlr != null) { SetTransform("Character", Pathea.MainPlayerCmpt.gMainPlayer._camTarget); SetTransform("Bone Neck M", Pathea.MainPlayerCmpt.gMainPlayer._bneckModel); } if (vcmpt.monoRagdollCtrlr != null) { SetTransform("Bone Neck R", Pathea.MainPlayerCmpt.gMainPlayer._bneckRagdoll); } bool is_rag_doll = vcmpt.IsRagdoll; SetVar("Is Ragdoll", is_rag_doll); mainPlayerPosTracker.Record(trans.position, Time.time); SetVar("Character Velocity", mainPlayerPosTracker.aveVelocity); drivePosTracker.breakDistance = 10; drivePosTracker.maxRecord = 4; drivePosTracker.Record(trans.position, Time.time); SetVar("Driving Velocity", drivePosTracker.aveVelocity); SetVar("Rigidbody Velocity", drivePosTracker.aveVelocity); activitySpaceSize = Utils.EvaluateActivitySpaceSize(trans.camAnchor.position, 0.5f, 50f, Vector3.up, 4f, obstacle_layermask); SetVar("Activity Space Size", activitySpaceSize); // Some vars SetBool("Lock Cursor Mode", lockCursorMode || PeInput.UsingJoyStick); SetVar("Arouse Cursor", arouseCursor); SetVar("Roll Mode", Pathea.MainPlayerCmpt.isCameraRollable); if (GetVar("Build Mode").value_b) { //lz-2017.05.18 Tutorial模式下建造不允许进入自由视角 if (PeInput.Get(PeInput.LogicFunction.Build_FreeBuildModeOnOff) && !Pathea.PeGameMgr.IsTutorial) { freeLook = !freeLook; camc.CrossFade("Global Blend", freeLook ? 0 : 1, 0.3f); } } else { int mode = 1; if (psgr != null) { WhiteCat.CarrierController dc = psgr.drivingController; if (dc != null) { mode = 2; SetVar("Vehicle Arm", dc.isAttackMode); } } camc.CrossFade("Global Blend", mode, 0.3f); freeLook = false; } UpdateShake(); } // Internal Logic #if true if (PeInput.Get(PeInput.LogicFunction.ChangeContrlMode)) { if (SystemSettingData.Instance.FirstPersonCtrl) { // F3->F1 lockCursorMode = false; SystemSettingData.Instance.mMMOControlType = true; SystemSettingData.Instance.FirstPersonCtrl = false; SystemSettingData.Instance.dataDirty = true; if (onControlModeChange != null) { onControlModeChange.Invoke(ControlMode.ThirdPerson); } } else if (SystemSettingData.Instance.mMMOControlType) { // F1->F2 lockCursorMode = true; SystemSettingData.Instance.mMMOControlType = false; SystemSettingData.Instance.FirstPersonCtrl = false; SystemSettingData.Instance.dataDirty = true; if (onControlModeChange != null) { onControlModeChange.Invoke(ControlMode.MMOControl); } } else { // F2->F3 lockCursorMode = true; SystemSettingData.Instance.FirstPersonCtrl = true; SystemSettingData.Instance.dataDirty = true; if (onControlModeChange != null) { onControlModeChange.Invoke(ControlMode.FirstPerson); } } } #else if (PeInput.Get(PeInput.LogicFunction.F1Mode)) { lockCursorMode = false; SystemSettingData.Instance.mMMOControlType = true; SystemSettingData.Instance.FirstPersonCtrl = false; SystemSettingData.Instance.dataDirty = true; } else if (PeInput.Get(PeInput.LogicFunction.F2Mode)) { lockCursorMode = true; SystemSettingData.Instance.mMMOControlType = false; SystemSettingData.Instance.FirstPersonCtrl = false; SystemSettingData.Instance.dataDirty = true; } else if (PeInput.Get(PeInput.LogicFunction.F3Mode)) { lockCursorMode = true; SystemSettingData.Instance.FirstPersonCtrl = true; SystemSettingData.Instance.dataDirty = true; } #endif if (shootModeIndex == 0 && shootModeTime > 0) { shootModeTime -= Time.deltaTime; if (shootModeTime <= 0) { camc.CrossFade("3rd Person Blend", 0, 0.05f); camc.CrossFade("1st Person Blend", 0, 0.05f); } } if (isFirstPerson) { SetVar("1st Offset Up", camModeData.offsetUp); SetVar("1st Offset", camModeData.offset); SetVar("1st Offset Down", camModeData.offsetDown); } // Mouse states SetGlobalVar("Mouse On Scroll", UIMouseEvent.opAnyScroll); SetGlobalVar("Mouse On GUI", UIMouseEvent.onAnyGUI); SetGlobalVar("Mouse Op GUI", UIMouseEvent.opAnyGUI); } }