1. schottenrock
  2. Anis

Commits

hans...@hanswurst_pc.fritz.box  committed 73f191c

Initial project

  • Participants
  • Branches default

Comments (0)

Files changed (11)

File AnIs/AnIs.csproj

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectGuid>{5E82E0DC-9E7F-4A17-80A0-DC24080D910F}</ProjectGuid>
+    <ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AnIs</RootNamespace>
+    <AssemblyName>AnIs</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
+    <XnaPlatform>Windows</XnaPlatform>
+    <XnaProfile>HiDef</XnaProfile>
+    <XnaCrossPlatformGroupID>27787431-92ff-4218-8a39-f8ce384f4567</XnaCrossPlatformGroupID>
+    <XnaOutputType>Library</XnaOutputType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\x86\Debug</OutputPath>
+    <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoStdLib>true</NoStdLib>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <PlatformTarget>x86</PlatformTarget>
+    <XnaCompressContent>false</XnaCompressContent>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\x86\Release</OutputPath>
+    <DefineConstants>TRACE;WINDOWS</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoStdLib>true</NoStdLib>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <PlatformTarget>x86</PlatformTarget>
+    <XnaCompressContent>true</XnaCompressContent>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Video, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Avatar, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="mscorlib">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.Xml">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.Xml.Linq">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.Net">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="VitaminC.General">
+      <HintPath>..\..\VitaminC\VitaminC.General\bin\x86\Debug\VitaminC.General.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Camera.cs" />
+    <Compile Include="Helper.cs" />
+    <Compile Include="IRenderable.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Renderer.cs" />
+    <Compile Include="RenderSettings.cs" />
+    <Compile Include="Size.cs" />
+    <Compile Include="Tile\Map.cs" />
+    <Compile Include="Tile\Tile.cs" />
+    <Compile Include="Tile\TileIterator.cs" />
+    <Compile Include="Tile\Wall.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
+  <!--
+      To modify your build process, add your task inside one of the targets below and uncomment it. 
+      Other similar extension points exist, see Microsoft.Common.targets.
+      <Target Name="BeforeBuild">
+      </Target>
+      <Target Name="AfterBuild">
+      </Target>
+    -->
+</Project>

File AnIs/Camera.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis
+{
+    public class Camera
+    {
+        public Vector2 ViewPosition;
+    }
+}

File AnIs/Helper.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis
+{
+    public static class Helper
+    {
+        //
+        public static Vector2 DetermineTile( Vector2 somePosition, Camera someCamera, RenderSettings someRenderSettings )
+        {
+            //
+            Vector2 viewDiff = Vector2.Zero;
+            Vector2 tileCoord = Vector2.Zero;
+
+            if( someRenderSettings.Mode == RenderMode.Isometric2D )
+            {
+                viewDiff = somePosition - someCamera.ViewPosition;
+
+                tileCoord.X = (float)Math.Floor( ( viewDiff.Y + viewDiff.X / 2 ) / someRenderSettings.TileRenderSize.Height );
+                tileCoord.Y = (float)Math.Floor( ( viewDiff.Y - viewDiff.X / 2 ) / someRenderSettings.TileRenderSize.Height );
+            }
+            else if( someRenderSettings.Mode == RenderMode.Plane2D )
+            {
+                viewDiff = somePosition - someCamera.ViewPosition;
+
+                tileCoord.X = (float)Math.Floor( ( viewDiff.X / 2 ) / someRenderSettings.TileRenderSize.Height );
+                tileCoord.Y = (float)Math.Floor( ( viewDiff.Y / 2 ) / someRenderSettings.TileRenderSize.Height );
+            }
+
+            return tileCoord;
+        }
+
+        public static Vector2 DetermineTile( Vector2 someGridPosition, RenderSettings someRenderSettings )
+        {
+            //
+            Vector2 buffer = new Vector2();
+
+            buffer.X = (float)Math.Floor( someGridPosition.X );
+            buffer.Y = (float)Math.Floor( someGridPosition.Y );
+
+            return buffer;
+        }
+    }
+}

File AnIs/IRenderable.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis
+{
+    public interface IRenderable
+    {
+        Vector2 Position { get; set; }
+        Vector2 Scale { get; set; }
+        string AssetName { get; set; }
+        Vector2 Origin { get; set; }
+    }
+}

