Esempio n. 1
0
        public void ExecuteAction(BoardGameLayer layerToPerform)
        {
            //this.CardToSocket.Card.CardUnsocketed(layerToPerform, this.OwnerStar);
            layerToPerform.CardEntityPicked = null;

            if (this.OffBoard)
            {
                HashSet <CardEntity> cardEntities = layerToPerform.NameToOnBoardCardEntities[this.CardToUnsocket.Card.Name];

                cardEntities.Remove(this.CardToUnsocket);

                if (cardEntities.Count == 0)
                {
                    layerToPerform.NameToOnBoardCardEntities.Remove(this.CardToUnsocket.Card.Name);
                }

                this.CardToUnsocket.Card.CurrentOwner = this.CardToUnsocket.Card.FirstOwner;

                layerToPerform.CardsOffBoard.Add(this.CardToUnsocket);
            }

            this.OwnerStar.CardSocketed = null;
            //else
            //{
            //    this.OwnerStar.CardSocketed = null;
            //}
        }
Esempio n. 2
0
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            HashSet <StarLinkEntity> starLinkEntities = layer.StarToLinks[starEntity];

            List <CardEntity> currentAffectedStarEntity = new List <CardEntity>();

            if (starEntity.CardSocketed.Card.Constellation != null)
            {
                IConstellation constellation = starEntity.CardSocketed.Card.Constellation;

                currentAffectedStarEntity.AddRange(constellation.NodeToStarEntity.Values.Where(pElem => pElem.CardSocketed != null && pElem.CardSocketed.Card.CurrentOwner == starEntity.CardSocketed.Card.CurrentOwner).Select(pElem => pElem.CardSocketed));
            }

            IEnumerable <CardEntity> noMoreAffected = this.affectedCardEntities.Except(currentAffectedStarEntity);
            IEnumerable <CardEntity> newAffected    = currentAffectedStarEntity.Except(this.affectedCardEntities);

            foreach (CardEntity cardEntity in noMoreAffected)
            {
                layer.PendingActions.Add(new ClearCardValueModifier(cardEntity, this));
            }

            foreach (CardEntity cardEntity in newAffected)
            {
                layer.PendingActions.Add(new SetCardValueModifier(cardEntity, this, this.Value));
            }

            this.affectedCardEntities = currentAffectedStarEntity;
        }
Esempio n. 3
0
 public void OnCardAwakened(BoardGameLayer layer, StarEntity starEntity)
 {
     //foreach (ICardBehavior cardBehavior in this.CardBehaviors)
     //{
     //    cardBehavior.OnAwakened(layer, starEntity);
     //}
 }
Esempio n. 4
0
        public override void VisitStart(World world)
        {
            base.VisitStart(world);

            CJMenuLayer startPage = new CJMenuLayer();

            BackgroundLayer background = new BackgroundLayer();
            //EntityLayer entityLayer = new EntityLayer();
            BoardGameLayer boardGameLayer = new BoardGameLayer();

            boardGameLayer.ParentLayer = background;

            BoardPlayerLayer boardPlayerLayer   = new BoardPlayerLayer();
            BoardPlayerLayer boardOpponentLayer = new BoardPlayerLayer();

            BoardNotifLayer boardNotifLayer = new BoardNotifLayer();

            BoardBannerLayer bannerLayer = new BoardBannerLayer();

            world.InitializeWorld(new List <Tuple <string, ALayer> >()
            {
                new Tuple <string, ALayer>("startPage", startPage),

                new Tuple <string, ALayer>("VsO7nJK", background),
                new Tuple <string, ALayer>("gameLayer", boardGameLayer),
                new Tuple <string, ALayer>("playerLayer", boardPlayerLayer),
                new Tuple <string, ALayer>("opponentLayer", boardOpponentLayer),
                new Tuple <string, ALayer>("notifLayer", boardNotifLayer),
                new Tuple <string, ALayer>("bannerLayer", bannerLayer)
            });

            this.nextLevelNodeName = "StartPageLevel";
            this.UpdateCurrentLevelNode(world);
        }
