public AnimatedSprite()
 {
     name = SpriteEnum.Not_Initialized;
     index = Index.Index_Null;
     sprite = null;
     imgToSwap = null;
 }
 public void set(SpriteEnum sName, ImageEnum iName, Index index = Index.Index_Null)
 {
     this.name = sName;
     this.index = index;
     sprite = GameSpriteManager.find(sName, index);
     imgToSwap = ImageManager.find(iName);
 }
 public void set(BaseSprite spr)
 {
     this.sprite = spr;
     Debug.Assert(sprite != null);
     this.name = (SpriteEnum)spr.getName();
     this.index = spr.getIndex();
 }
示例#4
0
        public override void Render(BufferedGraphics graphics)
        {
            for (int y = 0; y < _map.Layout.GetLength(0); y++)
            {
                for (int x = _map.Layout.GetLength(1) - 1; x >= 0; x--)
                {
                    SpriteEnum    sprinteEnum = _map.Layout[y, x];
                    SpriteDetails sprite      = _spriteSheets.GetSprite(sprinteEnum);
                    if (sprite != null)
                    {
                        // This is the point where the sprite should be painted.
                        Point pointOnScreen = GraphicsHelper.ConvertMapCoordsToWindowCoords(x, y, _graphicsTracker.MapOffset);

                        // Calculate the anchor location of the sprite.

                        var anchor = new Point(sprite.Location.X + sprite.Location.Width / 2, sprite.Location.Y + sprite.Location.Height - 32);

                        int xx = anchor.X - sprite.Location.X;
                        int yy = anchor.Y - sprite.Location.Y;

                        Point realPoint = new Point(pointOnScreen.X - xx, pointOnScreen.Y - yy);

                        graphics.Graphics.DrawImage(sprite.Bitmap, realPoint);
                        graphics.Graphics.DrawString(y + "," + x, _fontsAndColors.MonospaceFontSmaller,
                                                     _fontsAndColors.BlackBrush, pointOnScreen);
                    }
                }
            }
        }
 /// <summary>
 /// Gets the sprite.
 /// </summary>
 /// <returns>The sprite.</returns>
 /// <param name="_spriteEnum">Sprite enum.</param>
 public Sprite GetSprite(SpriteEnum _spriteEnum)
 {
     if (!sprites.Exists(item => item.spriteEnum == _spriteEnum))
     {
         return(null);
     }
     return(sprites.FirstOrDefault(item => item.spriteEnum == _spriteEnum).sprite);
 }
 /// <summary>
 /// Determines whether this instance has sprite of the specified _spriteEnum.
 /// </summary>
 /// <returns><c>true</c> if this instance has sprite the specified _spriteEnum; otherwise, <c>false</c>.</returns>
 /// <param name="_spriteEnum">Sprite enum.</param>
 public bool HasSprite(SpriteEnum _spriteEnum)
 {
     if (sprites.FirstOrDefault(item => item.spriteEnum == _spriteEnum).sprite != null)
     {
         return(true);
     }
     return(false);
 }
示例#7
0
 protected BaseSprite()
 {
     this.index = Index.Index_Null;
     this.name = SpriteEnum.Not_Initialized;
     this.batch = null;
     this.xPos = 0f;
     this.yPos = 0f;
     this.sprColor = null;
 }
        public SpriteDetails GetSprite(SpriteEnum spriteEnum)
        {
            SpriteDetails details = _spriteDetails[spriteEnum];

            if (details.Bitmap == null)
            {
                details.Bitmap = details.Spritesheet.Clone(details.Location, details.Spritesheet.PixelFormat);
            }
            return(details);
        }
        public void set(SpriteEnum sName, Index index, Azul.Color color, float x, float y, float width, float height)
        {
            //Debug.Assert(color != null);

            this.setBase(sName, index, 0.0f, 0.0f);
            lineWidth = 1.0f;
            this.sprColor = color;
            rect = new Azul.Rect(x, y, width, height);
            line = new Azul.Line(this.lineWidth, this.sprColor, x, y, x + width, y + height);
        }
