Ejemplo n.º 1
0
        public StagedGraphic StageGraphic(string filePath, string id)
        {
            var definition = File.ReadAllLines(filePath).Where(l => l.Length > 0)
                             .Where(l => l.ToLower().StartsWith("graphic") && l.Contains($"id={id}"))
                             .FirstOrDefault();

            if (definition.Length == 0)
            {
                return(new StagedGraphic());
            }

            var work = definition.Split(';');

            GraphicType type = GraphicType.None;

            for (int i = 0; i < work.Length; i++)
            {
                var pair = work[i].Split('=');
                if (pair[0].Trim().ToLower() == "graphic")
                {
                    type = ParseType(pair[1].Trim().ToLower());
                    break;
                }
            }

            if (type == GraphicType.None)
            {
                return(new StagedGraphic());
            }

            var stagedGraphic = new StagedGraphic(id, filePath, type);

            return(stagedGraphic);
        }
Ejemplo n.º 2
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type)
        {
            int vWidth; int vHeight;

            IntRange vBounds;

            try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); }

            //Plants only care for verts
            //This is assuming PLANTS TAKE UP A FULL TILE!!
            // TODO : Refactor
            if (type == GraphicType.Plant)
            {
                return(new Vector2(
                           1f,
                           (float)(vBounds.max - vBounds.min) / (float)vHeight));
            }

            int hWidth; int hHeight;

            IntRange hBounds;

            try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); }

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Ejemplo n.º 3
0
        public void Draw(SpriteBatch spritebatch, int angle, Color tint, Vector2 position, GraphicType gtype)
        {
            int gidx = (int)gtype;
            int closesta=int.MaxValue;
            FramePair current;
            int i, j = 0;

            if (pairs == null || pairs.Length < 1)
                return;
            current = pairs[0];

            for (i = 0; i < pairs.Length; ++i)
            {
                if (Math.Max(pairs[i].deg, angle) - Math.Min(pairs[i].deg, angle) < closesta)
                {
                    closesta = Math.Max(pairs[i].deg, angle) - Math.Min(pairs[i].deg, angle);
                    current = pairs[i];
                    j = i;
                    if (closesta == 0)
                        break;

                }
            }
            System.Diagnostics.Trace.WriteLine(j);

            parts[gidx].invertHorizontal = current.flip;
            parts[gidx].gotoAndStop(current.frame);
            // TODO(xoorath): don't hard code 128*128
            parts[gidx].Draw(spritebatch, new Rectangle((int)position.X, (int)position.Y, 128, 128), tint, 0.0f);

            if (SnakeManager.Instance().DFont != null)
                spritebatch.DrawString(SnakeManager.Instance().DFont, j.ToString() + " : " + angle.ToString(), position, Color.White);
        }
Ejemplo n.º 4
0
 public void ShouldInsertGraphicTypeWhenDBContextIsValid()
 {
     furniture = CreateGraphicType();
     _spacePlanningUnitOfWork.GraphicTypeRepository.Add(furniture);
     _spacePlanningUnitOfWork.Save();
     Assert.IsTrue(_spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId) != null);
 }
    private void SetInitialValues()
    {
        initialRectValues = new TransformAnimationRecord()
        {
            Position      = rectTransform.anchoredPosition,
            Scale         = rectTransform.localScale,
            RotationEuler = rectTransform.rotation.eulerAngles,
            Pivot         = rectTransform.pivot,
            AnchorMin     = rectTransform.anchorMin,
            AnchorMax     = rectTransform.anchorMax
        };

        if (graphic)
        {
            if (graphic is Image)
            {
                graphicType = GraphicType.Image;
                img         = GetComponent <Image>();
            }
            else if (graphic is Text)
            {
                graphicType = GraphicType.Text;
                txt         = GetComponent <Text>();
            }

            initialGraphicValues = new GraphicAnimationRecord()
            {
                Color  = graphic.color,
                Sprite = (graphicType == GraphicType.Image) ? img.sprite : null,
                Text   = (graphicType == GraphicType.Text) ? txt.text : "",
            };
        }
    }
