예제 #1
0
        /// <summary>
        /// draws the registered sprite objects by using the sprite batch.
        /// </summary>
        /// <param name="renderTracer"></param>
        protected override void OnDraw(RenderTracer renderTracer)
        {
            if (TextureResource == null)
            {
                throw new InvalidOperationException("The texture is empty");
            }
            else if (TextureResource.IsDisposed)
            {
                throw new ObjectDisposedException("TextureResource");
            }

            for (int i = 0; i < spriteList.Count; i++)
            {
                Sprite2DObject sprite = spriteList[i];

                if (sprite != null)
                {
                    //  If active visible
                    if (sprite.Visible)
                    {
                        renderTracer.SpriteBatch.Draw(TextureResource,
                                                      sprite.ScreenRectangle, sprite.SourceRectangle,
                                                      sprite.Color);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// initializes this screen. 
        /// play a BGM sound.
        /// </summary>
        public override void InitializeScreen()
        {            
            this.activeElapsedTime = TimeSpan.Zero;

            //  creates a 2D layer.
            FrameworkCore.RenderContext.CreateScene2DLayer(1);
            this.refScene2DRoot = FrameworkCore.Scene2DLayers[0];
            
            this.refScene2DRoot.AddChild(this.spriteMain);
            spriteObjMain = this.spriteMain.AddSprite(0, "MainTitle");
            
            this.refScene2DRoot.AddChild(this.spriteButton);

            //  Initialize start button
            spriteObjStartButton = this.spriteButton.AddSprite(0, "Start Button");
            AddMenuEntry(spriteObjStartButton); //  Entry a start button

            //  Initialize versus button
            spriteObjVersusButton = this.spriteButton.AddSprite(1, "Versus Button");
            AddMenuEntry(spriteObjVersusButton);//  Entry a versus button

            //  Initialize exit button
            spriteObjExitButton = this.spriteButton.AddSprite(2, "Exit Button");
            AddMenuEntry(spriteObjExitButton);  //  Entry a exit button

            //  calculates all image size.
            OnSize();

            //  play the title music.
            GameSound.Play(SoundTrack.MainTitle);

            //  play an open menu sound.
            GameSound.Play(SoundTrack.MenuOpen);
        }
예제 #3
0
        /// <summary>
        /// initializes this screen. 
        /// </summary>
        public override void InitializeScreen()
        {
            //  creates a 2D layer.
            FrameworkCore.RenderContext.CreateScene2DLayer(1);
            this.refScene2DRoot = FrameworkCore.Scene2DLayers[0];

            this.refScene2DRoot.AddChild(this.spriteBG);
            this.refScene2DRoot.AddChild(this.spriteLoadingText);

            //  loading image.
            {
                loadingSprite = this.spriteBG.AddSprite(0, "Loading screen");

                //  Matching logo image size with screen size.
                loadingSprite.ScreenSize = new Vector2(FrameworkCore.ViewWidth,
                                                       FrameworkCore.ViewHeight);

                float aspect = (float)FrameworkCore.ViewWidth /
                               (float)FrameworkCore.ViewHeight;

                if (1.6f > aspect) // no wide screen
                {
                    int recalcWidth = (int)(aspect / 1.6f *
                                            this.spriteBG.TextureResource.Width);

                    loadingSprite.SourceRectangle = new Rectangle(
                        ((this.spriteBG.TextureResource.Width - recalcWidth) / 2) - 140,
                        0,
                        recalcWidth,
                        this.spriteBG.TextureResource.Height);
                }
            }

            //  loading text.
            {
                spriteObjNowLoading = 
                        this.spriteLoadingText.AddSprite(0, "Loading text");

                spriteObjNowLoading.SourceRectangle = new Rectangle(362, 64, 333, 57);
                spriteObjNowLoading.Visible = true;

                spriteObjPressToContinue = 
                        this.spriteLoadingText.AddSprite(1, "Press A to Continue");

                spriteObjPressToContinue.SourceRectangle = 
                    new Rectangle(170, 139, 653, 76);
                spriteObjPressToContinue.Visible = false;
            }

            //  Calculate all image size
            OnSize();
        }
예제 #4
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="name">sprite object name</param>
        /// <returns></returns>
        public Sprite2DObject AddSprite(int index, string name)
        {
            if (TextureResource == null)
            {
                throw new InvalidOperationException("The texture is empty");
            }

            Sprite2DObject newSprite = new Sprite2DObject(name, TextureResource);

            AddSprite(index, newSprite);

            return(newSprite);
        }
예제 #5
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="name">sprite object name</param>
        /// <param name="screenPosition">
        /// 2D screen position of sprite object (pixel)
        /// </param>
        /// <param name="screenSize">2D screen size of sprite object (pixel)</param>
        /// <param name="sourcePosition">position of the source image (pixel)</param>
        /// <param name="sourceSize">size of the source image (pixel)</param>
        /// <returns></returns>
        public Sprite2DObject AddSprite(int index, string name,
                                        Vector2 screenPosition, Vector2 screenSize,
                                        Vector2 sourcePosition, Vector2 sourceSize)
        {
            if (TextureResource == null)
            {
                throw new InvalidOperationException("The texture is empty");
            }

            Sprite2DObject newSprite = new Sprite2DObject(name,
                                                          screenPosition, screenSize,
                                                          sourcePosition, sourceSize);

            AddSprite(index, newSprite);

            return(newSprite);
        }
예제 #6
0
        /// <summary>
        /// swaps two sprite objects and changes the priority and the
        /// position in the list.
        /// </summary>
        /// <param name="tex1"></param>
        /// <param name="tex2"></param>
        public void SwapSprite(Sprite2DObject tex1, Sprite2DObject tex2)
        {
            int index1 = FindSpriteIndex(tex1);

            //  Cannot find sprite
            if (index1 < 0)
            {
                throw new ArgumentException("Cannot find tex1");
            }

            int index2 = FindSpriteIndex(tex2);

            //  Cannot find sprite
            if (index2 < 0)
            {
                throw new ArgumentException("Cannot find tex2");
            }

            spriteList[index1] = tex2;
            spriteList[index2] = tex1;
        }
예제 #7
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="spriteObject">source sprite object</param>
        public void AddSprite(int index, Sprite2DObject spriteObject)
        {
            if (TextureResource == null)
            {
                throw new InvalidOperationException("The texture is empty");
            }

            if (spriteList.Count <= index || index < 0)
            {
                throw new ArgumentException(
                          "Cannot add sprite. Invalid index : " + index.ToString());
            }

            if (spriteList[index] != null)
            {
                throw new ArgumentException(
                          "Cannot add sprite. already exist other sprite : " +
                          index.ToString());
            }

            spriteList[index] = spriteObject;
        }
예제 #8
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="spriteObject">source sprite object</param>
        public void AddSprite(int index, Sprite2DObject spriteObject)
        {
            if (TextureResource == null)
                throw new InvalidOperationException("The texture is empty");

            if (spriteList.Count <= index || index < 0)
                throw new ArgumentException(
                    "Cannot add sprite. Invalid index : " + index.ToString());
            
            if( spriteList[index] != null)
                throw new ArgumentException(
                    "Cannot add sprite. already exist other sprite : " +
                    index.ToString());

            spriteList[index] = spriteObject;
        }
예제 #9
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="name">sprite object name</param>
        /// <param name="screenRectangle">a rectangle of sprite object (pixel)</param>
        /// <param name="sourceRectangle">a rectangle of the source image (pixel)</param>
        /// <returns></returns>
        public Sprite2DObject AddSprite(int index, string name, 
                                        Rectangle screenRectangle, 
                                        Rectangle sourceRectangle)
        {
            if (TextureResource == null)
                throw new InvalidOperationException("The texture is empty");

            Sprite2DObject newSprite = 
                new Sprite2DObject(name, screenRectangle, sourceRectangle);

            AddSprite(index, newSprite);

            return newSprite;
        }
예제 #10
0
        /// <summary>
        /// add a sprite object.
        /// </summary>
        /// <param name="index">an index of sprite object</param>
        /// <param name="name">sprite object name</param>
        /// <param name="screenPosition">
        /// 2D screen position of sprite object (pixel)
        /// </param>
        /// <param name="screenSize">2D screen size of sprite object (pixel)</param>
        /// <param name="sourcePosition">position of the source image (pixel)</param>
        /// <param name="sourceSize">size of the source image (pixel)</param>
        /// <returns></returns>
        public Sprite2DObject AddSprite(int index, string name, 
                                        Vector2 screenPosition, Vector2 screenSize, 
                                        Vector2 sourcePosition, Vector2 sourceSize)
        {
            if (TextureResource == null)
                throw new InvalidOperationException("The texture is empty");

            Sprite2DObject newSprite = new Sprite2DObject(name,
                                                          screenPosition, screenSize, 
                                                          sourcePosition, sourceSize);

            AddSprite(index, newSprite);

            return newSprite;
        }
예제 #11
0
        /// <summary>
        /// loads graphics contents.  This uses the shared ContentManager
        /// provided by the ScreenManager, so the content will remain loaded forever.
        /// Whenever a subsequent MessageBoxScreen tries to load this same content,
        /// it will just get back another reference to the already loaded instance.
        /// </summary>
        public override void LoadContent()
        {
            spriteBox = new GameSprite2D();
            spriteBox.Create(1, "Textures/Text_Window");

            refScene2DTopRoot.AddChild(spriteBox);
            spriteObjBox = spriteBox.AddSprite(0, "MessageBox frame");


            textMessageItem = 
                new TextItem(messageFont, message, 0, 0, new Color(136, 217, 224));
            FrameworkCore.TextManager.AddText(textMessageItem);

            textControlsItem = 
                new TextItem(messageFont, controls, 0, 0,Color.White);
            FrameworkCore.TextManager.AddText(textControlsItem);

            //  Resizing all images
            OnSize();
        }
예제 #12
0
 public void RemoveMenuEntry(Sprite2DObject item)
 {
     MenuEntries.Remove(item);
 }
예제 #13
0
 /// <summary>
 /// finds an index of sprite object by object
 /// </summary>
 /// <param name="sprite"></param>
 /// <returns></returns>
 public int FindSpriteIndex(Sprite2DObject sprite)
 {
     return(spriteList.IndexOf(sprite));
 }
예제 #14
0
        /// <summary>
        /// creates the Hud image which is communally used in a stage and 
        /// configures the Hud information.
        /// </summary>
        public virtual void CreateHud()
        {
            int viewCount = FrameworkCore.CurrentCamera.Count;

            //  Hud Aiming
            {
                int spriteCount = 0;

                this.spriteHudAiming = new GameSprite2D();
                this.spriteHudAiming.Create(2 * viewCount, "Textures/Hud_Aiming");

                this.refSceneHudRoot.AddChild(this.spriteHudAiming);

                spriteObjHudAimingSite = new Sprite2DObject[viewCount];
                spriteObjHudAlertSite = new Sprite2DObject[viewCount];

                for (int i = 0; i < viewCount; i++)
                {
                    //  Aiming Site
                    this.spriteObjHudAimingSite[i] =
                    this.spriteHudAiming.AddSprite(spriteCount++, "Firing site");

                    //  Alert Site
                    this.spriteObjHudAlertSite[i] =
                        this.spriteHudAiming.AddSprite(spriteCount++, "Alert site");

                    this.spriteObjHudAlertSite[i].Visible = false;
                }
            }

            // Hud State (Armor and ammo)
            {
                int spriteCount = 0;

                this.spriteHudState = new GameSprite2D();
                this.spriteHudState.Create(8 * viewCount, "Textures/Hud1");

                this.refSceneHudRoot.AddChild(this.spriteHudState);

                Color textColor = new Color(136, 217, 224);

                this.spriteObjHudArmorFrame = new Sprite2DObject[viewCount];
                this.spriteObjHudArmorState = new Sprite2DObject[viewCount];
                this.spriteObjHudWeaponWindow = new Sprite2DObject[viewCount];
                this.spriteObjHudBoosterCoolTime = new Sprite2DObject[viewCount];
                this.spriteObjHudPickupCoolTime = new Sprite2DObject[viewCount];
                this.spriteObjHudWeaponMachineGun = new Sprite2DObject[viewCount];
                this.spriteObjHudWeaponShotgun = new Sprite2DObject[viewCount];
                this.spriteObjHudWeaponHandgun = new Sprite2DObject[viewCount];
                this.textHudCurrentAmmo = new GameText[viewCount];
                this.textHudRemainAmmo = new GameText[viewCount];
                this.textPickup = new GameText[viewCount];
                this.textControlHelper = new GameText[viewCount, 2];

                for (int i = 0; i < viewCount; i++)
                {
                    //  Armor frame   
                    this.spriteObjHudArmorFrame[i] =
                            this.spriteHudState.AddSprite(spriteCount++, "Armor Frame");

                    //  Armor state bar
                    this.spriteObjHudArmorState[i] =
                            this.spriteHudState.AddSprite(spriteCount++, "Armor State");

                    //  Weapon window
                    this.spriteObjHudWeaponWindow[i] =
                            this.spriteHudState.AddSprite(spriteCount++, "Weapon Ammo");

                    //  Booster Cool Time
                    this.spriteObjHudBoosterCoolTime[i] =
                        this.spriteHudState.AddSprite(spriteCount++,
                        "Booster Cool Time");

                    //  Display message for pickup items
                    this.textPickup[i] = new GameText(this.fontHud,
                                                string.Format("Text pick up {0}", i),
                                                0, 0, hudPickupColor);

                    this.textPickup[i].Visible = false;

                    this.refSceneHudRoot.AddChild(this.textPickup[i]);

                    //  Pickup cool time bar
                    this.spriteObjHudPickupCoolTime[i] = this.spriteHudState.AddSprite(
                                            spriteCount++, "Pickup Cool Time Bar");

                    this.spriteObjHudPickupCoolTime[i].Color = new Color(200, 200, 255);
                    this.spriteObjHudPickupCoolTime[i].Visible = false;

                    //  MachineGun Image
                    this.spriteObjHudWeaponMachineGun[i] =
                        this.spriteHudState.AddSprite(spriteCount++,
                        "MachineGun Image");

                    this.spriteObjHudWeaponMachineGun[i].Visible = false;

                    //  Shotgun Image
                    this.spriteObjHudWeaponShotgun[i] =
                            this.spriteHudState.AddSprite(spriteCount++,
                            "Shotgun Image");

                    this.spriteObjHudWeaponShotgun[i].Visible = false;

                    //  Handgun Image
                    this.spriteObjHudWeaponHandgun[i] =
                            this.spriteHudState.AddSprite(spriteCount++,
                            "Handgun Image");

                    this.spriteObjHudWeaponHandgun[i].Visible = false;

                    // Weapon Infomation 
                    this.textHudCurrentAmmo[i] =
                                new GameText(this.fontHud, "0", 0, 0, textColor);

                    this.refSceneHudRoot.AddChild(this.textHudCurrentAmmo[i]);

                    this.textHudRemainAmmo[i] =
                                new GameText(this.fontHud, "0", 0, 0, textColor);

                    this.refSceneHudRoot.AddChild(this.textHudRemainAmmo[i]);

                    //  Control helper on screen
                    for (int column = 0; column < 2; column++)
                    {
                        this.textControlHelper[i, column] = new GameText(
                                                this.fontHud,
                                                String.Empty,
                                                0, 0,
                                                Color.White);

                        this.refSceneHudRoot.AddChild(this.textControlHelper[i, column]);
                    }
                }

                SetVisibleHud(true);
            }

            //  Mission Result
            {
                this.spriteMission = new GameSprite2D();
                this.spriteMission.Create(2, "Textures/Mission");

                this.refSceneMissionRoot.AddChild(this.spriteMission);

                //  Mission Complete
                this.spriteObjMissionClear =
                                    this.spriteMission.AddSprite(0, "Mission Complete");

                this.spriteObjMissionClear.Visible = false;


                //  Mission Failed
                this.spriteObjMissionFailed =
                                    this.spriteMission.AddSprite(1, "Mission Failed");

                this.spriteObjMissionFailed.Visible = false;
            }

            //  Calculate all image size
            OnSize();
        }
예제 #15
0
 /// <summary>
 /// finds an index of sprite object by object
 /// </summary>
 /// <param name="sprite"></param>
 /// <returns></returns>
 public int FindSpriteIndex(Sprite2DObject sprite)
 {
     return spriteList.IndexOf(sprite);
 }
예제 #16
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {            
            // Load content belonging to the screen manager.
            fadeSprite.Create(1, "blank");

            fadeObject = fadeSprite.AddSprite(0, "Screen fade");
            
            fadeObject.ScreenSize = 
                    new Vector2(FrameworkCore.ViewWidth, FrameworkCore.ViewHeight);

            fadeObject.Visible = false;

            // Tell each of the screens to load their content.
            foreach (GameScreen screen in screens)
            {
                screen.LoadContent();
            }
        }
예제 #17
0
        /// <summary>
        /// swaps two sprite objects and changes the priority and the 
        /// position in the list.
        /// </summary>
        /// <param name="tex1"></param>
        /// <param name="tex2"></param>
        public void SwapSprite(Sprite2DObject tex1, Sprite2DObject tex2)
        {
            int index1 = FindSpriteIndex(tex1);

            //  Cannot find sprite
            if( index1 < 0)
                throw new ArgumentException("Cannot find tex1");

            int index2 = FindSpriteIndex(tex2);

            //  Cannot find sprite
            if (index2 < 0)
                throw new ArgumentException("Cannot find tex2");

            spriteList[index1] = tex2;
            spriteList[index2] = tex1;
        }
예제 #18
0
 public void AddMenuEntry(Sprite2DObject item)
 {
     MenuEntries.Add(item);
 }