Example #1
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteSimple()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic sprite
        IDrawable drawable = DemoSprites.PixbufFactory.Create("blue-sphere");
        sprite = new DrawableSprite(drawable);
        sprite.X = 10;
        sprite.Y = 10;
        sprite.Width = sprite.Height = 64;
        sprites.Add(sprite);

        // Load the second sprite
        drawable = DemoSprites.PixbufFactory.Create("green-sphere");
        sprite2 = new DrawableSprite(drawable);
        sprite2.X = 10;
        sprite2.Y = 300;
        sprite2.Width = sprite2.Height = 128;
        sprites.Add(sprite2);

        // Load in just a red sphere
        drawable = DemoSprites.TilesetFactory.Create("red-sphere");
        ISprite s = new DrawableSprite(drawable);
        s.X = 400;
        s.Y = 10;
        s.Width = s.Height = 256;
        sprites.Add(s);
    }
Example #2
0
        public static void ValidateDependencies(List<SpriteSave> spriteSaves,
            SpriteList spritesToValidate)
        {
            foreach (SpriteSave ss in spriteSaves)
                if (ss.Parent != string.Empty)
                    spritesToValidate.FindByName(ss.Name).AttachTo(
                        spritesToValidate.FindByName(ss.Parent), false);

        }
    public void CreateAnimations()
    {
        SpriteAnimator myScript = (SpriteAnimator)target;
        Animation myAnimation = myScript.gameObject.GetComponent<Animation>();

        Object[] selection = Selection.GetFiltered(typeof(Texture2D), SelectionMode.Unfiltered);

        SpriteList[] sheets = new SpriteList[selection.Length];

        for (int i = 0; i < selection.Length; i++)
        {
            Object texture = selection[i];

            sheets[i] = new SpriteList();

            string textureAssetPath = AssetDatabase.GetAssetPath(texture);

            Sprite[] sprites = AssetDatabase.LoadAllAssetsAtPath(textureAssetPath).OfType<Sprite>().ToArray();

            sheets[i].sprites = sprites;
            sheets[i].name = texture.name;

            AnimationClip clip = new AnimationClip();

            clip.name = texture.name;
            clip.frameRate = sprites.Length + 1;
            clip.wrapMode = WrapMode.Once;

            float frameDuration = 1.0f / clip.frameRate;

            AnimationCurve indexCurve = AnimationCurve.Linear(0.0f, 0.0f, (clip.frameRate - 1) * frameDuration, sprites.Length - 1);
            AnimationCurve sheetCurve = AnimationCurve.Linear(0.0f, i, clip.frameRate * frameDuration, i);

            indexCurve.AddKey(clip.frameRate * frameDuration, sprites.Length - 1);

            clip.SetCurve("", typeof(SpriteAnimator), "index", indexCurve);
            clip.SetCurve("", typeof(SpriteAnimator), "sheet", sheetCurve);

        //            AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Legacy);

            string prefabFolder = Directory.GetParent(textureAssetPath).ToString();
            string clipFile = prefabFolder + "/" + clip.name + ".anim";

            AssetDatabase.CreateAsset(clip, clipFile);

            myAnimation.AddClip(clip, clip.name);
        }

        AssetDatabase.SaveAssets();

        myScript.sheets = sheets;
    }
 public PartyGUIMember(PartyPokemon pkmn, SpriteList sprites)
 {
     _usePartyPkmn = true;
     _partyPkmn    = pkmn;
     _color        = GetColor();
     _mini         = new Sprite()
     {
         Image    = PokemonImageUtils.GetMini(pkmn.Species, pkmn.Form, pkmn.Gender, pkmn.Shiny, pkmn.IsEgg),
         Y        = Sprite_BounceDefY,
         Callback = Sprite_Bounce,
         Data     = new Sprite_BounceData()
     };
     sprites.Add(_mini);
     _background = new Image((UI.Program.RenderWidth / 2) - (UI.Program.RenderWidth / 20), (UI.Program.RenderHeight / 4) - (UI.Program.RenderHeight / 20));
     UpdateBackground();
 }
Example #5
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count == 0 && SpriteList.All.Count == 0)
            {
                FontList.Load(EFont.timelineNormal, "Times New Roman", 2.0, Color.FromArgb(193, 180, 255), FontStyle.Bold);
                FontList.Load(EFont.timelineError, "Times New Roman", 2.0, Color.Red, FontStyle.Bold);

                FontList.Load(EFont.main, "Times New Roman", 3.0, Color.FromArgb(193, 209, 255), FontStyle.Bold);

                FontList.Load(EFont.player0, "Times New Roman", 3.0, Color.FromArgb(230, 70, 70), FontStyle.Bold);
                FontList.Load(EFont.player1, "Times New Roman", 3.0, Color.FromArgb(70, 230, 70), FontStyle.Bold);

                SpriteList.Load(ESprite.man0, -90);
                SpriteList.Load(ESprite.man1, -90);
            }
        }
Example #6
0
        public override void EnterLevel(int fromLevelNum)
        {
            base.EnterLevel(fromLevelNum);
            Console.WriteLine("BEGINNING ");
            if (gameStateManager.getLevel(fromLevelNum) is GameLevel1)
            {
                GameLevel1 lastGameLevel = gameStateManager.getLevel(fromLevelNum) as GameLevel1;
                level = lastGameLevel.level + 1;
                Console.WriteLine("LEVEL: " + level.ToString());
                score        = lastGameLevel.score;
                enemyToSpawn = lastGameLevel.enemyToSpawn + 3;
            }
            else
            {
                level        = 1;
                score        = 0;
                enemyToSpawn = 10;
            }

            enemyCounter = 0;
            //initialize level texts
            textLevel      = new TextRenderable("LEVEL: " + level.ToString(), new Vector2(20, 20), spriteFont, Color.Red);
            textScore.text = "Score : " + score.ToString();

            //initialize player for new level
            player = new Player(true, playerTex, 50, Game1.SCREEN_HEIGHT / 2 - 50);
            player.setWidthHeight(100, 100);
            player.setFlip(SpriteEffects.FlipHorizontally);

            //initalize level state
            levelState = LEVELSTATE.LEVELSTART;

            //initialize lists
            particleList     = new SpriteList();
            enemyList        = new SpriteList();
            playerBulletList = new SpriteList();

            Console.WriteLine("enemyCounter" + enemyCounter);
            Console.WriteLine("enemyToSpawn" + enemyToSpawn);


            scrollBack = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -1 + player.playerBackgroundSpeed, 2);
            scrollFore = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -2 + player.playerBackgroundSpeed, 2);

            //initialize eneemy player targetting.
            EnemyEasy.player = player;
        }
Example #7
0
 private void Start()
 {
     enemyPicks = new List <PickableSprite>();
     foreach (KeyValuePair <int, Sprite> pair in SpriteList.GetEnemyIDs())
     {
         PickableSprite ps = Instantiate(pickableSpritePrefab, enemyHolder);
         ps.Init(pair.Key, pair.Value);
         enemyPicks.Add(ps);
     }
     boosterPicks = new List <PickableSprite>();
     foreach (KeyValuePair <int, Sprite> pair in SpriteList.GetBoosterIDs())
     {
         PickableSprite ps = Instantiate(pickableSpritePrefab, boosterHolder);
         ps.Init(pair.Key, pair.Value);
         boosterPicks.Add(ps);
     }
 }
Example #8
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteMoving()
    {
        // Create the basics
        sprites  = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable      drawable = DemoSprites.TilesetFactory.Create("red-sphere");
        DrawableSprite sprite1  = new DrawableSprite(drawable);

        sprite = new MovingSprite(sprite1);
        sprite.StoppedMoving += OnStoppedMoving;
        sprite.Height         = sprite.Width = 64;
        sprite.X              = sprite.Y = 10;
        sprites.Add(sprite);

        // Create the target
        drawable      = DemoSprites.TilesetFactory.Create("green-sphere");
        target        = new DrawableSprite(drawable);
        target.Height = target.Width = 32;
        sprites.Add(target);

        // Load in the static green sphere
        drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
        DrawableSprite sprite2a = new DrawableSprite(drawable);

        sprite2        = new MovingSprite(sprite2a);
        sprite2.Height = sprite2.Width = 64;
        sprite2.X      = sprite2.Y = 10;
        sprites.Add(sprite2);

        // Create the target
        drawable       = DemoSprites.TilesetFactory.Create("green-sphere");
        target2        = new DrawableSprite(drawable);
        target2.Height = target2.Width = 32;
        sprites.Add(target2);
        sprite2.DesiredX = Entropy.Next(0, viewport.Width - sprite.Width);
        sprite2.DesiredY = Entropy.Next(0, viewport.Height - sprite.Height);
        target2.X        = sprite2.DesiredX + 16;
        target2.Y        = sprite2.DesiredY + 16;

        // Start our timer
        Timeout.Add(1000, OnNewLocation2);
    }
        public override void LoadContent()
        {
            base.LoadContent();

            texTarget      = Content.Load <Texture2D>("Target");
            texTest        = Content.Load <Texture2D>("SShip4m");
            texPixel       = Content.Load <Texture2D>("pixel");
            texMouseCursor = Content.Load <Texture2D>("sword_02");
            spriteFontFile = Content.Load <SpriteFont>("File");

            texPlayerDoubleJump = Content.Load <Texture2D>("doublejump");
            texPlayerDash       = Content.Load <Texture2D>("dash");
            texPlayerSlice      = Content.Load <Texture2D>("slice2");

            Slice.pixel            = texPixel;
            EnemyHitbox.texHitbox  = texPixel;
            TestEnemy.texTestEnemy = texTarget;
            Player.texPlayer       = texPixel;

            particleList = new RC_RenderableList();
            sliceList    = new SpriteList();
            platformList = new SpriteList();
            enemyList    = new SpriteList();

            //Initialize abilities
            abilityIconDoubleJump = new AbilityIcon(texPlayerDoubleJump, new Vector2(900, Game1.SCREEN_HEIGHT - 100));
            abilityIconDash       = new AbilityIcon(texPlayerDash, new Vector2(1000, Game1.SCREEN_HEIGHT - 100));
            abilityIconSlice      = new AbilityIcon(texPlayerSlice, new Vector2(800, Game1.SCREEN_HEIGHT - 100));

            Player.iconDoubleJump = abilityIconDoubleJump;
            Player.iconDash       = abilityIconDash;
            Player.iconSlice      = abilityIconSlice;

            //player = new Player(new Vector2(100, 100));
            //LoadLevel();

            //ResetPlayer();

            //cam.Pos = new Vector2(0, 0);

            ////cam.Zoom = 2.0f // Example of Zoom in
            //cam.Zoom = 1f; // Example of Zoom out

            //SpawnTargets();
        }
