private void IninCompentData() { singleRoadSucceed = 0; scheduleSlider.value = 0; scheduleSlider_text.text = "0%"; numberText.text = string.Format(GetL10NString("Ui_Text_123"), CrossRoadModelManager.GetInstance().stageID); }
void GetScreenConnerLine() { var pLB = GetScreenPointInWorld(Camera.main, new Vector2(0, 0)); CrossRoadModelManager.GetInstance().spLBW = pLB; #if UNITY_EDITOR GameObject.CreatePrimitive(PrimitiveType.Capsule).transform.position = pLB; #endif var pLT = GetScreenPointInWorld(Camera.main, new Vector2(0, Screen.height)); CrossRoadModelManager.GetInstance().spLTW = pLT; #if UNITY_EDITOR GameObject.CreatePrimitive(PrimitiveType.Capsule).transform.position = pLT; #endif var pRB = GetScreenPointInWorld(Camera.main, new Vector2(Screen.width, 0)); CrossRoadModelManager.GetInstance().spRBW = pRB; #if UNITY_EDITOR GameObject.CreatePrimitive(PrimitiveType.Capsule).transform.position = pRB; #endif var pRT = GetScreenPointInWorld(Camera.main, new Vector2(Screen.width, Screen.height)); CrossRoadModelManager.GetInstance().spRTW = pRT; #if UNITY_EDITOR GameObject.CreatePrimitive(PrimitiveType.Capsule).transform.position = pRT; #endif }
void GetEndEffect() { var go = endPos.transform.Find("EndEffectNodeName").gameObject; CrossRoadModelManager.GetInstance().endPosEffectSp = new SimpleParticle(); CrossRoadModelManager.GetInstance().endPosEffectSp.Init(go); }
protected void Callback_SpawnCar(IntCD CD, IVoidParam spawnCarParam) { SpawnCarParam _spawnCarParam = spawnCarParam as SpawnCarParam; var car = EntityManager.GetInstance().GenEntityGameObject(1, EntityFuncType.CrossRoadCar) as EntityCrossRoadCar; //var car = EntityManager.GetInstance().GetRandomEntity(ResType.Car, EntityFuncType.CrossRoadCar) as EntityCrossRoadCar; car.Init(_spawnCarParam.startPos, _spawnCarParam.endPos, _spawnCarParam.speed); //重要:Entity取出后先设置位置,再把Collider设置成true,防止在未设置位置时触发碰撞 car.position = _spawnCarParam.startPos; try { car.GetTrans().Find("Collider").gameObject.SetActive(true); } catch (System.Exception e) { #if UNITY_EDITOR throw new System.Exception(string.Format("汽车 {0} 取Collider 失败", car.mainGameObject.name)); #endif } car.LookAt(_spawnCarParam.endPos); car.Active(); CrossRoadModelManager.GetInstance().entityModel.AddToEntityMovables(car); if (CD != null) { CD.Reset(); CD.Run(); } }
public override void Tick(int deltaTimeMS) { if (!this.CouldRun()) { return; } CrossRoadModelManager.GetInstance().entityModel.Tick(deltaTimeMS); }
private void OnGetCrossRoadGameSingleRoadSucceed(Message obj) { singleRoadSucceed += 1; float value = AddPercentage(singleRoadSucceed, cellStage.roadnum); scheduleSlider.value = value; scheduleSlider_text.text = value * 100 + "%"; numberText.text = string.Format(GetL10NString("Ui_Text_123"), CrossRoadModelManager.GetInstance().stageID); }
public void UnLoad() { gameModules.Release(); CrossRoadModelManager.GetInstance().Release(); PoolManager.GetInstance().Release(); Resources.UnloadUnusedAssets(); System.GC.Collect(); }
/// <summary> /// 按钮 再来一次界面 /// </summary> /// <param name="obj"></param> private void OnClickAgainButton(string obj) { //LogWarp.LogError(" 按钮 再来一次界面 "); int stageID = CrossRoadModelManager.GetInstance().stageID; CrossRoadStageManager.GetInstance().UnLoad(); CrossRoadStageManager.GetInstance().Load(stageID); Hide(); }
public void MoveCamera(Vector3 lookAt) { //LogWarp.LogError("小游戏过马路 相机移动"); Vector3 target = CalcCameraMoveTo(lookAt); CrossRoadModelManager.GetInstance().isCameraMoving = true; TweenMoveCamera(target); }
void Next() { PageMgr.ClosePage <UIGameVictoryPage>(); PageMgr.ClosePage <UIGameFailPage>(); int stageID = CrossRoadModelManager.GetInstance().stageID; CrossRoadStageManager.GetInstance().UnLoad(); CrossRoadGame.CrossRoadStageManager.GetInstance().Load(stageID); }
protected void LoadEndPos() { endPos = ResourceManager.GetInstance().LoadGameObject(Config.globalConfig.getInstace().CrossRoadSceneEnd); CrossRoadModelManager.GetInstance().endPos = lastRoadPos + Vector3.forward * (endPos.GetComponent <BoxCollider>().size.z * 0.5f + preHalfWidth); endPos.transform.position = CrossRoadModelManager.GetInstance().endPos; GetEndEffect(); GetEndAnimalePos(); }
/// <summary> /// 相机移动结束 /// </summary> /// <param name="obj"></param> private void OnGetCrossRoadCameraStopMove(Message obj) { //LogWarp.LogError("AAAAAAAAAAAAAAAAAAAAAAAAAAAA"); //取消不可点击 uIBackgroundImage.gameObject.SetActive(false); //UI显示更新 singleRoadSucceed += 1; float value = AddPercentage(singleRoadSucceed, cellStage.roadnum); scheduleSlider.value = value; scheduleSlider_text.text = value * 100 + "%"; numberText.text = string.Format(GetL10NString("Ui_Text_123"), CrossRoadModelManager.GetInstance().stageID); }
void NavTest(GameObject mainGameObject) { //mainGameObject.GetComponentInChildren<NavMeshAgent>().destination // = CrossRoadModelManager.GetInstance().endAnimalTransferPos; var navAgent = mainGameObject.GetComponent <NavMeshAgent>(); if (navAgent == null) { navAgent = mainGameObject.AddComponent <NavMeshAgent>(); } navAgent.speed = moveSpeed * 1000; navAgent.destination = CrossRoadModelManager.GetInstance().endAnimalPos[14]; }
public void Load(int stageID) { if (stageID < 0 || stageID > Config.crossroadstageConfig.getInstace().RowNum) { string e = string.Format("过马路关卡数不正确 {0}", stageID); throw new System.Exception(e); } CrossRoadModelManager.GetInstance().stageID = stageID; PageMgr.CloseAllPage(true, ""); PageMgr.ShowPage <UICrossRoadLoading>(); SetFSM("UICrossRoadLoading"); LoadModule(); }
public override void Enter(int preStateName) { base.Enter(preStateName); owner.MarkGameObject(); SWS_Walk(owner.mainGameObject, owner.idxInTeam); if (owner.idxInTeam == owner.animalTeamModel.entityCrossRoadAnimalList.Count - 1) { ++owner.animalTeamModel.currentRoad; CrossRoadCameraController.GetInstance().MoveCamera( CrossRoadModelManager.GetInstance().endPos); } }
/// <summary> /// 开始游戏隐藏按钮 /// </summary> /// <param name="obj"></param> private void OnClickReceiveButton(string obj) { uIBackgroundImage.gameObject.SetActive(false); reviveButton.gameObject.SetActive(false); UFrame.MessageManager.GetInstance().Send((int)GameMessageDefine.CrossRoadStartGame); if (CrossRoadModelManager.GetInstance().stageID != 1) { UFrame.MessageInt.Send((int)GameMessageDefine.AddStrength, -1); } tipsGroup.gameObject.SetActive(false); //if (!playerData.playerLittleGame.isFirst) //{ // tipsGroup.gameObject.SetActive(false); //} }
void GetEndAnimalePos() { List <Vector3> vector3s = new List <Vector3>(); if (endPos != null) { var tableView = endPos.transform.Find("AnimalStopSpot"); foreach (Transform child in tableView) { vector3s.Add(child.position); } CrossRoadModelManager.GetInstance().endAnimalPos = vector3s; Transform animalGatherSpot = endPos.transform.Find("AnimalGatherSpot"); CrossRoadModelManager.GetInstance().endAnimalTransferPos = animalGatherSpot.position; } }
protected void OnLoadAnimal(Message msg) { animalTeamModel.numArrivedEndPoint = 0; List <int> animalResourceloadList = GetAnimaelList(cellStage.animalnum); for (int i = 0; i < animalResourceloadList.Count; i++) { var animal = EntityManager.GetInstance().GenEntityGameObject( animalResourceloadList[i], EntityFuncType.Animal_LittleGame) as EntityCrossRoadAnimal; animal.Init(animalAnimationSpeed, animalMoveSpeed, i, animalAcceleration, rotateSpeed); animal.position = animalRoadSegment[animalTeamModel.currentRoad] + Vector3.back * (standardAnimalBoxSize.z * i + standardAnimalBoxSize.z * 0.8f); GameObject colliderGB = animal.GetTrans().Find("Collider").gameObject; colliderGB.SetActive(true); FSMCrossRoadGame.Scale_Z(animal.mainGameObject, standardAnimalBoxSize.z); animal.position = new Vector3(animal.position.x, 0, animal.position.z); if (animal.simpleAnimation != null) { animal.simpleAnimation.Init(animal.mainGameObject); } if (colliderGB.GetComponent <Rigidbody>() == null) { colliderGB.AddComponent <Rigidbody>(); SetRigidbody(colliderGB); } if (colliderGB.GetComponent <AnimalCollisionEnterHelp>() == null) { colliderGB.AddComponent <AnimalCollisionEnterHelp>(); } if (animal.runEffSp == null) { animal.runEffSp = new SimpleParticle(); animal.runEffSp.Init(animal.mainGameObject.transform.Find("Effect/MoveEffect").gameObject); } animal.Active(); animalTeamModel.entityCrossRoadAnimalList.Add(animal); CrossRoadModelManager.GetInstance().entityModel.AddToEntityMovables(animal); } }
void TweenMoveCamera(Vector3 target) { Vector3 tweenPos = cachedTrans.position; Tween tw = DOTween.To(() => tweenPos, x => tweenPos = x, target, moveDuration); tw.SetEase(Ease.InSine); tw.OnUpdate(() => { cachedTrans.position = tweenPos; }); tw.OnComplete(() => { CrossRoadModelManager.GetInstance().isCameraMoving = false; MessageManager.GetInstance().Send((int)GameMessageDefine.CrossRoadCameraStopMove); }); }
void SWS_Walk(GameObject mainGameObject, int idx) { var spm = mainGameObject.GetComponent <splineMove>(); if (spm == null) { spm = mainGameObject.AddComponent <splineMove>(); } spm.speed = moveSpeed * 1000f; //create path manager game object GameObject newPath = new GameObject(string.Format("Path{0} (Runtime Creation)", idx)); PathManager path = newPath.AddComponent <PathManager>(); //declare waypoint positions Vector3[] positions = new Vector3[] { position, CrossRoadModelManager.GetInstance().endAnimalTransferPos, CrossRoadModelManager.GetInstance().endAnimalPos[idx] }; Transform[] waypoints = new Transform[positions.Length]; //instantiate waypoints for (int i = 0; i < positions.Length; i++) { GameObject newPoint = new GameObject("Waypoint " + i); waypoints[i] = newPoint.transform; waypoints[i].position = positions[i]; } //assign waypoints to path path.Create(waypoints, true); spm.SetPath(path); spm.StartMove(); UnityEvent SWS_Event = spm.events[2]; SWS_Event.RemoveAllListeners(); SWS_Event.AddListener( delegate { PlayPose(); } ); }
public override void Tick(int deltaTimeMS) { if (!this.CouldActive()) { return; } if (Math_F.Approximate3D(position, endPos) || this.IsPassed(endPos) ) { //到达终点 //重要:回收前先把Collider设置成false,避免在pool中触发碰撞 GetTrans().Find("Collider").gameObject.SetActive(false); CrossRoadModelManager.GetInstance().entityModel.RemoveFromEntityMovables(this); return; } Tick_Move(deltaTimeMS); }
public void Load(int stageID) { if (stageID < 0) { string e = string.Format("过马路关卡数不正确 {0}", stageID); throw new System.Exception(e); } else if (stageID >= Config.crossroadstageConfig.getInstace().RowNum) { int number = Config.crossroadstageConfig.getInstace().RowNum; stageID = Config.crossroadstageConfig.getInstace().getCell(number).level; } GameSoundManager.GetInstance().PlayBGMusicAsync(Config.globalConfig.getInstace().ZooSceneBGM); CrossRoadModelManager.GetInstance().stageID = stageID; PageMgr.CloseAllPage(true, ""); PageMgr.ShowPage <UICrossRoadLoading>(); SetFSM("UICrossRoadLoading"); LoadModule(); }
protected void OnLoadAnimal(Message msg) { for (int i = 0; i < 15; i++) { var animal = EntityManager.GetInstance().GenEntityGameObject( 2201, EntityFuncType.Animal_LittleGame) as EntityCrossRoadAnimal; animal.Init(animalAnimationSpeed, animalMoveSpeed, i); animal.position = animalRoadSegment[animalTeamModel.currentRoad] + Vector3.back * (standardAnimalBoxSize.z * i + standardAnimalBoxSize.z * 0.8f); //animal.position = animalRoadSegment[animalTeamModel.currentRoad] // + Vector3.back * (standardAnimalBoxSize.z * i); GameObject colliderGB = animal.GetTrans().Find("Collider").gameObject; colliderGB.SetActive(true); FSMCrossRoadGame.Scale_Z(animal.mainGameObject, standardAnimalBoxSize.z); //animal.position = new Vector3(animal.position.x, colliderGB.transform.position.y * -1, animal.position.z); animal.position = new Vector3(animal.position.x, 0, animal.position.z); if (animal.simpleAnimation != null) { animal.simpleAnimation.Init(animal.mainGameObject); } if (colliderGB.GetComponent <Rigidbody>() == null) { colliderGB.AddComponent <Rigidbody>(); SetRigidbody(colliderGB); } if (colliderGB.GetComponent <AnimalCollisionEnterHelp>() == null) { colliderGB.AddComponent <AnimalCollisionEnterHelp>(); } animal.Active(); animalTeamModel.entityCrossRoadAnimalList.Add(animal); CrossRoadModelManager.GetInstance().entityModel.AddToEntityMovables(animal); } }
public void SWS_Walk(GameObject mainGameObject, int idx) { //return; var spm = mainGameObject.GetComponent <splineMove>(); if (spm == null) { spm = mainGameObject.AddComponent <splineMove>(); } //spm.animEaseType = (int)DG.Tweening.Ease.InOutSine; spm.speed = owner.moveSpeedBak * 1000f; //create path manager game object GameObject newPath = new GameObject(string.Format("Path{0} (Runtime Creation)", idx)); PathManager path = newPath.AddComponent <PathManager>(); //declare waypoint positions Vector3[] positions = new Vector3[] { owner.position, CrossRoadModelManager.GetInstance().endAnimalTransferPos, CrossRoadModelManager.GetInstance().endAnimalPos[idx] }; Transform[] waypoints = new Transform[positions.Length]; //instantiate waypoints for (int i = 0; i < positions.Length; i++) { GameObject newPoint = new GameObject("Waypoint " + i); waypoints[i] = newPoint.transform; waypoints[i].position = positions[i]; } //assign waypoints to path path.Create(waypoints, true); spm.SetPath(path); spm.StartMove(); UnityEvent SWS_ArrivedGate = spm.events[1]; SWS_ArrivedGate.RemoveAllListeners(); SWS_ArrivedGate.AddListener(delegate { CrossRoadModelManager.GetInstance().endPosEffectSp.Play(); }); UnityEvent SWS_ArrivedEndPoint = spm.events[2]; SWS_ArrivedEndPoint.RemoveAllListeners(); SWS_ArrivedEndPoint.AddListener( delegate { float angle = Vector3.Angle(mainGameObject.transform.forward, Vector3.back); Vector3 normal = Vector3.Cross(mainGameObject.transform.forward, Vector3.back); angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.up)); mainGameObject.transform.Rotate(new Vector3(0, angle, 0)); owner.PlayPose(); ++owner.animalTeamModel.numArrivedEndPoint; if (owner.animalTeamModel.numArrivedEndPoint == (owner.maxIdxInTeam + 1)) { MessageManager.GetInstance().Send( (int)GameMessageDefine.CrossRoadAnimalTeamArrived); foreach (var item in owner.animalTeamModel.entityCrossRoadAnimalList) { item.mainGameObject.transform.Find("Effect/MoveEffect").gameObject.SetActive(false); } } } ); }
public override void Tick(int deltaTimeMS) { if (!this.CouldActive()) { return; } if (!isMoving) { return; } if (arrivedLastPos) { return; } if (animalTeamModel.currentRoad < cellStage.roadnum - 1) { //过马路记录 if (IsPassed(firstPos)) { isPassedRoad = true; animalTeamModel.passedCurrRoadSet.Add(idxInTeam); DebugFile.GetInstance().WriteKeyFile(string.Format("Animal-{0}", idxInTeam), "PassedFirstPos, currentRoad={0}", animalTeamModel.currentRoad); } //到达终点记录 if (IsPassed(nextRoadPos)) { //所有人到达 if (idxInTeam == animalTeamModel.entityCrossRoadAnimalList.Count - 1) { CrossRoadCameraController.GetInstance().MoveCamera(nextFirstPos); animalTeamModel.passedCurrRoadSet.Clear(); ++animalTeamModel.currentRoad; DebugFile.GetInstance().WriteKeyFile("CrossRoad", "currentRoad = {0}", animalTeamModel.currentRoad); for (int i = 0; i < animalTeamModel.entityCrossRoadAnimalList.Count; i++) { var animal = animalTeamModel.entityCrossRoadAnimalList[i]; animal.isMoving = false; animal.isPassedRoad = false; animal.moveSpeed = CrossRoadStageManager.GetInstance().animalMoveSpeed * 0.001f; DebugFile.GetInstance().WriteKeyFile(string.Format("Animal-{0}", idxInTeam), "isMoving = false {0}, currentRoad={1}", 1, animalTeamModel.currentRoad); } } position = targetPos; isMoving = false; DebugFile.GetInstance().WriteKeyFile(string.Format("Animal-{0}", idxInTeam), "isMoving = false {0}, currentRoad={1}", 2, animalTeamModel.currentRoad); PlayIdle(); return; } } else if (animalTeamModel.currentRoad == cellStage.roadnum - 1) { if (IsPassed(firstPos)) { isPassedRoad = true; animalTeamModel.passedCurrRoadSet.Add(idxInTeam); } if (IsPassed(lastRoadPos)) { PlayWalk(); isMoving = false; position = lastRoadPos; arrivedLastPos = true; SWS_Walk(mainGameObject, idxInTeam); if (idxInTeam == animalTeamModel.entityCrossRoadAnimalList.Count - 1) { ++animalTeamModel.currentRoad; CrossRoadCameraController.GetInstance().MoveCamera( CrossRoadModelManager.GetInstance().endAnimalTransferPos + Vector3.forward * 50f); } return; } } else { return; } //到达目标点停止 if (IsPassed(targetPos)) { position = targetPos; isMoving = false; DebugFile.GetInstance().WriteKeyFile(string.Format("Animal-{0}", idxInTeam), "isMoving = false {0}, currentRoad={1}", 3, animalTeamModel.currentRoad); PlayIdle(); return; } //position += Vector3.forward * moveSpeed * deltaTimeMS; ////跨马路的时候速度最快 //if (IsPassed(firstPos)) //{ // position += Vector3.forward * moveSpeed * deltaTimeMS; //} //else //{ // position += Vector3.forward * moveSpeed * 0.4f * deltaTimeMS; //} //跨马路的时候加速 if (IsPassed(firstPos)) { //匀加速或者减速 float animalAcceleration = CrossRoadStageManager.GetInstance().animalAcceleration; float animalMaxSpeed = CrossRoadStageManager.GetInstance().animalMaxSpeed; float animalMinSpeed = CrossRoadStageManager.GetInstance().animalMinSpeed; Vector3 old = Vector3.forward * moveSpeed * deltaTimeMS; float delta = (moveSpeed + animalAcceleration * 0.001f) * deltaTimeMS; float max = animalMaxSpeed * 0.001f * deltaTimeMS; float min = animalMinSpeed * 0.001f * deltaTimeMS; if (animalAcceleration > 0) { delta = Mathf.Min(delta, max); } else { delta = Mathf.Max(delta, min); } position += Vector3.forward * delta; moveSpeed = delta / deltaTimeMS; } else { position += Vector3.forward * moveSpeed * deltaTimeMS; } ////前面的比后面的快 //float delta = moveSpeed * (1 - idxInTeam / 15f); //position += Vector3.forward * delta * deltaTimeMS; //Debug.LogErrorFormat("{0}, {1}, {2}", idxInTeam, moveSpeed, delta); ////匀加速或者减速 //float animalAcceleration = CrossRoadStageManager.GetInstance().animalAcceleration; //float animalMaxSpeed = CrossRoadStageManager.GetInstance().animalMaxSpeed; //float animalMinSpeed = CrossRoadStageManager.GetInstance().animalMinSpeed; //Vector3 old = Vector3.forward * moveSpeed * deltaTimeMS; //float delta = (moveSpeed + animalAcceleration * 0.001f) * deltaTimeMS; //float max = animalMaxSpeed * 0.001f * deltaTimeMS; //float min = animalMinSpeed * 0.001f * deltaTimeMS; //if (animalAcceleration > 0) //{ // delta = Mathf.Min(delta, max); //} //else //{ // delta = Mathf.Max(delta, min); //} //position += Vector3.forward * delta; //moveSpeed = delta / deltaTimeMS; }