Exemplo n.º 1
0
        public static void InitializeMapFromLevel(this AStarMap map, Tile[,] maptiles)
        {
            int yLength = maptiles.GetLength(0);
            int xLength = maptiles.GetLength(1);
            Node[,] aStarNodes;
            aStarNodes = new Node[yLength, xLength];
            for (int y = 0; y < yLength; y++)
            {
                for (int x = 0; x < xLength; x++)
                {
                    Walkable walkable = Walkable.Walkable;
                    switch (maptiles[y, x].TileType)
                    {
                        case TileType.Wall:
                        case TileType.Spike:
                            walkable = Walkable.Blocked;
                            break;

                        case TileType.Platform:
                            walkable = Walkable.Platform;
                            break;
                    }
                    if (walkable == Walkable.Walkable)
                    {
                        if (CheckForUnreachable(maptiles, y, x))
                            walkable = Walkable.NotReachable;

                    }

                    aStarNodes[y, x] = new Node(x, y, Tile.TILE_SIZE, walkable);
                }
            }
            AStarMap.InitializeMap(aStarNodes);
        }
Exemplo n.º 2
0
 public MapBoundsForm(StarEdit.LevelEditor.LevelWorker.TileOverLoad poverloader,Tile[,] oldTiles)
 {
     InitializeComponent();
     overloader = poverloader;
     oldtiles = oldTiles;
     SizeXBox.Value = oldtiles.GetLength(1);
     SizeYBox.Value = oldtiles.GetLength(0);
 }
Exemplo n.º 3
0
 public void ModifyTiles(Tile[,] poldTiles,Point pzeroPointModification,Point pnewSize,TileOverLoad poverloader)
 {
     percentage = 0;
     overloader = poverloader;
     oldTiles = poldTiles;
     zeroPointModification = pzeroPointModification;
     newSize = pnewSize;
     progessTimer.Enabled = true;
     worker = new Thread(new ThreadStart(ThreadModifiyTiles));
     worker.Start();
 }
Exemplo n.º 4
0
        public Quadtree(Tile[,] leveltiles, int layers)
        {
            levelBoundingBox = new Rectangle(
                0,
                0,
                leveltiles.GetLength(1) * Tile.TILE_SIZE,
                leveltiles.GetLength(0) * Tile.TILE_SIZE);
            rootNode = new QuadTreeNode(levelBoundingBox, layers, leveltiles);
            current_rects = new List<Rectangle>();
            MaxLayer = layers;

            enemyCollisionTiles = new List<Tile>[Environment.ProcessorCount];
            enemyiterateNodes = new List<QuadTreeNode>[Environment.ProcessorCount];
        }
