Exemplo n.º 1
0
        public void GenerateFreeActionButtons()
        {
            Selection.ThisShip.IsFreeActionSkipped = false;
            List <GenericAction> availableActions = Selection.ThisShip.GetAvailableFreeActions();

            foreach (var action in availableActions)
            {
                bool addedDecision = false;

                foreach (var kv in Selection.ThisShip.ActionBar.LinkedActions)
                {
                    Type          actionType   = kv.Key;
                    GenericAction linkedAction = kv.Value;

                    if (action.GetType() == actionType)
                    {
                        addedDecision = true;
                        string linkedActionName = linkedAction.Name;
                        if (linkedAction.IsRed)
                        {
                            linkedActionName = "<color=red>" + linkedActionName + "</color>";
                        }
                        string decisionName = action.Name + " > " + linkedActionName;

                        AddDecision(
                            decisionName,
                            delegate {
                            ActionWasPerformed = true;
                            Selection.ThisShip.CallBeforeFreeActionIsPerformed(
                                (GenericAction)action,
                                (Action) delegate { ActionsHolder.TakeActionStart((GenericAction)action); }
                                );
                        },
                            action.ImageUrl,
                            -1,
                            action.IsRed
                            );
                    }
                }

                if (!addedDecision)
                {
                    AddDecision(
                        action.Name,
                        delegate {
                        ActionWasPerformed = true;
                        Selection.ThisShip.CallBeforeFreeActionIsPerformed(
                            (GenericAction)action,
                            (Action) delegate { ActionsHolder.TakeActionStart((GenericAction)action); }
                            );
                    },
                        action.ImageUrl,
                        -1,
                        action.IsRed
                        );
                }
            }
        }
Exemplo n.º 2
0
        private void RemoveEffect(GenericAction action)
        {
            SelectedShip.OnActionIsPerformed -= RemoveEffect;

            SelectedShip.OnCheckCanPerformActionsWhileStressed -= ConfirmThatIsPossible;
            SelectedShip.OnCanPerformActionWhileStressed       -= AllowIfOneOrLessStressTokens;

            SelectedShip = null;
        }
 private void setCallback(CardID cardID, GenericAction callback)
 {
     if (savedCallback != null)
     {
         savedCallback?.Invoke(this, null);
     }
     lastDrawCardRID = cardID.CardRID;
     savedCallback   = callback;
 }
        private void onRecvAction(object sender, EventArgs args, GenericAction callback)
        {
            if (args is OnAttackEventArgs)
            {
                var arg = args as OnAttackEventArgs;
                UberDebug.LogChannel(this, "Frontend", "ServantView收到攻击事件");
                callback += (a, b) => { UberDebug.LogChannel("Frontend", "ServantAttack动画播放完毕"); };

                var targetServant = cardVM.Board.Deck.GetCardByRID(arg.TargetRID);
                if (targetServant != null)
                {
                    ObjectPositionEventArgs target;
                    if (targetServant is CharacterInfoViewModel)
                    {
                        target = new SpecialCardPositionEventArgs(SpecialCardPositionEventArgs.CardType.MasterCard, !cardVM.Board.IsSelf);
                    }
                    else
                    {
                        target = new CardPositionEventArgs(cardVM.Board.ServantCount, cardVM.Index, !cardVM.Board.IsSelf);
                    }
                    PlayAnimation("ServantAttack", new ServantAttackEventArgs(
                                      new CardPositionEventArgs(cardVM.Board.ServantCount, cardVM.Index, cardVM.Board.IsSelf),
                                      target)
                                  , callback);
                }
                else
                {
                    throw new NullReferenceException($"没有找到rid为{arg.TargetRID}的卡");
                }
            }

            if (args is IndexChangeEventArgs && drawed)
            {
                var arg = args as IndexChangeEventArgs;
                PlayAnimation(this, new CardAnimationEventArgs()
                {
                    AnimationName = "RetinueMove",
                    EventArgs     = new CardPositionEventArgs(arg.Count > 0 ? arg.Count : cardVM.Board.ServantCount, arg.Index, cardVM.Board.IsSelf)
                }, callback);
            }

            if (args is RetinueSummonEventArgs)
            {
                callback += (a, b) => { drawed = true; };
                var arg = args as RetinueSummonEventArgs;
                PlayAnimation(this, new CardAnimationEventArgs()
                {
                    AnimationName = "RetinueSummon",
                    EventArgs     = new CardPositionEventArgs(cardVM.Board.ServantCount, cardVM.Index, cardVM.Board.IsSelf)
                }, callback);
            }

            if (args is CardAnimationEventArgs)
            {
                PlayAnimation(this, args, callback);
            }
        }