File AnIs/RenderSettings.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis
+{
+
+    public class RenderSettings
+    {
+        //
+        private Size myTileRenderSize;
+        public Size TileRenderSize { get { return myTileRenderSize; } set { myTileRenderSize = value; TileSizeChanged(); } }
+        //
+        private RenderMode myMode;
+        public RenderMode Mode { get { return myMode; } set { myMode = value; } }
+
+        //
+        private Vector2 myIsometricYAxis;
+        internal Vector2 IsometricYAxis { get { return myIsometricYAxis; } }
+
+        //
+        private Vector2 myIsometricXAxis;
+        internal Vector2 IsometricXAxis { get { return myIsometricXAxis; } }
+
+        //
+        public RenderSettings( Size someSize, RenderMode someMode )
+        {
+            //
+            TileRenderSize = someSize;
+            Mode = someMode;
+        }
+
+        private void TileSizeChanged()
+        {
+            //
+            myIsometricYAxis = 
+                new Vector2( -1, 1 ) * 0.5f * new Vector2( this.myTileRenderSize.Width, this.myTileRenderSize.Height );
+
+            myIsometricXAxis =
+                new Vector2( 1, 1 ) * 0.5f * new Vector2( this.myTileRenderSize.Width, this.myTileRenderSize.Height );
+        }
+    }
+
+    public enum RenderMode
+    {
+        Isometric2D,
+        Plane2D
+    };
+}