示例#10
0
 public Sprite(SpriteEnum _name, float _screenX, float _screenY, float _width, float _height, bool _alpha, int _depth, Image _image, bool _isLine)
 {
     width      = _width;
     height     = _height;
     alpha      = _alpha;
     image      = _image;
     depth      = _depth;
     isLine     = _isLine;
     spriteName = _name;
 }
示例#11
0
 public ProxySprite(SpriteEnum sName, Index index, float x, float y)
     : base()
 {
     this.setBase(sName, index, x, y);
     this.spriteRef = GameSpriteManager.find(sName);
     Debug.Assert(spriteRef != null);
     this.sprColor = new Azul.Color(1, 1, 1);
     this.scaleX = spriteRef.getScaleX();
     this.scaleY = spriteRef.getScaleY();
 }
示例#12
0
 public Sprite(SpriteEnum _name, float _screenX, float _screenY, float _width, float _height, bool _alpha, int _depth, Image _image, bool _isLine)
 {
     width = _width;
     height = _height;
     alpha = _alpha;
     image = _image;
     depth = _depth;
     isLine = _isLine;
     spriteName = _name;
 }
示例#13
0
 public GameObject(GameObject.Name goName, SpriteEnum name, Index index, Azul.Color color, Azul.Color colColor, float x, float y)
 {
     this.colObj = new CollisionObject(name, index, colColor);
     this.goColor = color;
     this.name = goName;
     this.index = index;
     this.x = x;
     this.y = y;
     angle = 0.0f;
     sx = 1;
     sy = 1;
 }
 /// <summary>
 /// Sets the sprite enum and sprite
 /// </summary>
 /// <param name="_spriteEnum">Sprite enum.</param>
 public void SetSpriteEnum(SpriteEnum _spriteEnum)
 {
     m_spriteEnum = _spriteEnum;
     if (UISpriteManager.Instance.HasSprite(m_spriteEnum))
     {
         this.sprite = UISpriteManager.Instance.GetSprite(m_spriteEnum);
     }
     else
     {
         Debug.LogError("ImageExtension-OnGameObject: " + name + "   Has no sprite related to Enum: " + _spriteEnum.ToString());
     }
 }
        public ProxyCollisionSprite(Azul.Color color, SpriteEnum name, Index index)
            : base()
        {
            Debug.Assert(color != null);
            //Debug.Assert(name.Equals(SpriteEnum.Collision));
            //Debug.Assert(index.Equals(Index.Index_Null));

            setBase(name, index, 0.0f, 0.0f);
            colSprite = CollisionSpriteManager.find(SpriteEnum.Collision, Index.Index_Null);
            grid = new Azul.Rect();
            gridColor = color;
        }
        public static CollisionSprite add(SpriteEnum sName, Index index, Azul.Color color, float x, float y, float width, float height)
        {
            CollisionSprite sprite = (CollisionSprite)Instance.baseAdd();

            // Needs to be adjusted for the rectangle
            x -= width / 2;
            y -= height / 2;

            sprite.set(sName, index, color, x, y, width, height);

            return sprite;
        }
示例#17
0
        public TextSprite(SpriteEnum _name, SpriteFont _refFont, string _mes, Vector2 _pos, Color _color, float _scale)
        {
            refFont = _refFont;
            message = _mes;
            pos     = _pos;
            color   = _color;
            scale   = _scale;

            spriteSpeed = new Vector2((rnd.Next(0, 2) * 2) - 1, (rnd.Next(0, 2) * 2) - 1);
            size        = refFont.MeasureString(message);

            spriteName = _name;
        }