Esempio n. 5
0
 public void ReevaluateAwakening(BoardGameLayer layer, StarEntity starEntity, HashSet <StarEntity> starEntitiesChanged)
 {
     if (this.Constellation != null)
     {
         this.Constellation.OnOtherStarEntitiesChanged(layer, starEntity, starEntitiesChanged);
     }
 }
Esempio n. 6
0
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            int bonus = 0;

            foreach (string cardName in this.CardNames)
            {
                if (layer.NameToOnBoardCardEntities.TryGetValue(cardName, out HashSet <CardEntity> cardEntities))
                {
                    bonus += cardEntities.Count;

                    if (cardEntities.Contains(starEntity.CardSocketed))
                    {
                        bonus--;
                    }
                }
            }

            bonus *= this.Value;

            bool mustSetValue = starEntity.CardSocketed.Card.BehaviorToValueModifier.TryGetValue(this, out int currentValue) == false || currentValue != bonus;

            if (mustSetValue)
            {
                layer.PendingActions.Add(new SetCardValueModifier(starEntity.CardSocketed, this, bonus));
            }
        }
Esempio n. 7
0
        public void ExecuteAction(BoardGameLayer layerToPerform)
        {
            Vector2f previousPosition = this.CardToSocket.Position;

            this.OwnerStar.CardSocketed = this.CardToSocket;

            if (this.MustTravel)
            {
                this.CardToSocket.Position = previousPosition;
                IAnimation positionAnimation = new PositionAnimation(previousPosition, this.OwnerStar.Position, Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.SQUARE_DEC);

                this.CardToSocket.PlayAnimation(positionAnimation);
            }

            if (layerToPerform.NameToOnBoardCardEntities.TryGetValue(this.CardToSocket.Card.Name, out HashSet <CardEntity> cardEntities))
            {
                cardEntities.Add(this.CardToSocket);
            }
            else
            {
                layerToPerform.NameToOnBoardCardEntities.Add(this.CardToSocket.Card.Name, new HashSet <CardEntity>()
                {
                    this.CardToSocket
                });
            }

            //layerToPerform.CardEntityPicked = null;
        }
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            List <StarEntity> allyStarEntities = layer.StarSystem.Where(pElem => pElem.CardSocketed != null && pElem.CardSocketed.Card.CurrentOwner == starEntity.CardSocketed.Card.CurrentOwner).ToList();

            int bonus = 0;
            Dictionary <ConstellationNode, StarEntity>             nodeToStarEntity     = new Dictionary <ConstellationNode, StarEntity>();
            Dictionary <ConstellationLink, List <StarLinkEntity> > linkToStarLinkEntity = new Dictionary <ConstellationLink, List <StarLinkEntity> >();

            while (allyStarEntities.Count != 0)
            {
                StarEntity currentStarEntity = allyStarEntities.ElementAt(0);
                allyStarEntities.RemoveAt(0);

                if (this.patternToMatch.CreateConstellationSystem(layer, currentStarEntity, nodeToStarEntity, linkToStarLinkEntity))
                {
                    allyStarEntities = allyStarEntities.Except(nodeToStarEntity.Values).ToList();
                    bonus++;
                }
            }

            bonus *= this.Value;

            bool mustSetValue = starEntity.CardSocketed.Card.BehaviorToValueModifier.TryGetValue(this, out int currentValue) == false || currentValue != bonus;

            if (mustSetValue)
            {
                layer.PendingActions.Add(new SetCardValueModifier(starEntity.CardSocketed, this, bonus));
            }
        }
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            HashSet <StarLinkEntity> starLinkEntities = layer.StarToLinks[starEntity];

            List <CardEntity> currentAffectedStarEntity = new List <CardEntity>();

            foreach (StarLinkEntity starLinkEntity in starLinkEntities)
            {
                StarEntity otherStarEntity = starLinkEntity.StarFrom;
                if (otherStarEntity == starEntity)
                {
                    otherStarEntity = starLinkEntity.StarTo;
                }

                if (otherStarEntity.CardSocketed != null && otherStarEntity.CardSocketed.Card.CurrentOwner == starEntity.CardSocketed.Card.CurrentOwner)
                {
                    currentAffectedStarEntity.Add(otherStarEntity.CardSocketed);
                }
            }

            IEnumerable <CardEntity> noMoreAffected = this.affectedCardEntities.Except(currentAffectedStarEntity);
            IEnumerable <CardEntity> newAffected    = currentAffectedStarEntity.Except(this.affectedCardEntities);

            foreach (CardEntity cardEntity in noMoreAffected)
            {
                layer.PendingActions.Add(new ClearCardValueModifier(cardEntity, this));
            }

            foreach (CardEntity cardEntity in newAffected)
            {
                layer.PendingActions.Add(new SetCardValueModifier(cardEntity, this, this.Value));
            }

            this.affectedCardEntities = currentAffectedStarEntity;
        }
