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 ); } } }
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); } }
public void RemoveActionbarAction(Type type) { GenericAction action = ActionbarActions.Find(n => n.GetType() == type); if (action != null) { ActionbarActions.Remove(action); } }
public void CallBeforeFreeActionIsPerformed(GenericAction action, Action callBack) { if (BeforeFreeActionIsPerformed != null) { BeforeFreeActionIsPerformed(action); } Triggers.ResolveTriggers(TriggerTypes.BeforeFreeActionIsPerformed, callBack); }
/// <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."); }
public void CheckSupernaturalReflexesDamage(GenericAction action) { HostShip.OnActionIsPerformed -= CheckSupernaturalReflexesDamage; if (!HostShip.ActionBar.HasAction(action.GetType())) { RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, SufferDamage); } }
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); }
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); }
private void LoseCharge(GenericAction action) { if (action is SlamAction && HostUpgrade.State.Charges > 0) { HostUpgrade.State.LoseCharge(); RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, AskToReplaceToken); } ; }
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; }
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); }
public void CallActionIsTaken(GenericAction action, Action callBack) { if (OnActionIsPerformed != null) { OnActionIsPerformed(action); } Triggers.ResolveTriggers(TriggerTypes.OnActionIsPerformed, callBack); }
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'."); }
private void CheckAfterCoordinateAbility(GenericAction action) { if (HasFewStressTokens()) { if (action is CoordinateAction || action.IsCoordinatedAction) { RegisterAbilityTrigger(TriggerTypes.OnActionIsPerformed, AskPerformActionAsRed); } } }
public void AddAvailableFreeAction(GenericAction action) { if (CanPerformFreeAction(action)) { if (!AvailableFreeActionsList.Any(n => n.GetType() == action.GetType() && n.IsRed == action.IsRed)) { AvailableFreeActionsList.Add(action); } } }
public void AddAvailableFreeAction(GenericAction action) { if (CanPerformFreeAction(action)) { if (!AvailableFreeActionsList.Any(n => n.Name == action.Name && n.Color == action.Color)) { AvailableFreeActionsList.Add(action); } } }
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."); }
private void RestrictSlam(GenericShip ship, GenericAction action, ref bool canBeUsed) { if (action is SlamAction) { if (canBeUsed) { canBeUsed = HostUpgrade.State.Charges > 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."); }
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); }
// TAKE ACTION TRIGGERS public static void TakeAction(GenericAction action) { var ship = Selection.ThisShip; Tooltips.EndTooltip(); UI.HideSkipButton(); ship.AddAlreadyExecutedAction(action); CurrentAction = action; action.ActionTake(); }
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; }
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; } }
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; }