Example #10
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteBounce()
    {
        // Create the basics
        sprites  = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic drawable
        IDrawable drawable = DemoSprites.PixbufFactory.Create("green-sphere");

        // Create the sprites
        for (int i = 0; i < 20; i++)
        {
            Bounce sprite = new Bounce(drawable);
            sprite.Width = sprite.Height = 64;
            sprites.Add(sprite);
        }
    }
Example #11
0
        public void TestTimedRemoval()
        {
            Emitter emitter = new Emitter();

            emitter.RemovalEvent   = Emitter.RemovalEventType.Timed;
            emitter.SecondsLasting = 1000;

            SpriteList sprites = new SpriteList();;

            emitter.Emit(sprites);
            SpriteManager.RemoveSprite(sprites[0]);


            if (SpriteManager.NumberOfTimedRemovalObjects != 0)
            {
                throw new Exception("Timed removal is not being cleared out when removing particles");
            }
        }
Example #12
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteBounce()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic drawable
        IDrawable drawable = DemoSprites.PixbufFactory.Create("green-sphere");

        // Create the sprites
        for (int i = 0; i < 20; i++)
        {
            Bounce sprite = new Bounce(drawable);
            sprite.Width = sprite.Height = 64;
            sprites.Add(sprite);
        }
    }
Example #13
0
 private void SetPathSprites()
 {
     Sprite[] tiles = SpriteList.GetPathSprite(path);
     if (path != PathType.CLASSIC)
     {
         Debug.Log(floors.Length);
         foreach (FloorManager floor in floors)
         {
             for (int i = 0; i < floor.Rows; i++)
             {
                 for (int j = 0; j < floor.Columns; j++)
                 {
                     bool   isRowEven = (i % 2 == 0);
                     bool   isColEven = (j % 2 == 0);
                     Sprite tile      = null;
                     if (isRowEven)
                     {
                         if (isColEven)
                         {
                             tile = tiles[TOP_LEFT];
                         }
                         else
                         {
                             tile = tiles[TOP_RIGHT];
                         }
                     }
                     else
                     {
                         if (isColEven)
                         {
                             tile = tiles[BOT_LEFT];
                         }
                         else
                         {
                             tile = tiles[BOT_RIGHT];
                         }
                     }
                     SetTileSprite(floor, tile, i, j);
                 }
             }
         }
     }
 }
Example #14
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteMoving()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable drawable = DemoSprites.TilesetFactory.Create("red-sphere");
        DrawableSprite sprite1 = new DrawableSprite(drawable);
        sprite = new MovingSprite(sprite1);
        sprite.StoppedMoving += OnStoppedMoving;
        sprite.Height = sprite.Width = 64;
        sprite.X = sprite.Y = 10;
        sprites.Add(sprite);

        // Create the target
        drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        target = new DrawableSprite(drawable);
        target.Height = target.Width = 32;
        sprites.Add(target);

        // Load in the static green sphere
        drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
        DrawableSprite sprite2a = new DrawableSprite(drawable);
        sprite2 = new MovingSprite(sprite2a);
        sprite2.Height = sprite2.Width = 64;
        sprite2.X = sprite2.Y = 10;
        sprites.Add(sprite2);

        // Create the target
        drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        target2 = new DrawableSprite(drawable);
        target2.Height = target2.Width = 32;
        sprites.Add(target2);
        sprite2.DesiredX = Entropy.Next(0, viewport.Width - sprite.Width);
        sprite2.DesiredY = Entropy.Next(0, viewport.Height - sprite.Height);
        target2.X = sprite2.DesiredX + 16;
        target2.Y = sprite2.DesiredY + 16;

        // Start our timer
        Timeout.Add(1000, OnNewLocation2);
    }
Example #15
0
        public static void SetStrongHoldPiecesInStrongHoldList(TextureInfo textureinfo, ref SpriteList list,
                                                               ref StrongHoldPiece[] strongHoldPieces, float scale)
        {
            if (list == null)
            {
                list = new SpriteList(textureinfo);
            }

            foreach (StrongHoldPiece strongHoldPiece in strongHoldPieces)
            {
                strongHoldPiece.Quad.S = strongHoldPiece.TextureInfo.TextureSizef * scale;

                strongHoldPiece.CenterSprite();

                strongHoldPiece.Position = Director.Instance.CurrentScene.Camera2D.Center + strongHoldPiece.localPosition();

                list.AddChild(strongHoldPiece);
            }
        }
        private void fillAvailableSprites(ComboBox comboBox)
        {
            comboBox.Clear();
            SpriteList possibleSprites = new SpriteList();

            if (this.sceneOrGroup.Text == "Entire Scene")
            {
                possibleSprites = GameData.Scene.Sprites;
            }
            else if (GameData.EditorLogic.CurrentSprites.Count != 0)
            {
                ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
            }
            comboBox.AddItem("<No Root>");
            foreach (Sprite s in possibleSprites)
            {
                comboBox.AddItem(s.Name);
            }
        }
Example #17
0
        public static void SetLumberMillPiecesInLumberMillList(TextureInfo textureinfo, ref SpriteList list,
                                                               ref LumberMillPiece[] lumberMillPieces, float scale)
        {
            if (list == null)
            {
                list = new SpriteList(textureinfo);
            }

            foreach (LumberMillPiece lumberMillPiece in lumberMillPieces)
            {
                lumberMillPiece.Quad.S = lumberMillPiece.TextureInfo.TextureSizef * scale;

                lumberMillPiece.CenterSprite();

                lumberMillPiece.Position = Director.Instance.CurrentScene.Camera2D.Center + lumberMillPiece.localPosition();

                list.AddChild(lumberMillPiece);
            }
        }
Example #18
0
        public static void SetMinePiecesInMineList(TextureInfo textureinfo, ref SpriteList list,
                                                   ref MinePiece[] MinePieces, float scale)
        {
            if (list == null)
            {
                list = new SpriteList(textureinfo);
            }

            foreach (MinePiece minePiece in MinePieces)
            {
                minePiece.Quad.S = minePiece.TextureInfo.TextureSizef * scale;

                minePiece.CenterSprite();

                minePiece.Position = Director.Instance.CurrentScene.Camera2D.Center + minePiece.localPosition();

                list.AddChild(minePiece);
            }
        }
        public override void LoadLevel()
        {
            base.LoadLevel();
            Sprite3 newPlatform;

            OutOfBounds  = new Rectangle(0, 0, Game1.SCREEN_WIDTH, 1000);
            platformList = new SpriteList();

            newPlatform = new Sprite3(true, texPixel, 200, 700);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);
            targetSpawnPositions = new List <Vector2>();
            PlayerSpawnPosition  = new Vector2(newPlatform.getBoundingBoxAA().X + newPlatform.getBoundingBoxAA().Width / 2 - player.getWidth() / 2, newPlatform.getBoundingBoxAA().Y - 100);


            newPlatform = new Sprite3(true, texPixel, 700, 150);
            newPlatform.setWidthHeight(100, 30);
            platformList.addSpriteReuse(newPlatform);

            if (!isChallengeMode)
            {
                targetSpawnPositions.Add(new Vector2(280, 586));
                targetSpawnPositions.Add(new Vector2(325, 487));
                targetSpawnPositions.Add(new Vector2(367, 394));
                targetSpawnPositions.Add(new Vector2(414, 294));
                targetSpawnPositions.Add(new Vector2(469, 188));
                targetSpawnPositions.Add(new Vector2(526, 82));
            }
            else
            {
                targetSpawnPositions.Add(new Vector2(68, 608));
                targetSpawnPositions.Add(new Vector2(68, 497));
                targetSpawnPositions.Add(new Vector2(67, 399));
                targetSpawnPositions.Add(new Vector2(72, 293));
                targetSpawnPositions.Add(new Vector2(79, 185));
                targetSpawnPositions.Add(new Vector2(78, 90));
            }


            goal = new GoalZone(newPlatform);
            player.LoadPlatformsPlayer(platformList);
        }
Example #20
0
        public unsafe PartyGUI(Party party, Mode mode, Action onClosed)
        {
            _mode             = mode;
            _allowBack        = true;
            _useGamePartyData = true;
            _sprites          = new();
            _members          = new List <PartyGUIMember>(PkmnConstants.PartyCapacity);
            _gameParty        = new GamePartyData(party, _members, _sprites);
            _members[0].SetBigBounce();

            if (mode == Mode.SelectDaycare)
            {
                SetSelectionVar(-1);
            }

            _onClosed       = onClosed;
            _fadeTransition = new FadeFromColorTransition(500, 0);
            Game.Instance.SetCallback(CB_FadeInParty);
            Game.Instance.SetRCallback(RCB_Fading);
        }
