void Update() { timeAlive += Time.deltaTime; if (timeAlive > timeToLive) { fireballPool.ReturnObject(this); return; } transform.Translate(-transform.right * velocity * Time.deltaTime, Space.World); List <Hurtable> hurtables = hitboxManager.GetOverlappedHurtables(); if (hurtables.Count > 0) { Hurtable hurtable = hurtables[0]; HurtInfo hurtInfo = hurtable.OnHit(new HitInfo(this.transform.position, this.parrySpawnObjectPrototype)); if (hurtInfo.hitConnected) { fireballPool.ReturnObject(this); } } transform.localScale = velocity > 0 ? Vector3.one : invertedLocalScale; }
public HurtInfo OnHit(HitInfo hitInfo) { HurtInfo hurtInfo = fsm.currentState.OnHit(hitInfo); if (hurtInfo.hitConnected) { DieAndRestartScene(); } return(hurtInfo); }
public void Attack(AttackInfo attackInfo) { ActorBase attackerBase; ActorCenter.Instance.TryGet(attackInfo.attacker, out attackerBase); var attacker = attackerBase as FightActor; if (attacker == null) { DebugEx.Log("没有攻击者,你攻击个啥呢!"); return; } ActorBase hurterBase; ActorCenter.Instance.TryGet(attackInfo.attackTarget, out hurterBase); var target = hurterBase as FightActor; var error = 0; if (!CanAttack(target, attackInfo.skillId, out error)) { return; } var hurtInfo = new HurtInfo(); hurtInfo.attacker = attacker.instanceId; hurtInfo.hurtTarget = target.instanceId; hurtInfo.hurtTime = Time.realtimeSinceStartup; var minAttack = attacker.GetFightProperty(FightProperty.MinAttack); var maxAttack = attacker.GetFightProperty(FightProperty.MaxAttack); var attack = Random.Range(minAttack, maxAttack + 1); var critRate = attacker.GetFightProperty(FightProperty.Crit) * 10000; var isCrit = Random.Range(0, critRate) < critRate; var defense = target.GetFightProperty(FightProperty.Defense); var damage = attack * (1 + (isCrit ? 1 : 0)) - defense; hurtInfo.damage = damage; hurtInfo.damageType = isCrit ? DamageType.Crit : DamageType.Normal; hurtInfo.direction = Vector3.Normalize(target.transform.position - attackInfo.position); target.Hurt(hurtInfo); if (!IsAlive(target)) { target.Dead(); } }
private static void CalculateHurt(ICharaBattle battleInfo, FightEffectInfo effect, uint userId) { ICharaFight target = battleInfo as ICharaFight; ICharaFight user = ZTBattleSceneManager.GetInstance().GetCharaById(userId) as ICharaFight; if (null == target || null == user) { return; } HurtInfo hurtInfo = new HurtInfo(); hurtInfo.Type = HURT_TYPE.NORMAL; hurtInfo.BattleId = battleInfo.BattleId; hurtInfo.Pos = battleInfo.MovePos; hurtInfo.Value = -user.Attack; target.AddHurt(hurtInfo); }
private void OnAddUIHurtValue(Notification data) { HurtInfo info = (HurtInfo)data.param; if (null != _hurtGo) { Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(info.Pos); Vector3 screenToWorldPoint = _canvas.worldCamera.ScreenToWorldPoint(worldToScreenPoint); GameObject go = GameObject.Instantiate(_hurtGo); go.transform.SetParent(_hpTransform, false); go.transform.position = new Vector3(screenToWorldPoint.x, screenToWorldPoint.y + 0.2f, 0); go.transform.localScale = new Vector3(1, 1, 1); Text text = go.GetComponent <Text>(); text.text = Mathf.Abs(info.Value).ToString(); TextInfo ti = new TextInfo(text, info.Pos, _tiTime, _tiHorSpeedMin, _tiHorSpeedMax, _tiExtent); _hurtTs.Add(ti); } }
private static void ChangeAttribute(ICharaBattle battleInfo, FightEffectInfo effect) { ICharaFight target = battleInfo as ICharaFight; if (null == target) { return; } float multi = 0; //乘数 int value = 0; //值 //按以下选项修改上面属性 switch ((ATT_ALTER_TYPE)effect.Param2) { case ATT_ALTER_TYPE.VALUE: value = effect.Param3; break; case ATT_ALTER_TYPE.PRECENT: multi = effect.Param3 / 100.0f; break; } //改变的属性选择 switch ((ATTRIBUTE)effect.Param1) { case ATTRIBUTE.ATTACK: target.Attack += Mathf.CeilToInt(target.Attack * multi) + value; break; case ATTRIBUTE.HP: int result = Mathf.CeilToInt(target.MaxHp * multi) + value; HurtInfo hurtInfo = new HurtInfo(); hurtInfo.Type = HURT_TYPE.NORMAL; hurtInfo.BattleId = battleInfo.BattleId; hurtInfo.Pos = battleInfo.MovePos; hurtInfo.Value = result; target.AddHurt(hurtInfo); break; } }
public override void Tick() { if (manfred.playerInput.GetDidPressAttack()) { if (!allowNextAttack) { if (lockoutMashers) { lockout = true; } } else if (!lockout) { manfred.fsm.ChangeState(manfred.stateAttack2, manfred.stateAttack2); } } List <Hurtable> hurtables = manfred.hitboxManager.GetOverlappedHurtables(); if (hurtables.Count > 0 && !didLandAttack) { HitInfo hitInfo = new HitInfo(manfred.transform.position, false); foreach (Hurtable hurtable in hurtables) { HurtInfo hurtInfo = hurtable.OnHit(hitInfo); didLandAttack = didLandAttack || hurtInfo.hitConnected; if (hurtInfo.hitConnected) { Debug.Log("landed attack!"); } } if (didLandAttack) { TimeManagerSingleton.Instance.DoDramaticPause(0.2f); manfred.effectsAudioSource.PlayOneShot(soundEffect); } } }
public override void Tick() { List <Hurtable> hurtables = manfred.hitboxManager.GetOverlappedHurtables(); if (hurtables.Count > 0 && !didLandAttack) { HitInfo hitInfo = new HitInfo(manfred.transform.position, true); foreach (Hurtable hurtable in hurtables) { HurtInfo hurtInfo = hurtable.OnHit(hitInfo); didLandAttack = didLandAttack || hurtInfo.hitConnected; if (hurtInfo.hitConnected) { Debug.Log("landed attack!"); } } if (didLandAttack) { TimeManagerSingleton.Instance.DoDramaticPause(0.2f); manfred.effectsAudioSource.PlayOneShot(soundEffect); } } }
//添加伤害 显示 public void AddHurt(HurtInfo info) { Hp += info.Value; SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_UI_HURT_VALUE, new Notification(info)); }
public virtual void Hurt(HurtInfo info) { }