示例#1
0
        private void UpdateCardInteraction()
        {
            if (this.CardPicked != null)
            {
                Vector2i mousePosition = this.MousePosition;

                Vector2f cardPosition = new Vector2f(mousePosition.X, mousePosition.Y);

                CardEntity cardEntity = this.object2DToObjects[this.CardPicked] as CardEntity;

                if (this.focusedGraphicEntity2D is StarEntity2D)
                {
                    StarEntity2D starEntity2D = this.focusedGraphicEntity2D as StarEntity2D;

                    StarEntity starEntity = this.object2DToObjects[starEntity2D] as StarEntity;

                    if (starEntity.CanSocketCard(cardEntity))
                    {
                        cardPosition = new Vector2f(starEntity2D.Position.X, starEntity2D.Position.Y);
                    }
                }

                this.CardPicked.Position = cardPosition;
            }
        }
示例#2
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);
            }
        }
示例#3
0
        private void UpdateMapping(Dictionary <StarEntity, List <StarLinkEntity> > starEntityToStarLinks,
                                   Dictionary <ConstellationNode, StarEntity> nodeToStarEntity,
                                   Dictionary <ConstellationLink, List <StarLinkEntity> > linkToStarLinkEntity,
                                   Tuple <ConstellationLink, ConstellationNode> currentTuple,
                                   StarEntity starEntity)
        {
            if (nodeToStarEntity.ContainsKey(currentTuple.Item2))
            {
                nodeToStarEntity[currentTuple.Item2] = starEntity;
            }
            else
            {
                nodeToStarEntity.Add(currentTuple.Item2, starEntity);
            }

            if (currentTuple.Item1 != null)
            {
                List <StarLinkEntity> starLinks = starEntityToStarLinks[starEntity];

                if (linkToStarLinkEntity.ContainsKey(currentTuple.Item1))
                {
                    linkToStarLinkEntity[currentTuple.Item1] = starLinks;
                }
                else
                {
                    linkToStarLinkEntity.Add(currentTuple.Item1, starLinks);
                }
            }
        }
示例#4
0
 public void OnCardAwakened(BoardGameLayer layer, StarEntity starEntity)
 {
     //foreach (ICardBehavior cardBehavior in this.CardBehaviors)
     //{
     //    cardBehavior.OnAwakened(layer, starEntity);
     //}
 }
示例#5
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;
        }
示例#6
0
        public bool OnMouseClicked(ALayer2D parentLayer, ControlEventType eventType)
        {
            if (parentLayer is BoardGameLayer2D)
            {
                if (parentLayer.FocusedGraphicEntity2D == this)
                {
                    if (eventType == ControlEventType.MOUSE_LEFT_CLICK)
                    {
                        BoardGameLayer2D boardGameLayer2D = (parentLayer as BoardGameLayer2D);

                        if (boardGameLayer2D.CardPicked != null)
                        {
                            StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity;
                            CardEntity cardEntity = parentLayer.GetEntityFromEntity2D(boardGameLayer2D.CardPicked) as CardEntity;

                            if (starEntity.CanSocketCard(cardEntity))
                            {
                                boardGameLayer2D.SendEventToWorld(Model.Event.EventType.SOCKET_CARD, starEntity, null);
                            }
                        }
                        else if (boardGameLayer2D.SourceCardEntities2D != null && boardGameLayer2D.SourceCardEntities2D.Count > 0)
                        {
                            StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity;

                            boardGameLayer2D.SendEventToWorld(Model.Event.EventType.PICK_CARD, starEntity.CardSocketed, null);
                        }
                    }
                }
            }
            return(true);
        }
示例#7
0
        public Entity BuildItemEntity(ItemType type, Vector2 loc, EventSoundEffects sounds)
        {
            Entity toReturn = null;

            switch (type)
            {
            case ItemType.Flower:
                toReturn = new FlowerEntity(loc, sounds);
                break;

            case ItemType.Coin:
                toReturn = new CoinEntity(loc, sounds);
                break;

            case ItemType.RedMushroom:
                toReturn = new RedMushroomEntity(loc, sounds);
                break;

            case ItemType.GreenMushroom:
                toReturn = new GreenMushroomEntity(loc, sounds);
                break;

            case ItemType.Star:
                toReturn = new StarEntity(loc, sounds);
                break;
            }
            return(toReturn);
        }
示例#8
0
        public static ConstellationPattern CreateAssociatedCardsPatternFrom(ConstellationPattern modelPattern, IConstellation constellation)
        {
            ConstellationPattern patternToCreate = new ConstellationPattern();

            Dictionary <ConstellationNode, ConstellationNode> nodeToNewNode = new Dictionary <ConstellationNode, ConstellationNode>();

            ConstellationNode newNode;

            foreach (ConstellationNode node in modelPattern.ConstellationNodeSystem)
            {
                if (node != modelPattern.NodeSelf)
                {
                    StarEntity associatedStarEntity = constellation.NodeToStarEntity[node];

                    newNode = new ConstellationCardEntityNode(associatedStarEntity.CardSocketed);
                    nodeToNewNode.Add(node, newNode);

                    patternToCreate.AddNode(newNode);
                }
            }

            newNode = new ConstellationNodeSelf();
            nodeToNewNode.Add(modelPattern.NodeSelf, newNode);
            patternToCreate.AddNode(newNode);

            foreach (ConstellationLink link in modelPattern.ConstellationLinkSystem)
            {
                patternToCreate.AddNodeLink(new ConstellationLink(nodeToNewNode[link.Node1], nodeToNewNode[link.Node2]));
            }

            return(patternToCreate);
        }