Example #21
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count == 0 && SpriteList.All.Count == 0)
            {
                FontList.Load(EFont.timelineNormal, "Times New Roman", 1.6, Color.FromArgb(200, 200, 200));
                FontList.Load(EFont.timelineError, "Times New Roman", 1.9, Color.Red, FontStyle.Bold);
                FontList.Load(EFont.playerNumbers, "Times New Roman", 1.5, Color.White);
                FontList.Load(EFont.Time, "Times New Roman", 2.0, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                FontList.Load(EFont.TeamOne, "Times New Roman", 2.0, Color.FromArgb(200, 0, 180, 230), FontStyle.Bold);
                FontList.Load(EFont.TeamTwo, "Times New Roman", 2.0, Color.FromArgb(200, 180, 140, 0), FontStyle.Bold);
                FontList.Load(EFont.ScoreOne, "Times New Roman", 4.0, Color.FromArgb(255, 0, 180, 230), FontStyle.Bold);
                FontList.Load(EFont.ScoreTwo, "Times New Roman", 4.0, Color.FromArgb(255, 180, 140, 0), FontStyle.Bold);
                //  SpriteList.Load(ESprite.green);
                FontList.Load(EFont.CoordsOnField, "Times New Roman", 1.5, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                FontList.Load(EFont.Possession, "Times New Roman", 1.5, Color.FromArgb(150, 150, 150), FontStyle.Bold);
                FontList.Load(EFont.Goal, "Lucida Console", 20, Color.FromArgb(150, 220, 0, 0), FontStyle.Bold);

                SpriteList.Load(ESprite.explosion, defaultSizeExact: new Vector2d(50), defaultDepth: 10000, frameCountHorizontal: 6, frameCountVertical: 5);
            }
        }
Example #22
0
        public SESpriteGridManager()
        {
            camera         = GameData.Camera;
            cursor         = GameData.Cursor;
            currentSprites = GameData.EditorLogic.CurrentSprites;

            messages = GuiData.messages;

            mSpriteGridBorder = new SpriteGridBorder(cursor,
                                                     camera);

            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "XLeftBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "XRightBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "YTopBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "YBottomBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "ZCloseBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "ZFarBound", RepopulateSpriteGrid);

            tla = new List <TextureLocation <Texture2D> >();
        }
Example #23
0
        public void TestTimedRemoval()
        {
            Emitter emitter = new Emitter();
            emitter.RemovalEvent = Emitter.RemovalEventType.Timed;
            emitter.SecondsLasting = 1000;

            SpriteList sprites = new SpriteList(); ;
            emitter.Emit(sprites);
            SpriteManager.RemoveSprite(sprites[0]);


            if (SpriteManager.NumberOfTimedRemovalObjects != 0)
            {
                throw new Exception("Timed removal is not being cleared out when removing particles");
            }




        }
Example #24
0
        /** [シングルトン]constructor
         */
        private Render2D()
        {
            //ルート。
            {
                this.root_gameobject      = new UnityEngine.GameObject();
                this.root_gameobject.name = "Render2D";
                UnityEngine.GameObject.DontDestroyOnLoad(this.root_gameobject);
                this.root_transform = this.root_gameobject.GetComponent <UnityEngine.Transform>();
            }

            //スクリーン。
            this.screen = new Screen();

            //マテリアルリスト。
            this.materiallist = new MaterialList();

            //スプライトリスト。
            this.spritelist = new SpriteList();

            //テキストリスト。
            this.textlist = new TextList();

            //入力フィールドリスト。
            this.inputfieldlist = new InputFieldList();

            //デフォルト。フォント。
            this.default_font = UnityEngine.Resources.GetBuiltinResource <UnityEngine.Font>(Config.DEFAULT_FONT_NAME);

            //レイヤーリスト。
            this.layerlist = new LayerList(this.root_gameobject.GetComponent <UnityEngine.Transform>());

            //Resourceリスト。
            this.resource_list = new ResourceList(this);

            //callback_on_change_screen_size
            this.callback_on_change_screen_size = null;

            //PlayerLoopType
            this.playerloop_flag = true;
            Fee.PlayerLoopSystem.PlayerLoopSystem.GetInstance().Add(PlayerLoopSystem.AddType.AddFirst, typeof(UnityEngine.PlayerLoop.PostLateUpdate), typeof(PlayerLoopType.PreDraw), this.PreDraw);
        }
Example #25
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteTileset()
    {
        // Create the basics
        sprites  = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable      drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        DrawableSprite sprite   = new DrawableSprite(drawable);

        sprite.Height = sprite.Width = 64;
        sprite.X      = sprite.Y = 10;
        sprites.Add(sprite);

        // Load in the animated red sphere
        int rows = 6;
        int cols = 6;

        for (int i = 0; i < cols; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                if (i == j)
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
                }
                else
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere");
                }

                sprite        = new DrawableSprite(drawable);
                sprite.Height = sprite.Width = 64;
                sprite.X      = 100 + i * 100;
                sprite.Y      = 10 + j * 100;
                sprite.Randomize();
                sprites.Add(sprite);
            }
        }
    }
Example #26
0
        //--------------------------------------------------------
        //  虚函数
        //--------------------------------------------------------
        protected override void InitUI()
        {
            base.InitUI();

            mSelectedServerInfo      = null;
            mMaintainingServerTimers = new List <Utils.DecimalTimer>();
            mMaintainingServerTimers.Clear();

            // 选服界面
            mCloseServerListPanelButton = FindChild <Button>("CloseServerListPanelButton");
            mCloseServerListPanelButton.onClick.AddListener(OnClickCloseServerListPanelButton);

            // 大区列表界面
            mRegionListContent = FindChild <Transform>("RegionListContent").gameObject;
            mRegionItem        = FindChild <Transform>("RegionItem").gameObject;
            mRegionItem.SetActive(false);
            mRegionListScrollViewEx = FindChild <ScrollViewEx>("RegionListScrollView");
            mRegionListScrollViewEx.LoopItemRefreshData = UpdateRegionItem;

            // 已有角色界面
            mHaveRoleServerListPanel   = FindChild <Transform>("HaveRoleServerListPanel").gameObject;
            mHaveRoleServerListContent = FindChild <Transform>("HaveRoleServerListContent").gameObject;
            mHaveRoleServerItem        = FindChild <Transform>("HaveRoleServerItem").gameObject;
            mHaveRoleServerItem.SetActive(false);
            mRoleHeadSpriteList = FindChild <Transform>("RoleHeadPanel").GetComponent <SpriteList>();

            // 推荐界面
            mRecommendServerListPanel   = FindChild <Transform>("RecommendServerListPanel").gameObject;
            mRecommendServerListContent = FindChild <Transform>("RecommendServerListContent").gameObject;
            mRecommendServerItem        = FindChild <Transform>("RecommendServerItem").gameObject;
            mRecommendServerItem.SetActive(false);
            mWillOpenServerListContent = FindChild <Transform>("WillOpenServerListContent").gameObject;
            mWillOpenServerItem        = FindChild <Transform>("WillOpenServerItem").gameObject;
            mWillOpenServerItem.SetActive(false);

            // 普通服务器列表界面
            mNormalServerListPanel   = FindChild <Transform>("NormalServerListPanel").gameObject;
            mNormalServerListContent = FindChild <Transform>("NormalServerListContent").gameObject;
            mNormalServerItem        = FindChild <Transform>("NormalServerItem").gameObject;
            mNormalServerItem.SetActive(false);
        }
        public override void LoadContent()
        {
            base.LoadContent();

            menuStrings = new List <String>();
            menuStrings.Add("START GAME");
            menuStrings.Add("TUTORIAL");
            menuStrings.Add("EXIT GAME");

            titleFont   = Content.Load <SpriteFont>("File");
            menuFont    = Content.Load <SpriteFont>("File");
            selectorTex = Content.Load <Texture2D>("Target");

            soundMenu = Content.Load <SoundEffect>("sounds/MenuMove");

            TestEnemy.texTestEnemy = selectorTex;

            particleList = new RC_RenderableList();
            sliceList    = new SpriteList();
            enemyList    = new SpriteList();
        }
Example #28
0
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteTileset()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        DrawableSprite sprite = new DrawableSprite(drawable);
        sprite.Height = sprite.Width = 64;
        sprite.X = sprite.Y = 10;
        sprites.Add(sprite);

        // Load in the animated red sphere
        int rows = 6;
        int cols = 6;

        for (int i = 0; i < cols; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                if (i == j)
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
                }
                else
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere");
                }

                sprite = new DrawableSprite(drawable);
                sprite.Height = sprite.Width = 64;
                sprite.X = 100 + i * 100;
                sprite.Y = 10 + j * 100;
                sprite.Randomize();
                sprites.Add(sprite);
            }
        }
    }
Example #29
0
        /// <summary>
        /// Removes all Sprites and SpriteFrames referencing the argument Texture2D.  Sets all
        /// SpriteGrid TextureLocationArray references to the argument texture back to the base texture or removes the
        /// SpriteGrid if the base texture is the same as the argument.
        /// </summary>
        /// <param name="texture">The texture being removed.</param>
        #endregion
        public static void RemoveObjectsReferencing(Texture2D texture)
        {
            SpriteList spritesToRemove = new SpriteList();

            // will need to store all removed objects for undo
            foreach (Sprite s in mScene.Sprites)
            {
                if (s.Texture == texture)
                {
                    spritesToRemove.Add(s);
                }
            }
            DeleteSprites(spritesToRemove, false);

            for (int i = GameData.Scene.SpriteGrids.Count - 1; i > -1; i--)
            {
                if (GameData.Scene.SpriteGrids[i].Blueprint.Texture == texture)
                {
                    /* The blueprint texture matches the texture being removed.  Remove the
                     * SpriteGrid from the SE.
                     */
                    sesgMan.DeleteGrid(GameData.Scene.SpriteGrids[i]);
                }
                else
                {
                    GameData.Scene.SpriteGrids[i].ReplaceTexture(
                        texture,
                        GameData.Scene.SpriteGrids[i].Blueprint.Texture);
                }
            }


            for (int i = Scene.SpriteFrames.Count - 1; i > -1; i--)
            {
                if (Scene.SpriteFrames[i].Texture == texture)
                {
                    DeleteSpriteFrame(Scene.SpriteFrames[i], true);
                }
            }
        }
        internal override XDocument CreateXml()
        {
            XmlParserTempProjectHelper.currentObjectNum   = 0;
            XmlParserTempProjectHelper.currentScriptNum   = 0;
            XmlParserTempProjectHelper.currentBrickNum    = 0;
            XmlParserTempProjectHelper.currentVariableNum = 0;

            XmlParserTempProjectHelper.Document = new XDocument {
                Declaration = new XDeclaration("1.0", "UTF-8", "yes")
            };

            XmlParserTempProjectHelper.Program = this;

            var xProject = new XElement(XmlConstants.Program);

            xProject.Add(ProgramHeader.CreateXml());
            xProject.Add(SpriteList.CreateXml());
            xProject.Add(VariableList.CreateXml());
            XmlParserTempProjectHelper.Document.Add(xProject);

            return(XmlParserTempProjectHelper.Document);
        }