Esempio n. 10
0
 public void OnCardUnawakened(BoardGameLayer layer, CardEntity ownerCardEntity)
 {
     //foreach (ICardBehavior cardBehavior in this.CardBehaviors)
     //{
     //    cardBehavior.OnUnawakened(layer, starEntity);
     //}
 }
Esempio n. 11
0
        public override void OnOtherStarEntitiesChanged(BoardGameLayer boardGameLayer, StarEntity starEntity, HashSet <StarEntity> starEntitiesChanged)
        {
            if (this.isAwakened)
            {
                StarEntity starEntityChanged = this.NodeToStarEntity.Values.FirstOrDefault(pElem => starEntitiesChanged.Contains(pElem));

                if (starEntityChanged != null)
                {
                    bool isStillAwake = this.holdingConstellationPattern.CreateConstellationSystem(
                        boardGameLayer,
                        starEntity,
                        this.NodeToStarEntity,
                        this.LinkToStarLinkEntity);

                    if (isStillAwake == false)
                    {
                        this.TryToAwake(boardGameLayer, starEntity, starEntitiesChanged);
                    }
                }
            }
            else
            {
                this.TryToAwake(boardGameLayer, starEntity, starEntitiesChanged);
            }
        }
Esempio n. 12
0
 public void OnActionsOccured(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionOccured)
 {
     //foreach(ICardBehavior cardBehavior in this.CardBehaviors)
     //{
     //    cardBehavior.OnActionsOccured(layer, starEntity, actionOccured);
     //}
 }
Esempio n. 13
0
        //public virtual void CardSocketed(BoardGameLayer layer, StarEntity parentStarEntity)
        //{
        //    //foreach(Constellation constellation in this.constellations)
        //    //{
        //    //    constellation.OnCardSocketed(layer, parentStarEntity);
        //    //}
        //}

        //public void CardUnsocketed(BoardGameLayer layer, StarEntity oldParentStarEntity)
        //{
        //    //foreach (Constellation constellation in this.constellations)
        //    //{
        //    //    constellation.OnCardUnsocketed(layer, oldParentStarEntity);
        //    //}
        //}

        //public virtual void OtherCardSocketed(BoardGameLayer layer, StarEntity starEntity, StarEntity starFromUnsocketedCard)
        //{
        //    //foreach (Constellation constellation in this.constellations)
        //    //{
        //    //    constellation.OnOtherCardSocketed(layer, starEntity, starFromUnsocketedCard);
        //    //}
        //}

        public void NotifyActionsOccured(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionOccured)
        {
            this.cardTemplate.OnActionsOccured(layer, starEntity, actionOccured);

            foreach (ICardBehavior cardBehavior in this.CardBehaviors)
            {
                cardBehavior.OnActionsOccured(layer, starEntity, actionOccured);
            }
        }
        public override void OnUnawakened(BoardGameLayer layer, CardEntity ownerCardEntity)
        {
            foreach (CardEntity cardEntity in this.affectedCardEntities)
            {
                layer.PendingActions.Add(new ClearCardValueModifier(cardEntity, this));
            }

            this.affectedCardEntities.Clear();
        }