Exemplo n.º 5
0
        private void CliffJump(float elapsed,Tile[,] map)
        {
            int xpos = (int)pos.X / Tile.TILE_SIZE;
            int ypos = (int)pos.Y / Tile.TILE_SIZE;
            if (xpos + 1 < map.GetLength(1) && xpos - 1 >= 0 && ypos + 1 < map.GetLength(0))
            {
                if (map[ypos + 1, xpos].Standable)
                    if (rundirection == StandardDirection.Left)
                    {
                        if (map[ypos + 1, xpos - 1].TileColission_Type == TileCollision.Passable)
                            Jump(elapsed, false,4);
                    }
                    else if (map[ypos + 1, xpos + 1].TileColission_Type == TileCollision.Passable && rundirection == StandardDirection.Right)
                        Jump(elapsed, false,4);

            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks if the specified Tile is Unreachable for the AStar Algorithm.<para>(KI can not reach it by walking or jumping)</para>
        /// </summary>
        /// <param name="maptiles">The Level Tiles</param>
        /// <param name="tileX">x Coordinate of the Specified Tile</param>
        /// <param name="tileY">y Coordinate of the Specified Tile</param>
        /// <returns><para>True if tile is unreachable</para>, <para>Fals if tile is reachable.</para></returns>
        private static bool CheckForUnreachable(Tile[,] maptiles, int tileX, int tileY)
        {
            bool unreachable = true;

            int yOffset;
            int xOffset;
            int mapYMax = maptiles.GetLength(1);
            int mapXMax = maptiles.GetLength(0);
            //Build a Pyramide with height of 3 under the CurrentMaptile to check if it is Unreachable
            for (xOffset = 1; xOffset <= 4 && unreachable && xOffset + tileX < mapXMax; xOffset++)
            {
                for (yOffset = -xOffset; yOffset <= xOffset && unreachable && yOffset + tileY < mapXMax && yOffset + tileY >= 0; yOffset++)
                {
                    unreachable = !maptiles[tileX + xOffset, tileY + yOffset].Standable;
                }
            }
            return unreachable;
        }
Exemplo n.º 7
0
        //public LevelVariables(string levelfilecontext,Tile[,] leveltiles)
        //{
        //    ErrorMessages = new List<string>();
        //    string[] leveldata = levelfilecontext.Split(';');
        //    dict = new Dictionary<string, string>();
        //    foreach (string data in leveldata)
        //    {
        //        string valuename;
        //        string value;
        //        string[] temp = data.Split('=');
        //        if (temp.Length > 1)
        //        {
        //            valuename = temp[0];
        //            value = temp[1];
        //            valuename = valuename.Trim();
        //            value = value.Trim();
        //            dict.Add(valuename, value);
        //        }
        //    }
        //    ParseDict();
        //    GetExit(leveltiles);
        //}
        public LevelVariables(string levelfilecontext, Tile[,] leveltiles)
        {
            ErrorMessages = new List<string>();
            lv = new Dictionary<LV, string>();
            dict = new Dictionary<string, string>();
            killrectangles = new List<Rectangle>();
            string[] leveldata = levelfilecontext.Split(';');

            foreach (string data in leveldata)
            {
                string valuename;
                string value;
                string[] temp = data.Split('=');
                if (temp.Length > 1)
                {
                    valuename = temp[0];
                    value = temp[1];
                    valuename = valuename.Trim();
                    value = value.Trim();

                    dict.Add(valuename, value);
                }
            }
            foreach(LV levelvariables in Enum.GetValues(typeof(LV)))
            {
                try
                {
                    if (dict.ContainsKey(levelvariables.ToString()))
                        lv.Add(levelvariables, dict[levelvariables.ToString()]);
                    else
                        lv.Add(levelvariables, "");
                }
                catch (Exception e)
                {
                    successfull = false;
                    ErrorMessages.Add("Failed to Load " + levelvariables.ToString() + "\n Additional Info: " + e.Message);
                }
            }
            ParseDict();
            GetExit(leveltiles);
        }
Exemplo n.º 8
0
 /// <summary>
 /// This Generates a last node in the Quadtree.
 /// It contains the Leveltiles which are important for the collision.
 /// </summary>
 /// <param name="parentRect">The Rectangle of the Parent Node</param>
 /// <param name="indicator"></param>
 /// <param name="levelTiles">The Tiles from the Level which should be included into the Quadtree</param>
 public QuadTreeNode(Rectangle parentRect, Tile[,] levelTiles)
 {
     Rectangle intersectsRect;
     isLastLayer = true;
     ownRect = parentRect;
     intersectsRect = new Rectangle(
         ownRect.X ,
         ownRect.Y ,
         ownRect.Width,
         ownRect.Height);
     ownRect = intersectsRect;
     tiles = new List<Tile>();
     foreach (Tile tile in levelTiles)
     {
         if (intersectsRect.Intersects(tile.get_rect) &&
             (tile.TileColission_Type != TileCollision.Passable))
         {
             tiles.Add(tile);
         }
     }
 }
Exemplo n.º 9
0
        protected void UpdateEnemy(GameTime gameTime, Quadtree quadtree,Vector2 playerPos,int numThread,Tile[,] map)
        {
            if (!alive)
            {
                timeTillDeath += (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (timeTillDeath > 10)
                    removable = true;
                //particleManager.Update(gameTime);
                wave.Update(gameTime, pos);
            }
            else
            {

                speed = new Vector2();
                gravity.Y += GameParameters.Gravity * (float)gameTime.ElapsedGameTime.TotalSeconds;
                UpdateRectangles(pos);
                speed.Y += gravity.Y;
                DoEnemyKI(gameTime, quadtree, playerPos, map);
                if (movementType == MovementType.Normal && !standXStill)
                {
                    if (rundirection == StandardDirection.Left)
                        speed.X = -maxSpeed;
                    else
                        speed.X = maxSpeed;
                }
                speed.Y += jumpSpeed.Y;
                if (jumping)
                    animations.CurrentAnimation = Anims.Jump;
                else
                    animations.CurrentAnimation = Anims.Walk;
                //#TODO : Speed
                Collision(quadtree, (float)gameTime.ElapsedGameTime.TotalSeconds, numThread);
                animations.Update(gameTime, !(rundirection == standardirection));
                pos += speed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                UpdateRectangles(pos);
            }
        }
Exemplo n.º 10
0
 public void loadGrass(Tile[,] tiles)
 {
     int max_height = tiles.GetLength(0);
     int max_width = tiles.GetLength(1);
     if (tile_x - 1 >= 0)
     {
         if (tiles[tile_y, tile_x - 1].TileType != TileType.Wall)
         {
             grass[(int)GrassType.Left].rect = new Rectangle(rect.Left, rect.Top, 10, TILE_SIZE);
             grass[(int)GrassType.Left].type = GrassType.Left;
         }
         else
         {
             grass[(int)GrassType.Left].rect = Rectangle.Empty;
             grass[(int)GrassType.Left].type = GrassType.Empty;
         }
     }
     else
     {
         grass[(int)GrassType.Left].rect = new Rectangle(rect.Left, rect.Top, 10, TILE_SIZE);
         grass[(int)GrassType.Left].type = GrassType.Left;
     }
     if (tile_x + 1 < max_width)
     {
         if (tiles[tile_y, tile_x + 1].TileType != TileType.Wall)
         {
             grass[(int)GrassType.Right].rect = new Rectangle(rect.Right - 10, rect.Top, 10, TILE_SIZE);
             grass[(int)GrassType.Right].type = GrassType.Right;
         }
         else
         {
             grass[(int)GrassType.Right].rect = Rectangle.Empty;
             grass[(int)GrassType.Right].type = GrassType.Empty;
         }
     }
     else
     {
         grass[(int)GrassType.Right].rect = new Rectangle(rect.Right - 10, rect.Top, 10, TILE_SIZE);
         grass[(int)GrassType.Right].type = GrassType.Right;
     }
     if (tile_y - 1 >= 0)
     {
         if (tiles[tile_y - 1, tile_x].TileType != TileType.Wall)
         {
             grass[(int)GrassType.Top].rect = new Rectangle(rect.Left - 5, rect.Top - 5, TILE_SIZE + 10, 20);
             grass[(int)GrassType.Top].type = GrassType.Top;
         }
         else
         {
             grass[(int)GrassType.Top].rect = Rectangle.Empty;
             grass[(int)GrassType.Top].type = GrassType.Empty;
         }
     }
     else
     {
         grass[(int)GrassType.Top].rect = new Rectangle(rect.Left - 5, rect.Top - 5, TILE_SIZE + 10, 20);
         grass[(int)GrassType.Top].type = GrassType.Top;
     }
     if (tile_y + 1 < max_height)
     {
         if (tiles[tile_y + 1, tile_x].TileType != TileType.Wall)
         {
             grass[(int)GrassType.Bottom].rect = new Rectangle(rect.Left, rect.Bottom - 10, TILE_SIZE, 10);
             grass[(int)GrassType.Bottom].type = GrassType.Bottom;
         }
         else
         {
             grass[(int)GrassType.Bottom].rect = Rectangle.Empty;
             grass[(int)GrassType.Bottom].type = GrassType.Empty;
         }
     }
     else
     {
         grass[(int)GrassType.Bottom].rect = new Rectangle(rect.Left, rect.Bottom - 10, TILE_SIZE, 10);
         grass[(int)GrassType.Bottom].type = GrassType.Bottom;
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Loads the Level Tiles
        /// </summary>
        /// <param name="leveldata">the Content from Level = leveldata ;</param>
        /// <returns>if it was successfull</returns>
        private bool load_level_tiles(string leveldata)
        {
            bool successfull = true;

            try
            {
                //Split Lines
                string[] level_lines = leveldata.Split(':');
                int x_max = 0;
                int y_max = level_lines.Count();

                string[][] tiledata = new string[y_max][];

                //Split  each Line into Tiles
                for (int y = 0; y < y_max; y++)
                {
                    tiledata[y] = level_lines[y].Split(',');
                }

                //Search for longest Line
                foreach (string[] temp in tiledata)
                {
                    x_max = (int)MathHelper.Max(temp.Count(), x_max);
                }

                // Initializes the 2 dimensional Array
                tiles = new Tile[y_max, x_max];

                //Initialize every Tile
                for (int y = 0; y < y_max; y++)
                {
                    //Invoke LevelLoadLineEnhanced Event
                    if (LevelLoadLineEnhanced != null)
                        if ((y + 1) % 20 == 0 || y + 1 == y_max)
                        {
                            LevelLoadLineEnhanced(y + 1, y_max);
                            //System.Threading.Thread.Sleep(500);
                        }
                    for (int x = 0; x < x_max; x++)
                    {
                        //Set Tile Position
                        tiles[y, x] = new Tile(x, y);

                        //If this line is shorter than the longest Line,
                        //then fill rest with Empty tiles
                        if (x >= tiledata[y].Count() )
                        {
                            tiles[y, x].load_tile(((int)TileType.Empty),null);

                        }
                        else
                        {
                            //Load the Tile
                            //FAIL
                            bool parsing;
                            int tileint;
                            parsing = int.TryParse(tiledata[y][x],out tileint);
                            if (parsing == true)
                            {
                                if(y-1>=0)
                                    tiles[y, x].load_tile(int.Parse(tiledata[y][x]), tiles[y - 1, x]);
                                else
                                    tiles[y, x].load_tile(int.Parse(tiledata[y][x]),null);

                                //Search for the Start of the Level
                                if (tiles[y, x].TileType == TileType.Start)
                                {
                                    startpos.X = tiles[y, x].get_rect.Location.X + Tile.TILE_SIZE / 2;
                                    startpos.Y = tiles[y, x].get_rect.Location.Y + Tile.TILE_SIZE / 2;
                                }
                            }
                            else
                            {

                                tiles[y, x].load_tile((int)TileType.Empty,null);
                            }
                        }
                    }
                }

                //If Tiles is wall then load grass
                foreach (Tile tile in tiles)
                {
                    if (tile.TileType == TileType.Wall)
                    {
                        tile.loadGrass(tiles);
                    }
                }
                AStarMap map = new AStarMap();
                map.InitializeMapFromLevel(tiles);
            }
            catch (Exception ex)
            {
                successfull = false;
                throw new Exception(ex.Message);
            }

            return successfull;
        }
Exemplo n.º 12
0
 public void Update(GameTime gameTime,Quadtree quadtree,Vector2 playerPos,int numThread,Tile[,] map)
 {
     //try
     {
         UpdateEnemy(gameTime, quadtree,playerPos,numThread,map);
     }
     //catch (Exception e)
     {
         //errorMessage = ("Couldn't Update Enemy: " + e.Message);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Generates an Empty Level with default Values
 /// </summary>
 /// <param name="serviceProvider">For The Content</param>
 public void LoadLevel(IServiceProvider serviceProvider, GraphicsDevice graphicsDevice, Options options)
 {
     content = new ContentManager(serviceProvider);
     content.RootDirectory = "Data";
     textures = new Texture2D[AMOUNT_TILE_TYPES];
     startpos = Vector2.Zero;
     levelvariables = new LevelVariables();
     error_messages = new List<string>();
     tiles = new Tile[1, 1];
     tiles[0, 0] = new Tile(0, 0);
     tiles[0, 0].load_tile((int)TileType.Empty,null);
     InitializeEffects(serviceProvider, graphicsDevice, options);
     reLoadTextures();
 }
Exemplo n.º 14
0
        /// <summary>
        /// Generates an new default Level with px rows an py coloumns
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="px"></param>
        /// <param name="py"></param>
        public void LoadLevel(IServiceProvider serviceProvider, GraphicsDevice graphicsDevice, Options options, int px, int py)
        {
            content = new ContentManager(serviceProvider);
            content.RootDirectory = "Data";
            textures = new Texture2D[AMOUNT_TILE_TYPES];
            startpos = Vector2.Zero;
            levelvariables = new LevelVariables();
            error_messages = new List<string>();
            tiles = new Tile[py, px];

            for (int x = 0; x < px; x++)
            {
                for (int y = 0; y < py; y++)
                {
                    tiles[y, x] = new Tile(x, y);
                    if (y - 1 >= 0)
                        tiles[y, x].load_tile(((int)TileType.Empty), tiles[y - 1, x]);
                    else
                        tiles[y, x].load_tile(((int)TileType.Empty), null);
                }
            }
            InitializeEffects(serviceProvider, graphicsDevice, options);
            reLoadTextures();
        }
Exemplo n.º 15
0
        private QuadTreeNode[] GenerateChildNodes(Rectangle parentRect,int layernumber,int maxLayer,Tile[,] leveltiles)
        {
            QuadTreeNode[] childs;

            layernumber++;
            if (layernumber + 1 >= maxLayer)
            {
                childs = new QuadTreeNode[1];
                childs[0] = new QuadTreeNode(parentRect, leveltiles);
            }
            else
            {
                childs = new QuadTreeNode[4];
                childs[0] = new QuadTreeNode(parentRect, QTI.LeftTop, layernumber, maxLayer, leveltiles);
                childs[1] = new QuadTreeNode(parentRect, QTI.RightTop, layernumber, maxLayer, leveltiles);
                childs[2] = new QuadTreeNode(parentRect, QTI.LeftBottom, layernumber, maxLayer, leveltiles);
                childs[3] = new QuadTreeNode(parentRect, QTI.RightBottom, layernumber, maxLayer, leveltiles);
            }

            return childs;
        }
Exemplo n.º 16
0
 private void DoEnemyKI(GameTime gameTime, Quadtree quadtree, Vector2 playerPos,Tile[,] map)
 {
     switch (tracking)
     {
         case PlayerTracking.NotTracking:
             break;
         case PlayerTracking.Tracking:
             TrackPlayer((float)gameTime.ElapsedGameTime.TotalSeconds,playerPos);
             CliffJump((float)gameTime.ElapsedGameTime.TotalSeconds, map);
             break;
     }
 }
Exemplo n.º 17
0
        public void load_tile(int indicator,Tile tileAbove)
        {
            #region "PerChar"
            /*
            switch (indicator)
            {

                case 'S':
                    //type = TileType.Wall;
                    passable = TileColission.Passable;
                    tile_type = TileType.Start;
                    break;
                case 'X':
                    //type = "Exit";
                    passable = TileColission.Passable;
                    tile_type = TileType.Exit;
                    break;
                case 'W':
                    //type = "Wall";
                    passable = TileColission.Impassable;
                    tile_type = TileType.Wall;
                    break;
                default :
                    //type = "Empty";
                    passable = TileColission.Passable;
                    tile_type = TileType.Empty;
                    break;
            }
            */
            #endregion

            //tile_type = TileType.Empty;
            tile_type = TileType.Empty;
            passable = TileCollision.Passable;
            //indicator = indicator.Trim();

            foreach (TileType type in Enum.GetValues(typeof(TileType)))
            {
                if (((int)type) == indicator)
                {
                    tile_type = type;
                }
            }

            switch (tile_type)
            {
                case (TileType.Wall):
                    passable = TileCollision.Impassable;
                    break;
                case (TileType.Platform):
                    passable = TileCollision.Platform;
                    break;
                case TileType.Spike:
                    passable = TileCollision.Event;
                    break;
            }

            switch (tile_type)
            {
                case TileType.Platform:
                case TileType.Wall:
                    standable = true;
                    break;
                default:
                    standable = false;
                    break;
            }
            if (tileAbove != null)
            {
                switch (tileAbove.TileType)
                {
                    case TileType.Wall:
                        standable = false;
                        break;
                    default:
                        break;
                }
            }
        }
Exemplo n.º 18
0
        private void UpdateMouseTile()
        {
            Vector2 tilepos = new Vector2();
            tilepos += new Vector2(MousePosition.X, MousePosition.Y) / camera.Scale;
            tilepos -= FormLocation / camera.Scale;
            tilepos -= camera.Position;
            tilepos -= camera.Offset;
            tilepos -= mouseoffset / camera.Scale;
            int tx = (int)(tilepos.X / 32 - 0.5f);
            int ty = (int)((tilepos.Y / 32)) - (int)(1 / camera.Scale);

            mousetile = new Tile(tx, ty);
            if (tx >= 0 && ty >= 0 && tx < level.Tiles.GetLength(1) && ty < level.Tiles.GetLength(0))
            {
                mousetile.load_tile((int)mousetiletype,null);
                if (level.Tiles != null && mousetile.TileType == TileType.Wall)
                {
                    mousetile.LoadGrass();
                }
            }
            else
            {
                mousetile.load_tile((int)TileType.Error,null);
            }
            if (placing == true)
            {
                PlaceMouseTile();
            }
        }
Exemplo n.º 19
0
 private void GetKillRectangles(Tile[,] leveltiles)
 {
     foreach(Tile tile in leveltiles)
     {
         if (tile.TileType == TileType.Spike)
         {
             Rectangle rect = tile.get_rect;
             rect.Y += 12;
             rect.Height -= 12;
             killrectangles.Add(rect);
         }
     }
 }
Exemplo n.º 20
0
 private void GetExit(Tile[,] leveltiles)
 {
     foreach (Tile tile in leveltiles)
     {
         if (tile.TileType == TileType.Exit)
         {
             exitrect = tile.get_rect;
             break;
         }
     }
 }
Exemplo n.º 21
0
        protected override void Initialize()
        {
            //Initilaize Layer Data
            layerData = new Dictionary<LayerFX, LayerFXData>();

            //Fill Dictionary with Default Values
            foreach (LayerFX layer in Enum.GetValues(typeof(LayerFX)))
            {
                layerData.Add(layer, LayerFXData.Default);
            }

            editorcontent = new ContentManager(Services, "StarEditData");
            gamecontent = new ContentManager(Services, "Data");
            blanktex = gamecontent.Load<Texture2D>("Stuff/Blank");

            recttool = new Rectangle();
            options = new Options();
            options.ScreenHeight = DisplayRectangle.Height;
            options.ScreenWidth = DisplayRectangle.Width;
            options.ScreenWidth = GraphicsDevice.PresentationParameters.BackBufferWidth;
            options.ScreenHeight = GraphicsDevice.PresentationParameters.BackBufferHeight;
            options.InitObjectHolder.graphics = GraphicsDevice;

            options.InitObjectHolder.serviceProvider = Services;
            oldscreensize = new Point(DisplayRectangle.Width, DisplayRectangle.Height);
            try
            {
                arial = editorcontent.Load<SpriteFont>("Arial");
                spritebatch = new SpriteBatch(GraphicsDevice);
            }
            catch (Exception e)
            {
                string error = e.Message;
            }
            level = new Level();
            level.LoadLevel(Services,GraphicsDevice,options);
            //level = new Level(Services);
            iObjectManager = new InteractiveObjectManager();
            iObjectManager.Initialize(Services, level.LevelVariables, GraphicsDevice, options);
            rearparallaxLayer = new ParallaxLayer();
            frontparallaxLayer = new ParallaxLayer();
            cloudlayer = new CloudLayer();
            reardecoLayer = new DecoLayer();
            frontDecoLayer = new DecoLayer();
            SetBGRect();
            camera = new Camera(DisplayRectangle.Width, DisplayRectangle.Height, Vector2.Zero, DisplayRectangle.Height / 600f);
            mousetile = new Tile(0, 0);
            mousetile.load_tile((int)TileType.Wall,null);
            mouseTex = editorcontent.Load<Texture2D>("mousetile");
            if (level.Tiles != null)
            {
                mousetile.LoadGrass();
            }
            SetBorders(1, 1);
            enemymanager = new EnemyManager(Services, new Options());
            try
            {
                placeEnemy = new SingleEnemyManager(Services);
                placeEnemy.LoadEnemy(selectedEnemy);
            }
            catch (Exception e)
            {
                FileManager.WriteInErrorLog(this, e.Message, e.GetType());
            }

            bg_tex = new Texture2D(GraphicsDevice, 1, 1);
            colorizePost = new ColorizeLUT();
            colorizePost.Initialize(Services,GraphicsDevice,new Options());
            colorizePost.Enabled = true;
            colorizePost.StartResetEffect();
            colorizePost.FxData = LayerFXData.Default;
            colorizeBackground = new ColorizeLUT();
            colorizeBackground.Initialize(Services, GraphicsDevice, new Options());
            colorizeBackground.Enabled = true;
            colorizeBackground.StartResetEffect();

            target = new RenderTarget2D(GraphicsDevice,
                GraphicsDevice.PresentationParameters.BackBufferWidth,
                GraphicsDevice.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,

                GraphicsDevice.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);
        }
Exemplo n.º 22
0
 private void platform_collision(Tile tile,ref Vector2 speed,ref Vector2 temp_pos,ref List<CollisionType> intersects)
 {
     Rectangle tile_rect = tile.get_rect;
     tile_rect.Y += 7;
     if (bottom.Intersects(tile_rect) && speed.Y > 0 &&
         !left.Intersects(tile_rect) &&
         !right.Intersects(tile_rect) &&
         !top.Intersects(tile_rect))
     {
         intersects.Add(CollisionType.StandsOnIt);
         temp_pos.Y -= bottom.Bottom - tile_rect.Top;
         speed.Y = 0;
     }
 }
Exemplo n.º 23
0
        private void impassable_collision(Tile tile,ref Vector2 speed,
            ref Vector2 temp_pos,ref List<CollisionType> intersects)
        {
            if (bottom.Intersects(tile.get_rect) &&
                    speed.Y > 0)
            {
                intersects.Add(CollisionType.StandsOnIt);
                //int temp = (bounding_box.Bottom - tile.get_rect.Top);
                speed.Y = 0;
                temp_pos.Y -= bounding_box.Bottom - tile.get_rect.Top;
                //pos.Y -= bottom.Bottom - tile.get_rect.Top;
                //move_down = false;
            }
            else if (right.Intersects(tile.get_rect) &&
                speed.X >= 0)
            {
                if (is_jumping == true)
                {

                    intersects.Add(CollisionType.JumpsAgainstIt);
                }
                else
                {
                    intersects.Add(CollisionType.WalksAgainstIt);
                }
                speed.X = 0;
                temp_pos.X -= right.Right - tile.get_rect.Left;
                //move_right = false;
            }
            else if (left.Intersects(tile.get_rect) &&
                speed.X <= 0)
            {
                if (is_jumping == true)
                {
                    intersects.Add(CollisionType.JumpsAgainstIt);
                }
                else
                {
                    intersects.Add(CollisionType.WalksAgainstIt);
                }
                speed.X = 0;
                temp_pos.X += tile.get_rect.Right - left.Left;
                //move_left = false;
            }
            else if (top.Intersects(tile.get_rect) &&
                speed.Y < 0)
            {
                intersects.Add(CollisionType.JumpsAgainstTop);
                speed.Y = 0;
                jump.Y = -physics.Y;
                temp_pos.Y += tile.get_rect.Bottom - bounding_box.Top;
                //physics.Y = 0;
                //move_up = false;
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Generates the RootNode of the Quadtree
 /// </summary>
 /// <param name="parentRect">The Rectangle of the RootNode 
 /// (normally the Bounding Box of the Level)</param>
 /// <param name="maxLayer">The Maximum count of Layers in the Quadtree</param>
 /// <param name="leveltiles">The Tiles from the Level which should be included into the Quadtree</param>
 public QuadTreeNode(Rectangle parentRect, int maxLayer, Tile[,] leveltiles)
 {
     ownRect = parentRect;
     childTreeNodes = GenerateChildNodes(ownRect, 0, maxLayer, leveltiles);
 }
Exemplo n.º 25
0
        private void ThreadModifiyTiles()
        {
            Tile[,] newtiles;

            Point oldSize = new Point(
                oldTiles.GetLength(1),
                oldTiles.GetLength(0));

            Point totalSize = new Point(
                newSize.X - zeroPointModification.X,
                newSize.Y - zeroPointModification.Y);

            newtiles = new Tile[totalSize.Y, totalSize.X];
            int y;
            int x;
            int newx;
            int newy;
            for (y = zeroPointModification.Y,newy=0; y < newSize.Y && newy<totalSize.Y; y++,newy++)
            {
                for(x=zeroPointModification.X,newx = 0;x< newSize.X && newx<totalSize.X;x++,newx++)
                {
                    newtiles[newy, newx] = new Tile(newx, newy);
                    if (x < 0 || y < 0 || x >= oldSize.X || y >= oldSize.Y)
                    {
                        newtiles[newy, newx].load_tile((int)TileType.Empty,null);
                    }
                    else
                    {
                        newtiles[newy, newx].load_tile((int)oldTiles[y, x].TileType,null);
                    }
                }
                percentage = ((float)newy / (float)totalSize.Y) *100;
            }
            foreach (Tile tile in newtiles)
            {
                tile.loadGrass(newtiles);
            }
            percentage = 100;
            overloader(newtiles);
        }
Exemplo n.º 26
0
 public void SetLevel(Tile[,] newtiles)
 {
     levelControl1.Level.Tiles = newtiles;
     levelControl1.SetBorders(newtiles.GetLength(1), newtiles.GetLength(0));
     //Focus();
 }
Exemplo n.º 27
0
 public void Update(GameTime gameTime, Quadtree quadtree, Vector2 playerPos,Rectangle playerRect,Tile[,] map,Matrix matrix)
 {
     this.map = map;
     this.gameTime = gameTime;
     this.quadtree = quadtree;
     this.playerPos = playerPos;
     CheckIntersection(playerRect,matrix);
     ClearEnemies();
     for (int i = 0; i < updater.Length;i++)
     {
         //thread = new Thread(new ParameterizedThreadStart(UpdateThread));
         if (updater[i].ThreadState == ThreadState.Unstarted)
             updater[i].Start(i);
         if (updater[i].ThreadState == ThreadState.Suspended)
             updater[i].Resume();
     }
 }
Exemplo n.º 28
0
 private List<CollisionType> collision(Tile tile,ref Vector2 speed,ref Vector2 temp_pos,Input.RunDirection rundirection)
 {
     //collission.Clear();
     right = new Rectangle(bounding_box.Right-5, bounding_box.Top+10, 5, bounding_box.Height-35);
     left = new Rectangle(bounding_box.Left, bounding_box.Top+10, 5, bounding_box.Height-35);
     top = new Rectangle(bounding_box.Left+6, bounding_box.Top-3, bounding_box.Width-12,3);
     bottom = new Rectangle(bounding_box.Left+6, bounding_box.Bottom-6, bounding_box.Width-12, 3);
     List<CollisionType> intersects = new List<CollisionType>();
     Vector2 distance_vector = new Vector2(tile.get_rect.Center.X,
         tile.get_rect.Center.Y) - temp_pos;
     switch (tile.TileColission_Type)
     {
         case (TileCollision.Impassable):
             impassable_collision(tile, ref speed, ref temp_pos, ref intersects);
             break;
         case (TileCollision.Platform):
             platform_collision(tile,ref speed,ref temp_pos,ref intersects);
             break;
     }
     return intersects;
 }
Exemplo n.º 29
-1
 /// <summary>
 /// Generates a normal node of the Quadtree.
 /// This one contains no Tiles, but conatins 4 ChildNodes
 /// </summary>
 /// <param name="parentRect">The Rectangle of the Parent Node.
 /// The Node will generate his own rectangle depending on the Indicator</param>
 /// <param name="indicator">The Indicator controlls which Position this Node will have in the Parent Node</param>
 /// <param name="layernumber">The current Layernumber</param>
 /// <param name="maxLayer">The Maximum count of Layers in the Quadtree</param>
 /// <param name="leveltiles">The Tiles from the Level which should be included into the Quadtree</param>
 public QuadTreeNode(Rectangle parentRect,QTI indicator,int layernumber,int maxLayer,Tile[,] leveltiles)
 {
     ownRect = GenerateRect(parentRect, indicator);
     childTreeNodes = GenerateChildNodes(ownRect, layernumber, maxLayer, leveltiles);
 }