Example #1
0
        private void startGrowInAnimation(bool inAndOut, int delay)
        {
            if (!_doingAnimation)
            {
                _doingAnimation          = true;
                Overlay.IsHitTestVisible = true;
                ContentHolder.Opacity    = 0;

                //do fade in on overlay
                ColorAnimation overlayAnimation;
                overlayAnimation          = new ColorAnimation();
                overlayAnimation.From     = Color.FromArgb(0, 0, 0, 0);
                overlayAnimation.To       = Color.FromArgb(88, 0, 0, 0);
                overlayAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
                Overlay.Background.BeginAnimation(SolidColorBrush.ColorProperty, overlayAnimation);

                //do grow in animation
                ScaleTransform scale = new ScaleTransform(1.0, 1.0);
                Card.RenderTransformOrigin = new Point(0.5, 0.5);
                Card.RenderTransform       = scale;

                DoubleAnimation growXAnimation = new DoubleAnimation();
                growXAnimation.Duration       = new Duration(TimeSpan.FromSeconds(0.5));
                growXAnimation.From           = 0;
                growXAnimation.To             = 1;
                growXAnimation.EasingFunction = new CubicEase
                {
                    EasingMode = EasingMode.EaseOut
                };
                Card.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, growXAnimation);

                DoubleAnimation growYAnimation = new DoubleAnimation();
                growYAnimation.Duration       = new Duration(TimeSpan.FromSeconds(0.5));
                growYAnimation.From           = 0;
                growYAnimation.To             = 1;
                growYAnimation.EasingFunction = new CubicEase
                {
                    EasingMode = EasingMode.EaseOut
                };
                growYAnimation.Completed += delegate
                {
                    _doingAnimation = false;
                    if (inAndOut)
                    {
                        startGrowOutAnimation(delay);
                    }
                };
                Card.RenderTransform.BeginAnimation(ScaleTransform.ScaleYProperty, growYAnimation);

                //do fade in on content
                DoubleAnimation fadeIn = new DoubleAnimation
                {
                    From      = 0,
                    To        = 1,
                    BeginTime = TimeSpan.FromSeconds(0.2),
                    Duration  = new Duration(TimeSpan.FromSeconds(0.3))
                };
                ContentHolder.BeginAnimation(UIElement.OpacityProperty, fadeIn);
            }
        }
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            int?score_to_unlock_next_level = this.GetScoreToUnlockNextLevel();

            if (score_to_unlock_next_level != null)
            {
                var         texture = ContentHolder.Get(Settings.CurrentSnake);
                const float scale   = 0.3125f;

                for (int i = 0; i < LevelRequirementsLogo.BaseTextLocations.Length; i++)
                {
                    var pos = LevelRequirementsLogo.BaseTextLocations[i];
                    sprite_batch.Draw(texture, pos, null, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                }

                string    score_string = score_to_unlock_next_level.ToString();
                const int start_x      = 240 + 32 - 10 - 11 - 6;
                const int start_y      = 480 - 60 + 5;
                const int spread_x     = 23;
                for (int i = 0; i < score_string.Length; i++)
                {
                    int integer  = int.Parse(score_string[i].ToString());
                    var base_pos = new Vector2(start_x + spread_x * i, start_y);
                    foreach (var pos in LogoDrawData.ScoreNumberLocations[integer])
                    {
                        sprite_batch.Draw(texture, base_pos + pos, null, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                    }
                }
            }
        }
Example #3
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     ContentHolder.Init(Content);
     ecsEngine.Init();
     ecsEngine.SetScene(SceneType.Menu);
 }
Example #4
0
 private void Navigation_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
 {
     if (ContentHolder.CanGoBack)
     {
         ContentHolder.GoBack();
     }
 }
Example #5
0
        private FallingEntity spawnEntity(Vector2 position)
        {
            Array             values         = Enum.GetValues(typeof(AvailableTextures));
            AvailableTextures random_texture = (AvailableTextures)values.GetValue(Utilities.Random.Next(values.Length));
            var texture = ContentHolder.Get(random_texture);

            return(new FallingEntity(texture, new Vector2(position.X, position.Y)));
        }
Example #6
0
        public void ReadWAD(String p)
        {
            var reader = new WADReader(p);

            ContentHolder = reader.ReadFile();

            Debugger.Break();
        }