示例#18
0
        public TextSprite(SpriteEnum _name, SpriteFont _refFont, string _mes, Vector2 _pos, Color _color, float _scale)
        {
            refFont = _refFont;
            message = _mes;
            pos = _pos;
            color = _color;
            scale = _scale;

            spriteSpeed = new Vector2((rnd.Next(0, 2) * 2) - 1, (rnd.Next(0, 2) * 2) - 1);
            size = refFont.MeasureString(message);

            spriteName = _name;
        }
        public static CollisionSprite find(SpriteEnum name, Index index = Index.Index_Null)
        {
            CollisionSprite ret;

            if (name.Equals(SpriteEnum.Null))
            {
                ret = Instance.nullSpr;
            }
            else
            {
                ret = (CollisionSprite)Instance.baseFind(name, index);
            }

            return ret;
        }
        public static GameSprite find(SpriteEnum se, Index index = Index.Index_Null)
        {
            GameSprite spr;

            if (se.Equals(SpriteEnum.Null))
            {
                spr = Instance.nullObj;
            }
            else
            {
                spr = (GameSprite)Instance.baseFind(se, index);
            }

            return spr;
        }
示例#21
0
 public CollisionObject(SpriteEnum name, Index index, Azul.Color color)
 {
     if (!name.Equals(SpriteEnum.Null))
     {
         GameSprite spr = GameSpriteManager.find(name);
         this.colSpr = new ProxyCollisionSprite(color, name, index);
         this.colBounds = new Azul.Rect(spr.Rect.x, spr.Rect.y, spr.Rect.w, spr.Rect.h);
         this.colBounds.x -= colBounds.w / 2;
         this.colBounds.y += colBounds.h / 2;
     }
     else
     {
         this.colSpr = new ProxyCollisionSprite(color, name, index);
         this.colBounds = new Azul.Rect();
     }
 }
 /// <summary>
 /// Sets the sprite enum, sprite and perform action OnSuccess
 /// </summary>
 /// <param name="_spriteEnum">Sprite enum.</param>
 /// <param name="_onSuccess">On success.</param>
 public void SetSpriteAndPerform(SpriteEnum _spriteEnum, Action _onSuccess)
 {
     m_spriteEnum = _spriteEnum;
     if (UISpriteManager.Instance.HasSprite(m_spriteEnum))
     {
         this.sprite = UISpriteManager.Instance.GetSprite(m_spriteEnum);
         if (_onSuccess != null)
         {
             _onSuccess();
         }
     }
     else
     {
         Debug.LogError("ImageExtension-OnGameObject: " + name + "   Has no sprite related to Enum: " + _spriteEnum.ToString());
     }
 }