Example #31
0
        /// <summary>
        /// Generate an image for each font character
        /// </summary>
        /// <param name="list">input list of characters</param>
        /// <param name="font">the font to use</param>
        /// <returns>maximum dimensions among the rendered chars</returns>
        static Size CreateCharSprites(char[] list, Font font)
        {
            Size dim = FindMaxDim(list, font);

            Log.Debug("dim = [" + dim.Width + "x" + dim.Height + "]");

            for (int ci = 0; ci < list.Length; ci++)
            {
                char c = list[ci];
                //Log.Debug("Spriting "+c);
                var img = RenderCharSprite(c, font, dim);
                //#if DEBUG
                //using (var fs = File.OpenWrite("sprite-"+((int)c)+".png")) {
                //	img.SaveAsPng(fs);
                //}
                //#endif
                SpriteList.Add(img);
                double avg = Helpers.FindAverageGray(img);
                //Log.Debug("Spriting avg = "+avg);
            }
            return(dim);
        }
Example #32
0
        /// <summary>
        /// Constructs the display and sets up the internal widgets.
        /// </summary>
        public Display()
        {
            // Set up our size
            tileSize = 72;
            SetSizeRequest(
                tileSize * Game.Config.BoardSize, tileSize * Game.Config.BoardSize);

            // Create our viewport
            sprites  = new SpriteList();
            viewport = new SpriteViewport(sprites);

            // Set up the events
            ExposeEvent      += OnExposed;
            ConfigureEvent   += OnConfigure;
            ButtonPressEvent += OnButtonPress;
            Events            = EventMask.AllEventsMask;

            // Set up the animation timer
            Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick);

            log = new Log();
        }
Example #33
0
        /// <summary>
        /// Constructs the display and sets up the internal widgets.
        /// </summary>
        public Display()
        {
            // Set up our size
            tileSize = 72;
            SetSizeRequest(
                tileSize * Game.Config.BoardSize, tileSize * Game.Config.BoardSize);

            // Create our viewport
            sprites = new SpriteList();
            viewport = new SpriteViewport(sprites);

            // Set up the events
            ExposeEvent += OnExposed;
            ConfigureEvent += OnConfigure;
            ButtonPressEvent += OnButtonPress;
            Events = EventMask.AllEventsMask;

            // Set up the animation timer
            Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick);

            log = new Log();
        }
Example #34
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count > 0)
            {
                return;
            }
            FontList.Load(EFont.regular, "Arial", 20, Color.Black,
                          FontStyle.Regular);
            FontList.Load(EFont.teamSmall1, "Times New Roman", 15, Color.FromArgb(64, 178, 119), FontStyle.Bold);
            FontList.Load(EFont.teamSmall2, "Times New Roman", 15, Color.FromArgb(188, 64, 66), FontStyle.Bold);
            FontList.Load(EFont.teamSmall3, "Times New Roman", 15, Color.FromArgb(114, 91, 200), FontStyle.Bold);
            FontList.Load(EFont.teamSmall4, "Times New Roman", 15, Color.FromArgb(150, 147, 61), FontStyle.Bold);
            FontList.Load(EFont.teamBig1, "Times New Roman", 27, Color.FromArgb(64, 178, 119), FontStyle.Bold);
            FontList.Load(EFont.teamBig2, "Times New Roman", 27, Color.FromArgb(188, 64, 66), FontStyle.Bold);
            FontList.Load(EFont.teamBig3, "Times New Roman", 27, Color.FromArgb(114, 91, 200), FontStyle.Bold);
            FontList.Load(EFont.teamBig4, "Times New Roman", 27, Color.FromArgb(150, 147, 61), FontStyle.Bold);

            FontList.Load(EFont.timelineNormal, "Times New Roman", 10, Color.Black, FontStyle.Regular);
            FontList.Load(EFont.timelineError, "Times New Roman", 12, Color.Red, FontStyle.Bold);

            SpriteList.Load(ESprite.board10, defaultSizeExact: new Vector2d(431, 452));
            //   SpriteList.Load(ESprite.background);
            SpriteList.Load(ESprite.Design);

            SpriteList.Load(ESprite.red, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.green, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.violet, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.yellow, defaultSizeExact: new Vector2d(40, 40));

            SpriteList.Load(ESprite.redRect);
            SpriteList.Load(ESprite.greenRect);
            SpriteList.Load(ESprite.violetRect);
            SpriteList.Load(ESprite.yellowRect);

            SpriteList.Load(ESprite.humanDestination, defaultSizeExact: new Vector2d(43, 43));
            SpriteList.Load(ESprite.humanSource, defaultSizeExact: new Vector2d(43, 43));
            SpriteList.Load(ESprite.humanPointer, defaultSizeExact: new Vector2d(43, 43));
        }
Example #35
0
    /// <summary>
    /// 初始化
    /// </summary>
    void Awake()
    {
        mInstance   = this;
        mCacheTrans = transform;
        mSpriteList = mCacheTrans.parent.GetComponent <SpriteList>();

        Transform mPowerTrans = transform.Find("PowerButton");

        mSkillImage        = mPowerTrans.Find("SkillImg").GetComponent <Image>();
        mPowerButtonObject = mPowerTrans.gameObject;
        mNoticeEffect      = mPowerTrans.Find("NoticeEffect").gameObject;
        mNoticeEffect.SetActive(false);
        mNoticeEffectClick = mPowerTrans.Find("NoticeEffect_back").gameObject;
        mNoticeEffectClick.SetActive(false);

        var childTrans = mPowerTrans.Find("ChangeEffect");

        if (childTrans != null)
        {
            mChangeEffect = childTrans.gameObject;
            if (mChangeEffect != null)
            {
                mChangeEffect.SetActive(false);
            }
        }

        mSliderImage = mPowerTrans.Find("Slider").GetComponent <Image>();
        EventTriggerListener.GetListener(mPowerButtonObject).onPointerClick += OnClick;
        EventTriggerListener.GetListener(mPowerButtonObject).onPointerDown  += OnDown;
        EventTriggerListener.GetListener(mPowerButtonObject).onPointerUp    += OnUp;
        ClientEventManager <ClientEvent> .Instance.SubscribeClientEvent(ClientEvent.SKILL_KEY_POS_SET, OnSkillUpdate);

        ClientEventManager <ClientEvent> .Instance.SubscribeClientEvent(ClientEvent.SKILL_KEY_CONFIG_CHOOSED, OnSkillUpdate);

        ClientEventMgr.Instance.SubscribeClientEvent((int)ClientEvent.CE_NET_RECONNECT, OnNetReconnect);

        SkillButtonManager.Instance.AddButton(mFuryHole, gameObject);
    }
Example #36
0
        public float Update(float energy)
        {
            if (energy - EnergyCost <= 0)
            {
                SpriteList.Clear();
                IsFiring = false;
            }

            if (IsFiring)
            {
                UpdateShots();
                TurnRate = BaseTurnrate * 0.1f;
                return(EnergyCost);
            }
            // VVV is not firing VVV
            TurnRate = BaseTurnrate;
            if (CooldownCounter != Cooldown)
            {
                CooldownCounter++;
            }
            SoundEffectInstance?.Stop();
            return(0f);
        }
