コード例 #1
0
ファイル: FlatChunk.cs プロジェクト: RichardBradley/MMEd
        public override List <string> GetDifferences(Chunk xiChunk)
        {
            FlatChunk lOther = xiChunk as FlatChunk;

            if (DeclaredIdx != lOther.DeclaredIdx ||
                DeclaredName != lOther.DeclaredName ||
                !OriginPosition.Equals(lOther.OriginPosition) ||
                !RotationVector.Equals(lOther.RotationVector) ||
                Width != lOther.Width ||
                Height != lOther.Height ||
                ScaleX != lOther.ScaleX ||
                ScaleY != lOther.ScaleY ||
                HasMetaData != lOther.HasMetaData ||
                FlgB != lOther.FlgB ||
                FlgC != lOther.FlgC ||
                Visible != lOther.Visible ||
                FlgE != lOther.FlgE ||
                !Utils.ArrayCompare(TerrainHeight, lOther.TerrainHeight) ||
                !Utils.ArrayCompare(TextureIds, lOther.TextureIds) ||
                !Utils.ArrayCompare(TexMetaData, lOther.TexMetaData))
            {
                List <string> lRet = base.GetDifferences(xiChunk);
                lRet.Add("Changed flat #" + DeclaredIdx.ToString() + " (" + DeclaredName + ")");
                return(lRet);
            }

            return(base.GetDifferences(xiChunk));
        }
コード例 #2
0
 public SpriteArrayFrameSource(Texture t)
 {
     GLThread.ExecuteGLThreadAsync(() =>
     {
         Frames       = AutoDetectFrames(t);
         FrameOffsets = new Vector2[Frames.Length];
         FrameOrigins = new OriginPosition[Frames.Length];
     });
 }
コード例 #3
0
ファイル: FlatChunk.cs プロジェクト: RichardBradley/MMEd
 public void WriteToStream(BinaryWriter bout)
 {
     RotationVector.WriteShort3Coord64(bout);
     OriginPosition.WriteShort3Coord64(bout);
     bout.Write(ObjtType);
     StreamUtils.WriteByteFlag(bout, FlagUnknown);
     StreamUtils.WriteByteFlag(bout, IsSolid);
     bout.Write(ShortUnknown);
 }
コード例 #4
0
        public void InitialLocationPositionTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);

            OriginPosition pos = iOrigin.Begin.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));
        }
コード例 #5
0
        public void RefreshOrigin(Sprite sprite, OriginPosition origin, Vector2f customOrigin)
        {
            if (origin < 0)
            {
                sprite.Origin = customOrigin;
                return;
            }

            float x = (int)origin % 3 / 2f;
            float y = (int)origin / 3 / 2f;

            sprite.Origin = new Vector2f(sprite.GetLocalBounds().Width *x, sprite.GetLocalBounds().Height *y);
        }
コード例 #6
0
        public void EmptySourcePositionTest()
        {
            string source = "";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            OriginPosition pos = iReader.CurrentLocation.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));

            Assert.IsFalse(iReader.MoveNext());
            pos = iReader.CurrentLocation.GetOriginPosition();
            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 0));
        }
コード例 #7
0
        public void OneLineEndPositionTest()
        {
            string source = "1234";

            iOrigin = CreateOriginTest(source);
            iReader = iOrigin.GetReader();

            while (iReader.MoveNext())
            {
                ;
            }

            OriginPosition pos = iReader.CurrentLocation.GetOriginPosition();

            Assert.IsTrue((pos.LineNumber == 1) && (pos.CharNumber == 4));
        }
コード例 #8
0
		private void MoveRenderOrigin(OriginPosition position)
		{
			if (position == OriginPosition.Center)
			{
				RenderOriginPoint = new Point(0.5, 0.5);
				ScaleX = ScaleY = 1;
				return;
			}
			if (position == OriginPosition.Top)
			{
				RenderOriginPoint = new Point(0.5, 0);
				ScaleX = 1;
				ScaleY = 1.8;
				return;
			}

			if (position == OriginPosition.Bottom)
			{
				RenderOriginPoint = new Point(0.5, 1);
				ScaleX = 1;
				ScaleY = 1.8;
				return;
			}

			if (position == OriginPosition.TopLeft)
				RenderOriginPoint = new Point(0, 0);

			if (position == OriginPosition.TopRight)
				RenderOriginPoint = new Point(1, 0);

			if (position == OriginPosition.BottomLeft)
				RenderOriginPoint = new Point(0, 1);

			if (position == OriginPosition.BottomRight)
				RenderOriginPoint = new Point(1, 1);
			ScaleX = ScaleY = 2;
		}
コード例 #9
0
    public override void CalculateTargetRotation()
    {
        targetDirection = Target.position.FlattenY() - OriginPosition.FlattenY();

        Target.rotation = targetDirection != Vector3.zero ? Quaternion.LookRotation(targetDirection, Vector3.up) : Quaternion.identity;
    }
コード例 #10
0
 public override void MakeSchemaCompliant()
 {
     base.MakeSchemaCompliant();
     OriginPosition.MakeSchemaCompliant();
     Interval.MakeSchemaCompliant();
 }
コード例 #11
0
ファイル: FlatChunk.cs プロジェクト: RichardBradley/MMEd
        public override void Serialise(Stream outStr)
        {
            BinaryWriter bout = new BinaryWriter(outStr);

            //header
            bout.Write(DeclaredIdx);
            StreamUtils.WriteASCIINullTermString(outStr, DeclaredName);
            OriginPosition.WriteShort3Coord64(bout);
            RotationVector.WriteShort3Coord64(bout);
            bout.Write(Width);
            bout.Write(Height);
            bout.Write(ScaleX);
            bout.Write(ScaleY);

            //every flat has a tex array:
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    bout.Write(TextureIds[x][y]);
                    bout.Write(TerrainHeight[x][y]);
                }
            }

            //General flags
            StreamUtils.WriteShortFlag(bout, HasMetaData);
            StreamUtils.WriteShortFlag(bout, FlgB);
            StreamUtils.WriteShortFlag(bout, FlgC);
            StreamUtils.WriteShortFlag(bout, Visible);
            StreamUtils.WriteByteFlag(bout, FlgE); //N.B. byte here. See Deserialise.

            //what do these mean?
            bout.Write(NextN);

            //unless (HasMetaData), we're done...
            if (HasMetaData)
            {
                //load the tex metadata
                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        bout.Write(TexMetaData[x][y]);
                    }
                }

                //objects:
                bout.Write((short)Objects.Length);
                foreach (ObjectEntry o in Objects)
                {
                    o.WriteToStream(bout);
                }

                //weapons:
                bout.Write((short)Weapons.Length);
                foreach (WeaponEntry w in Weapons)
                {
                    w.WriteToStream(bout);
                }
            }

            //pool5 hack:
            if (TrailingData != null)
            {
                bout.Write(TrailingData);
            }
        }