Esempio n. 1
0
        void game_OnPlayerProvinceAttacked(object sender, BattleEventArgs e)
        {
            string provinceName        = game.GetProvince(e.ProvinceId).Name;
            string attackerFactionName = game.GetFaction(e.AttackerFactionId).Name;

            if (e.BattleResult == BattleResult.Victory)
            {
                NotificationBar.AddNotification(NotificationIcon.ProvinceLost).Clicked += delegate
                {
                    ShowNotification($"{provinceName} province lost!",
                                     $"Bad news!" + Environment.NewLine + Environment.NewLine +
                                     $"One of our provinces, {provinceName}, was attacked by {attackerFactionName}, " +
                                     $"who managed to break the defence and occupy it!",
                                     NotificationType.Informational,
                                     NotificationStyle.Big,
                                     new Size2D(256, 224));
                };
            }
            else
            {
                NotificationBar.AddNotification(NotificationIcon.ProvinceDefended).Clicked += delegate
                {
                    ShowNotification($"{provinceName} province defended!",
                                     $"Important news!" + Environment.NewLine + Environment.NewLine +
                                     $"One of our provinces, {provinceName}, was attacked by {attackerFactionName}, " +
                                     $"but our brave troops managed to sucesfully defend it!",
                                     NotificationType.Informational,
                                     NotificationStyle.Big,
                                     new Size2D(256, 224));
                };
            }
        }
 private static void DisplayPokemon(BattleEventArgs args)
 {
     Display.Pokemon(args.thisBattle.PlayerSide.CurrentBattlePokemon,
                     args.thisBattle.OpponentSide.CurrentBattlePokemon,
                     args.thisBattle.PlayerSide.Name,
                     args.thisBattle.OpponentSide.Name);
 }
Esempio n. 3
0
        BattleResult AttackProvince(string factionId, string provinceId)
        {
            Province province             = GetProvince(provinceId);
            string   oldProvinceFactionId = province.FactionId;

            BattleResult result = attack.AttackProvince(factionId, provinceId);

            if (GetRelation(factionId, oldProvinceFactionId).Value > 0)
            {
                world.SetRelations(factionId, oldProvinceFactionId, 0);
            }

            if (result == BattleResult.Victory)
            {
                world.ChangeRelations(factionId, oldProvinceFactionId, -10);
            }

            switch (province.Type)
            {
            case ProvinceType.Capital:
                world.ChangeRelations(factionId, oldProvinceFactionId, -10);
                break;

            case ProvinceType.Province:
                world.ChangeRelations(factionId, oldProvinceFactionId, -5);
                break;
            }

            switch (province.State)
            {
            case ProvinceState.Sovereign:
                world.ChangeRelations(factionId, oldProvinceFactionId, -5);
                break;

            case ProvinceState.Occupied:
                world.ChangeRelations(factionId, oldProvinceFactionId, -2);
                break;
            }

            if (oldProvinceFactionId == PlayerFactionId)
            {
                BattleEventArgs e = new BattleEventArgs(provinceId, factionId, result);

                if (PlayerProvinceAttacked != null)
                {
                    PlayerProvinceAttacked(this, e);
                }
            }

            return(result);
        }
        public override async Task Process(BattleEventArgs arg)
        {
            AttackEventArgs e = arg as AttackEventArgs;

            string[] array = e.Skill.Item.Summonid.Split(new char[]
            {
                ','
            });
            e.Attacker.FaceTo(e.Point.transform.position);
            this.damageInfo             = this.CreateDamageInfo(e.Attacker, e.Defender, e.Skill);
            this.damageInfo.FloorEffect = e.Point.gameObject;
            await 0.1f;
            for (int i = 0; i < array.Length; i++)
            {
                string summonid = array[i];
                this.manager.GetCellNearestCamera();
                WuxiaCell point = e.Point;
                WuxiaUnit unit  = this.manager.AddUnit(summonid, e.Attacker.faction, (i == 0) ? point.CellNumber : -2, false);
                unit.Actor.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
                unit.transform.forward          = e.Attacker.transform.forward;
                unit.gameObject.OnTerrain(unit.transform.position);
                unit.gameObject.SetActive(false);
                this.summonUnits.Add(unit);
                unit.OnTurnStart();
                // 半即时支持
                if (HookInitiactiveBattle.bTimed)
                {
                    HookInitiactiveBattle.Timed_EncourageUnit(unit);
                }
            }
            await 0.1f;
            if (GameConfig.IsSkipSkillEffect)
            {
                this.ProcessAnimationTrack(this.damageInfo);
            }
            else
            {
                Task <float> attackEventTime = this.ProcessAnimation(this.damageInfo, 0f);
                await        attackEventTime;
                await attackEventTime.Result;
            }
            base.ProcessSkillMPCost(e);
            if (e.Attacker[BattleLiberatedState.No_CoolDown] == 0)
            {
                e.Skill.CurrentCD = e.Skill.MaxCD;
            }
        }
 private static void BattleOverEventHandler(object sender, BattleEventArgs args)
 {
     Console.Clear();
     DisplayPokemon(args);
     Console.WriteLine();
     Console.WriteLine("Battle over!");
     Thread.Sleep(2500);
     if (args.thisBattle.IsPlayerDefeated)
     {
         Console.WriteLine("Player lost!");
         Console.WriteLine();
     }
     else
     {
         Console.WriteLine("You won!");
         Console.WriteLine();
     }
 }