Example #7
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            var scale = new Vector2(2 / 3f);

            sprite_batch.Draw(ContentHolder.Get(AvailableTextures.splash), Vector2.Zero, null, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
        }
Example #8
0
        public void Given_Create_When_DataIsProvided_Then_ShouldCreateEntity()
        {
            // act
            var result = ContentHolder.Create(name, holderEmail, originId);

            // assert
            Assert.NotNull(result);
        }
Example #9
0
    public void Initialize(uint price, CatalogItem item)
    {
        Button newButton   = Instantiate(itemButton);
        
        transformItemImage = newButton.GetComponentInChildren<Transform>().Find("ItemImage");
        itemImage          = transformItemImage.GetComponent<Image>();
        priceText          = newButton.GetComponentInChildren<Text>();
        holder             = newButton.GetComponent<ContentHolder>();        

        holder.catalogItem = item;
        holder.itemClass   = item.ItemClass;
        priceText.text     = price.ToString();

        if (item.ItemClass == "Skin")
        {
            itemImage.sprite = SkinImageList[indexSkinSprite];
            holder.skin = PlayFabGameBridge.Instance.skins[item.ItemId];

            if (!PlayFabGameBridge.Instance.boughtSkins.ContainsKey(holder.catalogItem.ItemId))
            {
                itemImage.color = new Color(0.1f, 0.1f, 0.1f, 1f); 
                holder.skin.isBought = false;
            }
            else
            {
                itemImage.color = Color.white;
                holder.skin.isBought = true;
            }
                
            newButton.transform.SetParent(skinContentPanel.transform);
            indexSkinSprite++;

        }

        if (item.ItemClass == "Missile")
        {
            itemImage.sprite = MissileImageList[indexMissileSprite];
            holder.missile = PlayFabGameBridge.Instance.missiles[item.ItemId];

            if (!PlayFabGameBridge.Instance.boughtMissiles.ContainsKey(holder.catalogItem.ItemId))
            {
				itemImage.color = new Color(0.1f, 0.1f, 0.1f, 1f); 
				holder.missile.isBought = false;
            }
            else
            {
                itemImage.color = Color.white;
                holder.missile.isBought = true;
            }
                                 
            newButton.transform.SetParent(missileContentPanel.transform);
            indexMissileSprite++;

        }

        itemImages.Add(item.ItemId, itemImage);
        itemContentHolders.Add(item.ItemId, holder);
    }
Example #10
0
            internal SnakeTail()
            {
                var texture = ContentHolder.Get(Settings.CurrentSnake);
                var region  = new Region(texture, 0, 0, Snake.Size, Snake.Size, Snake.Size / 2, Snake.Size / 2);
                var sprite  = new Sprite(region);

                this.AddSprite("main", sprite);
                this.AddColliderRectangle("main", -Snake.Size / 2, -Snake.Size / 2, Snake.Size, Snake.Size);
            }
Example #11
0
        public void Create(string[] param, ContentHolder TCH, List <string> TilePlanRows)
        {
            // param of 0 is used for sorting earlier
            Width     = Convert.ToInt32(param[1]);
            Height    = Convert.ToInt32(param[2]);
            TilesWide = Convert.ToInt32(param[3]);
            TilesHigh = Convert.ToInt32(param[4]);
            TilePlan  = new int[TilesWide, TilesHigh];
            TileMap   = TCH.GetTexture(param[5]);
            int h = 0;

            foreach (string Row in TilePlanRows)
            {
                string[] temp = FileServices.LineCommaSplit(Row);
                int      k    = 0;
                foreach (string Tile in temp)
                {
                    TilePlan[k, h] = Convert.ToInt32(Tile);
                    k += 1;
                }
                h += 1;
            }


            Objects           = new List <Object>();
            SourceRect        = new Rectangle();
            SourceRect.Width  = Width / TilesWide;
            SourceRect.Height = Height / TilesHigh;
            if (Width % 100 == 0)
            {
                XZones = Width / 100;
            }
            else
            {
                XZones = (Width / 100) + 1;
            }
            if (Height % 100 == 0)
            {
                YZones = Height / 100;
            }
            else
            {
                YZones = (Height / 100) + 1;
            }
            Zones       = new List <Enemy> [XZones, YZones];
            ObjectZones = new List <Object> [XZones, YZones];

            for (int i = 0; i < XZones; i++)
            {
                for (int j = 0; j < YZones; j++)
                {
                    Zones[i, j]       = new List <Enemy>();
                    ObjectZones[i, j] = new List <Object>();
                }
            }
        }