File AnIs/Renderer.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis
+{
+    /**/
+    public partial class Renderer
+        //general stuff
+    {
+        VitaminC.General.IContentContainer myCC;
+
+        public RenderSettings RenderSettings;
+
+        private Texture2D myBuffer_Texture;
+        private Vector2 myBuffer_Scale;
+        private Vector2 myBuffer_RenderPosition;
+        private Vector2 myBuffer_Origin;
+
+        private Game Game;
+
+        //
+        public Renderer( Game someGame )
+        {
+            //            
+            this.Game = someGame;
+        }
+
+        //
+        public void Initialize( VitaminC.General.IContentContainer someContentContainer, RenderMode someMode = RenderMode.Plane2D ,int someTileRenderWidth = 32, int someTileRenderHeight = 32 )
+        {
+            myCC = someContentContainer;
+            //
+            this.RenderSettings = new RenderSettings( new Size( someTileRenderWidth, someTileRenderHeight ), someMode );            
+        }
+
+    }
+    /**/
+    
+
+    /**/
+    public partial class Renderer
+        //tile rendering
+    {
+        //
+        public void Render( Tile.Tile someTile, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            switch( this.RenderSettings.Mode )
+            {
+                //
+                case RenderMode.Plane2D: this.RenderPlane( someTile, someRenderTarget, startPos ); break;
+                case RenderMode.Isometric2D: this.RenderIsometric( someTile, someRenderTarget, startPos ); break;
+                default: throw new InvalidOperationException();
+            }
+        }
+
+        private void RenderPlane( Tile.Tile someTile, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            myBuffer_Texture = myCC.Retrieve<Texture2D>( someTile.Type );
+            //
+            myBuffer_Scale = new Vector2(
+                 (float)this.RenderSettings.TileRenderSize.Width / (float)myBuffer_Texture.Bounds.Width,
+                 (float)this.RenderSettings.TileRenderSize.Height / (float)myBuffer_Texture.Bounds.Height ); 
+            //
+            myBuffer_RenderPosition = startPos;
+            //
+            myBuffer_RenderPosition += someTile.Position * new Vector2( this.RenderSettings.TileRenderSize.Width, this.RenderSettings.TileRenderSize.Height );
+
+            //
+            someRenderTarget.Draw
+                (
+                    myBuffer_Texture,
+                    myBuffer_RenderPosition,
+                    myBuffer_Texture.Bounds,
+                    Color.White,
+                    0.0f,
+                    Vector2.Zero,
+                    myBuffer_Scale,
+                    SpriteEffects.None,
+                    1.0f
+                );
+        }
+
+        //
+        private void RenderIsometric( Tile.Tile someTile, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            myBuffer_Texture = myCC.Retrieve<Texture2D>( someTile.Type );
+            //
+            myBuffer_Scale = new Vector2(
+                 (float)this.RenderSettings.TileRenderSize.Width / (float)myBuffer_Texture.Bounds.Width,
+                 (float)this.RenderSettings.TileRenderSize.Height / (float)myBuffer_Texture.Bounds.Height ); 
+            //
+            myBuffer_Origin = new Vector2( myBuffer_Texture.Bounds.Width / 2.0f, 0.0f );
+            //
+            
+            myBuffer_RenderPosition =   startPos 
+                                        + ( RenderSettings.IsometricXAxis * someTile.Position.X ) 
+                                        + ( RenderSettings.IsometricYAxis * someTile.Position.Y );
+
+
+            //
+            someRenderTarget.Draw
+                (
+                    myBuffer_Texture,
+                    myBuffer_RenderPosition,
+                    myBuffer_Texture.Bounds,
+                    Color.White,
+                    0.0f,
+                    myBuffer_Origin,
+                    myBuffer_Scale,
+                    SpriteEffects.None,
+                    1.0f
+                );
+        }
+
+    }
+    /**/
+
+
+    /**/
+    public partial class Renderer
+        //tilewall rendering
+    {
+
+
+
+
+
+    }
+    /**/
+
+
+    /**/
+    public partial class Renderer
+        //general IRenderable rendering
+    {
+        public void Render( IRenderable someObjectToRender, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            switch( this.RenderSettings.Mode )
+            {
+                //
+                case RenderMode.Plane2D: this.RenderPlane( someObjectToRender, someRenderTarget, startPos ); break;
+                case RenderMode.Isometric2D: this.RenderIsometric( someObjectToRender, someRenderTarget, startPos ); break;
+                default: throw new InvalidOperationException();
+            }
+        }
+        private void RenderPlane( IRenderable someObjectToRender, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            myBuffer_Texture = myCC.Retrieve<Texture2D>( someObjectToRender.AssetName );
+            //
+            myBuffer_Scale = new Vector2(
+                 (float)this.RenderSettings.TileRenderSize.Width / (float)myBuffer_Texture.Bounds.Width,
+                 (float)this.RenderSettings.TileRenderSize.Height / (float)myBuffer_Texture.Bounds.Height );
+            //
+            myBuffer_RenderPosition = startPos;
+            //
+            myBuffer_RenderPosition +=
+                someObjectToRender.Position * new Vector2( this.RenderSettings.TileRenderSize.Width, this.RenderSettings.TileRenderSize.Height );
+
+            //
+            someRenderTarget.Draw
+                (
+                    myBuffer_Texture,
+                    myBuffer_RenderPosition,
+                    myBuffer_Texture.Bounds,
+                    Color.White,
+                    0.0f,
+                    Vector2.Zero,
+                    myBuffer_Scale,
+                    SpriteEffects.None,
+                    1.0f
+                );
+        }
+
+        //
+        private void RenderIsometric( IRenderable someObjectToRender, SpriteBatch someRenderTarget, Vector2 startPos )
+        {
+            //
+            myBuffer_Texture = myCC.Retrieve<Texture2D>( someObjectToRender.AssetName );
+            //
+            myBuffer_Scale = new Vector2(
+                 (float)this.RenderSettings.TileRenderSize.Width / (float)myBuffer_Texture.Bounds.Width,
+                 (float)this.RenderSettings.TileRenderSize.Height / (float)myBuffer_Texture.Bounds.Height );
+            //
+            myBuffer_RenderPosition = startPos
+                                        + ( RenderSettings.IsometricXAxis * someObjectToRender.Position.X )
+                                        + ( RenderSettings.IsometricYAxis * someObjectToRender.Position.Y );
+
+
+            //
+            someRenderTarget.Draw
+                (
+                    myBuffer_Texture,
+                    myBuffer_RenderPosition,
+                    myBuffer_Texture.Bounds,
+                    Color.White,
+                    0.0f,
+                    someObjectToRender.Origin,
+                    someObjectToRender.Scale,
+                    SpriteEffects.None,
+                    1.0f
+                );
+        }
+    }
+    /**/
+}

File AnIs/Size.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+
+namespace Anis
+{
+    public class Size
+    {
+        public int Width;
+        public int Height;
+
+        public Size( int someWidth, int someHeight )
+        {
+            //
+            this.Width = someWidth;
+            this.Height = someHeight;
+        }
+
+        public Vector2 ToVector2()
+        {
+            //
+            return new Vector2( (float)this.Width, (float)this.Height );
+        }
+    }
+}

