// Design requirement 2013.01.15: client calulate the nivose skill damage range void CalculateNivoseHitRange(List <SkillDamageRange.Rect> rectList) { if (skillDataSlot.MSkillData.BasicData.SkillType == ESkillType.GROUP_NIVOSE) { rectList.Clear(); if (skillUser.Property.WarshipIsAttacker) { // Its damage range is the be attacked position for (int i = 1; i <= 4; i++) { for (int j = -3; j <= 2; j++) { SkillDamageRange.Rect rect = new SkillDamageRange.Rect(); rect.left = ((float)i - 0.5f) * GameDefines.BATTLE_GRID_WIDTH; rect.right = ((float)i + 0.5f) * GameDefines.BATTLE_GRID_WIDTH; rect.top = ((float)j + 0.5f) * GameDefines.BATTLE_GRID_HEIGHT; rect.bottom = ((float)j - 0.5f) * GameDefines.BATTLE_GRID_HEIGHT; rectList.Add(rect); } } } else { for (int i = -4; i < -1; i++) { for (int j = -3; j <= 2; j++) { SkillDamageRange.Rect rect = new SkillDamageRange.Rect(); rect.left = ((float)i - 0.5f) * GameDefines.BATTLE_GRID_WIDTH; rect.right = ((float)i + 0.5f) * GameDefines.BATTLE_GRID_WIDTH; rect.top = ((float)j + 0.5f) * GameDefines.BATTLE_GRID_HEIGHT; rect.bottom = ((float)j - 0.5f) * GameDefines.BATTLE_GRID_HEIGHT; rectList.Add(rect); } } } // End if () } // End if () }
public static SkillDamageRange ParseSkillRange(string val) { // [[-1,-1],[1,-1],[-1,1],[1,1]] SkillDamageRange range = new SkillDamageRange(); range._damageRectList.Clear(); // Add the primary damage rect[0, 0] { SkillDamageRange.Rect rect = new SkillDamageRange.Rect(); rect.x = 0; rect.z = 0; Vector3 gridPos = GetGridPosition(rect.x, rect.z); rect.left = gridPos.x - 0.5f * GameDefines.BATTLE_GRID_WIDTH; rect.right = gridPos.x + 0.5f * GameDefines.BATTLE_GRID_WIDTH; rect.top = gridPos.z + 0.5f * GameDefines.BATTLE_GRID_HEIGHT; rect.bottom = gridPos.z - 0.5f * GameDefines.BATTLE_GRID_HEIGHT; range._damageRectList.Add(rect); } val = val.Replace("[", ""); val = val.Replace("]", ""); // Parse others char [] splitter = { ',' }; string[] vecs = val.Split(splitter); if (vecs.Length == 0) { return(range); } if (vecs.Length == 1 // Equal with "0" && (vecs[0].CompareTo("0") == 0)) { return(range); } if (vecs.Length % 2 != 0) { return(range); } for (int i = 0; i < vecs.Length; i += 2) { SkillDamageRange.Rect rect = new SkillDamageRange.Rect(); rect.x = StrParser.ParseDecInt(vecs[i], -10000); rect.z = StrParser.ParseDecInt(vecs[i + 1], -10000); Vector3 gridPos = GetGridPosition(rect.x, rect.z); rect.left = gridPos.x - 0.5f * GameDefines.BATTLE_GRID_WIDTH; rect.right = gridPos.x + 0.5f * GameDefines.BATTLE_GRID_WIDTH; rect.top = gridPos.z + 0.5f * GameDefines.BATTLE_GRID_HEIGHT; rect.bottom = gridPos.z - 0.5f * GameDefines.BATTLE_GRID_HEIGHT; range._damageRectList.Add(rect); } return(range); }
protected void CalculateHitParticleType(SkillDamageRange.Rect rect, out EHitParticleType hitType, out Vector3 hitPos) { hitType = EHitParticleType.HIT_PARTICLE_PRIMARY; hitPos = Vector3.zero; Rect checkRect = new Rect(); checkRect.xMin = rect.left; checkRect.yMin = rect.bottom; checkRect.xMax = rect.right; checkRect.yMax = rect.top; GUIBattleMain battle = Globals.Instance.MGUIManager.GetGUIWindow <GUIBattleMain>(); if (null == battle) { return; } // Calculate the real damage rect if (skillDataSlot.MSkillData.BasicData.SkillType != ESkillType.GROUP_NIVOSE) { FightCellSlot target = battle.GetFightCellSlot(skillDataSlot._primaryTargetID); if (null == target) { return; } Vector3 attachPosition = target.transform.position; checkRect.xMin += attachPosition.x; checkRect.yMin += attachPosition.z; checkRect.xMax += attachPosition.x; checkRect.yMax += attachPosition.z; } // Add the be attacked target effect on the target foreach (SkillDataSlot.AttackTargetData attackTargetData in skillDataSlot._attackTargetDataList.Values) { FightCellSlot target = battle.GetFightCellSlot(attackTargetData._targetID); Vector3 attachPosition = target.transform.position; bool isContains = checkRect.Contains(new Vector2(attachPosition.x, attachPosition.z)); if (isContains && attackTargetData._isPrimaryTarget) { hitType = EHitParticleType.HIT_PARTICLE_PRIMARY; hitPos = attachPosition; return; } else if (isContains) { hitType = EHitParticleType.HIT_PARTICLE_ASSISTANT; hitPos = attachPosition; return; } } // End foreach hitType = EHitParticleType.HIT_PARTICLE_WATER_SURFACE; hitPos.x = checkRect.center.x; hitPos.y = 0.0f; hitPos.z = checkRect.center.y; }
public virtual void CreateHitParticle() { bool isCreate = false; // Create the hit particles foreach (SkillEffectData.SkillHitParticleData hitParticleData in skillDataSlot._skillEffectData._skillHitParticleList) { // Play fire sound if (null != hitParticleData._skillSound) { Globals.Instance.MSoundManager.PlaySoundEffect(hitParticleData._skillSound._soundName); } // Calculate hit particle type according to DamageRange List <SkillDamageRange.Rect> rectList = null; // Check is need to inverse skill damage range bool isSingleSkill = skillDataSlot._skillDamageRange._damageRectList.Count == 1; if (isSingleSkill || skillUser.Property.WarshipIsAttacker) { rectList = skillDataSlot._skillDamageRange._damageRectList; } else { // Inverse legend, x Axis rectList = new List <SkillDamageRange.Rect>(); foreach (SkillDamageRange.Rect rect in skillDataSlot._skillDamageRange._damageRectList) { SkillDamageRange.Rect invRect = new SkillDamageRange.Rect(); invRect.left = -rect.left; invRect.right = -rect.right; invRect.bottom = rect.bottom; invRect.top = rect.top; rectList.Add(invRect); } } // Calulate the Nivose damage range CalculateNivoseHitRange(rectList); // Optimize the warter effect count int waterBloomIndex = 0; int waterBloomLimit = 20; foreach (SkillDamageRange.Rect rect in rectList) { EHitParticleType hitType; Vector3 hitPos; CalculateHitParticleType(rect, out hitType, out hitPos); if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE && waterBloomIndex >= waterBloomLimit) { continue; } UnityEngine.Object obj = null; switch (hitType) { case EHitParticleType.HIT_PARTICLE_PRIMARY: { obj = Resources.Load(hitParticleData._primaryParticleName); break; } case EHitParticleType.HIT_PARTICLE_ASSISTANT: { obj = Resources.Load(hitParticleData._assistantParticleName); break; } case EHitParticleType.HIT_PARTICLE_WATER_SURFACE: { waterBloomIndex++; obj = Resources.Load(hitParticleData._waterSurfaceParticleName); break; } } if (null == obj) { isCreate = true; Debug.Log("[Skill]: Cann't find the hit effect name " + hitParticleData._primaryParticleName); break; } hitPos.z += FightCellSlot.EffectSkillOffset; GUIBattleMain battle = Globals.Instance.MGUIManager.GetGUIWindow <GUIBattleMain>(); if (null == battle) { return; } FightCellSlot primaryTarget = battle.GetFightCellSlot(skillDataSlot._primaryTargetID); // Optimize the warter effect count if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE) { if (waterBloomIndex % 2 == 0) { GameObject go = Globals.Instance.M3DItemManager.CreateEZ3DItem(obj, hitPos); go.transform.position = hitPos; // Inverse the particle if (!primaryTarget.Property.WarshipIsAttacker) { Vector3 scale = go.transform.localScale; scale.x *= -1f; go.transform.localScale = scale; } Globals.Instance.M3DItemManager.DestroyEZ3DItem(go, hitParticleData._durationTime); } } else { GameObject go = Globals.Instance.M3DItemManager.CreateEZ3DItem(obj, hitPos); go.transform.position = hitPos; // Inverse the particle if (!primaryTarget.Property.WarshipIsAttacker) { Vector3 scale = go.transform.localScale; scale.x *= -1f; go.transform.localScale = scale; } Globals.Instance.M3DItemManager.DestroyEZ3DItem(go, hitParticleData._durationTime); } obj = null; // Release it isCreate = true; } } isHitParticleCreated = isCreate; }
protected void CalculateHitParticleType(SkillDamageRange.Rect rect, out EHitParticleType hitType, out Vector3 hitPos) { hitType = EHitParticleType.HIT_PARTICLE_PRIMARY; hitPos = Vector3.zero; // // Left-Bottom // Vector3 leftBottomPos = HelpUtil.GetGridPosition(rect.left, rect.bottom); // // Left-Top // Vector3 leftTopPos = HelpUtil.GetGridPosition(rect.left, rect.top); // // // Right-Bottom // Vector3 rightBottomPos = HelpUtil.GetGridPosition(rect.right, rect.bottom); // // Right-Top // Vector3 rightTopPos = HelpUtil.GetGridPosition(rect.right, rect.top); Rect checkRect = new Rect(); checkRect.xMin = rect.left; checkRect.yMin = rect.bottom; checkRect.xMax = rect.right; checkRect.yMax = rect.top; // Calculate the real damage rect if (_mSkillDataSlot.MSkillData.BasicData.SkillType != ESkillType.GROUP_NIVOSE) { WarshipL target = Globals.Instance.MPlayerManager.GetWarship(_mSkillDataSlot._primaryTargetID); Vector3 attachPosition = target.U3DGameObject.transform.position; checkRect.xMin += attachPosition.x; checkRect.yMin += attachPosition.z; checkRect.xMax += attachPosition.x; checkRect.yMax += attachPosition.z; } // Add the be attacked target effect on the target foreach (SkillDataSlot.AttackTargetData attackTargetData in _mSkillDataSlot._attackTargetDataList.Values) { WarshipL target = Globals.Instance.MPlayerManager.GetWarship(attackTargetData._targetID); Vector3 attachPosition = target.U3DGameObject.transform.position; bool isContains = checkRect.Contains(new Vector2(attachPosition.x, attachPosition.z)); if (isContains && attackTargetData._isPrimaryTarget) { hitType = EHitParticleType.HIT_PARTICLE_PRIMARY; hitPos = attachPosition; return; } else if (isContains) { hitType = EHitParticleType.HIT_PARTICLE_ASSISTANT; hitPos = attachPosition; return; } } // End foreach // hitType = EHitParticleType.HIT_PARTICLE_WATER_SURFACE; hitPos.x = checkRect.center.x; hitPos.y = 0.0f; hitPos.z = checkRect.center.y; }
public virtual void CreateHitParticle() { bool isCreate = false; // Create the hit particles foreach (SkillEffectData.SkillHitParticleData hitParticleData in _mSkillDataSlot._skillEffectData._skillHitParticleList) { // Play fire sound if (null != hitParticleData._skillSound) { Globals.Instance.MSoundManager.PlaySoundEffect(hitParticleData._skillSound._soundName); } // Calculate hit particle type according to DamageRange List <SkillDamageRange.Rect> rectList = null; // Check is need to inverse skill damage range bool isSingleSkill = _mSkillDataSlot._skillDamageRange._damageRectList.Count == 1; if (isSingleSkill || _mSkillUser.Property.WarshipIsAttacker) { rectList = _mSkillDataSlot._skillDamageRange._damageRectList; } else { // Inverse legend, x Axis rectList = new List <SkillDamageRange.Rect>(); foreach (SkillDamageRange.Rect rect in _mSkillDataSlot._skillDamageRange._damageRectList) { SkillDamageRange.Rect invRect = new SkillDamageRange.Rect(); invRect.left = -rect.left; invRect.right = -rect.right; invRect.bottom = rect.bottom; invRect.top = rect.top; rectList.Add(invRect); } } // Calulate the Nivose damage range CalculateNivoseHitRange(rectList); // Optimize the warter effect count int waterBloomIndex = 0; int waterBloomLimit = 20; foreach (SkillDamageRange.Rect rect in rectList) { EHitParticleType hitType; Vector3 hitPos; CalculateHitParticleType(rect, out hitType, out hitPos); if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE && waterBloomIndex >= waterBloomLimit) { continue; } UnityEngine.Object obj = null; switch (hitType) { case EHitParticleType.HIT_PARTICLE_PRIMARY: { obj = Resources.Load(hitParticleData._primaryParticleName); break; } case EHitParticleType.HIT_PARTICLE_ASSISTANT: { obj = Resources.Load(hitParticleData._assistantParticleName); break; } case EHitParticleType.HIT_PARTICLE_WATER_SURFACE: { waterBloomIndex++; obj = Resources.Load(hitParticleData._waterSurfaceParticleName); break; } } if (null == obj) { isCreate = true; Debug.Log("[Skill]: Cann't find the hit effect name " + hitParticleData._primaryParticleName); break; } // Optimize the warter effect count if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE) { if (waterBloomIndex % 2 == 0) { GameObject go = GameObject.Instantiate(obj, hitPos, Quaternion.identity) as GameObject; MonoBehaviour.DestroyObject(go, 3.0f); } } else { GameObject go = GameObject.Instantiate(obj, hitPos, Quaternion.identity) as GameObject; MonoBehaviour.DestroyObject(go, 3.0f); } isCreate = true; } } _isHitParticleCreated = isCreate; }