Example #12
0
    public void Initialize(uint price, CatalogItem item)
    {
        Button newButton = Instantiate(itemButton);

        transformItemImage = newButton.GetComponentInChildren <Transform>().Find("ItemImage");
        itemImage          = transformItemImage.GetComponent <Image>();
        priceText          = newButton.GetComponentInChildren <Text>();
        holder             = newButton.GetComponent <ContentHolder>();

        holder.catalogItem = item;
        holder.itemClass   = item.ItemClass;
        priceText.text     = price.ToString();

        if (item.ItemClass == "Skin")
        {
            itemImage.sprite = SkinImageList[indexSkinSprite];
            holder.skin      = PlayFabGameBridge.Instance.skins[item.ItemId];

            if (!PlayFabGameBridge.Instance.boughtSkins.ContainsKey(holder.catalogItem.ItemId))
            {
                itemImage.color      = new Color(0.1f, 0.1f, 0.1f, 1f);
                holder.skin.isBought = false;
            }
            else
            {
                itemImage.color      = Color.white;
                holder.skin.isBought = true;
            }

            newButton.transform.SetParent(skinContentPanel.transform);
            indexSkinSprite++;
        }

        if (item.ItemClass == "Missile")
        {
            itemImage.sprite = MissileImageList[indexMissileSprite];
            holder.missile   = PlayFabGameBridge.Instance.missiles[item.ItemId];

            if (!PlayFabGameBridge.Instance.boughtMissiles.ContainsKey(holder.catalogItem.ItemId))
            {
                itemImage.color         = new Color(0.1f, 0.1f, 0.1f, 1f);
                holder.missile.isBought = false;
            }
            else
            {
                itemImage.color         = Color.white;
                holder.missile.isBought = true;
            }

            newButton.transform.SetParent(missileContentPanel.transform);
            indexMissileSprite++;
        }

        itemImages.Add(item.ItemId, itemImage);
        itemContentHolders.Add(item.ItemId, holder);
    }
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ContentHolder.Init(this);
            Room r;

            r = new Room_Main();
            r.Initialize();
            RoomManager.ChangeRoom <Room_Main>();
        }
Example #14
0
        public Food(int x, int y)
        {
            this.Position = new Vector2(x, y);
            var texture = ContentHolder.Get(Settings.CurrentFood);
            var region  = new Region(texture, 0, 0, Food.Size, Food.Size, Food.Size / 2, Food.Size / 2);
            var sprite  = new Sprite(region);

            this.AddSprite("main", sprite);
            this.AddColliderRectangle("main", -Food.Size / 2, -Food.Size / 2, Food.Size, Food.Size);
        }
Example #15
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            // Set up variables for drawing selector
            float x           = this.Position.X;
            float y           = this.Position.Y;
            float width       = this.Size.X;
            float height      = this.Size.Y;
            var   texture     = ContentHolder.Get(Settings.CurrentSnake);
            var   scale       = new Vector2(0.3125f);
            float draw_width  = texture.Width * scale.X;
            float draw_height = texture.Height * scale.Y;

            // Draw vertical selector parts
            float draw_start_y = y - draw_height;
            float draw_y       = draw_start_y;
            float total_height = draw_start_y + height + draw_height * 2;

            while (draw_y < total_height)
            {
                Rectangle?source_rectangle = null;
                if (draw_y + draw_height > total_height)
                {
                    float remaining_space = total_height - draw_y;
                    float draw_percent    = remaining_space / draw_height;
                    source_rectangle = new Rectangle(0, 0, texture.Width, (int)(texture.Height * draw_percent));
                }

                sprite_batch.Draw(texture, new Vector2(x - draw_width, draw_y), source_rectangle, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 1);
                sprite_batch.Draw(texture, new Vector2(x + width, draw_y), source_rectangle, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 1);
                draw_y += draw_height;
            }

            // Draw horizontal selector parts
            float draw_start_x = x - draw_width;
            float draw_x       = draw_start_x;
            float total_width  = draw_start_x + width + draw_width * 2;

            while (draw_x < total_width)
            {
                Rectangle?source_rectangle = null;
                if (draw_x + draw_width > total_width)
                {
                    float remaining_space = total_width - draw_x;
                    float draw_percent    = remaining_space / draw_width;
                    source_rectangle = new Rectangle(0, 0, (int)(texture.Width * draw_percent), texture.Height);
                }

                sprite_batch.Draw(texture, new Vector2(draw_x, y - draw_height), source_rectangle, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 1);
                sprite_batch.Draw(texture, new Vector2(draw_x, y + height), source_rectangle, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 1);
                draw_x += draw_width;
            }
        }