Esempio n. 15
0
        public void NotifyCardUnawakened(BoardGameLayer layer, CardEntity ownerCardEntity)
        {
            this.cardTemplate.OnCardUnawakened(layer, ownerCardEntity);

            foreach (ICardBehavior cardBehavior in this.CardBehaviors)
            {
                cardBehavior.OnUnawakened(layer, ownerCardEntity);
            }
        }
Esempio n. 16
0
        //public virtual void CardEnteredBoard(BoardGameLayer layer)
        //{

        //}

        //public virtual void CardQuittedBoard(BoardGameLayer layer)
        //{

        //}

        public void NotifyCardAwakened(BoardGameLayer layer, StarEntity parentStarEntity)
        {
            this.cardTemplate.OnCardAwakened(layer, parentStarEntity);

            foreach (ICardBehavior cardBehavior in this.CardBehaviors)
            {
                cardBehavior.OnAwakened(layer, parentStarEntity);
            }
        }
Esempio n. 17
0
        public override void OnAwakened(BoardGameLayer layer, StarEntity starEntity)
        {
            this.AffectedCards.Clear();

            if (layer.StarSystem.Where(pElem => pElem.CardSocketed != null && pElem.CardSocketed.Card.CanBeValueModified).Any())
            {
                layer.RegisterNotifBehavior(new AddPointsNotifBehavior(this, starEntity.CardSocketed, this.PointsToAdd));
            }
        }
Esempio n. 18
0
 public override void OnActionsOccured(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionsOccured)
 {
     if (this.AffectedCards.Count > 0)
     {
         if (actionsOccured.Any(pElem => pElem is IModifyStarEntityAction))
         {
             this.UpdateValue(layer, starEntity);
         }
     }
 }
        protected override bool ActivateBehaviorEffect(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionsOccured)
        {
            if (base.ActivateBehaviorEffect(layer, starEntity, actionsOccured))
            {
                layer.RegisterNotifBehavior(new SendInternalEventNotifBehavior(starEntity.CardSocketed, Event.InternalEventType.GO_TO_LEVEL, "RulesLevel"));

                return(true);
            }
            return(false);
        }
Esempio n. 20
0
        protected virtual bool ActivateBehaviorEffect(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionsOccured)
        {
            if (this.IsActive)
            {
                this.CurrentActivationNb++;

                return(true);
            }
            return(false);
        }
 public override void OnActionsOccured(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionsOccured)
 {
     if (starEntity.CardSocketed.Card.IsAwakened)
     {
         if (actionsOccured.Any(pElem => pElem is IModifyStarEntityAction))
         {
             this.UpdateValue(layer, starEntity);
         }
     }
 }
Esempio n. 22
0
        protected override bool ActivateBehaviorEffect(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionsOccured)
        {
            if (base.ActivateBehaviorEffect(layer, starEntity, actionsOccured))
            {
                layer.RegisterNotifBehavior(new DeleteCardNotifBehavior(this, starEntity.CardSocketed));

                return(true);
            }
            return(false);
        }
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            int bonus = layer.GetNbOpponentDeadCard(starEntity.CardSocketed.Card.CurrentOwner) * this.Value;

            bool mustSetValue = starEntity.CardSocketed.Card.BehaviorToValueModifier.TryGetValue(this, out int currentValue) == false || currentValue != bonus;

            if (mustSetValue)
            {
                layer.PendingActions.Add(new SetCardValueModifier(starEntity.CardSocketed, this, bonus));
            }
        }
