private void SetPrefabNumber(UnitCtrl source, Vector3 pos, List <Sprite> numbers, Sprite head, float scale) { GameObject a = Instantiate(numberPrefab); a.transform.position = pos; a.GetComponent <DamageNumbers>().SetDamageNumber(source, numbers, head, scale); }
private int SetRecoveryAndGetOverRecovery(int _value, UnitCtrl _source, BasePartsData _target, bool _isMagic) { eInhibitHealType eInhibit = _isMagic ? eInhibitHealType.MAGIC : eInhibitHealType.PHYSICS; SetRecovery(_value, eInhibit, _source, true, false, false, false, true, _target); return((int)(Hp + _value - BaseValues.Hp)); }
public void SetBuffUI(Sprite sprite, UnitCtrl owner) { rular.sprite = sprite; this.owner = owner; transform.SetParent(owner.transform, false); SetAbnormalIcons(); StartCoroutine(ShowPosition()); }
private void SetPrefabNumber(UnitCtrl source, Vector3 pos, List <Sprite> numbers, Sprite head, float scale) { GameObject a = Instantiate(numberPrefab); Vector3 randomPos = new Vector3(Random.Range(-0.65f, 0.65f), Random.Range(-0.35f, 0.35f), 0); a.transform.position = pos + randomPos; a.GetComponent <DamageNumbers>().SetDamageNumber(source, numbers, head, scale); }
public void InterInitialize(UnitCtrl owner, bool initializeAttackOnly, UnitCtrl seOwner, int unitid) { LoadUnitActionController(unitid); Owner = owner; staticBattleManager = BattleManager.Instance; unitSkillData = MainManager.Instance.UnitRarityDic[unitid].skillData; Initialize(owner, unitid, initializeAttackOnly, seOwner); }
public void SetMissEffect(UnitCtrl source, UnitCtrl target, float scale = 1) { Vector3 randomPos = new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.25f), 0); Vector3 pos = target.transform.position + numberPosFix + randomPos; GameObject a = Instantiate(missPrefab); a.transform.position = pos; a.GetComponent <DamageNumbers>().SetMiss(source, scale); }
public void SetAbnormalState(UnitCtrl source, eAbnormalState abnormalState, float effectTime, ActionParameter action, Skill skill, float value, float value2, bool reduceEnergy, float reduceEnergyRate) { if (action != null) { //获取特效 } if ((this.staticBattleManager.GameState == eGameBattleState.FIGHTING) && ((!this.IsAbnormalState(eAbnormalState.NO_DAMAGE_MOTION) && !this.IsAbnormalState(eAbnormalState.NO_ABNORMAL)) || ABNORMAL_CONST_DATA[abnormalState].IsBuff)) { switch (abnormalState) { case eAbnormalState.BURN: case eAbnormalState.CURSE: case eAbnormalState.SLOW: case eAbnormalState.INHIBIT_HEAL: case eAbnormalState.FAINT: this.OnSlipDamage(); break; } int effecttime_int = (int)(staticBattleManager.FrameRate * effectTime); if (abnormalState == eAbnormalState.GUANG_BOTH && IsAbnormalState(eAbnormalState.DRAIN_BOTH) || abnormalState == eAbnormalState.GUARD_ATK && IsAbnormalState(eAbnormalState.DRAIN_ATK) || abnormalState == eAbnormalState.GUARG_MGC && IsAbnormalState(eAbnormalState.DRAIN_MGC)) { //设置特效 return; } AbnormalStateCategoryData categoryData = abnormalStateCategoryDataDictionary[GetAbnormalStateCategory(abnormalState)]; if (isDead) { return; } if (IsAbnormalState(GetAbnormalStateCategory(abnormalState))) { SwitchAbnormalState(abnormalState, null); } categoryData.Time = effectTime; categoryData.Duration = effectTime; categoryData.MainValue = value; categoryData.SubValue = value2; categoryData.EnergyReduceRate = reduceEnergyRate; categoryData.ActionId = action == null ? 0 : action.ActionId; categoryData.IsEnergyReduceMode = reduceEnergy; categoryData.Skill = skill; categoryData.Source = source; if (!IsAbnormalState(GetAbnormalStateCategory(abnormalState))) { categoryData.CurrentAbnormalState = abnormalState; StartCoroutine(UpdateAbnormalState(abnormalState, null)); } return; } if (IsAbnormalState(eAbnormalState.NO_ABNORMAL)) { SetMissAtk(source, eMissLogType.DODGE_BY_NO_DAMAGE_MOTION, eDamageEffectType.NORMAL, null, 1); } }
public void SetRecovery(int _value, eInhibitHealType _inhibitHealType, UnitCtrl _source, bool _isEffect = true, bool _isRevival = false, bool _isUnionBurstLifeSteal = false, bool _isRegenerate = false, bool _useNumberEffect = true, BasePartsData _target = null) { if (_target == null) { _target = GetFirstParts(true, 0); } if ((isDead || Hp <= 0) && !_isRevival) { Debug.LogError("治疗无效,目标已经死了!"); } else { if (_inhibitHealType != eInhibitHealType.NO_EFFECT && IsAbnormalState(eAbnormalState.INHIBIT_HEAL)) { if (GetAbnormalStateMainValue(eAbnormalStateCategory.INHIBIT_HEAL) != 0) { DamageData damageData_0 = new DamageData(); damageData_0.Target = GetFirstParts(this != null, 0); damageData_0.Damage = Mathf.FloorToInt(GetAbnormalStateMainValue(eAbnormalStateCategory.INHIBIT_HEAL) * _value); damageData_0.DamageType = eDamageType.NONE; AbnormalStateCategoryData abdata = abnormalStateCategoryDataDictionary[eAbnormalStateCategory.INHIBIT_HEAL]; damageData_0.Source = abdata.Source; damageData_0.DamageNumMagic = _inhibitHealType == eInhibitHealType.MAGIC; damageData_0.ActionType = eActionType.INHIBIT_HEAL; SetDamage(damageData_0, false, abdata.ActionId, null, true, abdata.Skill, true, null, false, 1, 1, null); } } else { Hp += _value; //AppendbattleLog; if (Hp > BaseValues.Hp) { Hp = BaseValues.Hp; } unitUI.SetHP(Hp / BaseValues.Hp); string msg = UnitName + "恢复<color=#00FF00>" + _value + "</color>生命"; BattleUIManager.Instance.LogMessage(msg, eLogMessageType.HP_RECOVERY, IsOther); if (_isUnionBurstLifeSteal) { unionburstLifeStealNum += _value; } else { if (_useNumberEffect) { //特效数字 } if (_isEffect) { //治疗特效 } } } } }
public void SetBuffUI(Sprite sprite, UnitCtrl owner) { rular.sprite = sprite; this.owner = owner; uIManager = BattleUIManager.Instance; transform.SetParent(owner.transform, false); SetAbnormalIcons(owner, eStateIconType.NONE, false); owner.OnChangeState += SetAbnormalIcons; StartCoroutine(ShowPosition()); }
public void SetEnergy(float energy, eSetEnergyType type, UnitCtrl source) { //log energy = Mathf.Min(Mathf.Max(0, energy), BattleDefine.MAX_ENERGY); Energy = energy; if (unitUI != null) { unitUI.SetTP(energy / BattleDefine.MAX_ENERGY); } EnergyChange?.Invoke(this); }
private IEnumerator _UpdateNumber(UnitCtrl source) { float time_0 = countTime; float deltaTime = 0.0167f; while (time_0 >= 0) { deltaTime = source.DeltaTimeForPause; transform.Translate(Vector3.up * speed * deltaTime); time_0 -= deltaTime; yield return(null); } Destroy(gameObject); }
public void SetHealNumber(UnitCtrl source, UnitCtrl target, int value, float scale = 1) { string valuestr = value.ToString(); List <Sprite> numbers = new List <Sprite>(); List <Sprite> sprites = number_heal_large; for (int i = 0; i < valuestr.Length; i++) { //int num = (int)valuestr[i]; int num = (int)valuestr[i] - 48; numbers.Add(sprites[num]); } Vector3 pos = target.transform.position + numberPosFix; SetPrefabNumber(source, pos, numbers, null, scale); }
public void SetAbnormalState(UnitCtrl _source, eAbnormalState abnomeralState, float effectTime, ActionParameter action, Skill skill, float value, float value2, bool reduceEnergy, float reduceEnergyRate) { if ((this.staticBattleManager.GameState == eGameBattleState.FIGHTING) && ((!this.IsAbnormalState(eAbnormalState.NO_DAMAGE_MOTION) && !this.IsAbnormalState(eAbnormalState.NO_ABNORMAL)) || ABNORMAL_CONST_DATA[abnomeralState].IsBuff)) { switch (((int)abnomeralState)) { case 9: case 10: case 11: case 0x22: case 0x27: this.OnSlipDamage(); break; } } }
/// <summary> /// 设置伤害特效显示 /// </summary> /// <param name="source">伤害源,用于获取deltatimeforpause</param> /// <param name="numberSprites">数字图片列表,最多6个</param> /// <param name="head">Total、Critical等,没有就写Null</param> /// <param name="scale"></param> public void SetDamageNumber(UnitCtrl source, List <Sprite> numberSprites, Sprite head, float scale = 1) { for (int i = 0; i < numbers.Count; i++) { if (i < numberSprites.Count) { numbers[i].sprite = numberSprites[i]; } else { numbers[i].sprite = null; } } headSprite.sprite = head; transform.localScale = Vector3.one * scale; StartCoroutine(_UpdateNumber(source)); }
public void SetAbnormalIcons(UnitCtrl unitCtrl, eStateIconType stateIconType, bool enable) { if (stateIconType == eStateIconType.NONE) { Reflash(); return; } if (currentBuffs.Contains(stateIconType)) { currentBuffs.Remove(stateIconType); } if (enable) { currentBuffs.Add(stateIconType); } Reflash(); }
public void SetEnergyNumber(UnitCtrl source, UnitCtrl target, int value, float scale = 1) { string valuestr = value.ToString(); List <Sprite> numbers = new List <Sprite>(); List <Sprite> sprites = number_energy_large; for (int i = 0; i < valuestr.Length; i++) { //int num = (int)valuestr[i]; int num = (int)valuestr[i] - 48; numbers.Add(sprites[num]); } Vector3 randomPos = new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.25f), 0); Vector3 pos = target.transform.position + numberPosFix + randomPos; SetPrefabNumber(source, pos, numbers, null, scale); }
public void SetDamageNumber(UnitCtrl source, UnitCtrl target, int value, eDamageType damageType, eDamageEffectType effectType, bool isCritical, bool isTotal) { string valuestr = value.ToString(); List <Sprite> numbers = new List <Sprite>(); List <Sprite> sprites = number_physical_large; if (damageType == eDamageType.MGC) { sprites = number_magical_large; } for (int i = 0; i < valuestr.Length; i++) { //int num = (int)valuestr[i]; int num = (int)valuestr[i] - 48; numbers.Add(sprites[num]); } Sprite head = null; if (isCritical) { if (damageType == eDamageType.MGC) { head = sprite_critical_magical; } else { head = sprite_critical_physical; } } if (isTotal) { head = damageType == eDamageType.MGC ? sprite_total_magical : sprite_total_physical; } float scale = 1; if (effectType == eDamageEffectType.LARGE) { scale = 2; } Vector3 randomPos = new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.25f), 0); Vector3 pos = target.transform.position + numberPosFix + randomPos; SetPrefabNumber(source, pos, numbers, head, scale); }
/// <summary> /// 判断目标是否活着,是否是特殊召唤物或隐身状态 /// </summary> /// <param name="unitCtrl"></param> /// <param name="actionParameter"></param> /// <returns></returns> private bool JudgeIsTarget(UnitCtrl unitCtrl, ActionParameter actionParameter) { if (unitCtrl.isStealth || (unitCtrl.SummonType == eSummonType.PHANTOM && actionParameter.TargetSort != PirorityPattern.OWN_SUMMON_RANDOM)) { return(false); } if ((!unitCtrl.IsDead && unitCtrl.Hp > 0) || unitCtrl.IsDead && unitCtrl.HasUnDeadTime) { if (actionParameter.TargetAssignment == eTargetAssignment.OTHER_SIDE) { return(Owner != unitCtrl); } else { return(true); } } return(false); }
public void SetEnergyNumber(UnitCtrl source, UnitCtrl target, int value, float scale = 1) { string valuestr = value.ToString(); List <Sprite> numbers = new List <Sprite>(); List <Sprite> sprites = number_energy_large; for (int i = 0; i < valuestr.Length; i++) { //int num = (int)valuestr[i]; int num = (int)valuestr[i] - 48; if (num >= 0 && num <= 9) { numbers.Add(sprites[num]); } else { Debug.LogError("伤害数字错误!错误数字:" + num); } } Vector3 pos = target.transform.position + numberPosFix; SetPrefabNumber(source, pos, numbers, null, scale); }
public void SetMiss(UnitCtrl source, float scale) { transform.localScale = Vector3.one * scale; StartCoroutine(_UpdateNumber(source)); }
private void ChargeEnergy(eSetEnergyType setEnergyType, float energy, bool hasEffect, UnitCtrl source, bool hasNumberEffect, bool isEffectTypeCommon, bool useRecoveryRate, bool isRegenerate) { if (!IsAbnormalState(eAbnormalState.TP_REGENERATION) || setEnergyType != eSetEnergyType.BY_ATK && setEnergyType != eSetEnergyType.KILL_BONUS) { if (energy > 0 && useRecoveryRate) { energy *= (100.0f + GetEnergyRecoveryRateZero()) / 100.0f; } SetEnergy(energy + Energy, setEnergyType, source); //加能量特效 string word = UnitName + "通过" + setEnergyType.GetDescription() + (energy >= 0 ? "增加<color=#3791FF>" : "减少<color=#3791FF>") + Mathf.Abs(energy) + "</color>点能量"; BattleUIManager.Instance.LogMessage(word, eLogMessageType.CHANGE_TP, IsOther); } }
private IEnumerator UpdateBuffParam(BuffParamKind _kind, Dictionary <BasePartsData, int> _value, float _maxTime, int _skillId, UnitCtrl _source, bool _despelable, int _buffDebuffId, bool _isBuff, bool _additional) { EnableBuffParam(_kind, _value, true, _source, _isBuff, _additional); float time_5 = 0; while (true) { time_5 += DeltaTimeForPause; if (DeltaTimeForPause > 1) { //buffDebuffSkilIds.Remove(_skillId); } bool k = _buffDebuffId <= (_despelable && _isBuff ? clearedBuffIndex : clearedDebuffIndex); bool v16 = false; if (time_5 >= _maxTime || IdleOnly) { v16 = true; } else { v16 = Hp < 1; } if (k || v16) { //buffDebuffSkilIds.Remove(_skillId);//特效相关 EnableBuffParam(_kind, _value, false, _source, _isBuff, _additional); yield break; } yield return(null); } }
public void SetBuffParam(BuffParamKind _kind, Dictionary <BasePartsData, int> _value, float _time, int _skillId, UnitCtrl _source, bool _despelable, eEffectType _effectType, bool _isBuff, bool _additional) { if (_isBuff || !IsAbnormalState(eAbnormalState.NO_EFFECT_SLIP_DAMAGE)) { if (_effectType == eEffectType.COMMON) { //添加特效图标 } buffDebuffIndex++; StartCoroutine(UpdateBuffParam(_kind, _value, _time, _skillId, _source, _despelable, buffDebuffIndex, _isBuff, _additional)); } else { SetMissAtk(_source, eMissLogType.DODGE_BY_NO_DAMAGE_MOTION, eDamageEffectType.NORMAL, null, 1); } }
public void EnableBuffParam(BuffParamKind _kind, Dictionary <BasePartsData, int> _value, bool _enable, UnitCtrl _source, bool _isBuff, bool _additional) { eStateIconType bufficon; BuffDebuffConstData buffDebuffConstData = new BuffDebuffConstData(0, 0); if (BUFF_DEBUFF_ICON_DIC.TryGetValue(_kind, out BuffDebuffConstData buffDebuffConstData1)) { buffDebuffConstData = buffDebuffConstData1; } else { string word = UnitName + "的BUFF图标种类出错,未找到种类为" + _kind.GetDescription() + "的图标!"; BattleUIManager.Instance.LogMessage(word, eLogMessageType.ERROR, IsOther); } if (_isBuff) { bufficon = buffDebuffConstData.BuffIcon; } else { bufficon = buffDebuffConstData.DebuffIcon; } OnChangeState?.Invoke(this, bufficon, _enable); if (bufficon != eStateIconType.NONE) { if (_enable) { if (_isBuff) { buffCounter++; } else { debuffCounter++; } } else { if (_isBuff) { buffCounter--; } else { debuffCounter--; } } } foreach (BasePartsData a in _value.Keys) { a.SetBuffDebuff(_enable, _value[a], _kind, _source, null, _additional); } }
public void EnableBuffParam(BuffParamKind _kind, Dictionary <BasePartsData, int> _value, bool _enable, UnitCtrl _source, bool _isBuff, bool _additional) { }
internal int SetDamage(DamageData damageData, bool byAttack, int actionId, ActionParameter.OnDamageHitDelegate onDamageHit, bool hasEffect, Skill skill, bool energyAdd, Action onDefeat, bool noMotion, float weight, float actionWeightSum, Func <int, float, int> p) { int randomInt = staticBattleManager.Random(); bool critical = false; if (randomInt <= damageData.CriticalRate && damageData.CriticalRate != 0) { critical = true; } if (damageData.ActionType == eActionType.ATTACK) { eDamageType damageType = damageData.DamageType; if ((damageType == eDamageType.ATK && IsAbnormalState(eAbnormalState.LOG_ATK_BARRIR)) || (damageType == eDamageType.MGC && IsAbnormalState(eAbnormalState.LOG_MGC_BARRIR)) || IsAbnormalState(eAbnormalState.LOG_ALL_BARRIR)) { critical = damageData.IsLogBarrierCritical; } } int damage = SetDamageImpl(damageData, byAttack, onDamageHit, hasEffect, skill, energyAdd, critical, onDefeat, noMotion, p); //boss相关代码鸽了 if (damageData.Source != null) { if (damageData.ActionType != eActionType.DESTROY) { if (damageData.ActionType != eActionType.ATTACK_FIELD && (skill == null || skill.IsLifeStealEnabled)) { int lifesteal = damageData.LifeSteal; if (skill != null) { lifesteal += skill.LifeSteal; } if (lifesteal >= 1) { float recovery_value = lifesteal * damage / (lifesteal + UnitData.level + 100); if (recovery_value > 0) { eInhibitHealType eh = damageData.DamageType == eDamageType.MGC ? eInhibitHealType.MAGIC : eInhibitHealType.PHYSICS; SetRecovery((int)recovery_value, eh, damageData.Source, false, false, false,//鸽了 false, true, null); } } } } if (IsOther ^ damageData.Source.IsOther) { UnitCtrl source = damageData.Source; if (damageData.Source.SummonType != eSummonType.NONE) { source = source.SummonSource; } //伤害统计 if (source != null) { //source.UnitDamageinfo.Setdamage(damage + 原伤害) } } } accumulateDamage += damage; //log if (skill != null) { if (damageData.Source != null) { if (skill.SkillId == damageData.Source.UBSkillId) { if (byAttack) { damageData.Target.PassiveUbIsMagic = damageData.DamageType == eDamageType.MGC; } damageData.Target.TotalDamage += damage; } } if (damage >= 1) { if (!skill.DamageedPartsList.Contains(damageData.Target)) { skill.DamageedPartsList.Add(damageData.Target); } } } if (damageData.Source != null) { if (damage >= 1 && DamageSealDataDictionary.ContainsKey(damageData.Source)) { Dictionary <int, AttackSealData> dic = DamageSealDataDictionary[damageData.Source]; foreach (AttackSealData sealData in dic.Values) { if (!sealData.OnlyCritical || critical) { sealData.AddSeal(this); } } } if (damage >= 1 && damageData.Source.DamageOnceOwnerSealDateDictionary.ContainsKey(damageData.Source) && skill != null) { if (!skill.AlreadyAddAttackSelfSeal) { Dictionary <int, AttackSealData> dic2 = DamageOnceOwnerSealDateDictionary[damageData.Source]; foreach (AttackSealData sealData in dic2.Values) { sealData.AddSeal(damageData.Source); } skill.AlreadyAddAttackSelfSeal = true; } } } if (damageData.Source == null || damage < 1 || !damageData.Source.DamageOwnerSealDataDictionary.ContainsKey(damageData.Source)) { if (skill == null) { return(damage); } skill.TotalDamage += damage; return(damage); } foreach (AttackSealData sealData1 in damageData.Source.DamageOwnerSealDataDictionary[damageData.Source].Values) { if (sealData1.OnlyCritical) { if (critical) { sealData1.AddSeal(damageData.Source); } } else { sealData1.AddSeal(damageData.Source); } } if (skill != null) { skill.TotalDamage += damage; } return(damage); }
private void Initialize(UnitCtrl owner, int unitid, bool initializeAttackOnly, UnitCtrl seOwner) { //Attack = new Skill(); Attack.animationId = eAnimationType.attack; if (initializeAttackOnly) { Attack.WeaponType = seOwner.WeaponSeType; } else { Attack.WeaponType = owner.WeaponSeType; } Attack.skillAreaWidth = Owner.SearchAreaWidth; Attack.SkillId = 1; Attack.SkillName = "普攻"; AttackAction attackAction = new AttackAction(); attackAction.TargetAssignment = eTargetAssignment.OTHER_SIDE; attackAction.TargetSort = PirorityPattern.NEAR; attackAction.TargetNth = 0; attackAction.TargetNum = 1; attackAction.TargetWidth = Owner.SearchAreaWidth; attackAction.Direction = DirectionType.FRONT; attackAction.ActionType = eActionType.ATTACK; attackAction.TargetList = new List <BasePartsData>(); attackAction.Value = new Dictionary <int, float> { { 1, 0 }, { 3, 1 } }; attackAction.ActionDetail1 = owner.AtkType; if (UseDefaultDelay) { if (!initializeAttackOnly) { seOwner = owner; } if (BattleDefine.WEAPON_HIT_DELAY_DIC.TryGetValue(seOwner.WeaponMotionType, out float value)) { List <ActionExecTime> execTimes = new List <ActionExecTime>(); ActionExecTime execTime = new ActionExecTime(); execTime.Weight = 1; execTime.DamageNumType = eDamageEffectType.NORMAL; execTimes.Add(execTime); attackAction.ExecTime = new float[1] { value }; attackAction.ActionWeightSum = 1; attackAction.ActionExecTimeList = execTimes; } } else { attackAction.ExecTime = new float[1] { AttackDetail.ExecTimeForPrefab[0].Time }; attackAction.ActionWeightSum = 1; attackAction.ActionExecTimeList = AttackDetail.ExecTimeForPrefab; } attackAction.ActionChildrenIndexes = new List <int>(); //attackAction.ActionId = Attack.ActionParmeters = new List <ActionParameter>(); Attack.ActionParmeters.Add(attackAction); skillDictionary.Add(1, Attack); DependActionSolve(Attack); ExecActionOnStart(Attack); if (!initializeAttackOnly) { isUnionBurstOnlyOwner = unitSkillData.UB != 0; UnionBurstList[0].SkillNum = 0; UnionBurstList[0].SkillId = unitSkillData.UB; skillDictionary.Add(unitSkillData.UB, UnionBurstList[0]); //skillDictionary.Add(unitSkillData.UB_ev, UnionBurstEvolutionList[0]); //UnionBurstEvolutionList[0].SkillNum = 0; /*if (MainSkillList.Count >= 1) * { * for(int i = 0; i < MainSkillList.Count; i++) * { * skillDictionary .Add(unitSkillData.) * } * }*/ skillDictionary.Add(owner.Skill_1Id, MainSkillList[0]); MainSkillList[0].SkillNum = 0; MainSkillList[0].SkillId = unitSkillData.skill_1; skillDictionary.Add(owner.Skill_2Id, MainSkillList[1]); MainSkillList[1].SkillNum = 1; MainSkillList[1].SkillId = unitSkillData.skill_2; } foreach (Skill skill in skillDictionary.Values) { SetSkillParameter(skill); } }
private void ChargeEnergy(eSetEnergyType setEnergyType, float energy, bool hasEffect, UnitCtrl source, bool hasNumberEffect, bool isEffectTypeCommon, bool useRecoveryRate, bool isRegenerate) { }