Example #16
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            var texture = ContentHolder.Get(Settings.CurrentWall);

            foreach (var position in this.DrawPositions)
            {
                sprite_batch.Draw(texture, position, Color.White);
            }
        }
Example #17
0
        public MainMenu(ContentHolder content, int width, int height)
            : base(content, width, height)
        {
            Items.Add("New Game");      // itemselected = 0
            Items.Add("Leaderboards");  //itemselected = 1
            Items.Add("Options");       // itemselected = 2
            Items.Add("Credits");       // itemselected = 3
            Items.Add("Exit Game");     // itemselected = 4

            Active = true;
        }
Example #18
0
        public int offsetX; // NOT IN USE AT THE MOMENT

        #endregion Fields

        #region Constructors

        /************************************************************************/
        /* Constructor                                                          */
        /************************************************************************/
        public Options(ContentHolder content, int width, int height)
            : base(content, width, height)
        {
            Items = new List<string>();
            Items.Add("Fullscreen");    // ItemSelected 0
            Items.Add("Resolution");    // ItemSelected 1
            Items.Add("Back");          // ItemSelected 2

            OffsetX = 50;

            Active = false;
        }
 public override void onKeyDown(KeyboardEventArgs e)
 {
     base.onKeyDown(e);
     if (e.Key == Keys.Back || e.Key == Keys.Escape)
     {
         if (this.ShouldPlaySoundOnClick)
         {
             ContentHolder.Get(AvailableSounds.click).TryPlay();
         }
         this.OnClick?.Invoke();
     }
 }
Example #20
0
        private void initializeGameworld(ContentHolder contentHolder)
        {
            playerObject = new Player(contentHolder.texturePlayer, contentHolder.texturePlayerTurret, 100, 100, Vector2.Zero, 100, 100);

            // The following should (and will, eventually) be loaded by reading a file generated by an editor,
            //  so this is temp, testing etc

            rock[0] = new Collidable(contentHolder.textureRock01, 150, 300, Vector2.Zero);
            rock[1] = new Collidable(contentHolder.textureRock02, -250, -330, Vector2.Zero);
            rock[2] = new Collidable(contentHolder.textureRock01, 500, 300, Vector2.Zero);
            rock[3] = new Collidable(contentHolder.textureRock02, -100, 250, Vector2.Zero);
        }
Example #21
0
        public Leaderboards(ContentHolder content, int width, int height, Highscores hs)
            : base(content, width, height)
        {
            Items = new List<string>();
            scores = new List<string>();

            this.hs = hs;

            hst = new HighscoreTable();

            Active = false;
        }
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);
            int spread = (int)(22 * this.Scale);

            for (int i = 0; i < this.ButtonText.Length; i++)
            {
                string text   = this.ButtonText[i];
                var    offset = new Vector2(0, spread * (i == 0 ? -1 : 1));
                sprite_batch.DrawString(ContentHolder.Get(AvailableFonts.blippo), text, this.Position + offset, Color.White, 0, DrawFrom.Center, this.Scale, SpriteEffects.None, 0);
            }
        }
Example #23
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            var texture = ContentHolder.Get(Settings.CurrentSnake);

            for (int i = 0; i < TitleLogo.SnakeLogoLocations.Length; i++)
            {
                var pos = TitleLogo.SnakeLogoLocations[i];
                sprite_batch.Draw(texture, this.Position + pos, Color.White);
            }
        }