Exemplo n.º 5
0
        public void RemoveActionbarAction(Type type)
        {
            GenericAction action = ActionbarActions.Find(n => n.GetType() == type);

            if (action != null)
            {
                ActionbarActions.Remove(action);
            }
        }
Exemplo n.º 6
0
        public void CallBeforeFreeActionIsPerformed(GenericAction action, Action callBack)
        {
            if (BeforeFreeActionIsPerformed != null)
            {
                BeforeFreeActionIsPerformed(action);
            }

            Triggers.ResolveTriggers(TriggerTypes.BeforeFreeActionIsPerformed, callBack);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Add the new action to the Table Layout Panel.
 /// </summary>
 /// <param name="actionToAdd">New GenericAction to add to the layout panel.</param>
 private void AddNewActionToUI(GenericAction actionToAdd)
 {
     actionToAdd.Dock = DockStyle.Top;
     actionToAdd.Click += actionToAdd_Click;
     actionToAdd.Change += actionToAdd_Change;
     this.IsUnsaved = true;
     this.tlpCustomActions.Controls.Add(actionToAdd);
     this.UpdateToolStripStatus();
 }
        public void IsSelectedTest()
        {
            GenericAction target = new GenericAction();

            Assert.IsFalse(target.IsSelected, "The property is not iniatilized properly.");

            target.IsSelected = true;
            Assert.IsTrue(target.IsSelected, "The property is not set properly.");
        }
Exemplo n.º 9
0
        public void CheckSupernaturalReflexesDamage(GenericAction action)
        {
            HostShip.OnActionIsPerformed -= CheckSupernaturalReflexesDamage;

            if (!HostShip.ActionBar.HasAction(action.GetType()))
            {
                RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, SufferDamage);
            }
        }