Example #37
0
        public void SetRootAsControlPointClick(Window callingWindow)
        {
            Sprite     topRoot;
            SpriteList allChildren;

            if (((Button)callingWindow).Text == "Set Root As Control Point")
            {
                topRoot     = (Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent;
                allChildren = new SpriteList();
                topRoot.GetAllDescendantsOneWay(allChildren);

                foreach (Sprite sprite in allChildren)
                {
                    if (sprite is EditorSprite)
                    {
                        ((EditorSprite)sprite).type = "Root Control";
                    }
                }

                ((EditorSprite)topRoot).type = "Top Root Control";
                ((Button)callingWindow).Text = "Clear Root Control Point";
            }
            else
            {
                topRoot     = (Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent;
                allChildren = new SpriteList();
                topRoot.GetAllDescendantsOneWay(allChildren);

                foreach (Sprite sprite in allChildren)
                {
                    ((EditorSprite)sprite).type = "Root Control";
                }

                ((EditorSprite)topRoot).type = "";
                ((Button)callingWindow).Text = "Set Root As Control Point";
            }
        }
Example #38
0
        public unsafe PartyGUI(SpritedBattlePokemonParty party, Mode mode, Action onClosed)
        {
            _mode             = mode;
            _allowBack        = mode != Mode.BattleReplace; // Disallow back for BattleReplace
            _useGamePartyData = false;
            _sprites          = new();
            _members          = new List <PartyGUIMember>(PkmnConstants.PartyCapacity);
            _battleParty      = new BattlePartyData(party, _members, _sprites);
            _members[0].SetBigBounce();

            if (mode == Mode.BattleSwitchIn)
            {
                SetSelectionVar(-1);
            }
            else if (mode == Mode.BattleReplace)
            {
                SetBattleReplacementMessage();
            }

            _onClosed       = onClosed;
            _fadeTransition = new FadeFromColorTransition(500, 0);
            Game.Instance.SetCallback(CB_FadeInParty);
            Game.Instance.SetRCallback(RCB_Fading);
        }
        public SESpriteGridManager()
		{
			camera = GameData.Camera;
			cursor = GameData.Cursor;
			currentSprites = GameData.EditorLogic.CurrentSprites;

			messages = GuiData.messages;

            mSpriteGridBorder = new SpriteGridBorder(cursor,
                camera);

            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "XLeftBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "XRightBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "YTopBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "YBottomBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "ZCloseBound", RepopulateSpriteGrid);
            UndoManager.SetAfterUpdateDelegate(typeof(SpriteGrid), "ZFarBound", RepopulateSpriteGrid);

            tla = new List<TextureLocation<Texture2D>>();
        }
        private void saveButtonClick(Window callingWindow)
        {
            // If a user thinks he's funny and selects AllNotJoint for BodySprites
            // and AllNotBodySprites for Joints, let the user know he has to
            // specify some criteria.
            if (this.bodySpriteSelectionMethod.Text == "All Not Joint" &&
                this.jointSpriteSelectionMethod.Text == "All Not Body")
            {
                GuiManager.ShowMessageBox(
                    "Cannot select All Not Body for Joint Selection when " +
                    "All Not Joint is selected for Body Sprite Selection.  " +
                    "Change one of the criteria and try to save again.", "Selection Error");
                return;

            }



            double error = 0;
            SpriteList possibleSprites = new SpriteList();

            if (this.sceneOrGroup.Text == "Entire Scene")
            {
                possibleSprites = GameData.Scene.Sprites;
            }
            else if (GameData.EditorLogic.CurrentSprites.Count != 0)
            {
                ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
            }

            #region Get rid of the Axes from the possibleSprites

            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.zAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.zAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.origin))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.origin);
            }
            #endregion

            if (this.bodySpriteSelectionMethod.Text == "Name Includes")
            {
                this.bodySprites = possibleSprites.FindSpritesWithNameContaining(this.bodyNameToInclude.Text);
            }
            else if (this.bodySpriteSelectionMethod.Text == "By Texture")
            {
                this.bodySprites = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load<Texture2D>(this.bodyAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.bodySpriteSelectionMethod.Text == "All")
            {
                this.bodySprites = possibleSprites;
            }

            if (this.jointSpriteSelectionMethod.Text == "Name Includes")
            {
                this.joints = possibleSprites.FindSpritesWithNameContaining(this.jointNameToInclude.Text);
            }
            else if (this.jointSpriteSelectionMethod.Text == "By Texture")
            {
                this.joints = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load<Texture2D>(this.jointAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.jointSpriteSelectionMethod.Text == "All")
            {
                this.joints = possibleSprites;
            }

            try
            {
                if (bodySpriteSelectionMethod == null) System.Windows.Forms.MessageBox.Show("a");

                if (this.bodySpriteSelectionMethod.Text == "All Not Joint")
                {
                    this.bodySprites = new SpriteList();

                    if (possibleSprites == null) System.Windows.Forms.MessageBox.Show("b");


                    foreach (Sprite s in possibleSprites)
                    {
                        if (this == null) System.Windows.Forms.MessageBox.Show("c");
                        if (this.joints == null) System.Windows.Forms.MessageBox.Show("d");
                        if (this.bodySprites == null) System.Windows.Forms.MessageBox.Show("e");



                        if (!this.joints.Contains(s))
                        {
                            this.bodySprites.Add(s);
                        }
                    }
                }
            }
            catch { error = 3.3; }
                if (this.jointSpriteSelectionMethod.Text == "All Not Body")
                {
                    this.joints = new SpriteList();
                    foreach (Sprite s in possibleSprites)
                    {
                        if (!this.bodySprites.Contains(s))
                        {
                            this.joints.Add(s);
                        }
                    }
                }

                if (this.rootSpriteComboBox.Text != "<No Root>")
                {
                    this.root = possibleSprites.FindByName(this.rootSpriteComboBox.Text);
                }
                else
                {
                    this.root = null;
                }




            FileButtonWindow.spriteRigOptionsOK(this);
            this.Visible = false;

        }
 public void FillComboBoxes()
 {
     SpriteList possibleSprites = new SpriteList();
     if (this.sceneOrGroup.Text == "Entire Scene")
     {
         possibleSprites = GameData.Scene.Sprites;
     }
     else if (GameData.EditorLogic.CurrentSprites.Count != 0)
     {
         ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
     }
     this.rootSpriteComboBox.AddItem("<No Root>");
     foreach (Sprite s in possibleSprites)
     {
         this.rootSpriteComboBox.AddItem(s.Name);
     }
     Sprite defaultRoot = possibleSprites.FindByName("root1");
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("Root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("Root1");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindWithNameContaining("root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindWithNameContaining("Root");
     }
     if (defaultRoot != null)
     {
         this.rootSpriteComboBox.Text = defaultRoot.Name;
     }
     else
     {
         this.rootSpriteComboBox.Text = "<No Root>";
     }
 }
 private void fillAvailableTextures(ComboBox comboBox)
 {
     comboBox.Clear();
     SpriteList possibleSprites = new SpriteList();
     if (this.sceneOrGroup.Text == "Entire Scene")
     {
         possibleSprites = GameData.Scene.Sprites;
     }
     else if (GameData.EditorLogic.CurrentSprites.Count != 0)
     {
         ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
     }
     List<Texture2D> ta = new List<Texture2D>();
     foreach (Sprite s in possibleSprites)
     {
         if (!ta.Contains(s.Texture))
         {
             ta.Add(s.Texture);
         }
     }
     foreach (Texture2D t in ta)
     {
         comboBox.AddItem(FileManager.MakeRelative(t.Name, FileManager.RelativeDirectory));
     }
 }
 private void fillAvailableSprites(ComboBox comboBox)
 {
     comboBox.Clear();
     SpriteList possibleSprites = new SpriteList();
     if (this.sceneOrGroup.Text == "Entire Scene")
     {
         possibleSprites = GameData.Scene.Sprites;
     }
     else if (GameData.EditorLogic.CurrentSprites.Count != 0)
     {
         ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
     }
     comboBox.AddItem("<No Root>");
     foreach (Sprite s in possibleSprites)
     {
         comboBox.AddItem(s.Name);
     }
 }
Example #44
0
 /// <summary>
 /// Constructs a sprite viewport with a given sprite list.
 /// </summary>
 public SpriteViewport(SpriteList sprites)
 {
     SpriteList = sprites;
     sprites.Invalidate += OnInvalidated;
 }
Example #45
0
    /// <summary>
    /// Constructs the sprite drawing area, along with the various
    /// rules needed.
    /// </summary>
    public Viewer()
    {
        // Create the drop-down list
        HBox box = new HBox();
        fps = new SpinButton(1, 100, 1);
        fps.Value = DesiredFps;
        fps.Changed += OnFpsChanged;
        showUpdate = new CheckButton();
        box.PackStart(new Label("FPS"), false, false, 0);
        box.PackStart(fps, false, false, 2);
        box.PackStart(new Label("Show Update"), false, false, 5);
        box.PackStart(showUpdate, false, false, 2);
        box.PackStart(new Label(), true, true, 0);
        PackStart(box, false, false, 2);

        // Create the drawing area and pack it
        area = new DrawingArea();
        area.Realized += OnRealized;
        area.ExposeEvent += OnExposed;
        area.ConfigureEvent += OnConfigure;
        PackStart(area, true, true, 2);

        // Create the viewport
        Sprites = new SpriteList();
        viewport = new SpriteViewport(Sprites);

        // Start up a little animation loop
        Timeout.Add(1000 / DesiredFps, OnTick);
    }
Example #46
0
        static EditorData()
        {
            // Force the UI to be created

            mEditorLogic = new EditorLogic();

            mGlobalInstructionSets = new List<AnimationSequence>();

            SpriteManager.Camera.Z = 40.0f;
            mCameraBounds = new CameraBounds(mSceneCamera);

            mBlockingScene = new Scene();

            #region create the spriteArrays, InstructionGroupArray, and SpriteGridArray
            ActiveSprites = new SpriteList();
            formationArray = new FormationArray();
            #endregion

            // Add the properties that are going to be watched for InstructionSets
            CreateMembersWatching();

            instructionPlayer = new InstructionPlayer();

            //= SpriteManager.AddSprite("genGfx/targetBox.bmp", sprMan.AddLayer());
            //			currentSpriteMarker.fade = 150;
            //			currentSpriteMarker.visible = false;


            rectangleSelector = new RectangleSelector();

        }
Example #47
0
        public void SaveSceneClick(string fileName)
        {


            if (!string.IsNullOrEmpty(fileName))
            {
                mLastFileName = fileName;
            }
            List<string> stringArray = new List<string>();
            namesToChange = new SpriteList();
            foreach (Sprite s in GameData.Scene.Sprites)
            {
                if (stringArray.Contains(s.Name))
                {
                    namesToChange.AddOneWay(s);
                }
                else
                {
                    stringArray.Add(s.Name);
                }
            }

            if (AskQuestionsAndDelaySaveIfNecessary(SaveSceneClick))
            {

                if (namesToChange.Count != 0)
                {
                    MultiButtonMessageBox mbmb = GuiManager.AddMultiButtonMessageBox();
                    mbmb.Name = "Duplicate Sprite names found";
                    mbmb.Text = "Duplicate names found in scene.  Duplicate names can alter attachment information.  What would you like to do?";
                    mbmb.AddButton("Leave names as they are and save.", new GuiMessage(OpenFileWindowSaveScene));
                    mbmb.AddButton("Automatically change Sprite names and save.", new GuiMessage(ChangeNamesAndSave));
                    mbmb.AddButton("Cancel save.", null);
                }
                else
                {
                    if (string.IsNullOrEmpty(fileName))
                    {
                        OpenFileWindowSaveScene(null);
                    }
                    else
                    {
                        SaveSceneFileWindowOk(null);
                    }

                }



                ShowWarningsAndMessagesBeforeSaving();
            }
        }
Example #48
0
        public static void LoadSpriteRigOk(Window callingWindow)
        {
            #region Load the SpriteRig

            EditorSprite es;
            string fileName = ((FileWindow)callingWindow).Results[0];

            SpriteRigSave srs = SpriteRigSave.FromFile(fileName);
            SpriteList loadedSprites = new SpriteList();

            SpriteRig spriteRig = srs.ToSpriteRig(GameData.SceneContentManager);

            #endregion

            #region Play some Pose so that the SpriteRig has a proper pose and texture coordinates

            // Play and stop an animation to get the texture coordinates set up in case
            // the SpriteRig has texture coords defined in its AnimationChains
            if (spriteRig.PoseChains.Count != 0)
            {
                spriteRig.SetPoseChain(spriteRig.PoseChains[0]);
                spriteRig.Animate = true;
                spriteRig.SetPositionAtTimeFromAnimationStart(0);
                spriteRig.Animate = false;

            }
            #endregion

            GuiData.srSaveOptions.joints = new SpriteList();
            GuiData.srSaveOptions.bodySprites = new SpriteList();
            GuiData.srSaveOptions.joints.Clear();
            GuiData.srSaveOptions.bodySprites.Clear();

            string oldRelativeDirectory = FileManager.RelativeDirectory;
            FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);


            foreach (Sprite regularSprite in spriteRig.Joints)
            {
                es = new EditorSprite();

                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.joints.Add(es);
            }
            foreach (Sprite regularSprite in spriteRig.BodySprites)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);
            }

            // The root is not part of the body Sprites, but it should be
            if (spriteRig.Root != null && GameData.Scene.Sprites.Contains(spriteRig.Root) == false)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(spriteRig.Root);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);

            }

            if (spriteRig.Root != null)
            {
                GuiData.srSaveOptions.root = GuiData.srSaveOptions.bodySprites.FindByName(spriteRig.Root.Name);
                GuiData.srSaveOptions.bodySprites.Remove(GuiData.srSaveOptions.root);
            }
            GuiData.srSaveOptions.poseChains = spriteRig.PoseChains;
            if (srs.JointsVisible)
            {
                GuiData.srSaveOptions.jointsVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.jointsVisible.Unpress();
            }
            if (srs.RootVisible)
            {
                GuiData.srSaveOptions.rootVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.rootVisible.Unpress();
            }

            FileManager.RelativeDirectory = oldRelativeDirectory;

            string oldRelative = FileManager.RelativeDirectory;
            if (srs.AssetsRelativeToFile)
            {
                FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);
            }

            FileManager.RelativeDirectory = oldRelative;
            foreach (SpriteSave ss in srs.Joints)
            {
                srs.BodySprites.Add(ss);
            }


            for (int i = 0; i < loadedSprites.Count; i++)
            {

                if (loadedSprites[i].PixelSize > 0f)
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = false;
                }
                else
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = true;
                }

                if (loadedSprites[i].Texture.texture != null)
                {
                    GuiData.ListWindow.Add(loadedSprites[i].Texture);
                }

                string parentName = "";

                Sprite matchingSprite = spriteRig.BodySprites.FindByName(loadedSprites[i].Name);

                if (matchingSprite == null)
                {
                    matchingSprite = spriteRig.Joints.FindByName(loadedSprites[i].Name);
                }
                // parent may be null if there is no root
                if (matchingSprite != null && matchingSprite.Parent != null)
                {
                    parentName = matchingSprite.Parent.Name;

                    loadedSprites[i].AttachTo(loadedSprites.FindByName(parentName), false);
                }
            }
            GameData.Scene.Sprites.SortZInsertionDescending();




            AskToSearchForReplacements(((FileWindow)callingWindow).Results[0]);
        }