Ejemplo n.º 6
0
 public SnakeNode(SnakeNode a_Follow, SegmentType a_SegmentType, GraphicType a_GraphicType, Vector2 a_Translation)
 {
     m_Follow      = a_Follow;
     SegmentType   = a_SegmentType;
     m_GraphicType = a_GraphicType;
     Position      = Vector2.Zero + a_Translation;
 }
Ejemplo n.º 7
0
 public static Vector2 BoundMap(Graphic graphic, GraphicType type)
 {
     if (!boundMap.ContainsKey(graphic.path))
     {
         boundMap[graphic.path] = ExtractBounds(graphic, type);
     }
     return(boundMap[graphic.path]);
 }
Ejemplo n.º 8
0
        GraphicInfo GraphicInfoFromType(GraphicType type)
        {
            var info = new GraphicInfo
            {
                Width         = 16,
                Height        = 16,
                GraphicFormat = GraphicFormat.Palette5Bit
            };

            switch (type)
            {
            case GraphicType.Tileset1:
            case GraphicType.Tileset2:
            case GraphicType.Tileset3:
            case GraphicType.Tileset4:
            case GraphicType.Tileset5:
            case GraphicType.Tileset6:
            case GraphicType.Tileset7:
            case GraphicType.Tileset8:
                info.Alpha = true;
                break;

            case GraphicType.Player:
                info.Width  = 16;
                info.Height = 32;
                info.Alpha  = true;
                break;

            case GraphicType.Portrait:
                info.Width  = 32;
                info.Height = 32;
                break;

            case GraphicType.Item:
                info.Width  = 16;
                info.Height = 16;
                break;

            case GraphicType.Layout:
                info.Width         = 320;
                info.Height        = 163;
                info.GraphicFormat = GraphicFormat.Palette3Bit;
                info.PaletteOffset = 24;
                info.Alpha         = true;
                break;

            case GraphicType.LabBackground:
                info.Width         = 144;
                info.Height        = 20;
                info.GraphicFormat = GraphicFormat.Palette4Bit;
                info.PaletteOffset = 0;
                info.Alpha         = false;
                break;
                // TODO
            }

            return(info);
        }
Ejemplo n.º 9
0
 public static Vector2 BoundMap(Graphic graphic, GraphicType type)
 {
     if (!boundMap.ContainsKey(graphic.path))
     {
         try { boundMap[graphic.path] = ExtractBounds(graphic, type); }
         catch (Exception e) { throw new Exception("BoundMap(,)", e); }
     }
     return(boundMap[graphic.path]);
 }
Ejemplo n.º 10
0
 public SlotItemAlbumDetailTextureInfo(GraphicType graphicType, int graphicSlotItemId, Vector3 scale, Vector3 offset, bool needPixelPerfect)
 {
     mGraphicSlotItemMstId = graphicSlotItemId;
     mGraphicType          = graphicType;
     mWidth            = -1;
     mHeight           = -1;
     mVector3_Offset   = offset;
     mVector3_Scale    = scale;
     mNeedPixelPerfect = needPixelPerfect;
 }
Ejemplo n.º 11
0
        public static Vector2 BoundMap(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            string path = graphic.path + (headGraphic == null ? "" : "+" + headGraphic.path);

            if (!boundMap.ContainsKey(path))
            {
                boundMap[path] = ExtractBounds(graphic, type, headGraphic, headOffset);
            }
            return(boundMap[path]);
        }
Ejemplo n.º 12
0
 public SlotItemAlbumDetailTextureInfo(GraphicType graphicType, int graphicSlotItemId, Vector3 scale, Vector3 offset, int width, int height)
 {
     mGraphicSlotItemMstId = graphicSlotItemId;
     mGraphicType          = graphicType;
     mWidth            = width;
     mHeight           = height;
     mVector3_Offset   = offset;
     mVector3_Scale    = scale;
     mNeedPixelPerfect = false;
 }
