public bool m_isSwitchForDead = false;//死亡后切换 //private int m_switchBuffID = 0; //切换主控角色 public bool SwitchMainActor(bool isSwitchForDead, bool isAttacking = false) { if (m_switchCDTotal > 0 && !MainActor.IsDead) {//cd中,并且当前角色未死 //msg("XXX尚未休整完毕,请稍后再试!"); return(false); } if (Deputy == null) {//没有可切换的角色 return(false); } int curID, lastID; if (MainActor == Chief) { curID = Deputy.ID; lastID = Chief.ID; } else { curID = Chief.ID; lastID = Deputy.ID; } MainPlayer curActor = Lookup(curID) as MainPlayer; if (curActor.IsDead) {//要切换的角色已经死亡 return(false); } MainPlayer lastActor = Lookup(lastID) as MainPlayer; // 小地图的点管理 把原来的角色移除 Map.Singleton.RomvePoint(lastActor); //退场角色的信息 begin Vector3 lastPos = lastActor.MainPos; Vector3 lastForward = lastActor.MainObj.transform.forward; Vector3 targetPos = Vector3.zero; if (!isAttacking) { if (lastActor.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction)) {//move action MoveAction action = lastActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (action.mRealSpeed / action.m_currentSpeed <= 0.1f) { } else { targetPos = action.m_realTargetPos; } } } int targetID = 0; if (lastActor.TargetManager.CurrentTarget != null) { targetID = lastActor.TargetManager.CurrentTarget.ID; } //退场角色的信息 end ActorExitAction exitAction = lastActor.ActionControl.AddAction(ActorAction.ENType.enActorExitAction) as ActorExitAction; if (exitAction == null) {//退场失败,不能切换 return(false); } lastActor.ActorExit(); //开始CD m_switchCDTimer = Time.time; m_switchCDTotal = (curActor.CurrentTableInfo.SwitchCD + lastActor.CurrentTableInfo.SwitchCD) / 2; m_isSwitchForDead = isSwitchForDead; //当前角色上场 if (lastActor.IsDead) { float percent = (float)m_switchCDTotal / ((curActor.CurrentTableInfo.SwitchCD + lastActor.CurrentTableInfo.SwitchCD) / 2); float hp = (float)curActor.HP; if (percent != 0) { hp *= percent; curActor.SetCurHP((int)hp); } } curActor.ActorEnter(lastPos, lastForward, targetID, targetPos, isAttacking); // 小地图新进入的角色 加入 Map.Singleton.AddPoint(curActor); return(true); }
public override void OnEnter() { base.OnEnter(); if (ForwardDirectionArrow.Singleton == null) { new ForwardDirectionArrow(); } //主角色 { MainPlayer chief = ActorManager.Singleton.Chief; if (chief == null) { chief = ActorManager.Singleton.CreatePureActor(ActorType.enMain, (int)EnMyPlayers.enChief, Team.Singleton.Chief.Guid, Team.Singleton.Chief.IDInTable) as MainPlayer; ActorManager.Singleton.SetChief(chief); chief.IsActorExit = false; } chief.Props.SetProperty_Int32(ENProperty.vocationid, 1); chief.CreateNeedModels(); if (!chief.IsActorExit) { chief.UnhideMe(new Vector3(chief.PositionX, 0, chief.PositionZ)); } } if (!ClientNet.Singleton.IsLongConnecting) {//长连接,不创建角色 //副角色 if (null != Team.Singleton.Deputy) { MainPlayer deputy = ActorManager.Singleton.Deputy; if (deputy == null) { deputy = ActorManager.Singleton.CreatePureActor(ActorType.enMain, (int)EnMyPlayers.enDeputy, Team.Singleton.Deputy.Guid, Team.Singleton.Deputy.IDInTable) as MainPlayer; ActorManager.Singleton.SetDeputy(deputy); deputy.IsActorExit = true; } deputy.Props.SetProperty_Int32(ENProperty.vocationid, 1); deputy.CreateNeedModels(); //副角色退场 deputy.ActorExit(); deputy.HideMe(); } //支援角色 // if (null != Team.Singleton.Support) // { // Player support = ActorManager.Singleton.Support; // if (support == null) // { // support = ActorManager.Singleton.CreatePureActor(ActorType.enSwitch, (int)EnMyPlayers.enSupport, Team.Singleton.Support.Guid, Team.Singleton.Support.IDInTable) as Player; // ActorManager.Singleton.SetSupport(support); // } // support.Props.SetProperty_Int32(ENProperty.vocationid, 5); // support.CreateNeedModels(); // support.InitSwitchSkillUI(); // //支援角色隐藏 // support.HideMe(); // //停止tick // ActorManager.Singleton.ReleaseActor(support.ID, false); // } // if (!GameSettings.Singleton.m_isHideChangeAndFollow) // {//战友角色 // if (null != Team.Singleton.Comrade) // { // Player comrade = ActorManager.Singleton.Comrade; // if (comrade == null) // { // comrade = ActorManager.Singleton.CreatePureActor(ActorType.enFollow, (int)EnMyPlayers.enComrade, Team.Singleton.Comrade.Guid, Team.Singleton.Comrade.IDInTable) as Player; // ActorManager.Singleton.SetComrade(comrade); // } // comrade.CreateNeedModels(); // } // } } InitGUI(); GameTable.SwitchAnimationTable("AnimationFight"); //摄像机就位后,再隐藏界面 // UIStageMenu.GetInstance().HideWindow(); //!加载场景 SM.RandomRoomLevel.Singleton.LoadNeedResource(); // 初始化升级数据 LevelUp.Singleton.InitData(); //战斗stage开始 BattleArena.Singleton.StageStart(); Loading.Singleton.m_conFailedNum = 0; Reward.Singleton.Reset(); // 一进入战斗状态时 记录一些数据 BattleSummary.Singleton.RecordData(); Map.Singleton.SetMapSize(); KillTips.Singleton.Clear(); }