Esempio n. 1
0
 private void RunBattleScene(BattleScene scene)
 {
     while (scene.IsSceneActive())
     {
         IAction action;
         Console.WriteLine(TagHandler.TranslateTag(scene.PlayerTeam[0].HealthTag));
         Console.WriteLine(TagHandler.TranslateTag(scene.EnemyTeam[0].HealthTag));
         if (YN("Do you want to attack?"))
         {
             action = new AttackAction(scene.PlayerTeam[0], scene.EnemyTeam[0]);
         }
         else
         {
             action = new NullAction();
         }
         List <IAction> resultingActions = scene.Update(action);
         foreach (IAction resultingAction in resultingActions)
         {
             if (resultingAction.HasResult())
             {
                 Console.WriteLine(TagHandler.TranslateTag(resultingAction.Result.Tag));
             }
         }
     }
 }
        public void DetectLackOfActionType()
        {
            var action = new NullAction();

            Assert.Throws <MissingActionTypeException>(
                () => new PolymorphicAction <NullAction>(action)
                );
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jsonObject = JObject.Load(reader);

            if (Enum.TryParse <GambitActionTypes>(jsonObject["GambitActionType"].Value <string>(), out var parsedEnum))
            {
                GambitAction action;
                switch (parsedEnum)
                {
                case GambitActionTypes.CastSpellOnSelf:
                    action = new CastSpellOnSelfAction();
                    break;

                case GambitActionTypes.CastSpellOnCurrentTarget:
                    action = new CastSpellOnCurrentTargetAction();
                    break;

                case GambitActionTypes.CastSpellOnAlly:
                    action = new CastSpellOnAllyAction();
                    break;

                case GambitActionTypes.CastSpellOnEnemy:
                    action = new CastSpellOnEnemyAction();
                    break;

                case GambitActionTypes.CastSpellOnFriendlyNpc:
                    action = new CastSpellOnFriendlyNpcAction();
                    break;

                case GambitActionTypes.SleepForMilliseconds:
                    action = new SleepForTimeAction();
                    break;

                case GambitActionTypes.NoAction:
                    action = new NullAction();
                    break;

                case GambitActionTypes.ToastMessage:
                    action = new ToastMessageAction();
                    break;

                case GambitActionTypes.UseItemOnSelf:
                    action = new UseItemOnSelfAction();
                    break;

                case GambitActionTypes.PetCast:
                    action = new PetCastAction();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                serializer.Populate(jsonObject.CreateReader(), action);
                return(action);
            }
            throw new InvalidCastException();
        }
Esempio n. 4
0
        public Weakling(string name) : base(name)
        {
            ActionList.Add("null1", NullAction.GetActionBuilder());
            ActionList.Add("null2", NullAction.GetActionBuilder());
            ActionList.Add("attack", AttackAction.GetActionBuilder());
            ItemBuilderFactory factory = ItemBuilderFactory.GetInstance();

            LootTable.Add(new LootTableElement(999, factory.GetBuilder("rusty-spoon")));
            LootTable.Add(new LootTableElement(999, factory.GetBuilder("loincloth")));
            LootTable.Add(new LootTableElement(100, factory.GetBuilder("healing-potion")));
        }
Esempio n. 5
0
 public override TurnAction RequestAction()
 {
     SnapToGrid();
     Debug.Assert(currentAction.isComplete);
     currentAction = pendingAction;
     pendingAction = new NullAction(this);
     if (!(currentAction is NullAction))
     {
         //Debug.Log(currentAction);
         //prints the action, but can clutter log
         //that currently has some game information in it
         HideDialogBox();
     }
     return(currentAction);
 }
Esempio n. 6
0
    public IAction CreateAction(ACTION_ID id)
    {
        IAction Action = null;

        switch (id)
        {
        case ACTION_ID.ACTION_1: Action = new Action1(); break;

        case ACTION_ID.ACTION_2: Action = new Action2(); break;

        case ACTION_ID.ACTION_3: Action = new Action3(); break;

        case ACTION_ID.ACTION_4: Action = new Action4(); break;

        case ACTION_ID.ACTION_5: Action = new Action5(); break;

        case ACTION_ID.ACTION_6: Action = new Action6(); break;

        case ACTION_ID.ACTION_DasheBackward: Action = new ActionDashBackward(); break;

        case ACTION_ID.ACTION_DasheForward: Action = new ActionDashForward(); break;

        case ACTION_ID.ACTION_Jab: Action = new ActionJab(); break;

        case ACTION_ID.ACTION_Kick: Action = new ActionKick(); break;

        case ACTION_ID.ACTION_MoveAttack1: Action = new ActionMoveAttack1(); break;

        case ACTION_ID.ACTION_MoveAttack2: Action = new ActionMoveAttack2(); break;

        case ACTION_ID.ACTION_Punch: Action = new ActionPunch(); break;

        case ACTION_ID.ACTION_RangeAttack1: Action = new ActionRangeAttack1(); break;

        case ACTION_ID.ACTION_RangeAttack2: Action = new ActionRangeAttack2(); break;

        case ACTION_ID.ACTION_SpecialAttack1: Action = new ActionSpecialAttack1(); break;

        case ACTION_ID.ACTION_SpecialAttack2: Action = new ActionSpecialAttack2(); break;

        case ACTION_ID.ACTION_Uppercut: Action = new ActionUppercut(); break;

        default: Action = new NullAction(); break;
        }
        ControllerCenter.Instance.ActionSystem.Add((uint)(Time.realtimeSinceStartup) * 100, Action);
        return(Action);
    }
 public NullRuleAttribute(NullAction action)
 {
     Action = action;
 }
Esempio n. 8
0
 public void WithNullAction_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => NullAction.Retry());
 }
Esempio n. 9
0
        public static void AddActionToGambit(Gambit gambit, GambitActionTypes selectedValue)
        {
            IGambitAction newAction;

            switch (selectedValue)
            {
            case GambitActionTypes.NoAction:
                newAction = new NullAction();
                break;

            case GambitActionTypes.CastSpellOnSelf:
                newAction = new CastSpellOnSelfAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnAlly:
                newAction = new CastSpellOnAllyAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnEnemy:
                newAction = new CastSpellOnEnemyAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastSpellOnFriendlyNpc:
                newAction = new CastSpellOnFriendlyNpcAction {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.SleepForMilliseconds:
                newAction = new SleepForTimeAction {
                    DurationInMilliseconds = 1000
                };
                break;

            case GambitActionTypes.ToastMessage:
                newAction = new ToastMessageAction {
                    displaySeconds = 2, message = "The Toast Message"
                };
                break;

            case GambitActionTypes.UseItemOnSelf:
                newAction = new UseItemOnSelfAction()
                {
                    ItemName = "The Item's Name", AnyQuality = true
                };
                break;

            case GambitActionTypes.CastSpellOnCurrentTarget:
                newAction = new CastSpellOnCurrentTargetAction()
                {
                    SpellName = "The Spell's Name"
                };
                break;

            case GambitActionTypes.CastFillerOnCurrentTarget:
                newAction = new CastFillerOnCurrentTargetAction()
                {
                    SpellName = "The Filler's SpellName", ProcName = "The Proc's SpellName"
                };
                break;

            case GambitActionTypes.PetCast:
                newAction = new PetCastAction()
                {
                    SpellName = "The Spell's Name"
                };
                break;

            default:
                return;
            }

            gambit.ActionType = selectedValue;
            gambit.Action     = newAction;
        }
Esempio n. 10
0
 static NullAction()
 {
     Instance = new NullAction();
 }