Ejemplo n.º 13
0
        public void SetDiagrammValues(float[,] values)
        {
            quadsCount     = new Vector2(values.GetLength(0), values.GetLength(1));
            diagramm       = new Mesh[values.GetLength(0), values.GetLength(1)];
            diagrammValues = values;
            type           = GraphicType.Diagramm;

            CreateDiagramm();
            Invalidate();
        }
Ejemplo n.º 14
0
        public string LoadList(string stSql)
        {
            try
            {
                tBoxGridX.Text = "";
                tBoxGridY.Text = "";
                tBoxMaxX.Text  = "";
                tBoxMaxY.Text  = "";
                tBoxMinX.Text  = "";
                tBoxMinY.Text  = "";

                using (var reader = new ReaderAdo(ConnectionString, stSql))
                {
                    while (reader.Read())
                    {
                        switch (reader.GetString("GraficType"))
                        {
                        case "График":
                            _graphicType = GraphicType.Graphic;
                            break;

                        case "График0":
                            _graphicType = GraphicType.Graphic0;
                            break;

                        case "Диаграмма":
                            _graphicType = GraphicType.Diagram;
                            break;
                        }
                        string uS = "(" + reader.GetString("UnitsX2") + ")";
                        if (uS == "()")
                        {
                            uS = "";
                        }
                        chart1.ChartAreas[0].AxisX.Title = reader.GetString("NameX2") + uS;
                        uS = "(" + reader.GetString("UnitsX1") + ")";
                        if (uS == "()")
                        {
                            uS = "";
                        }
                        chart1.ChartAreas[0].AxisY.Title = reader.GetString("NameX1") + uS;
                        chart1.Titles[0].Text            = reader.GetString("Code");
                        //_graphicId = int.Parse(reader.GetString("GraficId"));
                        _dim = reader.GetInt("Dimension");
                        chart1.Legends[0].Enabled = _dim >= 3;
                    }
                }
                return("");
            }
            catch (Exception exception)
            {
                Error = new ErrorCommand("Траблы с LoadParams", exception);
                return(ErrorMessage);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Constructs a new instance of the <see cref="BaseGraphic" /> class
        /// with properties filed from XML
        /// </summary>
        /// <param name="type">Type of the graphic</param>
        /// <param name="xml">XML to read properties from</param>
        public BaseGraphic(GraphicType type, XmlNode xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }

            Type = type;

            ID = xml.Attributes["id"].Value;
        }
Ejemplo n.º 16
0
        public static Vector2 BoundMap(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            string path = graphic.path + (headGraphic == null ? "" : "+" + headGraphic.path);

            if (!boundMap.ContainsKey(path))
            {
                try { boundMap[path] = ExtractBounds(graphic, type, headGraphic, headOffset); }
                catch (Exception e) { throw new Exception("BoundMap(,,,)", e); }
            }
            return(boundMap[path]);
        }
Ejemplo n.º 17
0
        private GraphicType CreateGraphicType()
        {
            furniture = new GraphicType()
            {
                GraphicTypeId = Guid.NewGuid(),
                Name          = "furniture",
                Description   = "Group of furniture"
            };

            return(furniture);
        }
Ejemplo n.º 18
0
        public void ShouldUpdateGraphicTypeWhenDBContextIsValid()
        {
            furniture = CreateGraphicType();
            string graphicName = "New GraphicName";

            _spacePlanningUnitOfWork.GraphicTypeRepository.Add(furniture);
            _spacePlanningUnitOfWork.Save();
            this.furniture      = _spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId);
            this.furniture.Name = graphicName;
            _spacePlanningUnitOfWork.Save();
            Assert.AreEqual(graphicName, _spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId).Name);
        }
