public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineShuttle).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateShuttleGobackCalcPath.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "Shuttle_{0}_{1}_{2}", entity.entityID, (ShuttleState)this.preStateName, (ShuttleState)this.stateName); isStateShuttleGobackDynamicPath = false; MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastAfterExtendSceneAndModifiedPath, this.OnBroadcastAfterExtendSceneAndModifiedPath); //var cfgPath = PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().Path_ShuttleGobackDynamic); //var pathList = new List<Vector3>(); //pathList.Add(entity.position); //pathList.AddRange(cfgPath); //entity.followPath.Init(entity, pathList.ToArray(), pathList[0], 0, entity.moveSpeed, false); //entity.followPath.Run(); var cfgPathStatic = PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().Path_ShuttleGobackStatic); var cfgPathDynamic = PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().Path_ShuttleGobackDynamic); //var pathList = new List<Vector3>(); entity.pathList.Clear(); entity.pathList.AddRange(cfgPathStatic); entity.pathList.Add(cfgPathDynamic[0]); entity.followPath.Init(entity, entity.pathList, entity.pathList[0], 0, entity.moveSpeed, false); entity.followPath.Run(); }
public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineShuttle).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateShuttleGotoCalcPath.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "Shuttle_{0}_{1}_{2}", entity.entityID, (ShuttleState)this.preStateName, (ShuttleState)this.stateName); isToStateShuttleGobackCalcPath = false; getOffAccumulativeTime = 0; lastVisitorIdx = 0; isGetOff = false; shuttleVisitorGetOffInterval = Math_F.FloatToInt1000(Config.globalConfig.getInstace().ShuttleVisitorGetOffInterval); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); //var cfgPath = PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().Path_ShuttleGotoStatuc); //var pathList = new List<Vector3>(); //pathList.Add(entity.position); //pathList.AddRange(cfgPath); //entity.followPath.Init(entity, pathList.ToArray(), pathList[0], 0, entity.moveSpeed, false); //entity.followPath.Run(); var cfgPathGoback = PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().Path_ShuttleGobackStatic); entity.pathList.Clear(); //var pathList = new List<Vector3>(); entity.pathList.Add(entity.position); entity.pathList.Add(cfgPathGoback[0]); entity.followPath.Init(entity, entity.pathList, entity.pathList[0], 0, entity.moveSpeed, false); entity.followPath.Run(); }
protected void OnArrived(Message msg) { var _msg = (MessageArrived)msg; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; //自己的entity if (_msg.followPath.ownerEntity.entityID != entity.entityID) { return; } //到达终点, 游客消失,地上游客地上发车,地下游客地下发车,广告游客什么车都不发 if (_msg.followPath.isArrivedEnd) { if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car) { DebugFile.GetInstance().WriteKeyFile("FromUnder_", "{0}", entity.entityID); MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo); } else if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_GroundParking) { MessageGroundParkingSpace.Send((int)GameMessageDefine.BroadcastLetGroundParingCarLeave, entity.groundParkingGroupID, entity.groundParkingIdx); } // 回POOL EntityManager.GetInstance().RemoveFromEntityMovables(entity); } }
public override void Enter(int preStateName) { //LogWarp.LogError("StateVisitorChoseLittleZoo.Enter"); base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorChoseLittleZoo.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); MessageManager.GetInstance().Regist((int)GameMessageDefine.VisitorGetRandomLittleZooReply, OnVisitorGetRandomLittleZooReply); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); isToEnterLittleZooApply = false; isToStateVisitorLeaveNonLittleZoo = false; isToStateVisitorLeaveFromZooEntry = false; isArrivedLittleZoo = false; isArrivedStartOfPath = false; if (preStateName == (int)VisitorState.StayFirstPosInEntryQueue) { isArrivedStartOfPath = true; } var msg = VisitorGetRandomLittleZooApply.Send(entity.entityID, this.preStateName == (int)VisitorState.StayFirstPosInEntryQueue); }
protected void OnSendExitGateCheckinCDFinish(Message msg) { var _msg = msg as SendExitGateCheckinCDFinish; var exitGate = exitGates[_msg.entryID]; int entityID = exitGate.RemoveVisitorFromQueue(); //int entityID = exitGate.visitorQueue.Dequeue(); LogWarp.LogFormat("{0} Parkingmodule recv {1}", _msg.entityID, _msg); DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "{0} Parkingmodule recv {1}", _msg.entityID, _msg); #if UNITY_EDITOR if (entityID != _msg.entityID) { string e = string.Format("出口排队异常 entityID={0}, _msg.entityID={1}", entityID, _msg.entityID); throw new System.Exception(e); } #endif broadcastEntityIDs.Clear(); foreach (var val in exitGate.visitorQueue) { this.broadcastEntityIDs.Add(val); DebugFile.GetInstance().WriteKeyFile(val, "{0} BroadcastForwardOneStepInExitGateQueue by {1}", val, entityID); } BroadcastForwardOneStepInExitGateQueue.Send(broadcastEntityIDs); SendExitGateCheckinCDFinishReply.Send(_msg.entityID); AlterValue(_msg.entryID); }
public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoParking.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived); Vector3 startPos = Vector3.zero; if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car) { PathManager.GetInstance().GetPathFirstPos(Config.globalConfig.getInstace().ShuttleVisitorLeavePath, ref startPos); entity.position = startPos; EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().ShuttleVisitorLeavePath); return; } PathManager.GetInstance().GetPathFirstPos(Config.globalConfig.getInstace().AdvertVisitorLeavePath, ref startPos); entity.position = startPos; EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().AdvertVisitorLeavePath); }
public void Init(float animalAnimationSpeed, float animalMoveSpeed, int idxInTeam, float animalAcceleration, float rotateSpeed) { this.animalAnimationSpeed = animalAnimationSpeed; this.moveSpeed = animalMoveSpeed * 0.001f; this.moveSpeedBak = this.moveSpeed; this.animalAccelerationMS = animalAcceleration * 0.001f; this.rotateSpeedMS = rotateSpeed * 0.001f; this.idxInTeam = idxInTeam; isMoving = false; isPassedRoad = false; isArrivedNextRoadPos = false; arrivedLastPos = false; isRotateback = false; isRotateForward = false; rotateAngle = 0f; waitFrameCount = 0; //var a = roadModel.animalRoadSegment[roadModel.animalRoadSegment.Count - 1]; //var b = roadModel.crossRoadRectArea[roadModel.animalRoadSegment.Count - 1].height; //Debug.LogError(a + b * Vector3.forward + Vector3.forward * standardAnimalBoxSize.z); if (fsm == null) { fsm = new FSMCrossRoadAnimal(this); fsm.AddState(new StateCrossRoadAnimalIdle((int)FSMCrossRoadAnimalState.Idle, fsm)); fsm.AddState(new StateCrossRoadAnimalCrossRoad((int)FSMCrossRoadAnimalState.CrossRoad, fsm)); fsm.AddState(new StateCrossRoadRunToEndPoint((int)FSMCrossRoadAnimalState.RunToEndPoint, fsm)); } fsm.GotoState((int)FSMCrossRoadAnimalState.Idle); fsm.Run(); DebugFile.GetInstance().MarkGameObject(mainGameObject, "Animal-{0}", idxInTeam); }
public Config.npcactionCell PlayActionAnim() { int idx = Const.Invalid_Int; Math_F.TableProbability(animWeight, ref idx); #if UNITY_EDITOR if (idx == Const.Invalid_Int) { string e = string.Format("随机动画异常{0}", mainGameObject.name); throw new System.Exception(e); } #endif //var cell = Config.npcactionConfig.getInstace().getCell(idx); var cell = GlobalDataManager.GetInstance().logicTableVisitorAction.actionList[idx]; #if UNITY_EDITOR if (cell == null) { string e = string.Format("随机动画异常{0}, {1}", mainGameObject.name, idx); throw new System.Exception(e); } #endif anim.Play(cell.actionname); DebugFile.GetInstance().WriteKeyFile(entityID, "{0} PlayAnim {1}", entityID, cell.actionname); return(cell); }
public void AfterTickMoveables() { foreach (var v in this.entityMovableRemoves) { bool retCode = entityMovables.Remove(v.entityID); #if UNITY_EDITOR if (!retCode) { string e = string.Format("{0} AfterTickMoveables 异常{1}", v.entityID, v.mainGameObject.name); throw new System.Exception(e); } #endif DebugFile.GetInstance().WriteKeyFile(v.entityID, "{0} AfterTickMoveables {1}", v.entityID, v.mainGameObject.GetInstanceID()); DebugFile.GetInstance().WriteKeyFile(v.mainGameObject.GetInstanceID(), "{0} AfterTickMoveables {1}", v.mainGameObject.GetInstanceID(), v.entityID); EntityFuncType eEntityFuncType = (EntityFuncType)v.entityFuncType; switch (eEntityFuncType) { case EntityFuncType.CrossRoadCar: CrossRoadGame.EntityCrossRoadCar.pool.Delete(v as CrossRoadGame.EntityCrossRoadCar); break; case EntityFuncType.Animal_LittleGame: EntityCrossRoadAnimal.pool.Delete(v as CrossRoadGame.EntityCrossRoadAnimal); break; default: string e = string.Format("没有这种 EntityFuncType {0}", eEntityFuncType); throw new System.Exception(e); } } entityMovableRemoves.Clear(); }
protected void OnArrived(Message msg) { var _msg = (MessageArrived)msg; //自己的entity var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; if (_msg.followPath.ownerEntity.entityID != entity.entityID) { return; } //到达观察点 if (_msg.followPath.isArrivedEnd && !isArrivedObservePos) { isArrivedObservePos = true; //请求占位 var toMsg = AddVisitorToEntryQueuePlaceHolderApply.Send(entity.entityID); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态,发送{1}", entity.entityID, toMsg); return; } //到达终点 if (_msg.followPath.isArrivedEnd) { //转排队状态 //LogWarp.LogErrorFormat("{0} 在VisitorGotoZooEntry状态 准备转 VisitorStateEntryQueue状态", entity.entityID); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态 准备转 VisitorStateEntryQueue状态", entity.entityID); this.isToVisitorStateEntryQueue = true; } }
void OnGUI() { if (GUI.Button(new Rect(10, 100, 200, 50), "Cross Road Camera")) { TestCamera(); } if (GUI.Button(new Rect(10, 200, 200, 50), "Back To Zoo")) { CrossRoadStageManager.GetInstance().UnLoad(); ZooGameLoader.GetInstance().BackFromCrossRoad(); } if (GUI.Button(new Rect(10, 300, 200, 50), "New Stage")) { CrossRoadStageManager.GetInstance().UnLoad(); CrossRoadStageManager.GetInstance().Load(1); DebugFile.GetInstance().ClearAllFiles(); } if (GUI.Button(new Rect(10, 400, 200, 50), "Retry")) { //todo 本关卡复活 //动物卸载,并重新加载 //相机回到初始 MessageManager.GetInstance().Send((int)GameMessageDefine.IncreaseCrossRoadStageID); } }
protected void OnArrived(Message msg) { var _msg = (MessageArrived)msg; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; //自己的entity if (_msg.followPath.ownerEntity.entityID != entity.entityID) { return; } if (_msg.followPath.isArrivedEnd) { EntityManager.GetInstance().RemoveFromEntityMovables(entity); //通知生成离开的汽车 //MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo); //通知生成离开的汽车 if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car) { DebugFile.GetInstance().WriteKeyFile("FromUnder_", "{0}", entity.entityID); MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo); } } }
protected void ArrivedVisitorCar(FollowPathRightAngles followPath, EntityFuncType entityFuncType) { DebugFile.GetInstance().WriteKeyFile(followPath.ownerEntity.entityID, "{0} {1} ArrivedVisitorCar", followPath.ownerEntity.entityID, entityFuncType); var entity = followPath.ownerEntity as EntityVisitorCar; EntityManager.GetInstance().RemoveFromEntityMovables(entity); // 生成游客 LogWarp.Log("car -> visistor"); switch (entityFuncType) { case EntityFuncType.VisitorCar_EnterZoo: //车到了,刷下游客停车场数量 numShowParking--; ShowLeftParkingNum(numShowParking); SpawnVisitorFromCar.Send(VisitorStage.GotoZoo, EntityFuncType.Visitor_From_Car); #if DEBUG_VISIT BroadcastNum.Send((int)GameMessageDefine.BroadcastVisitorNum, numGroundParkingCar + numUnderParkingCar, 0f, 0); BroadcastNum.Send((int)GameMessageDefine.BroadcastMaxVisitorNum, numMaxParking, 0f, 0); #endif break; case EntityFuncType.VisitorCar_LeaveZoo: break; } }
protected void OnAddVisitorToExitGateQueueApplyReply(Message msg) { var _msg = msg as AddVisitorToExitGateQueueApplyReply; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; if (_msg.entityID != entity.entityID) { return; } DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "{0} 收到 {1}", _msg.entityID, msg); //出口排队申请失败,转从大门走状态 if (!_msg.result) { isToStateVisitorLeaveFromZooEntry = true; return; } entity.ExitGateEntryID = _msg.entryID; entity.indexInExitGateEntryQueue = _msg.indexInQueue; //从buildUp表中取第一段路 //0 正 //1 反 var cell = Config.buildupConfig.getInstace().getCell(entity.stayBuildingID); EntityVisitor.GotoStartOfPath(entity, cell.outpath); }
/// <summary> /// CD 结束 发送消息 /// </summary> protected void WhenCDFinished() { var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; var msg = EntryGateCheckInCDFinshedApply.Send(entity.entityID, entity.zooEntryID); isSendCDFinshed = true; if (GlobalData.GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true) { UIGuidePage uIGuidePage = PageMgr.GetPage <UIGuidePage>(); if (uIGuidePage == null) { string e = string.Format("新手引导界面 PageMgr.allPages里 UIGuidePage 为空"); throw new System.Exception(e); } if (uIGuidePage.newBieGuild_step == NewBieGuild.Step_15) { PageMgr.ShowPage <UIGuidePage>(); //开启新手引导UI } else if (uIGuidePage.newBieGuild_step < NewBieGuild.Step_15) { uIGuidePage.TAEvent_finish(); uIGuidePage.newBieGuild_step = NewBieGuild.Step_15; uIGuidePage.TAEvent_start(); //本阶段显示文本 uIGuidePage.TAEvent_process(); uIGuidePage.OnClickDialogBoxButton(); } } DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} WhenCDFinished send {1}", entity.entityID, msg); }
public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoGroundParking.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived); #if UNITY_EDITOR if (entity.entityFuncType != (int)EntityFuncType.Visitor_From_GroundParking) { string e = string.Format("{0}这里必须是地面停车场来的游客", entity.entityID); throw new System.Exception(e); } #endif //先走完基路 isFinishedBasePath = false; EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().GroundParkingVistorBasePath); ////构建去地面停车场的路 //List<Vector3> pathList = null; //var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx); //if (!GroundParingSpacePathManager.IsExist(pathUnit.visitorBackPath)) //{ // pathList = GroundParingSpacePathManager.GenVisitorBackPath(entity.groundParkingGroupID, entity.groundParkingIdx); // GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.VisitorBackPath, pathUnit, pathList, null); //} //pathList = pathUnit.visitorBackPath; //EntityVisitor.GodownPath(entity, pathList); }
public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorLeaveNonLittleZoo.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); isToStateVisitorLeaveFromZooEntry = false; isToStateVisitorGotoStartOfExitGateEntryPath = false; entity.ExitGateEntryID = Const.Invalid_Int; entity.indexInExitGateEntryQueue = Const.Invalid_Int; //MessageManager.GetInstance().Regist((int)GameMessageDefine.AddVisitorToExitGateQueueApplyReply, // OnAddVisitorToExitGateQueueApplyReply); //MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); //MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastForwardOneStepInExitGateQueue, // OnBroadcastForwardOneStepInExitGateQueue); //改成不去出口排队了,直接从前门离开 //AddVisitorToExitGateQueueApply.Send(entity.entityID); isToStateVisitorLeaveFromZooEntry = true; entity.moveSpeed = Config.globalConfig.getInstace().ZooVisitorBackSpeed; }
public override void Enter(int preStateName) { //LogWarp.LogError("StateVisitorStayWaitSeat.Enter"); base.Enter(preStateName); isToStateVisitorStayVisitSeat = false; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; //等待位看向前面 entity.LookAt(entity.position + GlobalDataManager.GetInstance().SceneForward); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorStayWaitSeat.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} Play {1}", entity.entityID, Config.globalConfig.getInstace().VisitorIdle); entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorIdle); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived); MessageManager.GetInstance().Regist((int)GameMessageDefine.WaitSeatToVisitSeat, OnWaitSeatToVisitSeat); //以进入就检查是否已经在上一个状态收到观光位WaitSeatToVisitSeat if (entity.isApproveVisitSeat) { GotoVisitSeat(entity, entity.stayBuildingID, entity.indexInVisitQueue); return; } }
/// <summary> /// 在这个状态收到这个消息,被通知走到观光位,说明在去等待位的途中就收到了, /// 直接设置标志位,在下一个状态处理 /// </summary> /// <param name="msg"></param> protected void OnWaitSeatToVisitSeat(Message msg) { var _msg = msg as WaitSeatToVisitSeat; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; //不是自己的 if (_msg.entityID != entity.entityID) { return; } LogWarp.LogFormat("途中收到去观光位 排位{0}", _msg.indexInVisitQueue); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0}在状态StateVisitorChoseLittleZoo 收到{1}, tickCount={2}", entity.entityID, msg, GameManager.GetInstance().tickCount); entity.isApproveVisitSeat = true; entity.indexInVisitQueue = _msg.indexInVisitQueue; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0}在状态StateVisitorChoseLittleZoo, 收到{1}, entity.followPath.isArrivedEnd={2}, tickCount={3}", entity.entityID, msg, entity.followPath.isArrivedEnd, GameManager.GetInstance().tickCount); if (entity.followPath.isArrivedEnd) { DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0}在状态StateVisitorChoseLittleZoo, 并且处于到达状态 收到{1}", entity.entityID, msg); } }
protected void OnEntryGateCheckInCDFinshedApply(Message msg) { var _msg = msg as EntryGateCheckInCDFinshedApply; EntryGate entryGate = null; if (!this.entryGates.TryGetValue(_msg.entryID, out entryGate)) { #if UNITY_EDITOR string e = string.Format("{0} 找不到入口ID {1}", _msg.entityID, _msg.entryID); throw new System.Exception(e); #endif } bool retCode = entryGate.RemoveVisitorFromQueue(_msg.entityID); #if UNITY_EDITOR if (!retCode) { string e = string.Format("{0} cd结束, 入口{1}队伍中没有它", _msg.entityID, _msg.entryID); throw new System.Exception(e); } #endif EntryGateCheckInCDFinshedReply.Send(_msg.entityID); //通知队伍中除了自己之外已经有正式位置的往前移动一步 var sendMsg = BroadcastForwardOneStepInQueue.Send((int)(GameMessageDefine.BroadcastForwardOneStepInEntryGateQueue), _msg.entityID, _msg.entryID); DebugFile.GetInstance().WriteKeyFile(string.Format("entry_{0}", _msg.entryID), "{0} EntryGateModule {1}", _msg.entityID, sendMsg); AlterValue(_msg.entryID); }
public override void Enter(int preStateName) { base.Enter(preStateName); var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoExitGateEntryQueue.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastAfterExtendSceneAndModifiedPath, this.OnBroadcastAfterExtendSceneAndModifiedPath); MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastForwardOneStepInExitGateQueue, this.OnBroadcastForwardOneStepInExitGateQueue); MessageManager.GetInstance().Regist((int)GameMessageDefine.SendExitGateCheckinCDFinishReply, this.OnSendExitGateCheckinCDFinishReply); finishQueueStep = 0; GoToOrgPosOfQueue(entity); if (checkInCD == null) { checkInCD = new IntCD(0); } checkInCD.Stop(); LogWarp.LogFormat("{0} GoToOrgPosOfQueue step = {1}", entity.entityID, finishQueueStep); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} GoToOrgPosOfQueue step = {1}", entity.entityID, finishQueueStep); }
private void add_curr_cell() { if ((m_curr_cell.area | m_curr_cell.cover) != 0) { if (m_num_used_cells >= (int)cell_block_scale_e.cell_block_limit) { return; } allocate_cells_if_required(); m_cells.data()[m_num_used_cells].Set(m_curr_cell); m_num_used_cells++; #if false if (m_num_used_cells == 281) { int a = 12; } DebugFile.Print(m_num_used_cells.ToString() + ". x=" + m_curr_cell.m_x.ToString() + " y=" + m_curr_cell.m_y.ToString() + " area=" + m_curr_cell.m_area.ToString() + " cover=" + m_curr_cell.m_cover.ToString() + "\n"); #endif } }
protected void OnSpawnShuttle(Message msg) { var _msg = msg as SpawnShuttle; EntityShuttle entity = null; if (isRandomSpawn) { entity = EntityManager.GetInstance().GetRandomEntity( ResType.Shuttle, EntityFuncType.Shuttle) as EntityShuttle; } else { entity = EntityManager.GetInstance().GenEntityGameObject( 6001, EntityFuncType.Shuttle) as EntityShuttle; } DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "Shuttle_{0}", entity.entityID); EntityManager.GetInstance().AddToEntityMovables(entity); entity.SetVisistorList(_msg.shuttleVisitorList); if (entity.anim == null) { entity.anim = new SimpleAnimation(); } entity.anim.Init(entity.mainGameObject); entity.moveSpeed = Config.globalConfig.getInstace().ShuttleBaseSpeed; if (entity.followPath == null) { entity.followPath = new FollowPath(); } if (entity.fsmMachine == null) { entity.fsmMachine = new FSMMachineShuttle(entity); entity.fsmMachine.AddState(new StateShuttleGotoDynamicPath((int)ShuttleState.GotoDynamicPath, entity.fsmMachine)); entity.fsmMachine.AddState(new StateShuttleGotoCalcPath((int)ShuttleState.GotoCalcPath, entity.fsmMachine)); entity.fsmMachine.AddState(new StateShuttleGobackCalcPath((int)ShuttleState.GobackCalcPath, entity.fsmMachine)); entity.fsmMachine.AddState(new StateShuttleGobackDynamicPath((int)ShuttleState.GobackDynamicPath, entity.fsmMachine)); entity.fsmMachine.SetDefaultState((int)ShuttleState.GotoDynamicPath); } else { entity.fsmMachine.SetDefaultState((int)ShuttleState.GotoDynamicPath); } entity.Active(); TracedCamera(entity, isTracedCar); }
public void RemoveFromEntityMovables(EntityMovable entity) { DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} entityMovableRemoves.add {1}", entity.entityID, entity.mainGameObject.GetInstanceID()); DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} entityMovableRemoves.add {1}", entity.mainGameObject.GetInstanceID(), entity.entityID); this.entityMovableRemoves.Add(entity); }
public void MarkGameObject() { DebugFile.GetInstance().MarkGameObject(mainGameObject, "animal_{0}_{1}_{2}", idxInTeam, (FSMCrossRoadAnimalState)fsm.GetPreStateName(), (FSMCrossRoadAnimalState)fsm.GetCurrentStateName()); }
protected void WhenCheckinCDFinished() { var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; var msg = SendExitGateCheckinCDFinish.Send(entity.entityID, entity.ExitGateEntryID); LogWarp.LogFormat("{0} send {1}", entity.entityID, msg); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} send {1}", entity.entityID, msg); }
public override void Deactive() { DebugFile.GetInstance().WriteKeyFile(entityID, "{0} Deactive {1} , pos {2}", entityID, mainGameObject.GetInstanceID(), Const.Invisible_Postion); DebugFile.GetInstance().WriteKeyFile(mainGameObject.GetInstanceID(), "{0} Deactive {1} pos {2}", mainGameObject.GetInstanceID(), entityID, Const.Invisible_Postion); //移动到看不见的地方 this.position = Const.Invisible_Postion; base.Deactive(); }
protected void OnAddVisitorToEntryQueuePlaceHolderApply(Message msg) { var _msg = msg as AddVisitorToEntryQueuePlaceHolderApply; LogWarp.LogFormat("{0} EntryGateModule recv {1}", _msg.entityID, _msg); DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "{0} EntryGateModule recv {1}", _msg.entityID, _msg); bool result = false; int entryID = Const.Invalid_Int; int indexInQueue = Const.Invalid_Int; this.idleGates.Clear(); if (this.isOnlyOneEntry) { var exitGate = entryGates[1]; if (!exitGate.IsQueueFull()) { this.idleGates.Add(exitGate); } //保留最后一个遍历的 entryID = exitGate.entryID; } else { foreach (var kv in this.entryGates) { if (!kv.Value.IsQueueFull()) { this.idleGates.Add(kv.Value); } //保留最后一个遍历的 entryID = kv.Value.entryID; } } //LogWarp.LogFormat("还能排队的入口数{0}", idleEntrys.Count); EntryGate idleGate = null; string pathName = null; if (idleGates.Count > 0) { int rVal = 0; if (isRandomEntry) { rVal = Random.Range(0, idleGates.Count); } idleGate = idleGates[rVal]; result = true; entryID = idleGate.entryID; pathName = idleGate.pathName; idleGate.AddVisitorPlaceHolder(_msg.entityID); LogWarp.LogFormat("给出的排队位{0}", indexInQueue); } //AddVisitorToEntryQueuePlaceHolderReply.Send(result, _msg.entityID, pathName, indexInQueue, entryID); AddVisitorToEntryQueuePlaceHolderReply.Send(result, _msg.entityID, pathName, entryID); //AddVisitorToEntryQueuePlaceHolderReply.Send(false, _msg.entityID, pathName, entryID); AlterValue(entryID); }
protected void OnAddVisitorToEntryQueuePlaceHolderReply(Message msg) { var _msg = msg as AddVisitorToEntryQueuePlaceHolderReply; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; if (_msg.entityID != entity.entityID) { return; } //无论成功失败,都有入口ID entity.zooEntryID = _msg.entryID; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态 收到{1}", entity.entityID, msg); if (!_msg.result) { LogWarp.Log("入口所有排队满了, 准备离开, 转离开"); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态 收到{1}入口所有排队满了, 准备离开, 转离开", entity.entityID, msg); this.isToVisitorStateLeaveZooEntryQueueFull = true; return; } isHold = true; Vector3 endPos = UnityEngine.Vector3.zero; EntityFuncType entityFuncType = (EntityFuncType)(entity.entityFuncType); switch (entityFuncType) { case EntityFuncType.Visitor_From_Ship: entity.pathList.Clear(); entity.pathList.Add(entity.position); endPos = UnityEngine.Vector3.zero; PathManager.GetInstance().GetPathLastPos(_msg.pathName, ref endPos); entity.pathList.Add(endPos); EntityVisitor.GodownPath(entity, entity.pathList); break; case EntityFuncType.Visitor_From_Car: EntityVisitor.GodownPath(entity, _msg.pathName, true); break; case EntityFuncType.Visitor_From_GroundParking: entity.pathList.Clear(); entity.pathList.Add(entity.position); endPos = Vector3.zero; PathManager.GetInstance().GetPathLastPos(_msg.pathName, ref endPos); entity.pathList.Add(endPos); EntityVisitor.GodownPath(entity, entity.pathList, true); break; default: string e = string.Format("没有这种游客类型{0}", entityFuncType); throw new System.Exception(e); } }
void OnFingerUp(FingerUpEvent e) { if (!isCameraMoving) { isFingerUp = true; DebugFile.GetInstance().WriteKeyFile("OnFingerUp", "OnFingerUp"); MessageManager.GetInstance().Send( (int)GameMessageDefine.CrossRoadAnimalTeamStopMove); } }
public SourcePawnFile(byte[] binary) { BinaryReader reader = new BinaryReader(new MemoryStream(binary)); header_.magic = reader.ReadUInt32(); if (header_.magic != MAGIC) throw new Exception("bad magic - not SourcePawn file"); header_.version = reader.ReadUInt16(); header_.compression = (Compression)reader.ReadByte(); header_.disksize = (int)reader.ReadUInt32(); header_.imagesize = (int)reader.ReadUInt32(); header_.sections = (int)reader.ReadByte(); header_.stringtab = (int)reader.ReadUInt32(); header_.dataoffs = (int)reader.ReadUInt32(); sections_ = new Dictionary<string, Section>(); // There was a brief period of incompatibility, where version == 0x0101 // and the packing changed, at the same time .dbg.ntvarg was introduced. // Once the incompatibility was noted, version was bumped to 0x0102. debugUnpacked_ = (header_.version == 0x0101) && !sections_.ContainsKey(".dbg.natives"); switch (header_.compression) { case Compression.Gzip: { byte[] bits = new byte[header_.imagesize]; for (int i = 0; i < header_.dataoffs; i++) bits[i] = binary[i]; int uncompressedSize = header_.imagesize - header_.dataoffs; int compressedSize = header_.disksize - header_.dataoffs; MemoryStream ms = new MemoryStream(binary, header_.dataoffs + 2, compressedSize - 2); DeflateStream gzip = new DeflateStream(ms, CompressionMode.Decompress); int actualSize = gzip.Read(bits, header_.dataoffs, uncompressedSize); //Debug.Assert(actualSize == uncompressedSize, "uncompressed size mismatch, bad file?"); binary = bits; break; } } // Read sections. for (int i = 0; i < header_.sections; i++) { int nameOffset = (int)reader.ReadUInt32(); int dataoffs = (int)reader.ReadUInt32(); int size = (int)reader.ReadUInt32(); string name = ReadString(binary, header_.stringtab + nameOffset, header_.dataoffs); sections_[name] = new Section(dataoffs, size); } if (sections_.ContainsKey(".code")) { Section sc = sections_[".code"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); uint codesize = br.ReadUInt32(); byte cellsize = br.ReadByte(); byte codeversion = br.ReadByte(); ushort flags = br.ReadUInt16(); uint main = br.ReadUInt32(); uint codeoffs = br.ReadUInt32(); byte[] codeBytes = Slice(binary, sc.dataoffs + (int)codeoffs, (int)codesize); code_ = new Code(codeBytes, (int)flags, (int)codeversion); } if (sections_.ContainsKey(".data")) { Section sc = sections_[".data"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); uint datasize = br.ReadUInt32(); uint memsize = br.ReadUInt32(); uint dataoffs = br.ReadUInt32(); byte[] dataBytes = Slice(binary, sc.dataoffs + (int)dataoffs, (int)datasize); data_ = new Data(dataBytes, (int)memsize); } if (sections_.ContainsKey(".publics")) { Section sc = sections_[".publics"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); int numPublics = sc.size / 8; publics_ = new Public[numPublics]; for (int i = 0; i < numPublics; i++) { uint address = br.ReadUInt32(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".names"].dataoffs + (int)nameOffset, header_.dataoffs); publics_[i] = new Public(name, address); } } if (sections_.ContainsKey(".pubvars")) { Section sc = sections_[".pubvars"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); int numPubVars = sc.size / 8; pubvars_ = new PubVar[numPubVars]; for (int i = 0; i < numPubVars; i++) { uint address = br.ReadUInt32(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".names"].dataoffs + (int)nameOffset, header_.dataoffs); pubvars_[i] = new PubVar(name, address); } } if (sections_.ContainsKey(".natives")) { Section sc = sections_[".natives"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); int numNatives = sc.size / 4; natives_ = new Native[numNatives]; for (int i = 0; i < numNatives; i++) { uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".names"].dataoffs + (int)nameOffset, header_.dataoffs); natives_[i] = new Native(name, i); } } if (sections_.ContainsKey(".tags")) { Section sc = sections_[".tags"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); int numTags = sc.size / 8; tags_ = new Tag[numTags]; for (int i = 0; i < numTags; i++) { uint tag_id = br.ReadUInt32(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".names"].dataoffs + (int)nameOffset, header_.dataoffs); tags_[i] = new Tag(name, tag_id); } } if (sections_.ContainsKey(".dbg.info")) { Section sc = sections_[".dbg.info"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); debugHeader_.numFiles = (int)br.ReadUInt32(); debugHeader_.numLines = (int)br.ReadUInt32(); debugHeader_.numSyms = (int)br.ReadUInt32(); } if (sections_.ContainsKey(".dbg.files") && debugHeader_.numFiles > 0) { Section sc = sections_[".dbg.files"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); debugFiles_ = new DebugFile[debugHeader_.numFiles]; for (int i = 0; i < debugHeader_.numFiles; i++) { uint address = br.ReadUInt32(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".dbg.strings"].dataoffs + (int)nameOffset, header_.dataoffs); debugFiles_[i] = new DebugFile(name, nameOffset); } } if (sections_.ContainsKey(".dbg.lines") && debugHeader_.numLines > 0) { Section sc = sections_[".dbg.lines"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); debugLines_ = new DebugLine[debugHeader_.numLines]; for (int i = 0; i < debugHeader_.numLines; i++) { uint address = br.ReadUInt32(); uint line = br.ReadUInt32(); debugLines_[i] = new DebugLine((int)line, address); } } if (sections_.ContainsKey(".dbg.symbols") && debugHeader_.numSyms > 0) { Section sc = sections_[".dbg.symbols"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); List<Variable> locals = new List<Variable>(); List<Variable> globals = new List<Variable>(); List<Function> functions = new List<Function>(); for (int i = 0; i < debugHeader_.numSyms; i++) { int addr = br.ReadInt32(); short tagid = br.ReadInt16(); uint codestart = br.ReadUInt32(); uint codeend = br.ReadUInt32(); byte ident = br.ReadByte(); Scope vclass = (Scope)br.ReadByte(); ushort dimcount = br.ReadUInt16(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".dbg.strings"].dataoffs + (int)nameOffset, header_.dataoffs); if (ident == IDENT_FUNCTION) { Tag tag = tagid >= tags_.Length ? null : tags_[tagid]; Function func = new Function((uint)addr, codestart, codeend, name, tag); functions.Add(func); } else { VariableType type = FromIdent(ident); Dimension[] dims = null; if (dimcount > 0) { dims = new Dimension[dimcount]; for (int dim = 0; dim < dimcount; dim++) { short dim_tagid = br.ReadInt16(); Tag dim_tag = dim_tagid >= tags_.Length ? null : tags_[dim_tagid]; uint size = br.ReadUInt32(); dims[dim] = new Dimension(dim_tagid, dim_tag, (int)size); } } Tag tag = tagid >= tags_.Length ? null : tags_[tagid]; Variable var = new Variable(addr, tagid, tag, codestart, codeend, type, vclass, name, dims); if (vclass == Scope.Global) globals.Add(var); else locals.Add(var); } } globals.Sort(delegate(Variable var1, Variable var2) { return var1.address - var2.address; }); functions.Sort(delegate(Function fun1, Function fun2) { return (int)(fun1.address - fun2.address); }); variables_ = locals.ToArray(); globals_ = globals.ToArray(); functions_ = functions.ToArray(); } if (sections_.ContainsKey(".dbg.natives")) { Section sc = sections_[".dbg.natives"]; BinaryReader br = new BinaryReader(new MemoryStream(binary, sc.dataoffs, sc.size)); uint nentries = br.ReadUInt32(); for (int i = 0; i < (int)nentries; i++) { uint index = br.ReadUInt32(); uint nameOffset = br.ReadUInt32(); string name = ReadString(binary, sections_[".dbg.strings"].dataoffs + (int)nameOffset, header_.dataoffs); short tagid = br.ReadInt16(); Tag tag = tagid >= tags_.Length ? null : tags_[tagid]; ushort nargs = br.ReadUInt16(); Argument[] args = new Argument[nargs]; for (ushort arg = 0; arg < nargs; arg++) { byte ident = br.ReadByte(); short arg_tagid = br.ReadInt16(); ushort dimcount = br.ReadUInt16(); uint argNameOffset = br.ReadUInt32(); string argName = ReadString(binary, sections_[".dbg.strings"].dataoffs + (int)argNameOffset, header_.dataoffs); Tag argTag = arg_tagid >= tags_.Length ? null : tags_[arg_tagid]; VariableType type = FromIdent(ident); Dimension[] dims = null; if (dimcount > 0) { dims = new Dimension[dimcount]; for (int dim = 0; dim < dimcount; dim++) { short dim_tagid = br.ReadInt16(); Tag dim_tag = dim_tagid >= tags_.Length ? null : tags_[dim_tagid]; uint size = br.ReadUInt32(); dims[dim] = new Dimension(dim_tagid, dim_tag, (int)size); } } args[arg] = new Argument(type, argName, arg_tagid, argTag, dims); } if ((int)index >+ natives_.Length) continue; natives_[index].setDebugInfo(tagid, tag, args); } } // For every function, attempt to build argument information. for (int i = 0; i < functions_.Length; i++) { Function fun = functions_[i]; int argOffset = 12; var args = new List<Argument>(); do { Variable var = lookupVariable(fun.address, argOffset); if (var == null) break; Argument arg = new Argument(var.type, var.name, (int)var.tag.tag_id, var.tag, var.dims); args.Add(arg); argOffset += 4; } while (true); fun.setArguments(args); } }