Esempio n. 6
0
 virtual public void getHit(BodyParts attacked, BattleEventArgs e)
 {
     if (attacked == body)
     {
         Block?.Invoke(this, e);
     }
     else
     {
         Hp  -= (int)attacked;
         e.hp = Hp;
         if (Hp > 0)
         {
             Wound?.Invoke(this, e);
         }
         else
         {
             Death?.Invoke(this, e);
         }
     }
 }
Esempio n. 7
0
        private void ViewModelOnBattleOccured(object sender, BattleEventArgs e)
        {
            var notification = string.Format("Result:            {0}\n", e.Battle.Stars > 0 ? "DEFEAT" : "VICTORY") +
                               string.Format("Damage %:    {0}\n", e.Battle.BaseDamagePercent) +
                               string.Format("Stars scored:  {0}\n", e.Battle.Stars) +
                               string.Format("SC units left:  {0}", e.ScUnitsCountRemaining);

            Application.Current.Dispatcher.Invoke(() =>
            {
                var toast = new ToastPopUp("Defensive battle completed!", notification,
                                           NotificationType.Information)
                {
                    Background  = new LinearGradientBrush(Color.FromRgb(193, 237, 230), Color.FromRgb(128, 148, 255), 90),
                    BorderBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                    FontColor   = new SolidColorBrush(Color.FromArgb(255, 32, 32, 32)),
                };
                toast.MouseDoubleClick += delegate
                {
                    Show();
                    WindowState = WindowState.Normal;
                };
                toast.Show();
            });
        }