Example #24
0
        public void Given_AddContent_When_ContentIsProvidedAndEmailIsNotForCurrentContent_Then_ShouldReturnFailedResult()
        {
            // arrange
            var content       = Content.Create("test", new List <File>());
            var contentHolder = ContentHolder.Create(name, holderEmail, originId);
            // act

            var result = contentHolder.AddContent("noemail", content);

            // assert
            Assert.True(result.IsFailure);
        }
Example #25
0
        public void Given_AddContent_When_ContentIsProvidedAndEmailIsValid_Then_ShouldReturnOkResult()
        {
            // arrange
            var content       = Content.Create("test", new List <File>());
            var contentHolder = ContentHolder.Create(name, holderEmail, originId);
            // act

            var result = contentHolder.AddContent(holderEmail, content);

            // assert
            Assert.True(result.IsSuccess);
        }
Example #26
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            var texture = ContentHolder.Get(Settings.CurrentFood);
            var scale   = new Vector2(5 / (float)texture.Width);

            for (int i = 0; i < DeveloperLogo.DeveloperLogoLocations.Length; i++)
            {
                var pos = DeveloperLogo.DeveloperLogoLocations[i];
                sprite_batch.Draw(texture, this.Position + pos, null, Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
            }
        }
Example #27
0
        public Wall(int x, int y, float scale = 1)
        {
            this.Depth    = 1;
            this.Position = new Vector2(x, y);
            var texture = ContentHolder.Get(Settings.CurrentWall);
            var region  = new Region(texture, 0, 0, Wall.Size, Wall.Size, 0, 0);
            var sprite  = new Sprite(region)
            {
                Scale = new Vector2(scale)
            };

            this.AddSprite("main", sprite);
            this.AddColliderRectangle("main", 0, 0, (int)(Wall.Size * scale), (int)(Wall.Size * scale));
        }
Example #28
0
        public override void onDraw(SpriteBatch sprite_batch)
        {
            base.onDraw(sprite_batch);

            if (Engine.IsPaused())
            {
                var texture = ContentHolder.Get(Settings.CurrentFood);
                for (int i = 0; i < ControlPause.PausedLogoLocations.Length; i++)
                {
                    var pos = ControlPause.PausedLogoLocations[i];
                    sprite_batch.Draw(texture, pos, Color.White);
                }
            }
        }
Example #29
0
        public MenuHandler(ContentHolder content, int width, int height, Models.Highscores hs)
        {
            mainMenu = new Models.MainMenu(content, width, height);
            credits = new Models.Credits(content, width, height);
            options = new Models.Options(content, width, height);
            endMenu = new Models.EndMenu(content, width, height);
            leaderboards = new Models.Leaderboards(content, width, height, hs);

            sendScore = false;

            Active = true;

            exitGame = false;
        }
Example #30
0
    void Awake()
    {
        Transform t = GetComponentInChildren <Transform>().Find("ItemImage");

        itemImage = t.GetComponent <Image>();
        holder    = GetComponent <ContentHolder>();

        playerCharImage    = GameObject.Find("PlayerChar").GetComponent <Image>();
        playerMissileImage = GameObject.Find("PlayerMissile").GetComponent <Image>();

        buyMissileButton  = GameObject.Find("btnMissileBuy").GetComponent <Button>();
        buySkinButton     = GameObject.Find("btnSkinBuy").GetComponent <Button>();
        wearSkinButton    = GameObject.Find("btnSkinWear").GetComponent <Button>();
        wearMissileButton = GameObject.Find("btnMissileWear").GetComponent <Button>();
        lightGray         = new Color(0.78f, 0.78f, 0.78f, 0.5f);
    }
