Exemplo n.º 1
0
        protected bool CheckFocusDomainBoardEvent(World world, BoardPlayerLayer boardPlayerLayer, out CJStarDomain domainEntity, out string detailsFocused)
        {
            domainEntity   = null;
            detailsFocused = null;
            bool encounterGameEvent = false;

            if (this.pendingGameEvents.TryGetValue(EventType.FOCUS_DOMAIN_BOARD, out List <GameEvent> gameEventsList))
            {
                foreach (GameEvent gameEvent in gameEventsList)
                {
                    if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer)
                    {
                        if (domainEntity == null ||
                            gameEvent.Entity != null)
                        {
                            domainEntity = gameEvent.Entity as CJStarDomain;

                            detailsFocused = gameEvent.Details;

                            encounterGameEvent = true;
                        }
                    }
                }
            }

            return(encounterGameEvent);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private void UpdatePileFocus()
        {
            BoardPlayerLayer boardPlayerLayer      = this.parentLayer as BoardPlayerLayer;
            Vector2i         mousePositionOnScreen = this.MousePosition;

            float scaleY = mousePositionOnScreen.Y / this.OffsetCard;
            float scaleX = mousePositionOnScreen.X / this.DefaultViewSize.X;

            if (this.PileFocused == BoardPlayerLayer.PileFocused.NONE)
            {
                if (scaleY > 0.4)
                {
                    if (scaleX > 0.2)
                    {
                        this.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_PILE, null, ((int)BoardPlayerLayer.PileFocused.HAND).ToString());
                    }
                    else if (scaleX < -0.2)
                    {
                        this.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_PILE, null, ((int)BoardPlayerLayer.PileFocused.CEMETERY).ToString());
                    }
                }
            }
            else
            {
                if (scaleY < 0.2)
                {
                    this.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_PILE, null, ((int)BoardPlayerLayer.PileFocused.NONE).ToString());
                }
            }
        }
Exemplo n.º 4
0
        protected bool CheckFocusCardHandEvent(World world, BoardPlayerLayer boardPlayerLayer, out CardEntity cardEntity, out string detailsFocused)
        {
            cardEntity     = null;
            detailsFocused = null;
            bool encounterGameEvent = false;

            if (this.pendingGameEvents.TryGetValue(EventType.FOCUS_CARD_HAND, out List <GameEvent> gameEventsList))
            {
                foreach (GameEvent gameEvent in gameEventsList)
                {
                    if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer)
                    {
                        if (cardEntity == null ||
                            gameEvent.Entity != null)
                        {
                            cardEntity = gameEvent.Entity as CardEntity;

                            detailsFocused = gameEvent.Details;

                            encounterGameEvent = true;
                        }
                    }
                }
            }

            return(encounterGameEvent);
        }
Exemplo n.º 5
0
        public BoardPlayerLayer2D(World2D world2D, IObject2DFactory factory, BoardPlayerLayer layer) :
            base(world2D, factory, layer)
        {
            this.Area = new Vector2i(int.MaxValue, int.MaxValue);

            this.hittableEntities2D = new List <AEntity2D>();

            layer.CardDrawn            += OnCardDrawn;
            layer.NbCardsToDrawChanged += OnNbCardToDrawsChanged;

            layer.CardFocused += OnCardFocused;

            layer.CardPicked   += OnCardPicked;
            layer.CardUnpicked += OnCardUnpicked;

            layer.PileFocusedChanged += OnPileFocusedChanged;

            layer.CardDestroyed += OnCardDestroyed;
            // layer.CardResurrected += OnCardResurrected;

            layer.SourceCardEntitiesSet += OnSourceCardEntitiesSet;

            //this.cardToolTip = new CardToolTip(this);
            //this.endTurnButton = new EndTurnButton2D(this);
            this.scoreLabel = new ScoreLabel2D(this);

            this.cardsDeck     = new List <CardEntity2D>();
            this.cardsCemetery = new List <CardEntity2D>();
            this.cardsHand     = new List <CardEntity2D>();

            this.pileFocused = BoardPlayerLayer.PileFocused.NONE;

            layer.BoardToLayerPositionConverter = this;
        }
        public override IAIObject CreateObjectAI(AIWorld worldAI, IObject obj)
        {
            if (obj is BoardPlayerLayer)
            {
                BoardPlayerLayer boardPlayerLayer = obj as BoardPlayerLayer;

                return(new AIBoardPlayerLayer(worldAI, this, boardPlayerLayer));
            }

            return(null);
        }
