void OnUseItemToHero(object p1, object p2) { int targetHeroId = (int)p1; int itemId = (int)p2; CatDebug.LogFunc("targetHeroId = " + targetHeroId + ", itemId = " + itemId); FightHero originHero = FightDataMgr.Instance.GetHero(_nowHeroId); FightHero targetHero = FightDataMgr.Instance.GetHero(targetHeroId); Item item = targetHero.Items[itemId]; if (item.Id == 1) { int nowHp = targetHero.CreatureData.Hp.Value; if (nowHp >= 0) { targetHero.CreatureData.Hp.Value = System.Math.Min(nowHp + 100, targetHero.CreatureData.HpMax.Value); originHero.DelItem(item.Id, 1); EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros); EventSys.Instance.AddEvent(ViewEvent.FightHeroHpSupply, targetHero.Id, 100); originHero.IsActioned = true; CheckChangeTurnToEnemy(); } } else if (item.Id == 2) { int nowMp = targetHero.CreatureData.Mp.Value; targetHero.CreatureData.Mp.Value = System.Math.Min(nowMp + 100, targetHero.CreatureData.MpMax.Value); originHero.DelItem(item.Id, 1); EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros); EventSys.Instance.AddEvent(ViewEvent.FightHeroMpSupply, targetHero.Id, 100); originHero.IsActioned = true; CheckChangeTurnToEnemy(); } else { EventSys.Instance.AddEvent(ViewEvent.FightShowTipNotSupportYet); } }
void OnUseItemToEnemy(object p1, object p2) { int enemyInstanceId = (int)p1; int itemId = (int)p2; Enemy enemy = FightDataMgr.Instance.GetEnemyByInstanceId(enemyInstanceId); FightHero fh = FightDataMgr.Instance.GetHero(_nowHeroId); Item item = fh.Items[itemId]; if (item.Id == 4) { int damage = 1000; enemy.CreatureData.Hp.Value -= damage; if (enemy.CreatureData.Hp.Value <= 0) { enemy.CreatureData.Hp.Value = 0; } EventSys.Instance.AddEvent(ViewEvent.FightHeroAttack, damage); EventSys.Instance.AddEvent(ViewEvent.FightUpdateEnemyState, enemy); if (enemy.CreatureData.Hp.Value <= 0) { EnemyBeHurtDead(enemy); } else { CheckChangeTurnToEnemy(); } fh.DelItem(item.Id, 1); EventSys.Instance.AddEvent(ViewEvent.FightUpdateHeroState, fh); fh.IsActioned = true; CheckChangeTurnToEnemy(); } else { EventSys.Instance.AddEvent(ViewEvent.FightShowTipNotSupportYet); } }