Example #49
0
        private void ControlAfterSnappingPosition()
        {
            

            #region initialize variables to be used for this method
            Sprite spriteGrabbed = GameData.Cursor.SpritesGrabbed[0];
            float originalX = spriteGrabbed.X;
            float originalY = spriteGrabbed.Y;

            // Modify this later to support rotation
            float scaleXAfterRotation = spriteGrabbed.X ;
            float scaleYAfterRotation = spriteGrabbed.Y ;

            bool snappingFound = false;

            #endregion

            if (spriteGrabbed != null)
            {
                // Get all the Sprites that are children or parents 
                // of the current
                SpriteList spritesToIgnore = new SpriteList();
                spriteGrabbed.GetAllDescendantsOneWay(spritesToIgnore);
                spriteGrabbed.GetAllAncestorsOneWay(spritesToIgnore);

                float otherSpriteScaleX;
                float otherSpriteScaleY;

                mAfterSnappingPosition.X = spriteGrabbed.X;
                mAfterSnappingPosition.Y = spriteGrabbed.Y;
                mAfterSnappingPosition.Z = spriteGrabbed.Z;

                #region Loop through all of the other Sprites excluding this one to see if this one should snap anywhere
                foreach (Sprite otherSprite in GameData.Scene.Sprites)
                {
                    if (otherSprite != spriteGrabbed && spritesToIgnore.Contains(otherSprite) == false)
                    {
                        otherSpriteScaleX = otherSprite.ScaleX;
                        otherSpriteScaleY = otherSprite.ScaleY;


                        #region Check for X snapping

                        if (AreSpritesCloseOnY(spriteGrabbed, otherSprite))
                        {
                            float value = otherSprite.X - otherSprite.ScaleX - spriteGrabbed.ScaleX;

                            if (Math.Abs(value - spriteGrabbed.X) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.X = value;
                                snappingFound = true;
                            }

                            value = otherSprite.X - otherSprite.ScaleX + spriteGrabbed.ScaleX;

                            if (Math.Abs(value - spriteGrabbed.X) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.X = value;
                                snappingFound = true;
                            }

                            value = otherSprite.X + otherSprite.ScaleX - spriteGrabbed.ScaleX;

                            if (Math.Abs(value - spriteGrabbed.X) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.X = value;
                                snappingFound = true;
                            }

                            value = otherSprite.X + otherSprite.ScaleX + spriteGrabbed.ScaleX;

                            if (Math.Abs(value - spriteGrabbed.X) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.X = value;
                                snappingFound = true;
                            }
                        }

                        #endregion

                        #region Check for Y Snapping

                        if (AreSpritesCloseOnX(spriteGrabbed, otherSprite))
                        {
                            float value = otherSprite.Y - otherSprite.ScaleY - spriteGrabbed.ScaleY;

                            if (Math.Abs(value - spriteGrabbed.Y) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.Y = value;
                                snappingFound = true;
                            }

                            value = otherSprite.Y - otherSprite.ScaleY + spriteGrabbed.ScaleY;

                            if (Math.Abs(value - spriteGrabbed.Y) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.Y = value;
                                snappingFound = true;
                            }

                            value = otherSprite.Y + otherSprite.ScaleY - spriteGrabbed.ScaleY;

                            if (Math.Abs(value - spriteGrabbed.Y) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.Y = value;
                                snappingFound = true;
                            }

                            value = otherSprite.Y + otherSprite.ScaleY + spriteGrabbed.ScaleY;

                            if (Math.Abs(value - spriteGrabbed.Y) < DistanceBasedBuffer)
                            {
                                mAfterSnappingPosition.Y = value;
                                snappingFound = true;
                            }
                        }

                        #endregion
                    }
                }
                #endregion
            }

            if (snappingFound)
            {
                UpdateSnappingDisplayToCurrentSprite();
            }
            mAfterSnappingPosition.Visible = snappingFound;

        }
        ClippedSpriteImage GetClippedSprite(Texture2D texture)
        {
            SpriteList l;
            long key = texture.AssetId;


            if (clippedImages.ContainsKey(key))
            {
                l = clippedImages[key];
            }
            else
            {
                l = new SpriteList(this, SpriteList.SpriteType.ClippedSpriteImage);
                l.BitmapCacheEnabled = BitmapCacheEnabled;
                l.RenderAtScale = RenderAtScale;
                l.Texture2D = texture;
                l.ParentCanvas = Canvas;
                clippedImages.Add(key, l);
            }
            ClippedSpriteImage s = l.GetSprite() as ClippedSpriteImage;
            return s;
        }
        BitmapSpriteText GetBitmapSpriteText(BitmapSpriteFont font)
        {
            SpriteList l;
            long key = font.AssetId;


            if (bitmapTexts.ContainsKey(key))
            {
                l = bitmapTexts[key];
            }
            else
            {
                l = new SpriteList(this, SpriteList.SpriteType.BitmapSpriteText);
                l.BitmapSpriteFont = font;
                l.ParentCanvas = Canvas;
                bitmapTexts.Add(key, l);
            }
            BitmapSpriteText s = l.GetSprite() as BitmapSpriteText;
            return s;
        }
        public void DrawString(SpriteFont spriteFont, string text, Vector2 position, G.Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
        {
            if (text == null) return;
            if (spriteFont is BitmapSpriteFont)
            {
                DrawBitmapStringInternal((BitmapSpriteFont)spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth);
                return;
            }
            SpriteList l;
            long key = spriteFont.AssetId;
            if (texts.ContainsKey(key))
            {
                l = texts[key];
            }
            else
            {
                l = new SpriteList(this, SpriteList.SpriteType.SpriteText);
                l.SpriteFont = spriteFont;
                l.ParentCanvas = Canvas;
                texts.Add(key, l);
            }
            SpriteText t = l.GetSprite() as SpriteText;
            if (t.ZIndex < zIndex)
            {
                t.ZIndex = zIndex;
            }
            else
            {
                zIndex = t.ZIndex;
            }
            Vector2 vscale = new Vector2(scale, scale);

            zIndex++;
            t.InUse = true;
            t.PositionX = position.X;
            t.PositionY = position.Y;
            t.Color = color;
            t.Text = text;
            t.Scale = vscale;
            t.Rotation = rotation;
            t.Origin = origin;
            t.Effects = effects;
        }
Example #53
0
        private static void DrawMixed(SpriteList spriteListUnfiltered, SortType sortType,
            PositionedObjectList<Text> textListUnfiltered, List<IDrawableBatch> batches,
            bool relativeToCamera, Camera camera, Section section)
        {
            if (section != null)
            {
                Section.GetAndStartContextAndTime("Start of Draw Mixed");
            }
            DrawMixedStart(camera);

            

            int spriteIndex = 0;
            int textIndex = 0;
            int batchIndex = 0;

            // The sort values can represent different
            // things depending on the sortType argument.
            // They can either represent pure Z values or they
            // can represent distance from the camera (squared).
            // The problem is that a larger Z means closer to the
            // camera, but a larger distance means further from the
            // camera.  Therefore, to fix this problem if these values
            // represent distance from camera, they will be multiplied by
            // negative 1.
            float nextSpriteSortValue = float.PositiveInfinity;
            float nextTextSortValue = float.PositiveInfinity;
            float nextBatchSortValue = float.PositiveInfinity;




            if (section != null)
            {
                Section.EndContextAndTime();
                Section.GetAndStartContextAndTime("Sort Lists");
            }

            SortAllLists(spriteListUnfiltered, sortType, textListUnfiltered, batches, relativeToCamera, camera);

            mVisibleSprites.Clear();
            mVisibleTexts.Clear();
            for (int i = 0; i < spriteListUnfiltered.Count; i++)
            {
                Sprite sprite = spriteListUnfiltered[i];
                bool isVisible = sprite.AbsoluteVisible && 
                    (sprite.ColorOperation == ColorOperation.InterpolateColor || sprite.Alpha > .0001) &&
                    camera.IsSpriteInView(sprite, false);

                if (isVisible)
                {
                    mVisibleSprites.Add(sprite);
                }
            }

            for (int i = 0; i < textListUnfiltered.Count; i++)
            {
                Text text = textListUnfiltered[i];
                if (text.AbsoluteVisible && text.Alpha > .0001 && camera.IsTextInView(text))
                {
                    mVisibleTexts.Add(text);
                }
            }
            int indexOfNextSpriteToReposition = 0;


            GetNextZValuesByCategory(mVisibleSprites, sortType, mVisibleTexts, batches, camera, ref spriteIndex, ref textIndex, ref nextSpriteSortValue, ref nextTextSortValue, ref nextBatchSortValue);

            int numberToDraw = 0;
            // This is used as a temporary variable for Z or distance from camera
            float sortingValue = 0;
            Section performDrawingSection = null;
            if (section != null)
            {
                Section.EndContextAndTime();
                performDrawingSection = Section.GetAndStartContextAndTime("Perform Drawing");
            }

            while (spriteIndex < mVisibleSprites.Count || textIndex < mVisibleTexts.Count ||
                (batches != null && batchIndex < batches.Count))
            {
                #region only 1 array remains to be drawn so finish it off completely
                
                #region Draw Texts
                if (spriteIndex >= mVisibleSprites.Count && (batches == null || batchIndex >= batches.Count) &&
                    textIndex < mVisibleTexts.Count)
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw Texts");
                    }

                    if (sortType == SortType.DistanceAlongForwardVector)
                    {
                        int temporaryCount = mVisibleTexts.Count;
                        for (int i = textIndex; i < temporaryCount; i++)
                        {
                            mVisibleTexts[i].Position = mVisibleTexts[i].mOldPosition;
                        }
                    }
                    // TEXTS: draw all texts from textIndex to numberOfVisibleTexts - textIndex
                    DrawTexts(mVisibleTexts, textIndex, mVisibleTexts.Count - textIndex, camera, section);
                    break;
                }
                #endregion

                #region Draw Sprites
                else if (textIndex >= mVisibleTexts.Count && (batches == null || batchIndex >= batches.Count) &&
                    spriteIndex < mVisibleSprites.Count)
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw Sprites");
                    }

                    numberToDraw = mVisibleSprites.Count - spriteIndex;
                    if (sortType == SortType.DistanceAlongForwardVector)
                    {
                        int temporaryCount = mVisibleSprites.Count;
                        for (int i = indexOfNextSpriteToReposition; i < temporaryCount; i++)
                        {
                            mVisibleSprites[i].Position = mVisibleSprites[i].mOldPosition;
                            indexOfNextSpriteToReposition++;
                        }
                    }


                    PrepareSprites(
                        mSpriteVertices, mSpriteRenderBreaks,
                        mVisibleSprites, spriteIndex, numberToDraw
                        );

                    DrawSprites(
                        mSpriteVertices, mSpriteRenderBreaks,
                        mVisibleSprites, spriteIndex,
                        numberToDraw, camera);

                    break;
                }

                #endregion

                #region Draw DrawableBatches
                else if (spriteIndex >= mVisibleSprites.Count && textIndex >= mVisibleTexts.Count &&
                    batches != null && batchIndex < batches.Count)
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw IDrawableBatches");
                    }
                    // DRAWABLE BATCHES:  Only DrawableBatches remain so draw them all.
                    while (batchIndex < batches.Count)
                    {
                        IDrawableBatch batchAtIndex = batches[batchIndex];
                        if (batchAtIndex.UpdateEveryFrame)
                        {
                            batchAtIndex.Update();
                        }

                        if (Renderer.RecordRenderBreaks)
                        {
                            // Even though we aren't using a RenderBreak here, we should record a render break
                            // for this batch as it does cause rendering to be interrupted:
                            RenderBreak renderBreak = new RenderBreak();
#if DEBUG
                            renderBreak.ObjectCausingBreak = batchAtIndex;
#endif
                            renderBreak.LayerName = CurrentLayerName;
                            LastFrameRenderBreakList.Add(renderBreak);
                        }

                        batchAtIndex.Draw(camera);

                        batchIndex++;
                    }

                    FixRenderStatesAfterBatchDraw();
                    break;
                }
                #endregion

                #endregion

                #region more than 1 list remains so find which group of objects to render

                #region Sprites

                else if (nextSpriteSortValue <= nextTextSortValue && nextSpriteSortValue <= nextBatchSortValue)
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw Sprites");
                    }
                    // The next furthest object is a Sprite.  Find how many to draw.

                    #region Count how many Sprites to draw and store it in numberToDraw
                    numberToDraw = 0;

                    if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                        sortingValue = mVisibleSprites[spriteIndex + numberToDraw].Position.Z;
                    else
                        sortingValue = -(camera.Position - mVisibleSprites[spriteIndex + numberToDraw].Position).LengthSquared();

                    while (sortingValue <= nextTextSortValue &&
                           sortingValue <= nextBatchSortValue)
                    {
                        numberToDraw++;
                        if (spriteIndex + numberToDraw == mVisibleSprites.Count)
                        {
                            break;
                        }

                        if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                            sortingValue = mVisibleSprites[spriteIndex + numberToDraw].Position.Z;
                        else
                            sortingValue = -(camera.Position - mVisibleSprites[spriteIndex + numberToDraw].Position).LengthSquared();

                    }
                    #endregion

                    if (sortType == SortType.DistanceAlongForwardVector)
                    {
                        for (int i = indexOfNextSpriteToReposition; i < numberToDraw + spriteIndex; i++)
                        {
                            mVisibleSprites[i].Position = mVisibleSprites[i].mOldPosition;
                            indexOfNextSpriteToReposition++;
                        }
                    }

                    PrepareSprites(
                        mSpriteVertices, mSpriteRenderBreaks,
                        mVisibleSprites, spriteIndex,
                        numberToDraw);

                    DrawSprites(
                        mSpriteVertices, mSpriteRenderBreaks,
                        mVisibleSprites, spriteIndex,
                        numberToDraw, camera);

                    // numberToDraw represents a range so increase spriteIndex by that amount.
                    spriteIndex += numberToDraw;

                    if (spriteIndex >= mVisibleSprites.Count)
                    {
                        nextSpriteSortValue = float.PositiveInfinity;
                    }
                    else
                    {
                        if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                            nextSpriteSortValue = mVisibleSprites[spriteIndex].Position.Z;
                        else
                            nextSpriteSortValue = -(camera.Position - mVisibleSprites[spriteIndex].Position).LengthSquared();
                    }
                }

                #endregion

                #region Texts


                else if (nextTextSortValue <= nextSpriteSortValue && nextTextSortValue <= nextBatchSortValue)// draw texts
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw Texts");
                    }
                    numberToDraw = 0;

                    if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                        sortingValue = mVisibleTexts[textIndex + numberToDraw].Position.Z;
                    else
                        sortingValue = -(camera.Position - mVisibleTexts[textIndex + numberToDraw].Position).LengthSquared();


                    while (sortingValue <= nextSpriteSortValue &&
                           sortingValue <= nextBatchSortValue)
                    {
                        numberToDraw++;
                        if (textIndex + numberToDraw == mVisibleTexts.Count)
                        {
                            break;
                        }

                        if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                            sortingValue = mVisibleTexts[textIndex + numberToDraw].Position.Z;
                        else
                            sortingValue = -(camera.Position - mVisibleTexts[textIndex + numberToDraw].Position).LengthSquared();

                    }

                    if (sortType == SortType.DistanceAlongForwardVector)
                    {
                        for (int i = textIndex; i < textIndex + numberToDraw; i++)
                        {
                            mVisibleTexts[i].Position = mVisibleTexts[i].mOldPosition;
                        }
                    }

                    DrawTexts(mVisibleTexts, textIndex, numberToDraw, camera, section);

                    textIndex += numberToDraw;

                    if (textIndex == mVisibleTexts.Count)
                        nextTextSortValue = float.PositiveInfinity;
                    else
                    {
                        if (sortType == SortType.Z || sortType == SortType.DistanceAlongForwardVector)
                            nextTextSortValue = mVisibleTexts[textIndex].Position.Z;
                        else
                            nextTextSortValue = -(camera.Position - mVisibleTexts[textIndex].Position).LengthSquared();
                    }

                }

                #endregion

                #region Batches


                else if (nextBatchSortValue <= nextSpriteSortValue && nextBatchSortValue <= nextTextSortValue)
                {
                    if (section != null)
                    {
                        if (Section.Context != performDrawingSection)
                        {
                            Section.EndContextAndTime();
                        }
                        Section.GetAndStartMergedContextAndTime("Draw IDrawableBatches");
                    }
                    while (nextBatchSortValue <= nextSpriteSortValue && nextBatchSortValue <= nextTextSortValue && batchIndex < batches.Count)
                    {
                        IDrawableBatch batchAtIndex = batches[batchIndex];

                        if (batchAtIndex.UpdateEveryFrame)
                        {
                            batchAtIndex.Update();
                        }

                        if(Renderer.RecordRenderBreaks)
                        {
                            // Even though we aren't using a RenderBreak here, we should record a render break
                            // for this batch as it does cause rendering to be interrupted:
                            RenderBreak renderBreak = new RenderBreak();
#if DEBUG
                            renderBreak.ObjectCausingBreak = batchAtIndex;
#endif
                            renderBreak.LayerName = CurrentLayerName;
                            LastFrameRenderBreakList.Add(renderBreak);
                        }

                        batchAtIndex.Draw(camera);

                        batchIndex++;

                        if (batchIndex == batches.Count)
                        {
                            nextBatchSortValue = float.PositiveInfinity;
                        }
                        else
                        {
                            batchAtIndex = batches[batchIndex];

                            if (sortType == SortType.Z)
                            {
                                nextBatchSortValue = batchAtIndex.Z;
                            }
                            else if (sortType == SortType.DistanceAlongForwardVector)
                            {
                                Vector3 vectorDifference = new Vector3(
                                batchAtIndex.X - camera.X,
                                batchAtIndex.Y - camera.Y,
                                batchAtIndex.Z - camera.Z);

                                float firstDistance;
                                Vector3 forwardVector = camera.RotationMatrix.Forward;

                                Vector3.Dot(ref vectorDifference, ref forwardVector, out firstDistance);

                                nextBatchSortValue = -firstDistance;
                            }
                            else
                            {
                                nextBatchSortValue = -(batchAtIndex.Z * batchAtIndex.Z);
                            }
                        }
                    }

                    FixRenderStatesAfterBatchDraw();
                }


                #endregion

                #endregion
            }

            if (section != null)
            {
                // Hop up a level
                if (Section.Context != performDrawingSection)
                {
                    Section.EndContextAndTime();
                }
                Section.EndContextAndTime();
                Section.GetAndStartContextAndTime("End of Draw Mixed");
            }

            // return the position of any objects not drawn
            if (sortType == SortType.DistanceAlongForwardVector)
            {
                for (int i = indexOfNextSpriteToReposition; i < mVisibleSprites.Count; i++)
                {
                    mVisibleSprites[i].Position = mVisibleSprites[i].mOldPosition;
                }
            }