Exemplo n.º 7
0
        public override IObject2D CreateObject2D(World2D world2D, IObject obj)
        {
            if (obj is BoardPlayerLayer)
            {
                BoardPlayerLayer boardPlayerLayer = obj as BoardPlayerLayer;

                return(new BoardPlayerLayer2D(world2D, this, boardPlayerLayer));
            }

            return(null);
        }
Exemplo n.º 8
0
        public CardEntity PickCard(BoardPlayerLayer boardPlayerLayer, CardEntity cardPicked)
        {
            if (this.BoardGameLayer.CardEntityPicked == null)
            {
                if (boardPlayerLayer.PickCard(cardPicked))
                {
                    return(this.BoardGameLayer.PickCard(cardPicked.Card));
                }
                this.BoardGameLayer.PickCard(cardPicked);
            }

            return(null);
        }
Exemplo n.º 9
0
        protected void InitializeEndTurnPhase(World world)
        {
            BoardPlayerLayer boardPlayerLayer = this.CurrentBoardPlayer;

            this.SetCurrentTurnPhase(world, TurnPhase.END_TURN);

            boardPlayerLayer.OnEndTurn();

            foreach (BoardPlayerLayer playerLayer in this.BoardPlayersList)
            {
                playerLayer.CardPileFocused = BoardPlayerLayer.PileFocused.NONE;
            }
        }
Exemplo n.º 10
0
        protected void InitializeDrawPhase(World world)
        {
            this.SetCurrentTurnPhase(world, TurnPhase.DRAW);

            BoardPlayerLayer boardPlayerLayer = this.CurrentBoardPlayer; // world.LoadedLayers["playerLayer"] as BoardPlayerLayer;

            boardPlayerLayer.NbCardsToDraw = 0;

            foreach (BoardPlayerLayer playerLayer in this.BoardPlayersList)
            {
                playerLayer.CardPileFocused = BoardPlayerLayer.PileFocused.HAND;
            }
        }
Exemplo n.º 11
0
        private void UpdateDrawPhase(World world)
        {
            BoardPlayerLayer boardPlayerLayer = this.CurrentBoardPlayer; // world.LoadedLayers["playerLayer"] as BoardPlayerLayer;

            if (this.CheckDrawCardEvent(world, boardPlayerLayer))
            {
                boardPlayerLayer.DrawCard();
            }

            if (this.CheckNextTurnPhaseEvent(TurnPhase.MAIN, boardPlayerLayer))
            {
                this.InitializeMainPhase(world);
            }
        }
Exemplo n.º 12
0
        protected void InitializeCreateHandPhase(World world)
        {
            this.SetCurrentTurnPhase(world, TurnPhase.CREATE_HAND);

            BoardPlayerLayer boardPlayerLayer = this.BoardPlayersList[0];

            boardPlayerLayer.NbCardsToDraw = this.MainPlayer.Deck.CardIds.Count;

            if (this.BoardPlayersList.Count > 1)
            {
                boardPlayerLayer = this.BoardPlayersList[1];
                boardPlayerLayer.NbCardsToDraw = this.Opponent.Deck.CardIds.Count;
            }
        }