Example #31
0
        public Scoreboard()
        {
            this.Depth    = -100;
            this.Position = new Vector2(Engine.Game.CanvasWidth / 2 - Scoreboard.Width / 2, 30 + 30 + 20);

            this.BackgroundRegion = new Region(ContentHolder.Get(Settings.CurrentBackground), (int)this.Position.X, (int)this.Position.Y, Scoreboard.Width, Scoreboard.Height, 0, 0);
            this.SnakeRegion      = new Region(ContentHolder.Get(Settings.CurrentSnake));

            string data    = SaveDataHandler.LoadData(Settings.CurrentSaveFilePath);
            bool   success = (data != null && int.TryParse(data, out this.HighScore));

            if (!success)
            {
                this.SaveHighscore();
            }
        }
    void Awake()
    {
        Transform t        = GetComponentInChildren<Transform>().Find("ItemImage");

        itemImage          = t.GetComponent<Image>();
        holder             = GetComponent<ContentHolder>();

        playerCharImage    = GameObject.Find("PlayerChar").GetComponent<Image>();
        playerMissileImage = GameObject.Find("PlayerMissile").GetComponent<Image>();        

        buyMissileButton   = GameObject.Find("btnMissileBuy").GetComponent<Button>();
        buySkinButton      = GameObject.Find("btnSkinBuy").GetComponent<Button>();
        wearSkinButton     = GameObject.Find("btnSkinWear").GetComponent<Button>();
		wearMissileButton  = GameObject.Find("btnMissileWear").GetComponent<Button>();
		lightGray = new Color(0.78f, 0.78f, 0.78f, 0.5f);
	}
Example #33
0
        public void AddObject(string[] param, ContentHolder TCH)
        {
            Object TempObject = new Object();

            TempObject.Create(param, TCH);
            Objects.Add(TempObject);
            for (int i = (int)(TempObject.Position.X) / 100; i <= (int)(TempObject.Position.X + TempObject.Picture.Width) / 100; i++)
            {
                for (int j = (int)(TempObject.Position.Y) / 100; j <= (int)(TempObject.Position.Y + TempObject.Picture.Height) / 100; j++)
                {
                    if (!ObjectZones[i, j].Contains(TempObject))
                    {
                        ObjectZones[i, j].Add(TempObject);
                    }
                }
            }
        }
Example #34
0
        // CONSTRUCTOR
        public Menu(ContentHolder content, int width, int height)
        {
            ScreenWidth = width;
            ScreenHeight = height;

            Items = new List<string>();

            Active = false;

            Title = content.title;
            TitlePadding = 150;
            TitlePosition = new Vector2((ScreenWidth / 2 - Title.Width / 2), TitlePadding - (Title.Height / 2));

            ItemFont = content.menuFont;

            SpaceBetweenItems = 50;
        }
Example #35
0
        /************************************************************************/
        /* Constructor                                                          */
        /************************************************************************/
        public Credits(ContentHolder content, int width, int height)
            : base(content, width, height)
        {
            Items.Add("Everything");
            Items.Add("Inge Dalby");
            Items.Add("Simen Løkken");
            Items.Add("Snorre Brecheisen");
            Items.Add("Thomas Nilsen");

            HeaderFont = content.creditsHeaderFont;
            CreditsFont = content.creditsFont;
            Active = false;
            Position = new Vector2[5];
            Alpha = new float[5];
            setPositions();
            setAlphas();
        }
Example #36
0
        private void Init()
        {
            container.Anchor = AnchorType.TopLeft;
            container.Pivot  = PivotType.TopLeft;
            container.X      = 16f;
            container.Y      = -16f;

            content = container.CreateChild <ContentHolder>("content", 0);
            {
                content.Anchor   = AnchorType.TopLeft;
                content.Pivot    = PivotType.TopLeft;
                content.Position = Vector2.zero;
                content.Width    = 320f;

                glowSprite.SetParent(content);
                glowSprite.Offset = new Offset(-15f);
            }
        }
Example #37
0
        public EndMenu(ContentHolder content, int width, int height)
            : base(content, width, height)
        {
            arrowUp = content.arrow_up;
            arrowDown = content.arrow_down;

            abcPosition = new int[3];

            abcPosition[0] = 0;
            abcPosition[1] = 0;
            abcPosition[2] = 0;

            sendScore = false;

            populateAbcArrays();

            Active = false;
        }
        private void Init()
        {
            settingsData = new SettingsData();
            settingsData.AddTabData(CreateTabData("A", "icon-settings"));
            settingsData.AddTabData(CreateTabData("B", "icon-play"));
            settingsData.AddTabData(CreateTabData("C", "icon-music"));

            var bg = RootMain.CreateChild <UguiSprite>("bg", -1);

            {
                bg.Size  = new Vector2(600f, 600f);
                bg.Alpha = 0.25f;
            }
            contentHolder = RootMain.CreateChild <ContentHolder>();
            {
                contentHolder.Size = new Vector2(500f, 500f);
                contentHolder.SetSettingsData(settingsData);
            }
        }
        public override void onDraw(SpriteBatch sprite_batch)
        {
            var font = ContentHolder.Get(AvailableFonts.blippo);

            base.onDraw(sprite_batch);
            int spread = (int)(22 * this.Scale);

            for (int i = 0; i < this.ButtonText.Length; i++)
            {
                string text       = this.ButtonText[i];
                float  line_scale = 1.0f;
                var    text_size  = font.MeasureString(text);
                if (text_size.X > ButtonRokuIP.MaxFontWidth)
                {
                    line_scale = ButtonRokuIP.MaxFontWidth / text_size.X;
                }
                var offset = new Vector2(0, spread * (i == 0 ? -1 : 1));
                sprite_batch.DrawString(font, text, this.Position + offset, Color.White, 0, DrawFrom.Center, this.Scale * line_scale, SpriteEffects.None, 0);
            }
        }
