Exemple #1
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);
        }
        public BoardBannerLayer2D(World2D world2D, IObject2DFactory factory, BoardBannerLayer layer) :
            base(world2D, factory, layer)
        {
            this.Area = new Vector2i(int.MaxValue, int.MaxValue);

            layer.PlayerScoreUpdated += OnPlayerScoreUpdated;
            layer.TurnCountChanged   += OnTurnCountChanged;

            this.bannerEntity2D = new BannerEntity2D(this);

            this.endLevelBanner2D            = new EndLevelBanner2D(this);
            this.returnMenuButton2D          = new ReturnMenuButton2D(this);
            this.returnMenuButton2D.Position = new Vector2f(-200, this.endLevelBanner2D.Canevas.Height / 2 - this.returnMenuButton2D.Canevas.Height / 2 - 20);
            this.replayMenuButton2D          = new ReplayMenuButton2D(this);
            this.replayMenuButton2D.Position = new Vector2f(200, this.endLevelBanner2D.Canevas.Height / 2 - this.returnMenuButton2D.Canevas.Height / 2 - 20);

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

            this.turnBanner2D         = new TurnBanner2D(this);
            this.cardsToPlaceBanner2D = new CardsToPlaceBanner2D(this);

            this.domainToolTip = new DomainToolTip2D(this);

            this.cardFocusedLayers = new HashSet <ICardFocusedLayer>();
            this.domainsLayers     = new HashSet <IDomainsLayer>();
            this.scoreLayers       = new Dictionary <string, IScoreLayer>();
        }
        public override void InitializeLayer(IObject2DFactory factory)
        {
            base.InitializeLayer(factory);

            this.LevelTurnPhase = TurnPhase.VOID;

            BoardBannerLayer boardBannerLayer = this.parentLayer as BoardBannerLayer;

            this.headerEntity2D     = new HeaderEntity2D(this, boardBannerLayer.Player, boardBannerLayer.Opponent);
            this.scoreDomainLabel2D = new ScoreDomainLabel2D(this, boardBannerLayer.Player, boardBannerLayer.Opponent);

            this.turnBanner2D.ResetTurn(boardBannerLayer.MaxTurnCount);
            this.cardsToPlaceBanner2D.ResetTurn();

            this.domainToolTip.HideToolTip();

            this.cardFocused        = null;
            this.domainLayerFocused = null;

            this.cardFocusedLayers.Clear();
            this.domainsLayers.Clear();
            this.scoreLayers.Clear();
            if (this.world2D.TryGetTarget(out World2D world2D))
            {
                foreach (ALayer2D layer in world2D.LayersList)
                {
                    ICardFocusedLayer cardFocusedLayer = layer as ICardFocusedLayer;

                    if (cardFocusedLayer != null)
                    {
                        this.cardFocusedLayers.Add(cardFocusedLayer);
                    }

                    IDomainsLayer domainLayer = layer as IDomainsLayer;
                    if (domainLayer != null)
                    {
                        this.domainsLayers.Add(domainLayer);

                        domainLayer.StartDomainEvaluated += OnStartDomainsEvaluated;
                        domainLayer.DomainEvaluated      += OnDomainEvaluated;
                        domainLayer.EndDomainEvaluated   += OnEndDomainsEvaluated;

                        domainLayer.DomainFocusedChanged += OnDomainFocusedChanged;

                        domainLayer.NbCardsToPlaceChanged += OnNbCardsToPlaceChanged;
                    }

                    IScoreLayer scoreLayer = layer as IScoreLayer;
                    if (scoreLayer != null)
                    {
                        this.scoreLayers.Add(scoreLayer.PlayerName, scoreLayer);
                    }
                }
            }
        }
Exemple #4
0
        public override IObject2D CreateObject2D(World2D world2D, IObject obj)
        {
            if (obj is BoardBannerLayer)
            {
                BoardBannerLayer backgroundLayer = obj as BoardBannerLayer;

                return(new BoardBannerLayer2D(world2D, this, backgroundLayer));
            }

            return(null);
        }
        private void OnDomainFocusedChanged(IDomainsLayer obj)
        {
            this.domainLayerFocused = obj as ALayer2D;

            if (obj.DomainFocused != null)
            {
                CJStarDomain     domainFocused     = (obj as ALayer2D).GetEntityFromEntity2D(obj.DomainFocused) as CJStarDomain;
                BoardBannerLayer parentBannerLayer = this.parentLayer as BoardBannerLayer;

                this.domainToolTip.DisplayToolTip(domainFocused, parentBannerLayer.Player, parentBannerLayer.Opponent);
            }
            else
            {
                this.domainToolTip.HideToolTip();
            }
        }
Exemple #6
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();
        }
Exemple #7
0
        protected void InitializeCountPointsPhase(World world)
        {
            BoardGameLayer   boardGameLayer = world.LoadedLayers["gameLayer"] as BoardGameLayer;
            BoardBannerLayer bannerLayer    = world.LoadedLayers["bannerLayer"] as BoardBannerLayer;

            int playerScore   = 0;
            int opponentScore = 0;

            foreach (CJStarDomain domain in boardGameLayer.StarDomains)
            {
                if (domain.IsThereAtLeastOneCard)
                {
                    if (domain.DomainOwner == null)
                    {
                        playerScore++;
                        opponentScore++;
                    }
                    else if (domain.DomainOwner == this.MainPlayer)
                    {
                        playerScore++;
                    }
                    else
                    {
                        opponentScore++;
                    }
                }
            }

            List <int> scoresPlayer   = bannerLayer.PlayerNameToTotalScores[this.MainPlayer.PlayerName];
            List <int> scoresOpponent = bannerLayer.PlayerNameToTotalScores[this.Opponent.PlayerName];

            if (scoresPlayer.Count > 0)
            {
                playerScore   += scoresPlayer.Last();
                opponentScore += scoresOpponent.Last();
            }

            playerScore   += bannerLayer.PlayerNameToModifier[this.MainPlayer.PlayerName];
            opponentScore += bannerLayer.PlayerNameToModifier[this.Opponent.PlayerName];

            bannerLayer.ClearModifiers();

            scoresPlayer.Add(playerScore);
            scoresOpponent.Add(opponentScore);

            this.SetCurrentTurnPhase(world, TurnPhase.COUNT_POINTS);
        }
        private void OnEndDomainsEvaluated()
        {
            if (this.scoreDomainLabel2D.IsActive)
            {
                this.bannerEntity2D.PlayAnimation(3);
                this.scoreDomainLabel2D.IsActive = false;
            }

            BoardBannerLayer parentLayer = this.parentLayer as BoardBannerLayer;

            foreach (KeyValuePair <string, IScoreLayer> scoreLayerPairValue in this.scoreLayers)
            {
                if (scoreLayerPairValue.Value.PlayerScore != parentLayer.PlayerNameToTotalScores[scoreLayerPairValue.Key].Last())
                {
                    throw new Exception("The score at the end of a game turn is not the same as the one computed by the view");
                }
            }

            this.endDomainsEvaluated = true;
        }
Exemple #9
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);
        }