using FullInspector; namespace MoleMole { public class MaxMonsterHitAirChallenge : BaseLevelChallenge { public readonly int targetHitAirAmount; [ShowInInspector] private bool _finished; [ShowInInspector] private int _tempHitAirAmount; public MaxMonsterHitAirChallenge(LevelChallengeHelperPlugin helper, LevelChallengeMetaData metaData) : base(helper, metaData) { _finished = false; _tempHitAirAmount = 0; targetHitAirAmount = _metaData.paramList[0]; } public override bool IsFinished() { return _finished; } public override string GetProcessMsg() { if (IsFinished()) { return "Succ"; } return string.Format("[{0}/{1}]", _tempHitAirAmount, targetHitAirAmount); } public override void OnAdded() { Singleton.Instance.RegisterEventListener(_helper.levelActor.runtimeID); } public override void OnDecided() { base.OnDecided(); Singleton.Instance.RemoveEventListener(_helper.levelActor.runtimeID); } public override bool ListenEvent(BaseEvent evt) { if (evt is EvtBeingHit) { return ListenBeingHit((EvtBeingHit)evt); } return false; } private bool ListenBeingHit(EvtBeingHit evt) { AvatarActor actor = Singleton.Instance.GetActor(evt.sourceID); MonsterActor actor2 = Singleton.Instance.GetActor(evt.targetID); if (actor == null || actor2 == null) { return false; } BaseMonoMonster monsterByRuntimeID = Singleton.Instance.GetMonsterByRuntimeID(actor2.runtimeID); if (monsterByRuntimeID.IsAnimatorInTag(MonsterData.MonsterTagGroup.Throw)) { return false; } if (evt.attackData.hitEffect == AttackResult.AnimatorHitEffect.ThrowAirBlow || evt.attackData.hitEffect == AttackResult.AnimatorHitEffect.ThrowBlow || evt.attackData.hitEffect == AttackResult.AnimatorHitEffect.ThrowUp || evt.attackData.hitEffect == AttackResult.AnimatorHitEffect.ThrowUpBlow) { _tempHitAirAmount++; if (_tempHitAirAmount >= targetHitAirAmount) { Finish(); } } return false; } private void Finish() { _finished = true; OnDecided(); } } }