Example #40
0
        /// <summary>
        /// Gets the IContentReaders for the current path(s)
        /// </summary>
        /// 
        /// <returns>
        /// An array of IContentReaders for the current path(s)
        /// </returns>
        /// 
        internal List<ContentHolder> GetContentReaders(
            string[] readerPaths,
            CmdletProviderContext currentCommandContext)
        {
            // Resolve all the paths into PathInfo objects

            Collection<PathInfo> pathInfos = ResolvePaths(readerPaths, false, true, currentCommandContext);

            // Create the results array

            List<ContentHolder> results = new List<ContentHolder>();

            foreach (PathInfo pathInfo in pathInfos)
            {
                // For each path, get the content writer

                Collection<IContentReader> readers = null;

                try
                {
                    string pathToProcess = WildcardPattern.Escape(pathInfo.Path);

                    if (currentCommandContext.SuppressWildcardExpansion)
                    {
                        pathToProcess = pathInfo.Path;
                    }

                    readers =
                        InvokeProvider.Content.GetReader(pathToProcess, currentCommandContext);
                }
                catch (PSNotSupportedException notSupported)
                {
                    WriteError(
                        new ErrorRecord(
                            notSupported.ErrorRecord,
                            notSupported));
                    continue;
                }
                catch (DriveNotFoundException driveNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            driveNotFound.ErrorRecord,
                            driveNotFound));
                    continue;
                }
                catch (ProviderNotFoundException providerNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            providerNotFound.ErrorRecord,
                            providerNotFound));
                    continue;
                }
                catch (ItemNotFoundException pathNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            pathNotFound.ErrorRecord,
                            pathNotFound));
                    continue;
                }

                if (readers != null && readers.Count > 0)
                {
                    if (readers.Count == 1 && readers[0] != null)
                    {
                        ContentHolder holder =
                            new ContentHolder(pathInfo, readers[0], null);

                        results.Add(holder);
                    }
                }
            } // foreach pathInfo in pathInfos

            return results;
        } // GetContentReaders
