public override void Release() { ResetValue(); BattleGeneralCmd.DestroyAllBattleGeneralCmd(); // Destroy all fleets and warships foreach (FleetL fleet in _currentFleets.Values) { Globals.Instance.MPlayerManager.RemoveFleet(fleet); } _currentFleets.Clear(); this.SetFingerEventActive(false); Globals.Instance.MFingerEvent.Remove3DEventListener(this); // Clean up some module, if we don't use the change scene Globals.Instance.MSkillManager.Cleanup(); Globals.Instance.MCamTrackController.StopTrack(FightCameraTrack); // tzz added for hide the battle ship selected prefab special effect if (m_battleSelectedPrefab != null) { GameObject.Destroy(m_battleSelectedPrefab); m_battleSelectedPrefab = null; } }
/// <summary> /// Shows the general cmd. /// </summary> /// <param name='avatar'> /// Avatar. /// </param> /// <param name='cmd'> /// Cmd. /// </param> public static void ShowGeneralCmd(string avatar, string cmd) { if (Application.isPlaying && Globals.Instance.M3DItemManager != null) { BattleGeneralCmd tGeneralCmd = (BattleGeneralCmd)GameObject.Instantiate(Globals.Instance.M3DItemManager.BattleGeneralCmdPrefab); tGeneralCmd.Popup(avatar, cmd); } }
/// <summary> /// Popup the specified avatar and cmd. /// </summary> /// <param name='avatar'> /// Avatar. /// </param> /// <param name='cmd'> /// Cmd. /// </param> private void Popup(string avatar, string cmd) { mAvatar.PlayAnim(avatar); GeneralCommandText.Text = cmd; mStartPosX = -(Screen.width + mSelfPackedSprite.width) / 2; mEndPosX = -(Screen.width - mSelfPackedSprite.width) / 2; // process former BattleGeneralCmd // for (int i = 0; i < smCurrCmdList.Count; i++) { BattleGeneralCmd c = smCurrCmdList[i]; c.transform.localPosition = new Vector3(c.transform.localPosition.x, ((i + 1) * (mSelfPackedSprite.height + 20)) + GeneralCmdPosY, c.transform.localPosition.z); } smCurrCmdList.Add(this); }
public virtual bool OneBattleStep(int step, GameData.BattleGameData.BattleStep stepData) { UnityEngine.Profiling.Profiler.BeginSample("BattleStatus.OneBattleStep"); // Has 3 parts /**Part1: * 1).Trim the basic data of all warships in this step * 2).Calculate the count of a warship is attacked * */ /**Part2: * 1).Simulate the all warships running logic * 2).Display its * */ /**Part3: Implement in OnOneBattleStepEnd() * 1).Trim all warships InitialLife for the next step simulate * */ // Debug.Log("The current stepID is : " + stepData.StepID.ToString()); foreach (GameData.BattleGameData.BattleShip battleShip in stepData.BattleShips) { // // Search the Warship // WarshipL warship = Globals.Instance.MPlayerManager.GetWarship(battleShip.ShipID); // // // Assign the base value // warship.Property.WarshipCurrentLife = battleShip.CurrentLife; // warship.Property.WarshipCurrentPower = (short)battleShip.CurrentPower; // Attack is the separate logic GameData.BattleGameData.AttackState attackState = battleShip.AttackState; if (attackState == GameData.BattleGameData.AttackState.IDLE) { continue; } // Construct a skill or a attackEvent? Include multiple be attacked target foreach (GameData.BattleGameData.AttackedTarget attackedTarget in battleShip.AttackedTargets) { // Stat. the num of be attacked WarshipL targetWarship = Globals.Instance.MPlayerManager.GetWarship(attackedTarget.ShipID); if (null == targetWarship) { Debug.Log("[BattleStatus]: Why the target ship " + attackedTarget.ShipID + " is null?"); continue; } targetWarship._numBeAttacked += 1; } } // Part2 foreach (GameData.BattleGameData.BattleShip battleShip in stepData.BattleShips) { // Search the Warship WarshipL warship = Globals.Instance.MPlayerManager.GetWarship(battleShip.ShipID); if (null == warship) { Debug.Log("[BattleStatus]: Why the ship " + battleShip.ShipID + " is null?"); continue; } // Assign the base value warship.Property.WarshipCurrentLife = battleShip.CurrentLife; warship.Property.WarshipCurrentPower = (short)battleShip.CurrentPower; // tzz added for modify some bug // warship.GirlData.PropertyData.Life = battleShip.CurrentLife; warship.GirlData.PropertyData.Power = battleShip.CurrentPower; Vector3 currentPosition = warship.U3DGameObject.transform.position; Vector3 targetPosition = HelpUtil.GetWarFiledGridPosition(battleShip.CurrentPosition); targetPosition += SceneOffset; // Perform the step logci GameData.BattleGameData.MoveState moveState = battleShip.MoveState; switch (moveState) { case GameData.BattleGameData.MoveState.MOVE: { // move speed warship.MoveTo(targetPosition); // tzz added // for teach first move in Teach first enter scene // check TeachFirstEnterGame.cs for detail //if(m_teachStartMovingEvent != null){ // m_teachStartMovingEvent(TeachBattleEvent.e_startMoving); // m_teachStartMovingEvent = null; // // battleStepDuration = 0.0f; // _mDelayTime = DELAY_TIME; //} break; } case GameData.BattleGameData.MoveState.STOP: { warship.ForceMoveTo(targetPosition); break; } case GameData.BattleGameData.MoveState.SINK: { //warship.ForceSink(); break; } } // Attack is the separate logic GameData.BattleGameData.AttackState attackState = battleShip.AttackState; if (attackState == GameData.BattleGameData.AttackState.IDLE) { continue; } // tzz added for setting buffer of fire if (warship.WarshipHeader != null && battleShip.BattleBuffersList != null) { warship.WarshipHeader.SetBufferStepInterval(battleShip.BattleBuffersList, step); } // Only perform the skill effect, construct the skill data now SkillDataSlot skillData = new SkillDataSlot(battleShip.SkillLogicID, warship._warshipID, (int)attackState); // Construct a skill or a attackEvent? Include multiple be attacked target int targetIndex = 0; foreach (GameData.BattleGameData.AttackedTarget attackedTarget in battleShip.AttackedTargets) { WarshipL targetWarship = Globals.Instance.MPlayerManager.GetWarship(attackedTarget.ShipID); if (null == targetWarship) { Debug.Log("[BattleStatus]: Why the target ship " + attackedTarget.ShipID + " is null?"); continue; } int targetMoveState; GetWarshipMoveStateInStep(attackedTarget.ShipID, stepData, out targetMoveState); SkillDataSlot.AttackTargetData attackTargetData = new SkillDataSlot.AttackTargetData(); attackTargetData._targetID = attackedTarget.ShipID; attackTargetData._moveState = targetMoveState; attackTargetData._beAttackedState = (int)attackedTarget.AttackedState; attackTargetData._beAttackedDamage = attackedTarget.Damage; if (targetIndex == 0) { skillData._primaryTargetID = attackTargetData._targetID; attackTargetData._isPrimaryTarget = true; } else { attackTargetData._isPrimaryTarget = false; } skillData._attackTargetDataList.Add(attackedTarget.ShipID, attackTargetData); // tzz added for general command show if (warship.WarshipHeader != null && warship.WarshipHeader.Avatar != null && !skillData.MSkillData.BasicData.SkillIsNormalAttack && // is NOT normal skill targetIndex == 0) // is first target { BattleGeneralCmd.ShowGeneralCmd(warship.WarshipHeader.Avatar, Globals.Instance.MDataTableManager.GetWordText(skillData.MSkillData.BasicData.SkillWord)); } targetIndex++; } warship.Attack(skillData); } UnityEngine.Profiling.Profiler.EndSample(); return(true); }