Exemplo n.º 10
0
        public bool CanUseDiceModification(GenericAction action)
        {
            bool result = true;

            if (!action.IsDiceModificationAvailable())
            {
                result = false;
            }

            if (IsDiceModificationAlreadyUsed(action))
            {
                result = false;
            }

            if (result)
            {
                switch (action.DiceModificationTiming)
                {
                case DiceModificationTimingType.Normal:
                    if (OnTryAddAvailableDiceModification != null)
                    {
                        OnTryAddAvailableDiceModification(this, action, ref result);
                    }
                    if (OnTryAddAvailableDiceModificationGlobal != null)
                    {
                        OnTryAddAvailableDiceModificationGlobal(this, action, ref result);
                    }
                    break;

                case DiceModificationTimingType.Opposite:
                    if (OnTryAddDiceModificationOpposite != null)
                    {
                        OnTryAddDiceModificationOpposite(this, action, ref result);
                    }
                    break;

                case DiceModificationTimingType.AfterRolled:
                    if (OnTryAddDiceModificationAfterRolled != null)
                    {
                        OnTryAddDiceModificationAfterRolled(this, action, ref result);
                    }
                    break;

                case DiceModificationTimingType.CompareResults:
                    if (OnTryAddDiceModificationCompareResults != null)
                    {
                        OnTryAddDiceModificationCompareResults(action, ref result);
                    }
                    break;

                default:
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 11
0
    public virtual GenericAction AddAction(string eventName, MoonSharp.Interpreter.Closure closure)
    {
        GenericAction action = new GenericAction(closure);

        EnsureEventExists(eventName);
        OnActionAdded(eventName, action);
        actions[eventName].Add(action);
        return(action);
    }
Exemplo n.º 12
0
 private void LoseCharge(GenericAction action)
 {
     if (action is SlamAction && HostUpgrade.State.Charges > 0)
     {
         HostUpgrade.State.LoseCharge();
         RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, AskToReplaceToken);
     }
     ;
 }
Exemplo n.º 13
0
 public SpriteInfo(SpriteInfo other)
 {
     this.id       = other.id;
     this.type     = other.type;
     this.category = other.category;
     this.action   = other.action;
     this.layer    = other.layer;
     this.tint     = other.tint;
 }
Exemplo n.º 14
0
 public virtual void ActionIsFailed(GenericShip ship, GenericAction action, bool overWrittenInstead = false, bool hasSecondChance = false)
 {
     if (!overWrittenInstead && !hasSecondChance)
     {
         ship.RemoveAlreadyExecutedAction(action);
         ActionsHolder.CurrentAction = null;
     }
     action.RevertActionOnFail(hasSecondChance);
 }
Exemplo n.º 15
0
        public void CallActionIsTaken(GenericAction action, Action callBack)
        {
            if (OnActionIsPerformed != null)
            {
                OnActionIsPerformed(action);
            }

            Triggers.ResolveTriggers(TriggerTypes.OnActionIsPerformed, callBack);
        }
Exemplo n.º 16
0
 private void CheckDecreaseComplexity(ref GenericAction action)
 {
     if (action is EvadeAction && action.IsRed)
     {
         if (IsNearObstacle())
         {
             action.IsRed = false;
         }
     }
 }
        public void BackgroundUnselectedColorTest()
        {
            GenericAction target   = new GenericAction();
            Color         expected = Color.MistyRose;
            Color         actual;

            target.BackgroundUnselectedColor = expected;
            actual = target.BackgroundUnselectedColor;
            Assert.AreEqual(expected, actual, "The property is not set properly.");
        }
        public void BackColorTest()
        {
            GenericAction target   = new GenericAction();
            Color         expected = Color.Transparent;
            Color         actual;

            target.BackColor = Color.SpringGreen;
            actual           = target.BackColor;
            Assert.AreEqual(expected, actual, "After assigning a color to the 'BackColor' property, this property should always return 'Transparent'.");
        }
Exemplo n.º 19
0
 private void CheckAfterCoordinateAbility(GenericAction action)
 {
     if (HasFewStressTokens())
     {
         if (action is CoordinateAction || action.IsCoordinatedAction)
         {
             RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, AskPerformActionAsRed);
         }
     }
 }
Exemplo n.º 20
0
 public void AddAvailableFreeAction(GenericAction action)
 {
     if (CanPerformFreeAction(action))
     {
         if (!AvailableFreeActionsList.Any(n => n.GetType() == action.GetType() && n.IsRed == action.IsRed))
         {
             AvailableFreeActionsList.Add(action);
         }
     }
 }
Exemplo n.º 21
0
 public void AddAvailableFreeAction(GenericAction action)
 {
     if (CanPerformFreeAction(action))
     {
         if (!AvailableFreeActionsList.Any(n => n.Name == action.Name && n.Color == action.Color))
         {
             AvailableFreeActionsList.Add(action);
         }
     }
 }
Exemplo n.º 22
0
 private void CheckDecreaseComplexity(GenericAction action, ref ActionColor color)
 {
     if (action is EvadeAction && color == ActionColor.Red)
     {
         if (IsNearObstacle())
         {
             color = ActionColor.White;
         }
     }
 }
        public void BackgroundSelectedColor()
        {
            GenericAction target   = new GenericAction();
            Color         expected = Color.Tomato;
            Color         actual;

            target.BackgroundSelectedColor = expected;
            actual = target.BackgroundSelectedColor;
            Assert.AreEqual(expected, actual, "The property is not set properly.");
        }
Exemplo n.º 24
0
 private void RestrictSlam(GenericShip ship, GenericAction action, ref bool canBeUsed)
 {
     if (action is SlamAction)
     {
         if (canBeUsed)
         {
             canBeUsed = HostUpgrade.State.Charges > 0;
         }
     }
 }
Exemplo n.º 25
0
 public void AddAvailableAction(GenericAction action)
 {
     if (CanPerformAction(action))
     {
         if (!AvailableActionsList.Any(n => n.Name == action.Name && n.IsRed == action.IsRed))
         {
             AvailableActionsList.Add(action);
         }
     }
 }
        public void SurroundColorTest()
        {
            GenericAction target   = new GenericAction();
            Color         expected = Color.RosyBrown;
            Color         actual;

            target.SurroundColor = expected;
            actual = target.SurroundColor;
            Assert.AreEqual(expected, actual, "The property is not set properly.");
        }
Exemplo n.º 27
0
    public virtual GenericAction AddAction(string eventName, System.Action <object[]> act)
    {
        GenericAction action = new GenericAction(act);

        EnsureEventExists(eventName);

        OnActionAdded(eventName, action);
        actions[eventName].Add(action);
        return(action);
    }
Exemplo n.º 28
0
    // TAKE ACTION TRIGGERS

    public static void TakeAction(GenericAction action)
    {
        var ship = Selection.ThisShip;

        Tooltips.EndTooltip();
        UI.HideSkipButton();
        ship.AddAlreadyExecutedAction(action);
        CurrentAction = action;
        action.ActionTake();
    }
Exemplo n.º 29
0
        private void SkipActionsUntilEndOfActivation(GenericAction action)
        {
            Messages.ShowInfoToHuman(HostUpgrade.UpgradeInfo.Name + ": You cannot perform another actions during your activation");

            HostShip.OnActionIsPerformed -= SkipActionsUntilEndOfActivation;
            HostShip.OnActionIsSkipped   -= SkipAbility;

            HostShip.OnTryAddAction             += DisallowAction;
            HostShip.OnMovementActivationFinish += ClearRestriction;
        }
Exemplo n.º 30
0
 private void CheckWhiteActionsWhileStressed(GenericAction action, ref ActionColor color)
 {
     if (AllowedActionTypes.Contains(action.GetType()) &&
         action.Color == ActionColor.White &&
         HostShip.IsStressed)
     {
         Messages.ShowInfo(HostUpgrade.UpgradeInfo.Name + ": Action is treated as red");
         color = ActionColor.Red;
     }
 }
Exemplo n.º 31
0
        public int ConvertAction(int BodyID, int Serial, int X, int Y, int Direction, GenericAction g, Mobile m)
        {
            this.Translate(ref BodyID);
            BodyType bodyType = this.GetBodyType(BodyID);
            this.m_SA_Body = BodyID;
            this.m_SA_Dir = Direction;
            if (bodyType == BodyType.Monster)
            {
                switch (g)
                {
                    case GenericAction.Die:
                        return this.SafeAction(2 + ((Direction >> 7) & 1), 2, 3);

                    case GenericAction.MountedWalk:
                        return 0;

                    case GenericAction.MountedRun:
                        return 0;

                    case GenericAction.Walk:
                        return 0;

                    case GenericAction.Run:
                        return 0;

                    case GenericAction.MountedStand:
                        return 1;

                    case GenericAction.Stand:
                        return 1;
                }
            }
            else if ((bodyType == BodyType.Animal) || (bodyType == BodyType.Sea))
            {
                switch (g)
                {
                    case GenericAction.Die:
                        return this.SafeAction(8 + (((Direction >> 7) & 1) * 4), 8, 12);

                    case GenericAction.MountedWalk:
                        return 0;

                    case GenericAction.MountedRun:
                        return this.SafeAction(1, 0);

                    case GenericAction.Walk:
                        return 0;

                    case GenericAction.Run:
                        return this.SafeAction(1, 0);

                    case GenericAction.MountedStand:
                        return 2;

                    case GenericAction.Stand:
                        return 2;
                }
            }
            else
            {
                switch (bodyType)
                {
                    case BodyType.Human:
                    case BodyType.Equipment:
                        switch (g)
                        {
                            case GenericAction.Die:
                                return this.SafeAction(0x15 + ((Direction >> 7) & 1), 0x15, 0x16);

                            case GenericAction.MountedWalk:
                                return 0x17;

                            case GenericAction.MountedRun:
                                return 0x18;

                            case GenericAction.Walk:
                                if ((m == null) || !m.Warmode)
                                {
                                    if (m.UsingTwoHandedWeapon())
                                    {
                                        return this.SafeAction(1, 0);
                                    }
                                    return this.SafeAction(0, 1, 15);
                                }
                                return this.SafeAction(15, m.UsingTwoHandedWeapon() ? 1 : 0, 0);

                            case GenericAction.Run:
                                if ((m == null) || !m.UsingTwoHandedWeapon())
                                {
                                    return this.SafeAction(2, 3);
                                }
                                return this.SafeAction(3, 2);

                            case GenericAction.MountedStand:
                                return 0x19;

                            case GenericAction.Stand:
                                if ((m == null) || !m.Warmode)
                                {
                                    return this.SafeAction(4, 7, 8);
                                }
                                if (!m.UsingTwoHandedWeapon())
                                {
                                    return this.SafeAction(7, 8, 4);
                                }
                                return this.SafeAction(8, 7, 4);
                        }
                        break;
                }
            }
            return 0;
        }