Example #41
0
        } // ProcessRecord

        /// <summary>
        /// Scan forwards to get the tail content
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="currentContext"></param>
        /// <returns>
        /// true if no error occured
        /// false if there was an error
        /// </returns>
        private bool ScanForwardsForTail(ContentHolder holder, CmdletProviderContext currentContext)
        {
            var fsReader = holder.Reader as FileSystemContentReaderWriter;
            Dbg.Diagnostics.Assert(fsReader != null, "Tail is only supported for FileSystemContentReaderWriter");
            var tailResultQueue = new Queue<object>();
            IList results = null;
            ErrorRecord error = null;

            do
            {
                try
                {
                    results = fsReader.ReadWithoutWaitingChanges(ReadCount);
                }
                catch (Exception e)
                {
                    CommandsCommon.CheckForSevereException(this, e);
                    ProviderInvocationException providerException =
                        new ProviderInvocationException(
                            "ProviderContentReadError",
                            SessionStateStrings.ProviderContentReadError,
                            holder.PathInfo.Provider,
                            holder.PathInfo.Path,
                            e);

                    // Log a provider health event
                    MshLog.LogProviderHealthEvent(
                        this.Context,
                        holder.PathInfo.Provider.Name,
                        providerException,
                        Severity.Warning);

                    // Create and save the error record. The error record
                    // will be written outside the while loop.
                    // This is to make sure the accumulated results get written
                    // out before the error record when the 'scanForwardForTail' is true.
                    error = new ErrorRecord(
                        providerException.ErrorRecord,
                        providerException);

                    break;
                }

                if (results != null && results.Count > 0)
                {
                    foreach (object entry in results)
                    {
                        if (tailResultQueue.Count == Tail)
                            tailResultQueue.Dequeue();
                        tailResultQueue.Enqueue(entry);
                    }
                }
            } while (results != null && results.Count > 0);

            if (tailResultQueue.Count > 0)
            {
                // Respect the ReadCount parameter.
                // Output single object when ReadCount == 1; Output array otherwise
                int count = 0;
                if (ReadCount <= 0 || (ReadCount >= tailResultQueue.Count && ReadCount != 1))
                {
                    count = tailResultQueue.Count;
                    ArrayList outputList = new ArrayList();
                    while (tailResultQueue.Count > 0)
                    {
                        outputList.Add(tailResultQueue.Dequeue());
                    }
                    // Write out the content as an array of objects
                    WriteContentObject(outputList.ToArray(), count, holder.PathInfo, currentContext);
                }
                else if (ReadCount == 1)
                {
                    // Write out the content as single object
                    while (tailResultQueue.Count > 0)
                        WriteContentObject(tailResultQueue.Dequeue(), count++, holder.PathInfo, currentContext);
                }
                else // ReadCount < Queue.Count
                {
                    while (tailResultQueue.Count >= ReadCount)
                    {
                        ArrayList outputList = new ArrayList();
                        for (int idx = 0; idx < ReadCount; idx++, count++)
                            outputList.Add(tailResultQueue.Dequeue());
                        // Write out the content as an array of objects
                        WriteContentObject(outputList.ToArray(), count, holder.PathInfo, currentContext);
                    }

                    int remainder = tailResultQueue.Count;
                    if (remainder > 0)
                    {
                        ArrayList outputList = new ArrayList();
                        for (; remainder > 0; remainder--, count++)
                            outputList.Add(tailResultQueue.Dequeue());
                        // Write out the content as an array of objects
                        WriteContentObject(outputList.ToArray(), count, holder.PathInfo, currentContext);
                    }
                }
            }

            if (error != null)
            {
                WriteError(error);
                return false;
            }

            return true;
        }
Example #42
0
 public SoundManager(ContentHolder soundContent)
 {
     this.soundContent = soundContent;
 }
Example #43
0
        /// <summary>
        /// Gets the IContentWriters for the current path(s)
        /// </summary>
        /// 
        /// <returns>
        /// An array of IContentWriters for the current path(s)
        /// </returns>
        /// 
        internal List<ContentHolder> GetContentWriters(
            string[] writerPaths,
            CmdletProviderContext currentCommandContext)
        {
            // Resolve all the paths into PathInfo objects

            Collection<PathInfo> pathInfos = ResolvePaths(writerPaths, true, false, currentCommandContext);

            // Create the results array

            List<ContentHolder> results = new List<ContentHolder>();

            foreach (PathInfo pathInfo in pathInfos)
            {
                // For each path, get the content writer

                Collection<IContentWriter> writers = null;

                try
                {
                    writers =
                        InvokeProvider.Content.GetWriter(
                            pathInfo.Path,
                            currentCommandContext);
                }
                catch (PSNotSupportedException notSupported)
                {
                    WriteError(
                        new ErrorRecord(
                            notSupported.ErrorRecord,
                            notSupported));
                    continue;
                }
                catch (DriveNotFoundException driveNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            driveNotFound.ErrorRecord,
                            driveNotFound));
                    continue;
                }
                catch (ProviderNotFoundException providerNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            providerNotFound.ErrorRecord,
                            providerNotFound));
                    continue;
                }
                catch (ItemNotFoundException pathNotFound)
                {
                    WriteError(
                        new ErrorRecord(
                            pathNotFound.ErrorRecord,
                            pathNotFound));
                    continue;
                }

                if (writers != null && writers.Count > 0)
                {
                    if (writers.Count == 1 && writers[0] != null)
                    {
                        ContentHolder holder =
                            new ContentHolder(pathInfo, null, writers[0]);

                        results.Add(holder);
                    }
                }
            } // foreach pathInfo in pathInfos

            return results;
        } // GetContentWriters