#if !SILVERLIGHT
            Renderer.Texture = null;
            Renderer.TextureOnDevice = null;
#endif
            if (section != null)
            {
                Section.EndContextAndTime();
            }
        }
Example #54
0
        public void SetRootAsControlPointClick(Window callingWindow)
        {
            Sprite topRoot;
            SpriteList allChildren;
            if (((Button)callingWindow).Text == "Set Root As Control Point")
            {
                topRoot = (Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent;
                allChildren = new SpriteList();
                topRoot.GetAllDescendantsOneWay(allChildren);

                foreach (Sprite sprite in allChildren)
                {
                    if(sprite is EditorSprite)
                        ((EditorSprite)sprite).type = "Root Control";
                }

                ((EditorSprite)topRoot).type = "Top Root Control";
                ((Button)callingWindow).Text = "Clear Root Control Point";
            }
            else
            {
                topRoot = (Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent;
                allChildren = new SpriteList();
                topRoot.GetAllDescendantsOneWay(allChildren);

                foreach (Sprite sprite in allChildren)
                {
                    ((EditorSprite)sprite).type = "Root Control";
                }
                
                ((EditorSprite)topRoot).type = "";
                ((Button)callingWindow).Text = "Set Root As Control Point";
            }
        }
Example #55
0
        private static void SortAllLists(SpriteList spriteList, SortType sortType, PositionedObjectList<Text> textList, List<IDrawableBatch> batches, bool relativeToCamera, Camera camera)
        {
            StoreOldPositionsForDistanceAlongForwardVectorSort(spriteList, sortType, textList, batches, camera);


            #region Sort the SpriteList and get the number of visible Sprites in numberOfVisibleSprites
            if (spriteList != null && spriteList.Count != 0)
            {
                lock (spriteList)
                {
                    switch (sortType)
                    {
                        case SortType.Z:
                        case SortType.DistanceAlongForwardVector:
                            // Sorting ascending means everything will be drawn back to front.  This
                            // is slower but necessary for translucent objects.
                            // Sorting descending means everything will be drawn back to front.  This
                            // is faster but will cause problems for translucency.
                            spriteList.SortZInsertionAscending();
                            break;
                        case SortType.DistanceFromCamera:
                            spriteList.SortCameraDistanceInsersionDescending(camera);
                            break;
                        case SortType.ZSecondaryParentY:
                            spriteList.SortZInsertionAscending();

                            spriteList.SortParentYInsertionDescendingOnZBreaks();

                            break;
                        case SortType.CustomComparer:

                            if (mSpriteComparer != null)
                            {
                                spriteList.Sort(mSpriteComparer);
                            }
                            else
                            {
                                spriteList.SortZInsertionAscending();
                            }

                            break;
                        case SortType.None:
                            // This will improve render times slightly...maybe?
                            spriteList.SortTextureInsertion();
                            break;
                        default:
                            break;
                    }
                }
            }
            #endregion

            #region Sort the TextList
            if (textList != null && textList.Count != 0)
            {
                switch (sortType)
                {
                    case SortType.Z:
                    case SortType.DistanceAlongForwardVector:
                        textList.SortZInsertionAscending();
                        break;
                    case SortType.DistanceFromCamera:
                        textList.SortCameraDistanceInsersionDescending(camera);
                        break;
                    case SortType.CustomComparer:
                        if (mTextComparer != null)
                        {
                            textList.Sort(mTextComparer);
                        }
                        else
                        {
                            textList.SortZInsertionAscending();
                        }


                        break;
                    default:
                        break;
                }
            }
            #endregion

            #region Sort the Batches
            if (batches != null && batches.Count != 0)
            {
                switch (sortType)
                {
                    case SortType.Z:
                        // Z serves as the radius if using SortType.DistanceFromCamera.
                        // If Z represents actual Z or radius, the larger the value the further
                        // away from the camera the object will be.
                        SortBatchesZInsertionAscending(batches);
                        break;
                    case SortType.DistanceAlongForwardVector:
                        batches.Sort(new FlatRedBall.Graphics.BatchForwardVectorSorter(camera));
                        break;

                    case SortType.CustomComparer:

                        if (mDrawableBatchComparer != null)
                        {
                            batches.Sort(mDrawableBatchComparer);
                        }
                        else
                        {
                            SortBatchesZInsertionAscending(batches);
                        }

                        break;

                }
            }
            #endregion
        }
Example #56
0
        public void CopyCurrentObjects(Window callingWindow)
        {
            if ((GameData.EditorLogic.CurrentSprites.Count != 0) ||
                (GameData.EditorLogic.CurrentSpriteFrames.Count != 0) ||
                (GameData.EditorLogic.CurrentPositionedModels.Count != 0) ||
                (GameData.EditorLogic.CurrentTexts.Count != 0))
            {
                int instructionNum = 0;

                #region Copy Sprites

                if (SpriteEditorSettings.EditingSprites)
                {

                    // remove the in-screen markers and axes so they don't get touched by the copying
                    GameData.EditorLogic.EditAxes.CurrentObject = null;

                    Sprite topSpriteAdded = null;
                    AttachableList<Sprite> oldestParents = AttachableList<Sprite>.GetTopParents<Sprite, Sprite>(GameData.EditorLogic.CurrentSprites);
                    SpriteList addedSprites = new SpriteList();

                    // The appendedNumbers variable is used for improving performance when copying large groups.  When a Sprite
                    // is copied, it is given a number at the end of its name or if there is already a number present,
                    // it is incremented.  However, copying large groups can result in a lot of string checking which
                    // can hurt performance.
                    // Consider copying 100 Sprites with the same texture.  Their names will likely be redball1, redball2,
                    // redball3, ... redball100.  Let's say redball1 gets copied first.  The SpriteEditor increments the
                    // number at the end to redball2, then checks to see if there is already a Sprite with that name.  If
                    // there is, it increments to redball3 and so on.  This must be conducted on average 10,000 times and each
                    // iteration requires string copying, concatenation, and parsing for integers.  To cut this down, the 
                    // appendedNumbers variable associates a given name (in this case redball) with the last integer appended
                    // to that particular name.  Therefore, when the first Sprite is created, it will loop through 1 - 100 and
                    // eventually end up at redball101.  It will then associate the number 101 with the name redball.  The next
                    // Sprite (named redball2) will know to begin at redball101.  This increases the performance of
                    // copying large groups from O(n^2) to O(n).

                    Dictionary<string, int> appendedNumbers = new Dictionary<string, int>();

                    foreach (Sprite s in oldestParents)
                    {
                        if (s is ISpriteEditorObject)
                        {
                            if (GuiData.ToolsWindow.groupHierarchyControlButton.IsPressed)
                            {
                                topSpriteAdded =
                                    GameData.copySpriteHierarchy(
                                        s, s.Parent as Sprite, GameData.EditorProperties.PixelSize, addedSprites, appendedNumbers);
                            }
                            else
                            {
                                topSpriteAdded =
                                    GameData.copySpriteHierarchy(
                                        s.TopParent as Sprite, null, GameData.EditorProperties.PixelSize, addedSprites, appendedNumbers);
                            }
                        }
                        SpriteList tempSpriteArray = new SpriteList();
                        topSpriteAdded.GetAllDescendantsOneWay(tempSpriteArray);
                        tempSpriteArray.Add(topSpriteAdded);

                    }

                    GameData.EditorLogic.EditAxes.CurrentObject =
                        GameData.EditorLogic.CurrentSprites[0];

                    GameData.Cursor.ClickSprite(null);
                    foreach (Sprite s in AttachableList<Sprite>.GetTopParents<Sprite, Sprite>(addedSprites))
                    {
                        // the 2nd true forces selection of all Sprites
                        GameData.Cursor.ClickObject<Sprite>(s, GameData.EditorLogic.CurrentSprites, true, true);
                    }

                    GameData.Cursor.VerifyAndUpdateGrabbedAgainstCurrent();
                }
                #endregion

                #region Copy SpriteGrids
                else if (SpriteEditorSettings.EditingSpriteGrids)
                {
                    SpriteGrid sg = SESpriteGridManager.CurrentSpriteGrid.Clone();


                    FlatRedBall.Utilities.StringFunctions.MakeNameUnique<SpriteGrid>(sg, GameData.Scene.SpriteGrids);


                    this.sesgMan.PopulateAndAddGridToEngine(sg, GameData.EditorLogic.CurrentSprites[0]);

                    sg.RefreshPaint();
                }
                #endregion

                #region Copy SpriteFrames
                else if (SpriteEditorSettings.EditingSpriteFrames)
                {
                    GameData.EditorLogic.EditAxes.CurrentObject = null;

                    AttachableList<SpriteFrame> oldestParents =
                        AttachableList<SpriteFrame>.GetTopParents<SpriteFrame, SpriteFrame>(GameData.EditorLogic.CurrentSpriteFrames);
                    foreach (SpriteFrame sf in oldestParents)
                    {
                        SpriteFrame topSpriteFrameAdded = GameData.CopySpriteFrameHierarchy(sf, null, GameData.EditorProperties.PixelSize);
                        GameData.Cursor.ClickSpriteFrame(topSpriteFrameAdded);
                    }
                }
                #endregion

                #region Copy Models

                else if (SpriteEditorSettings.EditingModels)
                {
                    GameData.EditorLogic.EditAxes.CurrentObject = null;

                    AttachableList<PositionedModel> oldestParents =
                        AttachableList<PositionedModel>.GetTopParents<PositionedModel, PositionedModel>(GameData.EditorLogic.CurrentPositionedModels);
                    foreach (PositionedModel model in oldestParents)
                    {

                        PositionedModel topSpriteFrameAdded =
                            GameData.CopyModelHierarchy(model, null, GameData.EditorProperties.PixelSize);

                        //         GameData.cursor.ClickSpriteFrame(topSpriteFrameAdded);
                    }
                }

                #endregion

                #region Copy Texts

                else if (SpriteEditorSettings.EditingTexts)
                {
                    GameData.EditorLogic.EditAxes.CurrentObject = null;

                    AttachableList<Text> oldestParents =
                        AttachableList<Text>.GetTopParents<Text, Text>(GameData.EditorLogic.CurrentTexts);
                    foreach (Text text in oldestParents)
                    {

                        Text topText =
                            GameData.CopyTextHierarchy(text, null, GameData.EditorProperties.PixelSize);

                        //         GameData.cursor.ClickSpriteFrame(topSpriteFrameAdded);
                    }

                }

                #endregion

            }
        }