示例#9
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));
            }
        }
示例#10
0
        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;
        }
示例#12
0
 public void ReevaluateAwakening(BoardGameLayer layer, StarEntity starEntity, HashSet <StarEntity> starEntitiesChanged)
 {
     if (this.Constellation != null)
     {
         this.Constellation.OnOtherStarEntitiesChanged(layer, starEntity, starEntitiesChanged);
     }
 }
示例#13
0
 public void OnActionsOccured(BoardGameLayer layer, StarEntity starEntity, List <IBoardGameAction> actionOccured)
 {
     //foreach(ICardBehavior cardBehavior in this.CardBehaviors)
     //{
     //    cardBehavior.OnActionsOccured(layer, starEntity, actionOccured);
     //}
 }
示例#14
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);
            }
        }
示例#15
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);
            }
        }
示例#16
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));
            }
        }
示例#17
0
        protected override void ExecuteBehavior(StarEntity starEntity)
        {
            if (this.NodeLevel.BoardGameLayer.CardEntityPicked != null)
            {
                this.ModifiedCardEntities.Add(this.NodeLevel.BoardGameLayer.CardEntityPicked);
            }

            this.NodeLevel.BoardGameLayer.MoveCard(starEntity);
        }
示例#18
0
        public void OnMouseFocused(ALayer2D parentLayer, ControlEventType eventType)
        {
            StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity;

            if (starEntity.CardSocketed != null)
            {
                parentLayer.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_BOARD, starEntity.CardSocketed, null);
            }
        }
示例#19
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);
        }
示例#21
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);
         }
     }
 }
示例#23
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);
        }
示例#24
0
        public SocketCardAction(CardEntity cardEntity, StarEntity starEntity, bool mustTravel = false)
        {
            this.CardToSocket = cardEntity;

            this.OwnerStar = starEntity;

            this.MustTravel = mustTravel;

            //this.PositionInNotifBoard = positionInNotifBoard;
        }
示例#25
0
        public override IObject2D CreateObject2D(World2D world2D, ALayer2D layer2D, IObject obj)
        {
            if (obj is StarEntity)
            {
                StarEntity entity = obj as StarEntity;

                return(new StarEntity2D(this, layer2D, entity));
            }

            return(null);
        }
        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));
            }
        }
示例#27
0
        public override IAIObject CreateObjectAI(AIWorld worldAI, AAILayer layerAI, IObject obj)
        {
            if (obj is StarEntity)
            {
                StarEntity entity = obj as StarEntity;

                return(new AIStarEntity(layerAI, this, entity));
            }

            return(null);
        }
示例#28
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));
            }
        }
示例#29
0
        public StarEntity2D(IObject2DFactory factory, ALayer2D parentLayer, StarEntity entity) :
            base(parentLayer, factory, entity)
        {
            Shader shader = new Shader(null, null, @"Assets\Graphics\Shaders\StarFrag.frag");

            Texture distortionMap = factory.GetTextureById("distortionTexture");

            distortionMap.Repeated = true;
            distortionMap.Smooth   = true;
            shader.SetUniform("currentTexture", new Shader.CurrentTextureType());
            shader.SetUniform("distortionMapTexture", distortionMap);

            render        = new RenderStates(BlendMode.Alpha);
            render.Shader = shader;

            this.isFocused = true;
            this.IsFocused = false;

            this.SetCardSocketed(entity.CardSocketed);

            this.ObjectSprite.Texture = factory.GetTextureById("starTexture");

            this.ObjectSprite.Origin = new SFML.System.Vector2f(this.ObjectSprite.TextureRect.Width / 2, this.ObjectSprite.TextureRect.Height / 2);

            // Active animation
            SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(4), AnimationType.LOOP);

            IAnimation anim = new ZoomAnimation(1, 1.5f, Time.FromSeconds(2), AnimationType.ONETIME, InterpolationMethod.LINEAR);

            sequence.AddAnimation(0, anim);

            anim = new ZoomAnimation(1.5f, 1, Time.FromSeconds(2), AnimationType.ONETIME, InterpolationMethod.LINEAR);
            sequence.AddAnimation(2, anim);

            this.animationsList.Add(sequence);

            // Start : Transitioning active animation
            Random rand      = new Random();
            float  startTime = (float)(rand.NextDouble() * 2);

            sequence = new SequenceAnimation(Time.FromSeconds(startTime + 2), AnimationType.ONETIME);

            anim = new ZoomAnimation(0, 0, Time.FromSeconds(startTime), AnimationType.ONETIME, InterpolationMethod.STEP);
            sequence.AddAnimation(0, anim);

            anim = new ZoomAnimation(0f, 1f, Time.FromSeconds(2), AnimationType.ONETIME, InterpolationMethod.LINEAR);
            sequence.AddAnimation(startTime, anim);

            this.animationsList.Add(sequence);

            this.InitializeState(entity);
        }
示例#30
0
        private void UpdateValue(BoardGameLayer layer, StarEntity starEntity)
        {
            HashSet <StarLinkEntity> starLinkEntities = layer.StarToLinks[starEntity];

            List <CardEntity> notSocketedAnymore = this.AffectedCards.Where(pElem => pElem.ParentStar == null).ToList();

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

                this.AffectedCards.Remove(cardEntity);
            }
        }