public void RegisterNotifBehavior(IBoardNotifBehavior notifBehavior) { CardBoardLevel ownerLevel = this.ownerLevelNode as CardBoardLevel; notifBehavior.NodeLevel = ownerLevel; ownerLevel.BoardNotifLayer.NotifBehaviorsList.Add(notifBehavior); }
private void UpdateBoard() { if (this.PendingActions.Count > 0) { // Clear the actions pending list to allow it to be fill by the next generation of events raised by card awakening ... List <IBoardGameAction> currentPendingActions = this.PendingActions.ToList();//Where(pElem => pElem.IsStillValid(this)).ToList(); this.PendingActions.Clear(); foreach (IBoardGameAction actionToResolve in currentPendingActions) { actionToResolve.ExecuteAction(this); } // Update off board cards if (this.CardsOffBoard.Count > 0) { CardBoardLevel ownerLevel = this.ownerLevelNode as CardBoardLevel; foreach (CardEntity cardEntity in this.CardsOffBoard) { cardEntity.Card.ResetConstellations(this, cardEntity); this.RemoveEntityFromLayer(cardEntity); ownerLevel.GetLayerFromPlayer(cardEntity.Card.CurrentOwner).AddCardToCemetery(cardEntity.Card, cardEntity.Position); } this.CardsOffBoard.Clear(); } // Update awaken states HashSet <StarEntity> starModifiedActions = new HashSet <StarEntity>(currentPendingActions.Where(pElem => pElem is IModifyStarEntityAction).Select(pElem => (pElem as IModifyStarEntityAction).OwnerStar)); if (starModifiedActions.Count > 0) { foreach (StarEntity star in this.StarSystem) { if (star.CardSocketed != null) { star.CardSocketed.Card.ReevaluateAwakening(this, star, starModifiedActions); } } } // Notify all cards of actions been executed. if (currentPendingActions.Count > 0) { foreach (StarEntity star in this.StarSystem) { if (star.CardSocketed != null) { star.CardSocketed.Card.NotifyActionsOccured(this, star, currentPendingActions); } } } // Reevaluate domains foreach (CJStarDomain domain in this.StarDomains) { domain.EvaluateDomainOwner(); } } }
protected override void InternalInitializeLayer(World world, ALevelNode levelNode) { this.currentTurnCount = 1; this.TurnIndex = -1; CardBoardLevel cardBoardLevel = levelNode as CardBoardLevel; this.Player = cardBoardLevel.MainPlayer; this.Opponent = cardBoardLevel.Opponent; this.PlayerTurn = this.Player; this.ToolTip = new ToolTipEntity(this); this.AddEntityToLayer(this.ToolTip); this.PlayerNameToTotalScores = new Dictionary <string, List <int> >(); this.PlayerNameToTotalScores.Add(this.Player.PlayerName, new List <int>()); this.PlayerNameToTotalScores.Add(this.Opponent.PlayerName, new List <int>()); this.ClearModifiers(); }
public void AddCardToCemetery(Card.Card cardToAdd, Vector2f startPosition) { CardEntity cardEntity = new CardEntity(this, cardToAdd, true); this.AddEntityToLayer(cardEntity); if (this.BoardToLayerPositionConverter != null) { CardBoardLevel testLevelNode = this.ownerLevelNode as CardBoardLevel; startPosition = this.BoardToLayerPositionConverter.BoardToLayerPosition(testLevelNode.BoardGameLayer, startPosition); } cardEntity.Position = startPosition; this.CardsCemetery.Add(cardEntity); this.CardDestroyed?.Invoke(cardEntity); this.UpdateCardsCimeteryPosition(); }
public void UnregisterNotifBehavior(CardEntity behaviorOwner) { CardBoardLevel ownerLevel = this.ownerLevelNode as CardBoardLevel; ownerLevel.BoardNotifLayer.NotifBehaviorsList.RemoveAll(pElem => pElem.OwnerCardEntity == behaviorOwner); }