Esempio n. 8
0
 public void TriggerEffects(object sender, BattleEventArgs args)
 {
     ResolveEffects((Battle)sender);
 }
        private void battle_BattleEvent(object sender, BattleEventArgs e)
        {
            HUD             display       = e.Monster == battle.PlayerCurrent ? (HUD)selfHUD : (HUD)foeHUD;
            MonsterRenderer current       = e.Monster == battle.PlayerCurrent ? (MonsterRenderer)selfRenderer : (MonsterRenderer)foeRenderer;
            MonsterRenderer opponent      = current == selfRenderer ? (MonsterRenderer)foeRenderer : (MonsterRenderer)selfRenderer;
            Panel           previousFocus = hasFocus;

            syncronize.Reset();

            if (e.Type == BattleEventType.MonHPChanged)
            {
                hasFocus = display;
                display.AnimateHPChange(e.HPBefore, e.HPAfter);
            }
            else if (e.Type == BattleEventType.MonFainted)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Fainted"], current, opponent);
            }
            else if (e.Type == BattleEventType.MonRecalled)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Recalled"], current, opponent);
            }
            else if (e.Type == BattleEventType.MonSentOut)
            {
                hasFocus = specialEffectManager;
                display.UpdateStatus();
                specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Sent Out"], current, opponent);
            }
            else if (e.Type == BattleEventType.MonSpawned)
            {
                hasFocus = specialEffectManager;
                display.UpdateStatus();
                specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Sent Out"], current, opponent);
            }
            else if (e.Type == BattleEventType.AttackHit || e.Type == BattleEventType.RecurringAttackHit)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new Delay(30));

                if (e.Monster.SubstituteHP > 0 && e.Move.Name != "Substitute")
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Substitute Pre-Attack"], current, opponent);
                }

                Sequence seq = null;
                if (e.Type == BattleEventType.RecurringAttackHit && Sequence.Sequences.ContainsKey(e.Move.Name + " Recurring"))
                {
                    seq = Sequence.Sequences[e.Move.Name + " Recurring"];
                }
                else if (Sequence.Sequences.ContainsKey(e.Move.Name))
                {
                    seq = Sequence.Sequences[e.Move.Name];
                }

                if (seq != null)
                {
                    specialEffectManager.QueueSpecialEffects(seq, current, opponent);
                }
                else
                {
                    specialEffectManager.QueueSpecialEffect(new Delay(30));
                }
                switch (e.Move.AttackType)
                {
                case AttackType.Damaging:
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences[e.Monster == battle.PlayerCurrent ? "Player Damaging" : "Enemy Damaging"], current, opponent);
                    break;

                case AttackType.DamagingWithEffectChance:
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences[e.Monster == battle.PlayerCurrent ? "Player Damaging With Effect Chance" : "Enemy Damaging With Effect Chance"], current, opponent);
                    break;

                case AttackType.NonDamaging:
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences[e.Monster == battle.PlayerCurrent ? "Player Non-Damaging" : "Enemy Non-Damaging"], current, opponent);
                    break;

                default:
                    specialEffectManager.QueueSpecialEffect(new Delay(20));
                    break;
                }

                if (e.Monster.SubstituteHP > 0 && e.Move.Name != "Substitute")
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Substitute Post-Attack"], current, opponent);
                }
            }
            else if (e.Type == BattleEventType.AttackMissed)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new TransformSprite(SpriteTransformation.Show, current));
                specialEffectManager.QueueSpecialEffect(new Delay(50));
            }
            else if (e.Type == BattleEventType.AttackCharged)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new Delay(30));

                if (Sequence.Sequences.ContainsKey(e.Move.Name + " Charge"))
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences[e.Move.Name + " Charge"], current, opponent);
                }
                else
                {
                    specialEffectManager.QueueSpecialEffect(new Delay(30));
                }
            }
            else if (e.Type == BattleEventType.StatusAilment)
            {
                hasFocus = specialEffectManager;
                if (e.Status == StatusCondition.Sleep)
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Asleep"], current, opponent);
                }
                else if (e.Status == StatusCondition.Confusion)
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Confused"], current, opponent);
                }
                else if (e.Status == StatusCondition.Seeded)
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Seeded"], current, opponent);
                }
                else if (e.Status == StatusCondition.Burn)
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Burned"], current, opponent);
                }
                else if (e.Status == StatusCondition.Poison || e.Status == StatusCondition.BadlyPoisoned)
                {
                    specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Poisoned"], current, opponent);
                }
                else
                {
                    throw new Exception();
                }
            }
            else if (e.Type == BattleEventType.MonTransformed)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new TransformSprite(SpriteTransformation.Show, current));
            }
            else if (e.Type == BattleEventType.SubstituteBroke)
            {
                hasFocus = specialEffectManager;
                display.UpdateStatus();
                specialEffectManager.QueueSpecialEffects(Sequence.Sequences["Substitute Broke"], current, opponent);
            }
            else if (e.Type == BattleEventType.MonCrashed)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new TransformScreen(this, ScreenTransformation.ShakeHorizontallyFast, 4, false));
            }
            else if (e.Type == BattleEventType.MonHurtItself)
            {
                hasFocus = specialEffectManager;
                specialEffectManager.QueueSpecialEffect(new Animations.DoublePow(current, 8));
            }
            else if (e.Type == BattleEventType.MonStatusUpdate)
            {
                display.UpdateStatus();
            }
            else
            {
                throw new Exception();
            }

            if (e.Type != BattleEventType.MonStatusUpdate)
            {
                syncronize.WaitOne();
            }

            hasFocus = previousFocus;
        }
 private static void SecondExecutionOverHandler(object sender, BattleEventArgs args)
 {
     Thread.Sleep(2200);
 }
 private static void SecondExecutionBegunHandler(object sender, BattleEventArgs args)
 {
     Console.Clear();
     DisplayPokemon(args);
 }
 private static void MakingSelectionsEventHandler(object sender, BattleEventArgs args)
 {
     DisplayPokemon(args);
 }
 //===================================================================================//
 //                          BATTLE EVENT HANDLERS                                    //
 //===================================================================================//
 private static void BattleBegunEventHandler(object sender, BattleEventArgs args)
 {
     Console.WriteLine("Battle has begun!");
     Thread.Sleep(2700);
     Console.Clear();
 }