Ejemplo n.º 19
0
        void LoadGraphics(GraphicType type)
        {
            if (!graphics.ContainsKey(type))
            {
                graphics.Add(type, new List <Graphic>());
                var reader      = new GraphicReader();
                var info        = GraphicInfoFromType(type);
                var graphicList = graphics[type];

                void LoadGraphic(IDataReader graphicDataReader, byte maskColor = 0)
                {
                    graphicDataReader.Position = 0;
                    int end = graphicDataReader.Size - info.DataSize;

                    while (graphicDataReader.Position <= end)
                    {
                        var graphic = new Graphic();
                        reader.ReadGraphic(graphic, graphicDataReader, info, maskColor);
                        graphicList.Add(graphic);
                    }
                }

                var allFiles = new SortedDictionary <int, IDataReader>();

                foreach (var graphicFile in graphicFiles[type])
                {
                    var containerFile = gameData.Files[graphicFile.File];

                    if (graphicFile.SubFiles == null)
                    {
                        foreach (var file in containerFile.Files)
                        {
                            allFiles[graphicFile.FileIndexOffset + file.Key] = file.Value;
                        }
                    }
                    else
                    {
                        foreach (var file in graphicFile.SubFiles)
                        {
                            allFiles[graphicFile.FileIndexOffset + file] = containerFile.Files[file];
                        }
                    }
                }

                foreach (var file in allFiles)
                {
                    LoadGraphic(file.Value, (byte)(type switch
                    {
                        GraphicType.Portrait => 25,
                        GraphicType.LabBackground => 9, // 9 is the sky color index
                        _ => 0
                    }));
Ejemplo n.º 20
0
        private void CreateElementUser()
        {
            Element     chairElement;
            GraphicType graphicType = new GraphicType()
            {
                GraphicTypeId = Guid.NewGuid(),
                Name          = "Straight", Description = "Straight"
            };
            Graphic graphic = new Graphic()
            {
                GraphicId     = Guid.NewGuid(),
                Height        = 100,
                Width         = 200,
                GraphicTypeId = graphicType.GraphicTypeId,
                Name          = "Straight",
                Description   = "Group of Straight"
            };

            graphic.GraphicType = graphicType;
            _spacePlanningUnitOfWork.Save();
            _spacePlanningUnitOfWork.GraphicRepository.Add(graphic);
            _spacePlanningUnitOfWork.Save();
            ElementType chairs = new ElementType {
                ElementTypeId = Guid.NewGuid(),
                Name          = "chairs", Description = "chairs"
            };

            chairElement = new Element()
            {
                ElementId     = Guid.NewGuid(),
                GraphicId     = graphic.GraphicId,
                ElementTypeId = chairs.ElementTypeId,
                Description   = "computer Chair",
                Label         = "tx chair"
            };
            chairElement.ElementType = chairs;
            _spacePlanningUnitOfWork.ElementypeRepository.Add(chairs);
            _spacePlanningUnitOfWork.Save();
            User user = new User()
            {
                Username = "******", Password = "******",
                UserId   = Guid.NewGuid()
            };

            _spacePlanningUnitOfWork.UserRepository.Add(user);
            _spacePlanningUnitOfWork.Save();
            ownerUser = new ElementUser()
            {
                ElementId = chairElement.ElementId, UserId = user.UserId,
                Element   = chairElement, User = user
            };
        }
Ejemplo n.º 21
0
        void LoadGraphics(GraphicType type)
        {
            if (!graphics.ContainsKey(type))
            {
                graphics.Add(type, new List <Graphic>());
                var reader      = new GraphicReader();
                var info        = GraphicInfoFromType(type);
                var graphicList = graphics[type];

                void LoadGraphic(IDataReader graphicDataReader)
                {
                    graphicDataReader.Position = 0;
                    int end = graphicDataReader.Size - info.DataSize;

                    while (graphicDataReader.Position <= end)
                    {
                        var graphic = new Graphic();
                        reader.ReadGraphic(graphic, graphicDataReader, info);
                        graphicList.Add(graphic);
                    }
                }

                var allFiles = new SortedDictionary <int, IDataReader>();

                foreach (var graphicFile in graphicFiles[type])
                {
                    var containerFile = gameData.Files[graphicFile.File];

                    if (graphicFile.SubFiles == null)
                    {
                        foreach (var file in containerFile.Files)
                        {
                            allFiles[graphicFile.FileIndexOffset + file.Key] = file.Value;
                        }
                    }
                    else
                    {
                        foreach (var file in graphicFile.SubFiles)
                        {
                            allFiles[graphicFile.FileIndexOffset + file] = containerFile.Files[file];
                        }
                    }
                }

                foreach (var file in allFiles)
                {
                    LoadGraphic(file.Value);
                }
            }
        }
 void Awake()
 {
     if (GetComponent <SpriteRenderer>() != null)
     {
         graphicRenderer = GetComponent <SpriteRenderer>();
         defaultSprite   = ((SpriteRenderer)graphicRenderer).sprite;
         graphicType     = GraphicType.SPRITERENDERER;
     }
     else if (GetComponent <Image>() != null)
     {
         graphicRenderer = GetComponent <Image>();
         defaultSprite   = ((Image)graphicRenderer).sprite;
         graphicType     = GraphicType.IMAGE;
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Определяет график, необходимый к отображению
 /// </summary>
 /// <param name="e">An object that contains the navigation data.</param>
 public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
 {
     try
     {
         graphicType = (GraphicType)int.Parse(e.Fragment);
         if (graphicType == GraphicType.Followers)
             PrintGraphicFollowers();
         else if (graphicType == GraphicType.Following)
             PrintGraphicFollowing();
         else PrintGraphicMedia();
     }
     catch(Exception exc)
     {
        Client.Pages.MainPage.ShowMessage(ApiServer.ErrorMessageForClient);
     }
 }
Ejemplo n.º 24
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            int vWidth; int vHeight;

            IntRange vBounds;

            try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); }

            int hWidth; int hHeight;

            IntRange hBounds;

            try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); }

            int vWidthHead; int vHeightHead;

            IntRange vBoundsHead;

            try { vBoundsHead = Def_Extensions.CropVertical((headGraphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + headGraphic.path + "_east", ex); }

            vBoundsHead.min -= (int)(headOffset.y * (float)vHeightHead);
            vBoundsHead.max -= (int)(headOffset.y * (float)vHeightHead);

            vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead));
            vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead));

            int hWidthHead; int hHeightHead;

            IntRange hBoundsHead;

            try { hBoundsHead = Def_Extensions.CropHorizontal((headGraphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + headGraphic.path + "_south", ex); }

            hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead);
            hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead);

            hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead));
            hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead));

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Ejemplo n.º 25
0
        private Texture LoadTexture(GraphicType graphicType, int graphicShipId)
        {
            switch (graphicType)
            {
            case GraphicType.Card:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 3));

            case GraphicType.ShipNormal:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 9));

            case GraphicType.ShipTaiha:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 10));

            default:
                return(null);
            }
        }