示例#23
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.Space();

            serializedObject.Update();
            EditorGUILayout.PropertyField(m_AutoSetOnEnable);
            EditorGUILayout.PropertyField(m_SpriteEnum);

            if (GUILayout.Button("Set Image Now"))
            {
                SpriteEnum enumValue = (SpriteEnum)Enum.Parse(typeof(SpriteEnum), ((int)(m_SpriteEnum.enumValueIndex)).ToString());
                if (UISpriteManager.Instance.HasSprite(enumValue))
                {
                    m_Sprite.objectReferenceValue = UISpriteManager.Instance.GetSprite(enumValue);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
示例#24
0
 public void setName(SpriteEnum s)
 {
     this.name = s;
 }
示例#25
0
 public Squid(GameObject.Name goName, SpriteEnum sName, Index index, float x, float y)
     : base(goName, sName, index, x, y)
 {
 }
示例#26
0
 public Bomb(Name name, Index index, SpriteEnum sName, Azul.Color color, BombBehavior behavior, float x, float y)
     : base(name, sName, index, color, new Azul.Color(1f, 0f, 0f), x, y)
 {
     this.sprite = new ProxySprite(sName, index, x, y);
     this.behavior = behavior;
 }
示例#27
0
 public NullGameSprite(SpriteEnum name = SpriteEnum.Null, Index index = Index.Index_Null)
     : base(name, index)
 {
 }
示例#28
0
 public Crab(GameObject.Name goName, Index index, SpriteEnum sName, float x, float y)
     : base(goName, sName, index, x, y)
 {
     //colObj.Bounds = this.sprite.
 }
示例#29
0
 public Octopus(GameObject.Name goName, Index index, SpriteEnum sName, float x, float y)
     : base(goName, sName, index, x, y)
 {
 }
示例#30
0
 public void set(SpriteEnum sName, Index index, ImageEnum iName, float x, float y, float width, float height)
 {
     base.setBase(sName, index, x, y);
     this.img = ImageManager.find(iName);
     this.sprite = new Azul.Sprite2D(this.img.getTexture(), this.img.TexCoords, new Azul.Rect(x, y, width, height));
     this.sprRect = new Azul.Rect(x, y, width, height);
     angle = 0;
     scaleX = this.sprite.sx;
     scaleY = this.sprite.sy;
 }
示例#31
0
 public bool HasSprite(SpriteEnum _spriteEnum)
 {
     return(spriteData.HasSprite(_spriteEnum));
 }
示例#32
0
 public void set(SpriteEnum sName, Index index, float x, float y)
 {
     this.setBase(sName, index, x, y);
     this.spriteRef = GameSpriteManager.find(sName);
     Debug.Assert(spriteRef != null);
 }
 public NullCollisionSprite(SpriteEnum name = SpriteEnum.Null, Index index = Index.Index_Null)
     : base()
 {
     this.Rect = new Azul.Rect();
 }
示例#34
0
 public Alien(GameObject.Name goName, SpriteEnum sprName, Index index, float x, float y)
     : base(goName, sprName, index, new Azul.Color(1f, 1f, 1f), new Azul.Color(1.0f, 0.0f, 0.0f), x, y)
 {
     sprite = new ProxySprite(sprName, index, x, y);
 }
示例#35
0
 public SpriteBatchNode()
     : base()
 {
     this.name = SpriteEnum.Not_Initialized;
     this.index = Index.Index_Null;
 }
 public static void remove(SpriteEnum name, Index index = Index.Index_Null)
 {
     Instance.baseRemove(name, index);
 }
示例#37
0
 public Sprite GetSprite(SpriteEnum _spriteEnum)
 {
     return(spriteData.GetSprite(_spriteEnum));
 }
示例#38
0
 protected GameSprite(SpriteEnum name, Index index)
 {
     base.setBase(name, index, 0.0f, 0.0f);
 }
 public static void detach(SpriteEnum sName, Index index = Index.Index_Null)
 {
     Instance.baseRemove(sName, index);
 }
示例#40
0
 public ShieldBlock(Name name, Index index, SpriteEnum type, float x, float y)
     : base(name, type, index, new Azul.Color(0f, 1f, 0f), new Azul.Color(0f, 0f, 1f), x, y)
 {
     this.sprite = new ProxySprite(type, index, x, y);
 }
示例#41
0
 public SpriteBatchNode find(SpriteEnum sName, Index index = Index.Index_Null)
 {
     return (SpriteBatchNode)this.Find(sName, index);
 }
示例#42
0
        public GeneratedMap GenerateMap()
        {
            var random = new Random();

            int mapWidth  = random.Next(10, 20);
            int mapHeight = random.Next(10, 15);

            bool[,] map = new bool[mapHeight, mapWidth];
            for (int i = 0; i < mapHeight; i++)
            {
                for (int j = 0; j < mapWidth; j++)
                {
                    map[i, j] = true;
                }
            }

            // Make some percentage impassable.
            int totalCount           = mapWidth * mapHeight;
            int impassablePercentage = random.Next(10, 20);
            int impassableCount      = (int)Math.Ceiling(totalCount * ((float)impassablePercentage / 100));

            for (int i = 0; i < impassableCount; i++)
            {
                int x = random.Next(0, map.GetLength(0) - 1);
                int y = random.Next(0, map.GetLength(1) - 1);

                map[x, y] = false;
            }

            // Generate a start and an end.
            int start = random.Next(0, mapHeight - 1);
            int end   = random.Next(0, mapHeight - 1);

            Point startPoint = new Point(0, start);
            Point endPoint   = new Point(mapWidth - 1, end);

            // Create the final map. (with impassable tiles)
            SpriteEnum[,] spriteMap = new SpriteEnum[mapHeight, mapWidth];
            for (int h = 0; h < spriteMap.GetLength(0); h++)
            {
                for (int w = 0; w < spriteMap.GetLength(1); w++)
                {
                    spriteMap[h, w] = map[h, w] ? SpriteEnum.LandscapeGrass : SpriteEnum.LandscapeMinerals;
                }
            }

            // Generate a path.
            List <Point> path     = _pathCreator.CreatePath(map, startPoint, endPoint);
            Point        previous = Point.Empty;

            for (int i = 0; i < path.Count; i++)
            {
                SpriteDirectionEnum from;
                SpriteDirectionEnum to;

                Point next = i == path.Count - 1 ? Point.Empty : path[i + 1];

                Point current = path[i];
                if (i == 0)
                {
                    from = SpriteDirectionEnum.BottomLeft;
                    if (next.X > current.X)
                    {
                        to = SpriteDirectionEnum.TopRight;
                    }
                    else if (next.Y < current.Y)
                    {
                        to = SpriteDirectionEnum.TopLeft;
                    }
                    else if (next.Y > current.Y)
                    {
                        to = SpriteDirectionEnum.BottomRight;
                    }
                    else
                    {
                        throw new Exception("That's unexpected.");
                    }
                }
                else
                {
                    if (previous.Y == current.Y)
                    {
                        // Straight.
                        from = SpriteDirectionEnum.BottomLeft;
                    }
                    else if (previous.Y > current.Y)
                    {
                        from = SpriteDirectionEnum.BottomRight;
                    }
                    else if (previous.Y < current.Y)
                    {
                        from = SpriteDirectionEnum.TopLeft;
                    }
                    else
                    {
                        throw new Exception("That's unexpected.");
                    }

                    if (i == path.Count - 1)
                    {
                        // The last one.
                        to = SpriteDirectionEnum.TopRight;
                    }
                    else
                    {
                        if (next.X > current.X)
                        {
                            to = SpriteDirectionEnum.TopRight;
                        }
                        else if (next.Y < current.Y)
                        {
                            to = SpriteDirectionEnum.TopLeft;
                        }
                        else if (next.Y > current.Y)
                        {
                            to = SpriteDirectionEnum.BottomRight;
                        }
                        else
                        {
                            throw new Exception("That's unexpected.");
                        }
                    }
                }
                previous = path[i];

                if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeRoadUp;
                }
                else if (from == SpriteDirectionEnum.TopLeft && to == SpriteDirectionEnum.BottomRight ||
                         from == SpriteDirectionEnum.BottomRight && to == SpriteDirectionEnum.TopLeft)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeRoadDown;
                }
                else if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.BottomRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomLeftBottomRight;
                }
                else if (from == SpriteDirectionEnum.TopLeft && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnTopLeftTopRight;
                }
                else if (from == SpriteDirectionEnum.BottomLeft && to == SpriteDirectionEnum.TopLeft)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomLeftTopLeft;
                }
                else if (from == SpriteDirectionEnum.BottomRight && to == SpriteDirectionEnum.TopRight)
                {
                    spriteMap[current.Y, current.X] = SpriteEnum.LandscapeTurnBottomRightTopRight;
                }
                else
                {
                    throw new Exception("That's unexpected.");
                }
            }
            return(new GeneratedMap
            {
                Map = spriteMap,
                Path = path
            });
        }
 public DisplayObject getDisplayObj(SpriteEnum _enum)
 {
     return((DisplayObject)privFind(_enum));
 }