public void OnBeAttacked(Skill skill) { _numCurrentBeAttacked += 1; // Check this warship is death SkillDataSlot.AttackTargetData beAttackData = skill._mSkillDataSlot._attackTargetDataList[this._warshipID]; int damage = beAttackData._beAttackedDamage; GameData.BattleGameData.AttackedState attackedState = (GameData.BattleGameData.AttackedState)beAttackData._beAttackedState; if (attackedState != GameData.BattleGameData.AttackedState.DODGE) { Property.WarshipSimulateLife -= damage; // tzz modified for damage and cure HP if (Property.WarshipSimulateLife > Property.WarshipMaxLife) { Property.WarshipSimulateLife = Property.WarshipMaxLife; } // Property.WarshipSimulateLife = Mathf.Clamp(Property.WarshipSimulateLife,0,Property.WarshipMaxLife); GirlData.PropertyData.Life = Property.WarshipSimulateLife; float remainLifePercent = (float)Property.WarshipSimulateLife / Property.WarshipMaxLife; if (remainLifePercent <= 0.4f && remainLifePercent > 0.2f) { GameObject go = GetTagPointGameObject(TagPointDefine.TAG_POINT_SHIP_BREAK_DOWN); if (null != go) { ActiveAttachObject(go); } } else if (remainLifePercent <= 0.2f && remainLifePercent > 0f) { GameObject go = GetTagPointGameObject(TagPointDefine.TAG_POINT_SHIP_DESTROY_FRONT); if (null != go) { ActiveAttachObject(go); } go = GetTagPointGameObject(TagPointDefine.TAG_POINT_SHIP_DESTROY_BACK); if (null != go) { ActiveAttachObject(go); } } } if (_numCurrentBeAttacked == _numBeAttacked) { _numBeAttacked = 0; _numCurrentBeAttacked = 0; if (Property.WarshipSimulateLife <= 0.0f) { Stop(); PlayAnimation(AnimationDefine.ANIMATION_DEAD, 1.0f, false, false); { // Play die particle, falling into sea effect GameObject go = GetTagPointGameObject(TagPointDefine.TAG_POINT_SHIP_SPRAY); if (null != go) { ActiveAttachObject(go); } } } else { PlayAnimation(AnimationDefine.ANIMATION_HURT, 1.0f, false, false); } } else { // Play be hit animation PlayAnimation(AnimationDefine.ANIMATION_HURT, 1.0f, false, false); } _bloodValue = (float)Property.WarshipSimulateLife / (float)Property.WarshipMaxLife; _bloodValue = Mathf.Clamp(_bloodValue, 0.0f, 1.0f); //tzz added for REDUCE_DAMAGE_SKILL_ATTACKED // if (!skill._mSkillDataSlot.IsReduceDamangeSkill()) { if (skill._mSkillDataSlot.IsCureSkill()) { _emitEffectFontUtil.EmitEffectFont(_thisGameObject, (GameData.BattleGameData.AttackedState)skill._mSkillDataSlot._attckerAttackState, Mathf.Abs(damage)); } else { _emitEffectFontUtil.EmitEffectFont(_thisGameObject, attackedState, damage); } } _mEventPublisher.NotifyBeAttacked(this, skill); GameStatusManager.Instance.MBattleStatus.OnBeAttacked(this, skill); // tzz added for shaking camera List <SkillEffectData.SkillFireParticleData> t_list = skill._mSkillDataSlot._skillEffectData._skillFireParticleList; if (t_list.Count > 0 && t_list[t_list.Count - 1]._shakeCamera && skill.IsNivoseType()) { iTween.ShakePosition(Globals.Instance.MSceneManager.mMainCamera.gameObject, new Vector3(20, 20, 0), 1); #if UNITY_IPHONE || UNITY_ANDROID if (GameDefines.Setting_ShakeEnable) { Handheld.Vibrate(); } #endif } }
public void OnBeAttacked(SkillDataSlot skillData) { mPublisher.NotifyBeAttacked(this, skillData); numCurrBeAttackedPerStep++; // Check this warship is death long shipId = ShipData.roleCardId; SkillDataSlot.AttackTargetData beAttackData = skillData._attackTargetDataList[shipId]; int damage = beAttackData._beAttackedDamage; GameData.BattleGameData.AttackedState attackedState = (GameData.BattleGameData.AttackedState)beAttackData._beAttackedState; if (attackedState != GameData.BattleGameData.AttackedState.DODGE) { Property.WarshipSimulateLife -= damage; // tzz modified for damage and cure HP if (Property.WarshipSimulateLife > Property.WarshipMaxLife) { Property.WarshipSimulateLife = Property.WarshipMaxLife; } // Property.WarshipSimulateLife = Mathf.Clamp(Property.WarshipSimulateLife,0,Property.WarshipMaxLife); if (numCurrBeAttackedPerStep == numBeAttackedPerStep) { // Reset numBeAttackedPerStep = 0; numCurrBeAttackedPerStep = 0; if (Property.WarshipSimulateLife <= 0.0f) { OnDeath(); } else { if (null != animComponent) { animComponent.Play("Hit", PlayMode.StopAll); // animComponent.CrossFade("Hit"); } } } else { if (null != animComponent) { animComponent.Play("Hit", PlayMode.StopAll); } } } else { if (null != animComponent) { animComponent.Play("Dodge", PlayMode.StopAll); } } UpdateLifeProgress((float)Property.WarshipSimulateLife); UpdatePowerProgress((float)Property.WarshipCurrentPower); //tzz added for REDUCE_DAMAGE_SKILL_ATTACKED // if (!skillData.IsReduceDamangeSkill()) { if (skillData.IsCureSkill()) { emitEffectFont.EmitEffectFont(gameObject, (GameData.BattleGameData.AttackedState)skillData._attckerAttackState, Mathf.Abs(damage)); } else { emitEffectFont.EmitEffectFont(gameObject, attackedState, damage); } } // tzz added for shaking camera List <SkillEffectData.SkillFireParticleData> t_list = skillData._skillEffectData._skillFireParticleList; if (t_list.Count > 0 && t_list[t_list.Count - 1]._shakeCamera && skillData.IsNivoseType()) { // iTween.ShakePosition(Globals.Instance.MSceneManager.mMainCamera.gameObject,new Vector3(20,20,0),1); #if UNITY_IPHONE || UNITY_ANDROID if (GameDefines.Setting_ShakeEnable) { Handheld.Vibrate(); } #endif } }
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); }