Esempio n. 24
0
        public override IObject2D CreateObject2D(World2D world2D, IObject obj)
        {
            if (obj is BoardGameLayer)
            {
                BoardGameLayer boardGameLayer = obj as BoardGameLayer;

                return(new BoardGameLayer2D(world2D, this, boardGameLayer));
            }

            return(null);
        }
Esempio n. 25
0
        //protected override void UpdateViewSize(Vector2f viewSize, Time deltaTime)
        //{
        //    this.DefaultViewSize = viewSize;
        //    this.view.Size = viewSize;

        //    foreach(KeyValuePair<AEntity, AEntity2D> pairEntity in this.objectToObject2Ds)
        //    {
        //        pairEntity.Value.Position = new Vector2f(pairEntity.Key.Position.X, this.view.Size.Y / 2 + pairEntity.Key.Position.Y);
        //    }
        //}

        public Vector2f BoardToLayerPosition(BoardGameLayer layer, Vector2f boardPosition)
        {
            Vector2f resultPosition = new Vector2f();

            if (this.world2D.TryGetTarget(out World2D world2D))
            {
                resultPosition = this.GetPositionInScene(world2D.LayersDictionary[layer].GetPositionInWindow(boardPosition));
            }

            return(new Vector2f(resultPosition.X, resultPosition.Y - this.OffsetCard));
        }
Esempio n. 26
0
        public override IAIObject CreateObjectAI(AIWorld worldAI, IObject obj)
        {
            if (obj is BoardGameLayer)
            {
                BoardGameLayer boardGameLayer = obj as BoardGameLayer;

                return(new AIBoardGameLayer(worldAI, this, boardGameLayer));
            }

            return(null);
        }
Esempio n. 27
0
        public override void OnAwakened(BoardGameLayer layer, StarEntity starEntity)
        {
            this.ConvertedCards.Clear();

            if (layer.StarToLinks[starEntity]
                .Select(pElem => pElem.StarFrom != starEntity ? pElem.StarFrom : pElem.StarTo)
                .Where(pElem => pElem.CardSocketed != null && pElem.CardSocketed.Card.CurrentOwner != starEntity.CardSocketed.Card.CurrentOwner).Any())
            {
                layer.RegisterNotifBehavior(new ConvertCardNotifBehavior(this, starEntity.CardSocketed));
            }
        }
Esempio n. 28
0
        public Vector2f LayerToBoardPosition(BoardGameLayer layer, Vector2f layerPosition)
        {
            Vector2f resultPosition = new Vector2f();

            if (this.world2D.TryGetTarget(out World2D world2D))
            {
                layerPosition  = new Vector2f(layerPosition.X, layerPosition.Y + this.OffsetCard);
                resultPosition = world2D.LayersDictionary[layer].GetPositionInScene(this.GetPositionInWindow(layerPosition));
            }

            return(resultPosition);
        }
Esempio n. 29
0
        public override void OnUnawakened(BoardGameLayer layer, CardEntity cardEntity)
        {
            foreach (CardEntity cardEntityConverted in this.AffectedCards)
            {
                if (cardEntityConverted.ParentStar != null)
                {
                    layer.PendingActions.Add(new ClearCardValueModifier(cardEntityConverted, this));
                }
            }

            this.AffectedCards.Clear();
        }
Esempio n. 30
0
        public override void OnUnawakened(BoardGameLayer layer, CardEntity cardEntity)
        {
            foreach (CardEntity cardEntityConverted in this.ConvertedCards)
            {
                if (cardEntityConverted.ParentStar != null && cardEntityConverted.Card.CurrentOwner != cardEntityConverted.Card.FirstOwner)
                {
                    layer.ConvertCard(cardEntityConverted.ParentStar, cardEntityConverted.Card.FirstOwner);
                }
            }

            this.ConvertedCards.Clear();
        }