Exemplo n.º 13
0
 protected bool CheckDrawCardEvent(World world, BoardPlayerLayer boardPlayerLayer)
 {
     if (this.pendingGameEvents.TryGetValue(EventType.DRAW_CARD, out List <GameEvent> gameEventsList))
     {
         foreach (GameEvent gameEvent in gameEventsList)
         {
             if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 14
0
        public CardEntity UnpickCard(BoardPlayerLayer boardPlayerLayer, string detailUnpicked)
        {
            if (this.BoardGameLayer.CardEntityPicked != null)
            {
                Card.Card cardToUnpick  = this.BoardGameLayer.CardEntityPicked.Card;
                Vector2f  startPosition = GetPositionFrom(detailUnpicked);

                if (this.BoardGameLayer.UnPickCard() && boardPlayerLayer != null)
                {
                    return(boardPlayerLayer.UnpickCard(cardToUnpick, startPosition));
                }
            }

            return(null);
        }
Exemplo n.º 15
0
        protected void InitializeStartTurnPhase(World world)
        {
            BoardBannerLayer bannerLayer    = this.BoardBannerLayer;
            BoardGameLayer   boardGameLayer = this.BoardGameLayer;

            this.TurnIndex++;

            BoardPlayerLayer boardPlayerLayer = this.CurrentBoardPlayer;

            bannerLayer.PlayerTurn    = boardPlayerLayer.SupportedPlayer;
            boardGameLayer.PlayerTurn = boardPlayerLayer.SupportedPlayer;

            this.SetCurrentTurnPhase(world, TurnPhase.START_TURN);

            boardPlayerLayer.OnStartTurn();
        }
Exemplo n.º 16
0
        protected bool CheckSocketCardEvent(World world, BoardPlayerLayer boardPlayerLayer, out StarEntity starEntity)
        {
            starEntity = null;
            if (this.pendingGameEvents.TryGetValue(EventType.SOCKET_CARD, out List <GameEvent> gameEventsList))
            {
                foreach (GameEvent gameEvent in gameEventsList)
                {
                    if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer)
                    {
                        starEntity = gameEvent.Entity as StarEntity;

                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 17
0
        protected override void UpdateCreateHandPhase(World world)
        {
            BoardPlayerLayer boardPlayerLayer = this.BoardPlayersList[0];

            if (this.CheckDrawCardEvent(world, boardPlayerLayer))
            {
                boardPlayerLayer.DrawCard();
            }

            //if (this.CheckDrawCardEvent(world, boardOpponentLayer))
            //{
            //    boardOpponentLayer.DrawCard(false);
            //}

            if (this.CheckNextTurnPhaseEvent(TurnPhase.START_TURN, null))
            {
                this.InitializeMainPhase(world);
            }
        }
Exemplo n.º 18
0
        protected bool CheckMoveCardOverboardEvent(World world, BoardPlayerLayer boardPlayerLayer, out CardEntity cardEntity, out string details)
        {
            cardEntity = null;
            details    = null;

            if (this.pendingGameEvents.TryGetValue(EventType.MOVE_CARD_OVERBOARD, out List <GameEvent> gameEventsList))
            {
                foreach (GameEvent gameEvent in gameEventsList)
                {
                    if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer)
                    {
                        cardEntity = gameEvent.Entity as CardEntity;
                        details    = gameEvent.Details;

                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 19
0
        public override void VisitStart(World world)
        {
            base.VisitStart(world);

            BackgroundLayer      background      = new BackgroundLayer();
            ImageBackgroundLayer imageBackground = new ImageBackgroundLayer();

            BoardGameLayer boardGameLayer = new BoardGameLayer();

            boardGameLayer.ParentLayer = background;

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

            BoardNotifLayer     boardNotifLayer     = new BoardNotifLayer();
            MenuBoardNotifLayer menuBoardNotifLayer = new MenuBoardNotifLayer();

            BoardBannerLayer bannerLayer = new BoardBannerLayer();

            MenuTextLayer menuTextLayer = new MenuTextLayer();

            menuTextLayer.ParentLayer = background;

            world.InitializeWorld(new List <Tuple <string, ALayer> >()
            {
                new Tuple <string, ALayer>("backgroundLayer", background),
                new Tuple <string, ALayer>("slidesLayer", imageBackground),
                new Tuple <string, ALayer>("menuTextLayer", menuTextLayer),
                new Tuple <string, ALayer>("gameLayer", boardGameLayer),
                new Tuple <string, ALayer>("playerLayer", boardPlayerLayer),
                new Tuple <string, ALayer>("opponentLayer", boardOpponentLayer),
                new Tuple <string, ALayer>("menuPlayerLayer", menuPlayerLayer),
                new Tuple <string, ALayer>("notifLayer", boardNotifLayer),
                new Tuple <string, ALayer>("menuNotifLayer", menuBoardNotifLayer),
                new Tuple <string, ALayer>("bannerLayer", bannerLayer)
            });

            this.nextLevelNodeName = "StartPageLevel";
            this.UpdateCurrentLevelNode(world);
        }
Exemplo n.º 20
0
        public override void InitializeLayer(IObject2DFactory factory)
        {
            this.cardsDeck.Clear();
            this.cardsCemetery.Clear();
            this.cardsHand.Clear();

            this.maxPriority = 0;

            this.nbCardsToDraw = 0;

            this.currentCooldownDraw = 0;

            this.LevelTurnPhase = TurnPhase.VOID;

            this.cardDrawn   = null;
            this.cardFocused = null;

            this.sourceCardEntities = null;
            //this.cardPicked = null;

            this.pileFocused = (this.parentLayer as BoardPlayerLayer).CardPileFocused;

            base.InitializeLayer(factory);

            BoardPlayerLayer parentBoardPlayerLayer = (this.parentLayer as BoardPlayerLayer);

            this.scoreLabel.DisplayScore(parentBoardPlayerLayer.IndexPlayer, parentBoardPlayerLayer.SupportedPlayer);
            this.scoreLabel.Score = 0;

            foreach (AEntity2D entity in this.objectToObject2Ds.Values)
            {
                if (entity is CardEntity2D)
                {
                    CardEntity2D cardEntity2D = entity as CardEntity2D;

                    cardEntity2D.Priority = this.maxPriority++;

                    this.cardsDeck.Add(cardEntity2D);
                }
            }
        }
Exemplo n.º 21
0
        protected bool CheckNextTurnPhaseEvent(TurnPhase nextTurnPhase, BoardPlayerLayer boardPlayerLayer)
        {
            string nextTurnPhaseString = Enum.GetName(typeof(TurnPhase), nextTurnPhase);

            if (this.pendingGameEvents.TryGetValue(EventType.LEVEL_PHASE_CHANGE, out List <GameEvent> gameEventsList))
            {
                if (boardPlayerLayer == null)
                {
                    return(true);
                }

                foreach (GameEvent gameEvent in gameEventsList)
                {
                    if ((boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer) && gameEvent.Details == nextTurnPhaseString)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 22
0
        public AIBoardPlayerLayer(AIWorld world2D, IAIObjectFactory layerFactory, BoardPlayerLayer layer)
            : base(world2D, layerFactory, layer)
        {
            this.cardsDeck     = new List <AICardEntity>();
            this.cardsCemetery = new List <AICardEntity>();
            this.cardsHand     = new List <AICardEntity>();

            layer.CardDrawn            += OnCardDrawn;
            layer.NbCardsToDrawChanged += OnNbCardToDrawsChanged;

            layer.CardFocused += OnCardFocused;

            layer.CardPicked   += OnCardPicked;
            layer.CardUnpicked += OnCardUnpicked;

            layer.PileFocusedChanged += OnPileFocusedChanged;

            layer.CardDestroyed += OnCardDestroyed;
            // layer.CardResurrected += OnCardResurrected;

            layer.SourceCardEntitiesSet += OnSourceCardEntitiesSet;
        }
Exemplo n.º 23
0
        protected virtual void UpdateCreateHandPhase(World world)
        {
            BoardPlayerLayer boardPlayerLayer = this.BoardPlayersList[0];

            if (this.CheckDrawCardEvent(world, boardPlayerLayer))
            {
                boardPlayerLayer.DrawCard();
            }

            if (this.BoardPlayersList.Count > 1)
            {
                BoardPlayerLayer boardOpponentLayer = this.BoardPlayersList[1];
                if (this.CheckDrawCardEvent(world, boardOpponentLayer))
                {
                    boardOpponentLayer.DrawCard(false);
                }
            }

            if (this.CheckNextTurnPhaseEvent(TurnPhase.START_TURN, null))
            {
                this.InitializeStartTurnPhase(world);
            }
        }
Exemplo n.º 24
0
 public OppBoardPlayerLayer2D(World2D world2D, IObject2DFactory factory, BoardPlayerLayer layer)
     : base(world2D, factory, layer)
 {
 }
Exemplo n.º 25
0
        protected virtual void UpdateMainPhase(World world)
        {
            BoardPlayerLayer boardPlayerLayer = this.CurrentBoardPlayer; // world.LoadedLayers["playerLayer"] as BoardPlayerLayer;

            //BoardGameLayer boardGameLayer = world.LoadedLayers["gameLayer"] as BoardGameLayer;
            //BoardNotifLayer boardNotifLayer = world.LoadedLayers["notifLayer"] as BoardNotifLayer;

            if (this.BoardNotifLayer.CurrentNotifBehavior != null)
            {
                this.BoardNotifLayer.ForwardGameEventsToBehavior(this.pendingGameEvents);
            }
            else
            {
                this.FowardFocusPileEvent(world);

                if (this.CheckMoveCardOverboardEvent(world, boardPlayerLayer, out CardEntity cardToMove, out string detailsMove))
                {
                    this.MoveCardOverBoard(detailsMove, cardToMove);
                }

                if (this.CheckFocusCardHandEvent(world, boardPlayerLayer, out CardEntity cardHandFocused, out string detailsHandFocused))
                {
                    boardPlayerLayer.CardEntityFocused = cardHandFocused;

                    this.BoardGameLayer.CardEntityFocused   = null;
                    this.BoardGameLayer.DomainEntityFocused = null;
                }


                if (this.CheckFocusCardBoardEvent(world, null, out CardEntity cardBoardFocused, out string detailsCardBoardFocused))
                {
                    if (boardPlayerLayer.CardEntityFocused == null)
                    {
                        this.BoardGameLayer.CardEntityFocused = cardBoardFocused;
                    }
                }

                if (this.CheckFocusDomainBoardEvent(world, null, out CJStarDomain domainBoardFocused, out string detailsDomainBoardFocused))
                {
                    if (boardPlayerLayer.CardEntityFocused == null)
                    {
                        this.BoardGameLayer.DomainEntityFocused = domainBoardFocused;
                    }
                }

                bool isThereSocketCardEvent = this.CheckSocketCardEvent(world, null, out StarEntity starEntity);
                if (isThereSocketCardEvent)
                {
                    if (starEntity != null)
                    {
                        this.BoardGameLayer.SocketCard(starEntity, true);
                    }
                }
                else
                {
                    bool IsTherePickCardEvent   = this.CheckPickCardEvent(world, boardPlayerLayer, out CardEntity cardPicked, out string detailsPicked);
                    bool IsThereUnpickCardEvent = this.CheckUnPickCardEvent(world, boardPlayerLayer, out CardEntity cardUnpicked, out string detailsUnpicked);

                    if (this.BoardGameLayer.CardEntityPicked == null)
                    {
                        if (IsTherePickCardEvent)
                        {
                            this.PickCard(boardPlayerLayer, cardPicked);
                        }
                    }
                    else
                    {
                        if (IsThereUnpickCardEvent)
                        {
                            this.UnpickCard(boardPlayerLayer, detailsUnpicked);
                        }

                        if (IsTherePickCardEvent)
                        {
                            this.PickCard(boardPlayerLayer, cardPicked);
                        }
                    }
                }

                if (this.CheckNextTurnPhaseEvent(TurnPhase.END_TURN, null))
                {
                    boardPlayerLayer.CardEntityFocused      = null;
                    this.BoardGameLayer.CardEntityFocused   = null;
                    this.BoardGameLayer.DomainEntityFocused = null;

                    if (this.BoardGameLayer.CardEntityPicked == null &&
                        this.BoardGameLayer.PendingActions.Count == 0)
                    {
                        this.InitializeEndTurnPhase(world);
                    }
                }
            }
        }