private void OnSceneFightLose() { int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.SetDestination(HeroObj.GetGameObject().transform.position); HeroObj.GetAnimation().Anim_Fidle(false); } } if (ObjectSelf.GetInstance().LimitFightMgr.m_bStartEnter) { ObjectSelf.GetInstance().LimitFightMgr.SendRoundOver(); } else { if (ObjectSelf.GetInstance().WorldBossMgr.m_bStartEnter) { ObjectSelf.GetInstance().WorldBossMgr.SendRoundOver(); } else { CEndBattle battle = new CEndBattle(); battle.pass = 0;// 未通过 IOControler.GetInstance().SendProtocol(battle); } } GameTimeControler.Inst.SetState(TimeScaleState.TimeScale_Normal); }
private void UpdateHeroBoarding() { moveTime += Time.deltaTime; if (moveTime < 0.1f) { return; } moveTime = 0f; int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; i++) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.speed = HeroObj.GetMoveSpeed(); Nav.SetDestination(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); //HeroObj.SetWorldPosRotation(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj), FightEditorContrler.GetInstantiate().GetFormationAngle(HeroObj)); HeroObj.SetObjectActionState(ObjectCreature.ObjectActionState.boarding); HeroObj.GetAnimation().Anim_Fidle(false); } } }
//英雄瞬间移动结束慢慢出现 private void UpdateMomentMoveExit() { int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { //..慢慢出现 m_ShowCount++; } } if (m_ShowCount == SceneObjectManager.GetInstance().GetObjectHeroCount()) { m_ShowCount = 0; FightEditorContrler.GetInstantiate().HeroPathNormalMove(); SetFightState(FightState.HeroMove); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { HeroObj.GetNavMesh().enabled = true; HeroObj.SetObjectActionState(ObjectCreature.ObjectActionState.forward); } } } }
//当前场景战斗结束 [3/13/2015 Zmy] private void OnSceneFightWin() { int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero pHero = SceneObjectManager.GetInstance().GetHeroObject(i); NavMeshAgent Nav = pHero.GetNavMesh(); Nav.SetDestination(pHero.GetGameObject().transform.position); pHero.GetAnimation().Anim_Fidle(false); } // 战斗胜利先刷新奖励数据 [4/2/2015 Zmy] //ObjectSelf.GetInstance().UpdateDataBattleWin(); // 战斗胜利后刷新关卡数据 [4/8/2015 Zmy] SceneObjectManager.GetInstance().UpdateBattleWinStageData(); GameTimeControler.Inst.SetState(TimeScaleState.TimeScale_Normal); GameEventDispatcher.Inst.dispatchEvent(GameEventID.F_BattleOver); }
//瞬间移动事件进入 public void CallBack_eroPathMomentMoveEnter() { SetFightState(FightState.HeroMonmentMoveEnter); int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { HeroObj.GetAnimation().Anim_Run(); NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.speed = HeroObj.GetMoveSpeed(); Nav.SetDestination(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); //Debug.Log(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); StartCoroutine(DelayCallPos(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj), HeroObj.GetGameObject(), HeroObj, CallBack_MomentMoveEnter)); } } }
private void CallBack_PrepareBoard() { SetFightState(FightState.PrepareBoard); int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { HeroObj.GetAnimation().Anim_Run(); NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.speed = HeroObj.GetMoveSpeed(); Nav.SetDestination(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); StartCoroutine(DelayCall(Nav, HeroObj.GetGameObject(), HeroObj, CallBack_PrepareBoardPos)); } } }
//进入战斗状态开始战斗,在这之前先修正一下人物位置 [1/20/2015 Zmy] private void CallBack_EnterFightState() { int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { // ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); // if (HeroObj != null) // { // GameObject obj = HeroObj.GetGameObject(); // if (obj != null) // { // obj.GetComponent<NavMeshAgent>().Stop(); // float _heroSpeed = HeroObj.GetMoveSpeed(); // float _moveTime = Vector3.Distance(obj.transform.position, FightEditorContrler.inst.GetFormationPos(HeroObj.GetGameObject())) / _heroSpeed; // //修正高度值 [1/22/2015 Zmy] // Vector3 targetPos = new Vector3(FightEditorContrler.inst.GetFormationPos(HeroObj.GetGameObject()).x, obj.transform.position.y, FightEditorContrler.inst.GetFormationPos(HeroObj.GetGameObject()).z); // obj.transform.DOMove(targetPos, _moveTime).SetUpdate(true).SetEase(Ease.Linear).OnComplete(()=>CallBack_RevisepPos(obj,HeroObj)); // } // } ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { HeroObj.GetAnimation().Anim_Run(); NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.speed = HeroObj.GetMoveSpeed(); Nav.SetDestination(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); StartCoroutine(DelayCall(Nav, HeroObj.GetGameObject(), HeroObj, CallBack_RevisepPos)); } } //切换准备战斗状态 SetFightState(FightState.prepareFight); //重算一下移动位置偏移量; HeroPathtContrler.GetInstantiate().ResetMoveTargetOffset(); }
//英雄慢慢消失后瞬间移动 private void UpdateMomentMoveIng() { int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { //..慢慢消失 m_DisappearCount++; HeroObj.GetNavMesh().enabled = false; HeroObj.OnConcealThis(); } } if (m_DisappearCount == SceneObjectManager.GetInstance().GetObjectHeroCount()) { m_DisappearCount = 0; FightEditorContrler.GetInstantiate().HeroPathNormalMove(); SetFightState(FightState.HeroMonmentMoveEnter); } }
//移动中更新obj位置 [1/20/2015 Zmy] private void UpdateHeroForward() { moveTime += Time.deltaTime; if (moveTime < 0.1f) { //控制刷新延迟 [1/21/2015 Zmy] return; } moveTime = 0.0f; int nHeroCount = SceneObjectManager.GetInstance().GetObjectHeroCount(); for (int i = 0; i < nHeroCount; ++i) { ObjectHero HeroObj = SceneObjectManager.GetInstance().GetHeroObject(i); if (HeroObj != null && HeroObj.IsAlive()) { NavMeshAgent Nav = HeroObj.GetNavMesh(); Nav.speed = HeroObj.GetMoveSpeed(); Nav.SetDestination(FightEditorContrler.GetInstantiate().GetFormationPos(HeroObj)); HeroObj.SetObjectActionState(ObjectCreature.ObjectActionState.forward); } } }