Ejemplo n.º 26
0
        private void CreateGeometryAndExtentForTrackOrRoute(GeometryData data, GraphicType typeOfGraphic)
        {
            var builder = new PolylineBuilder(new SpatialReference(4326));

            foreach (var wayPoint in data.Points)
            {
                builder.AddPoint(new MapPoint((double)wayPoint.lon, (double)wayPoint.lat));
            }
            var esriGeometry = builder.ToGeometry();

            data.Extent = esriGeometry.Extent;
            var geometry = new BikeTouringGISGraphic(esriGeometry, typeOfGraphic);

            geometry.Attributes["name"]     = data.Name;
            geometry.Attributes["filename"] = data.FileName;
            data.Geometry = geometry;
        }
Ejemplo n.º 27
0
        private void CreateDesktop()
        {
            GraphicType graphicType = new GraphicType()
            {
                GraphicTypeId = Guid.NewGuid(),
                Name          = "Straight",
                Description   = "Straight"
            };

            desktop = new Graphic()
            {
                GraphicId     = Guid.NewGuid(),
                Height        = 100,
                Width         = 200,
                GraphicTypeId = graphicType.GraphicTypeId,
                Name          = "Straight",
                Description   = "Group of Straight"
            };
            desktop.GraphicType = graphicType;
        }