File AnIs/Tile/Map.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis.Tile
+{
+    public partial class Map
+    {
+        //
+        public Dictionary<Vector2, Tile> Tiles;
+        public Size Dimensions;
+
+        //
+        public Map( int someWidth, int someHeight, string defaultType = "default" )
+        {
+            //
+            Dimensions = new Size( someWidth, someHeight );
+            Tiles = new Dictionary<Vector2, Tile>( someWidth * someHeight );
+
+            for( int y = 0; y < someHeight; ++y )
+            {
+                //
+                for( int x = 0; x < someWidth; ++x )
+                {
+                    //
+                    Vector2 v = new Vector2( x, y );
+                    Tiles.Add( v, new Tile() { Position = v, Type = defaultType } );
+                }
+            }
+        }        
+
+        //
+        public TileIterator GetIterator( Vector2 someStartPos, Vector2 someEndPoint )
+        {
+            //
+            return new TileIterator( this, someStartPos, someEndPoint );
+        }
+        //
+        public TileIterator GetIterator()
+        {
+            //
+            return this.GetIterator( Vector2.Zero, this.Dimensions.ToVector2() - new Vector2( 1, 1 ) );
+        }
+    }
+
+    
+}
+
+namespace AnotherIsoRendering.Tile
+{
+    
+
+}

File AnIs/Tile/Tile.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis.Tile
+{
+    public class Tile
+    {
+        //
+        public Vector2 Position;
+        public string Type;        
+    }
+}

File AnIs/Tile/TileIterator.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis.Tile
+{
+    public delegate void IterationEvent( object someSender, EventArgs someArgs );
+
+    public class TileIterator
+    {
+        private bool myIterationIsActive = false;
+        private readonly Vector2 myUpperLeftCornerBoundryPos;
+        private readonly Vector2 myLowerRightCornerBoundryPos;
+        private Vector2 myPosRunner;
+        private Vector2 myRootPos;
+        private Map myMapRef;
+
+        private int myStepsToMake;
+        private int myStepAmount;
+        public int Steps { get { return myStepAmount; } }
+
+        public IterationMode IterationMode;
+
+        public IterationEvent OnEndIteration;
+        public IterationEvent OnNewLine;
+
+        //
+        internal TileIterator( Map someMap, Vector2 someStartPos, Vector2 someEndPoint )
+        {
+            //
+            myMapRef = someMap;
+            //
+            myIterationIsActive = false;
+
+            myUpperLeftCornerBoundryPos = someStartPos;
+            myLowerRightCornerBoundryPos = someEndPoint;
+
+            myRootPos = myUpperLeftCornerBoundryPos;
+            myPosRunner = myRootPos;
+
+            Vector2 diff = someEndPoint - someStartPos;
+            diff += new Vector2( 1, 1 );
+            myStepsToMake = (int)( diff.X * diff.Y );
+            myStepAmount = 0;
+
+            IterationMode = IterationMode.YAligned;
+        }
+
+        //
+        public void Begin( IterationMode someMode )
+        {
+            //
+            myIterationIsActive = true;
+
+            myRootPos = myUpperLeftCornerBoundryPos;
+            myPosRunner = myRootPos;
+
+            myStepAmount = 0;
+
+            IterationMode = someMode;
+        }
+
+        //
+        public bool IsGood()
+        {
+            //
+            if( myPosRunner.X > myLowerRightCornerBoundryPos.X || myPosRunner.X < myUpperLeftCornerBoundryPos.X
+                ||
+                myPosRunner.Y > myLowerRightCornerBoundryPos.Y || myPosRunner.Y < myUpperLeftCornerBoundryPos.X
+                ||
+                !myIterationIsActive
+                ||
+                myStepAmount >= myStepsToMake )
+            { return false; }
+            else
+            { return true; }
+        }
+
+
+        //
+        public Tile NextTile()
+        {
+            if( !myIterationIsActive )
+            { return null; }
+
+            Tile t = myMapRef.Tiles[myPosRunner];
+
+            myPosRunner += ( IterationMode == IterationMode.Diagonal ) ? new Vector2( 1, -1 ) : new Vector2( 1, 0 );
+
+            myStepAmount++;
+
+            if( myPosRunner.Y < myUpperLeftCornerBoundryPos.X || myPosRunner.X > myLowerRightCornerBoundryPos.X )
+            {
+                if( myRootPos.Y == myLowerRightCornerBoundryPos.Y ) { myRootPos.X++; }
+                else { myRootPos.Y++; }
+
+                myPosRunner = myRootPos;
+
+                if( OnNewLine != null ) { OnNewLine( this, null ); }
+            }
+
+            return t;
+        }
+
+
+        //
+        public void End()
+        {
+            //
+            myIterationIsActive = false;
+
+            if( OnNewLine != null )
+            { OnEndIteration( this, null ); }
+        }
+    }
+
+    public enum IterationMode
+    {
+        //
+        Diagonal,
+        YAligned
+    }
+}

File AnIs/Tile/Wall.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Media;
+
+namespace Anis.Tile
+{
+    public class Wall
+    {
+        //
+        public Vector2 Position;
+        public string Type;
+    }
+}