public override void TakeDamage(float damage, string attackerID) { base.TakeDamage(damage, attackerID); currentHp -= damage; StopCoroutine("ToRed"); StartCoroutine("ToRed"); if (currentHp <= 0) { Debug.Log("Die"); bomb.SetActive(true); bomb.transform.position = transform.position += new Vector3(0, 1, 0); AudioManager.GetInstance().PlaySound(4); GameMgr.instance.TurnToAngel(attackerID, GetComponent <AngleControl>().id); FightManager.GetInstance().ToGhost(GetComponent <AngleControl>().id); FightManager.GetInstance().ToAngle(attackerID); currentHp = maxHp; } if (HpSlider) { HpSlider.value = currentHp; } else { Debug.LogError("No Slider"); } //splashTimer = Time.time; //splashTime = Time.time; }
void Update() { UpdateHeadShot(); UpdateEnergy(); //按左走或者 按右走 if (isLPress) { FightManager.GetInstance().MoveBack(); } else if (isRPress) { FightManager.GetInstance().MoveForward(); } //摄像机运动 FightManager.GetInstance().CaculateCinemaParameter(); FightManager.GetInstance().CinemaMoveBack(); FightManager.GetInstance().CinemaMoveToward(); //战斗背景移动 // ScrollSceneManager.instance.CaculateBackgroundParameter (); // ScrollSceneManager.instance.BackGroundMoveBack (); // ScrollSceneManager.instance.BackGroundMoveToward (); }
void Awake() { group = GroupType.Mine; FightManager.GetInstance().mineGroup = this; heroDataDic = Util.GetDic <MsgHeroData, HeroData>(); heroEvolution = Util.GetDic <MsgHeroEvolution, HeroEvolution>(); }
/// <summary> /// 取得某个坐标附近的单位(指定阵营或全阵营) /// </summary> public static List <FightUnit> GetPosNearby(Vector3 pos, float range, FightGroup targetGroup) { List <FightUnit> targets = new List <FightUnit>(); if (targetGroup != null) { for (int i = 0; i < targetGroup.fightUnits.Count; i++) { if (Util.Distance(pos, targetGroup.fightUnits[i].transform.localPosition) <= range) { targets.Add(targetGroup.fightUnits[i]); } } } else { for (int i = 0; i < FightManager.GetInstance().mineGroup.fightUnits.Count; i++) { if (Util.Distance(pos, FightManager.GetInstance().mineGroup.fightUnits[i].transform.localPosition) <= range) { targets.Add(FightManager.GetInstance().mineGroup.fightUnits[i]); } } for (int i = 0; i < FightManager.GetInstance().enemyGroup.fightUnits.Count; i++) { if (Util.Distance(pos, FightManager.GetInstance().enemyGroup.fightUnits[i].transform.localPosition) <= range) { targets.Add(FightManager.GetInstance().enemyGroup.fightUnits[i]); } } } return(targets); }
void OnClick_AutoFight(params object[] objs) { if (FightManager.GetInstance().isAutoFight) { FightManager.GetInstance().DisableAutoFight(); } else { FightManager.GetInstance().EnableAutoFight(); } }
/// <summary> /// buff造成伤害 /// </summary> public static void BuffAttackDamage(Buff buff, HurtType hurtType) { if (buff.target.isInvincible) { return; } FightUnit target = buff.target; int hurtNum = 0; if (hurtType == HurtType.True) { hurtNum = Mathf.RoundToInt(buff.buffValue * (1 - target.fightAttribute.allDefenseRate)); } else { float elementDefenseFactor = 0; switch (hurtType) { case HurtType.Fire: elementDefenseFactor = target.fightAttribute.fireDefenseRate; break; case HurtType.Water: elementDefenseFactor = target.fightAttribute.waterDefenseRate; break; case HurtType.Earth: elementDefenseFactor = target.fightAttribute.eathDefenseRate; break; case HurtType.Light: elementDefenseFactor = target.fightAttribute.lightDefeneseRate; break; case HurtType.Dark: elementDefenseFactor = target.fightAttribute.darkDefenseRate; break; } hurtNum = Mathf.RoundToInt(buff.buffValue * (1 - target.fightAttribute.allDefenseRate) * (1 - elementDefenseFactor)); } hurtNum = Mathf.Max(0, hurtNum); //护盾计算 hurtNum = CaculateHudun(hurtNum, target, hurtType); //伤血 HealthUIManager.instance.DisplayHurtNum(target, hurtNum.ToString(), true, false); target.health -= hurtNum; if (target.health == 0) { FightManager.GetInstance().UnitDead(buff.source, target); } }
/// <summary> /// 反弹伤害 /// </summary> public static void FantanDamage(int hurtNum, FightUnit attacker, FightUnit target) { if (target.isInvincible || target == null) { return; } //伤血 HealthUIManager.instance.DisplayHurtNum(target, hurtNum.ToString(), true, false); target.health -= hurtNum; if (target.health == 0) { FightManager.GetInstance().UnitDead(attacker, target); } }
IEnumerator Kongxi(AirWave wave) { yield return(new WaitForSeconds(wave.firstTime)); float waveInterval = Random.Range(wave.waveInterval[0], wave.waveInterval[1]); while (true) { int count = Random.Range(wave.crowNum[0], wave.crowNum[1] + 1); bool isToRight = Random.value <= 0.5f; FightGroup targetGroup = isToRight ? (FightGroup)FightManager.GetInstance().enemyGroup : (FightGroup)FightManager.GetInstance().mineGroup; while (targetGroup.fightUnits.Count == 0) { yield return(null); } Vector3 from, to; if (isToRight) { from = left.localPosition; to = right.localPosition; } else { to = left.localPosition; from = right.localPosition; } for (int i = 0; i < count; i++) { GameObject obj = Instantiate(wuya) as GameObject; obj.transform.parent = transform; obj.transform.localScale = Vector3.one; if (isToRight) { obj.transform.localRotation = Quaternion.Euler(0, 180, 0); } obj.SetActive(true); KongxiWuya kongxiWuya = obj.GetComponent <KongxiWuya>(); Vector3 target = GetOneTarget(targetGroup); kongxiWuya.from = from; kongxiWuya.to = to; kongxiWuya.target = target; kongxiWuya.speed = 100f; yield return(new WaitForSeconds(wave.interval)); } yield return(new WaitForSeconds(waveInterval)); } }
public static GameObject CreateLineAoe(string goName, Transform parent, Vector3 goPos, float xSpeed, bool isRight, HitHandler callBack) { GameObject obj = new GameObject(goName); obj.transform.parent = parent; obj.transform.localScale = Vector3.one; obj.transform.localPosition = goPos; LineAoeMove move = obj.AddComponent <LineAoeMove>(); move.xSpeed = xSpeed; move.direct = isRight ? Vector3.right : -Vector3.right; FightGroup targetGroup = isRight ? (FightGroup)FightManager.GetInstance().enemyGroup : FightManager.GetInstance().mineGroup; move.ToHitUnits = new List <FightUnit>(targetGroup.fightUnits); move.OnHit = callBack; return(obj); }
/// <summary> /// 每次普通攻击结束后思考一次是否使用技能 /// </summary> public void ThinkUseSkill(object[] objs) { if (self.isConfused) { if (FightManager.GetInstance().needEnergy <= FightEnergy.instance.EnergyVal) { isAutoUseUniqueSkill = true; } else if (normalSkill.cdValue != 0) { isAutoUseSkill = true; } } else if (FightManager.GetInstance().isAutoFight&& normalSkill.cdValue == 0 && Random.value * 10000 <= normalSkill.normalSkill.weight) { isAutoUseSkill = true; } }
void Update() { if (MovingToNext) { firstUnit.transform.position = Vector3.MoveTowards(firstUnit.transform.position, firstEndPos, Const.MoveToNextSpeed * Time.deltaTime); for (int i = 0; i < fightUnits.Count; i++) { if (fightUnits[i] == firstUnit) { continue; } fightUnits[i].transform.position += Const.MoveToNextSpeed * Time.deltaTime * Vector3.left; } if (firstUnit.transform.position == firstEndPos) { MovingToNext = false; FightManager.GetInstance().EndMoveToNext(); } } }
void Update() { if (MovingToNext) { firstUnit.transform.position = Vector3.MoveTowards(firstUnit.transform.position, firstEndPos, Const.MoveToNextSpeed * Time.deltaTime); for (int i = 0; i < fightUnits.Count; i++) { if (fightUnits[i] == firstUnit) { continue; } fightUnits[i].transform.position += Const.MoveToNextSpeed * Time.deltaTime * Vector3.left; } if (firstUnit.transform.position == firstEndPos) { MovingToNext = false; FightManager.GetInstance().EndMoveToNext(); } } if (this.FirstUnit.mTrans.localPosition.x >= (this.heroRStopPos.localPosition.x + this.heroRStopPos.parent.localPosition.x)) { this.FirstUnit.parentGroup.canMoveForward = false; } else { this.FirstUnit.parentGroup.canMoveForward = true; } if (this.FirstUnit.mTrans.localPosition.x <= (this.heroLStopPos.localPosition.x + this.heroLStopPos.parent.localPosition.x)) { this.FirstUnit.parentGroup.canMoveBack = false; } else { this.FirstUnit.parentGroup.canMoveBack = true; } }
void OnClick_BeginFight(params object[] objs) { FightManager.GetInstance().BeginToFight(); button_click_fight.Play(); }
public override void Start() { base.Start(); targetGroup = FightManager.GetInstance().enemyGroup; }
void Awake() { group = GroupType.Enemy; FightManager.GetInstance().enemyGroup = this; monsterDataDic = Util.GetDic <MsgMonsterData, MonsterData>(); }
public override void Start() { base.Start(); targetGroup = FightManager.GetInstance().mineGroup; InstUnits(); }
/// <summary> /// 普通攻击伤害 /// 普通攻击伤害=攻击方最终攻击*防御效果*攻击方伤害加成效果系数*防御方对应属性免伤系数*防御方全免伤系数*属性相克系数*暴击伤害系数*random(0.95,1.05) /// 防御效果=1/(1+防御系数*防御方最终防御) /// 防御效果必须介于20%和100%之间,这两个参数由策划配置 /// 防御常数为常量,由策划配置,下同 /// 普通攻击的属性和单位自身的属性相同 /// </summary> public static void NormalAttackDamage(FightUnit attacker, FightUnit target, NormalAttack skill, SpecialEffect hitEffect) { if (target == null || attacker == null || target.isInvincible) { return; } //判断命中 if (IsMiss(attacker, target)) { HealthUIManager.instance.DisplayHurtNum(target, "Miss", true, false); //触发闪避事件 if (target.OnDodge != null) { target.OnDodge(); } return; } //判断无敌 if (target.isInvincible) { HealthUIManager.instance.DisplayHurtNum(target, "Invincible", true, false); return; } //判断暴击 bool isCrit = false; float critScale = 1f; if (IsCritical(attacker, target)) { isCrit = true; critScale = Const.CONST_BASIC_CRIT_DMG + attacker.fightAttribute.criticalImprove; //当普通攻击暴击时 if (attacker.OnNormalAttackCritil != null) { attacker.OnNormalAttackCritil(target); } //当被暴击时 if (target.OnGotCritil != null) { attacker.OnGotCritil(); } } //受击特效 skill.StartCoroutine(skill.DisplayHitEffect(target, hitEffect)); //计算数值 float defense = (float)1 / (1 + Const.CONST_DEF_FACTOR * target.fightAttribute.Defence);//防御效果 defense = Mathf.Clamp(defense, Const.CONST_MIN_DEF_EFFECT, Const.CONST_MAX_DEF_EFFECT); float elementDefenseFactor = 0; HurtType hurtType = (HurtType)attacker.fightAttribute.elementType; switch (hurtType) { case HurtType.Fire: elementDefenseFactor = target.fightAttribute.fireDefenseRate; break; case HurtType.Water: elementDefenseFactor = target.fightAttribute.waterDefenseRate; break; case HurtType.Earth: elementDefenseFactor = target.fightAttribute.eathDefenseRate; break; case HurtType.Light: elementDefenseFactor = target.fightAttribute.lightDefeneseRate; break; case HurtType.Dark: elementDefenseFactor = target.fightAttribute.darkDefenseRate; break; } float elementFactor = ElementFactorDic[(int)attacker.fightAttribute.elementType * 10 + (int)target.fightAttribute.elementType].factor; int hurtNum = Mathf.RoundToInt(attacker.fightAttribute.attack * defense * (1 + attacker.fightAttribute.allDamageRate) * (1 - elementDefenseFactor) * (1 - target.fightAttribute.allDefenseRate) * elementFactor * critScale * Random.Range(0.95f, 1.05f)); hurtNum = Mathf.Max(0, hurtNum); //触发普通攻击命中事件 if (attacker.OnNoramlAttackHit != null) { attacker.OnNoramlAttackHit(hurtNum); } //触发反弹事件 if (target.OnFantan != null) { target.OnFantan(hurtNum, skill, hurtType); } //护盾计算 hurtNum = CaculateHudun(hurtNum, target, hurtType); //伤血 if (hurtNum == 0) { return; } HealthUIManager.instance.DisplayHurtNum(target, hurtNum.ToString(), true, isCrit); target.health -= hurtNum; if (target.health == 0) { FightManager.GetInstance().UnitDead(attacker, target); } }
public static void UniqueSkillDamage(FightUnit attacker, FightUnit target, UniqueSkill skill) { if (target == null || attacker == null || target.isInvincible) { return; } //判断命中 if (IsMiss(attacker, target)) { HealthUIManager.instance.DisplayHurtNum(target, "Miss", true, false); //当闪避攻击时 if (target.OnDodge != null) { target.OnDodge(); } return; } //判断无敌 if (target.isInvincible) { HealthUIManager.instance.DisplayHurtNum(target, "Invincible", true, false); return; } //判断暴击 bool isCrit = false; float critScale = 1f; if (IsCritical(attacker, target)) { isCrit = true; critScale = Const.CONST_BASIC_CRIT_DMG + attacker.fightAttribute.criticalImprove; //当被暴击时 if (target.OnGotCritil != null) { target.OnGotCritil(); } } float defense = (float)1 / (1 + Const.CONST_DEF_FACTOR * target.fightAttribute.Defence);//防御效果 defense = Mathf.Clamp(defense, Const.CONST_MIN_DEF_EFFECT, Const.CONST_MAX_DEF_EFFECT); int hurtNum = 1; HurtType hurtType = (HurtType)skill.specialSkill.attackAttribute; if (hurtType != HurtType.True) { float elementFactor = ElementFactorDic[skill.specialSkill.attackAttribute * 10 + (int)target.fightAttribute.elementType].factor;//属性伤害系数 float elementDefenseFactor = 0; switch (hurtType) { case HurtType.Fire: elementDefenseFactor = target.fightAttribute.fireDefenseRate; break; case HurtType.Water: elementDefenseFactor = target.fightAttribute.waterDefenseRate; break; case HurtType.Earth: elementDefenseFactor = target.fightAttribute.eathDefenseRate; break; case HurtType.Light: elementDefenseFactor = target.fightAttribute.lightDefeneseRate; break; case HurtType.Dark: elementDefenseFactor = target.fightAttribute.darkDefenseRate; break; } hurtNum = Mathf.RoundToInt((float)(attacker.fightAttribute.attack * skill.specialSkillLvUp.percent + skill.specialSkillLvUp.additional) * defense * (1 + attacker.fightAttribute.allDamageRate) * (1 - elementDefenseFactor) * (1 - target.fightAttribute.allDefenseRate) * elementFactor * critScale * Random.Range(0.95f, 1.05f)); } else { hurtNum = Mathf.RoundToInt((float)(attacker.fightAttribute.attack * skill.specialSkillLvUp.percent + skill.specialSkillLvUp.additional) * (1 + attacker.fightAttribute.allDamageRate) * (1 - target.fightAttribute.allDefenseRate) * critScale * Random.Range(0.95f, 1.05f)); } hurtNum = Mathf.Max(0, hurtNum); //受击特效 skill.StartCoroutine(skill.DisplayHitEffect(target)); //触发技能命中事件 if (attacker.OnSkillHit != null) { attacker.OnSkillHit(hurtNum); } //触发反弹事件 if (target.OnFantan != null) { target.OnFantan(hurtNum, skill, hurtType); } //护盾计算 hurtNum = CaculateHudun(hurtNum, target, hurtType); //附加buff SkillAttachBuff(attacker, target, skill.buffConfigList, (HurtType)skill.specialSkill.attackAttribute); //附加效果 AttachExtension(attacker, target, hurtNum, skill.attachExtension, skill.attachExtensionParam); //伤血 if (hurtNum == 0) { return; } HealthUIManager.instance.DisplayHurtNum(target, hurtNum.ToString(), true, isCrit); target.health -= hurtNum; if (target.health == 0) { FightManager.GetInstance().UnitDead(attacker, target); } }
public void CaculateCinemaParameter() { distance = Util.Distance(mineGroup.FirstUnit.mTrans.localPosition, mineGroup.middle_point.parent.localPosition); cinemaPos = FightManager.GetInstance().cinema.transform.localPosition; }