Ejemplo n.º 28
0
        private Texture LoadTexture(GraphicType graphicType, int graphicShipId)
        {
            switch (graphicType)
            {
            case GraphicType.First:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 1));

            case GraphicType.Second:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 2));

            case GraphicType.Third:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 3));

            case GraphicType.Fourth:
                return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 4));

            default:
                return(null);
            }
        }
Ejemplo n.º 29
0
        public static void FillTwoColumnMatrix(this double[][] matrix, GraphicType graphicType, double decreaseCoeff,
                                               double increaseCoeff)
        {
            var rows    = matrix.Length;
            var columns = matrix[0].Length;

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    if (j == 0)
                    {
                        matrix[i][j] = i + 1;
                    }
                    else
                    {
                        matrix[i][j] = (i + 1) * ((i + j) % 2 == 0 ? decreaseCoeff : increaseCoeff);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Loads a new graphics from a wad
        /// </summary>
        /// <param name="lumpName"></param>
        /// <param name="file"></param>
        public Graphic(WadFile file, string lumpName)
        {
            lump = file[lumpName];

            using (MemoryStream stream = lump.RawStream())
            {
                // Move to png marker
                stream.ReadByte();

                bool png  = IsPng(stream);
                bool jfif = false;

                if (!png)
                {
                    stream.Position = 4;
                    for (int i = 0; i < 2; i++)
                    {
                        stream.ReadByte();
                    }
                    jfif = IsJfif(stream);
                }

                if (png)
                {
                    Type = GraphicType.Png;
                }
                else if (jfif)
                {
                    Type = GraphicType.Jpeg;
                }
                else
                {
                    Type      = GraphicType.DoomPatch;
                    doomImage = new DoomGraphic(lump, file.Pallete(0));
                }
            }
        }
Ejemplo n.º 31
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type)
        {
            int vWidth; int vHeight;

            var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight);

            //Plants only care for verts
            //This is assuming PLANTS TAKE UP A FULL TILE!!
            // TODO : Refactor
            if (type == GraphicType.Plant)
            {
                return(new Vector2(
                           1f,
                           (float)(vBounds.max - vBounds.min) / (float)vHeight));
            }

            int hWidth; int hHeight;

            var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight);

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Ejemplo n.º 32
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            int vWidth; int vHeight;

            var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight);

            int hWidth; int hHeight;

            var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight);

            int vWidthHead; int vHeightHead;

            var vTexHead    = headGraphic.MatSide.mainTexture as Texture2D;
            var vBoundsHead = Def_Extensions.CropVertical(vTexHead.GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead);

            vBoundsHead.min += (int)(headOffset.y * (float)vHeightHead);
            vBoundsHead.max += (int)(headOffset.y * (float)vHeightHead);

            vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead));
            vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead));

            int hWidthHead; int hHeightHead;

            var hTexHead    = headGraphic.MatFront.mainTexture as Texture2D;
            var hBoundsHead = Def_Extensions.CropVertical(hTexHead.GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead);

            hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead);
            hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead);

            hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead));
            hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead));

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Ejemplo n.º 33
0
 public SnakeNode(SnakeNode a_Follow, SegmentType a_SegmentType, GraphicType a_GraphicType, Vector2 a_Translation)
 {
     m_Follow = a_Follow;
     SegmentType = a_SegmentType;
     m_GraphicType = a_GraphicType;
     Position = Vector2.Zero + a_Translation;
 }