Beispiel #1
0
        private NeighInfo getNumOfLinearNeighsByCode(cMapData map, Vector2i tile_pos, TileType type)
        {
            NeighInfo returner = new NeighInfo();

            int tx = tile_pos.X;
            int ty = tile_pos.Y;

            cTile left  = map.GetTileAtXY(tx - 1, ty);
            cTile top   = map.GetTileAtXY(tx, ty - 1);
            cTile right = map.GetTileAtXY(tx + 1, ty);
            cTile bot   = map.GetTileAtXY(tx, ty + 1);

            if (left != null && left.Type == type)
            {
                returner.HasLeft = true;
            }

            if (top != null && top.Type == type)
            {
                returner.HasTop = true;
            }

            if (right != null && right.Type == type)
            {
                returner.HasRight = true;
            }

            if (bot != null && bot.Type == type)
            {
                returner.HasBottom = true;
            }

            return(returner);
        }
Beispiel #2
0
        /// <summary>
        /// Itt választjuk ki és állítjuk be előre a kirjazoláshoz, hogy melyik csempéhez milyen al-textúra tartozik (több féle fal van, attól függ, hol és hány másik fal kapcsolódik az adott falhoz)
        /// </summary>
        private void initTileSprites()
        {
            cTile    tempTile      = null;
            Vector2i tilePos       = new Vector2i();
            Vector2f tileCenterTop = new Vector2f();

            for (int y = 0; y < m_Level1.Height; y++)
            {
                for (int x = 0; x < m_Level1.Width; x++)
                {
                    tempTile  = m_Level1.GetTileAtXY(x, y);
                    tilePos.X = x;
                    tilePos.Y = y;

                    tileCenterTop    = this.ToWorldPos(tilePos);
                    tileCenterTop.X += Constants.TILE_SIZE_HALF;
                    tileCenterTop.Y += Constants.TILE_SIZE_HALF;

                    tempTile.PosOnTexture = TileMask.NONE;

                    if (tempTile.Type == TileType.WALL)
                    {
                        NeighInfo info = getNumOfLinearNeighsByCode(m_Level1, tilePos, TileType.WALL);

                        if (info.NumNeighs == 1)
                        {
                            /* cLight l = cLightSystem.GetEnvironLight(tileCenterTop, 32.0f, Color.White);
                             * l.Bleed = 1.6f;
                             * l.LinearizeFactor = 0.4f;
                             * l.Color = new Color(246, 205, 105, 255);
                             * pScene.LightMap.AddStaticLight(l);*/
                        }

                        if (info.isAlone())
                        {
                            tempTile.PosOnTexture = TileMask.ALONE_BOT_WITH_TOP; // alone;

                            /* cLight l = cLightSystem.GetEnvironLight(tileCenterTop, 32.0f, Color.White);
                             * l.Bleed = 1.6f;
                             * l.LinearizeFactor = 0.4f;
                             * l.Color = new Color(246, 205, 105, 255);
                             * pScene.LightMap.AddStaticLight(l);*/
                        }
                        else
                        {
                            //egyedül van-e

                            if (!info.HasTop)
                            {
                                if (!info.HasBottom)
                                {
                                    if (!info.HasLeft)
                                    {
                                        tempTile.PosOnTexture = TileMask.NO_TOPBOT_LEFT;
                                    }
                                    else
                                    if (!info.HasRight)
                                    {
                                        tempTile.PosOnTexture = TileMask.NO_TOPBOT_RIGHT;
                                    }
                                    else
                                    {
                                        tempTile.PosOnTexture = TileMask.NO_TOPBOT_MIDDLE;
                                    }
                                }
                                else
                                {
                                    if (info.HasLeft)
                                    {
                                        if (info.HasRight)
                                        {
                                            tempTile.PosOnTexture = TileMask.TOP_MIDDLE;
                                        }
                                        else
                                        {
                                            tempTile.PosOnTexture = TileMask.TOP_RIGHT;
                                        }
                                    }
                                    else
                                    {
                                        if (info.HasRight)
                                        {
                                            tempTile.PosOnTexture = TileMask.TOP_LEFT;
                                        }
                                        else
                                        {
                                            tempTile.PosOnTexture = TileMask.ALONE_TOP_WITH_BOT;
                                        }
                                    }
                                }
                            }
                            else
                            if (!info.HasBottom)
                            {
                                if (info.HasLeft)
                                {
                                    if (info.HasRight)
                                    {
                                        tempTile.PosOnTexture = TileMask.BOTTOM_MIDDLE;
                                    }
                                    else
                                    {
                                        tempTile.PosOnTexture = TileMask.BOTTOM_RIGHT;
                                    }
                                }
                                else
                                {
                                    if (info.HasRight)
                                    {
                                        tempTile.PosOnTexture = TileMask.BOTTOM_LEFT;
                                    }
                                    else
                                    {
                                        tempTile.PosOnTexture = TileMask.ALONE_BOT_WITH_TOP;
                                    }
                                }
                            }
                            else
                            if (!info.HasLeft)
                            {
                                if (info.HasRight)
                                {
                                    tempTile.PosOnTexture = TileMask.MIDDLE_LEFT;
                                }
                                else
                                {
                                    tempTile.PosOnTexture = TileMask.ALONE;
                                }
                            }
                            else
                            if (!info.HasRight)
                            {
                                tempTile.PosOnTexture = TileMask.MIDDLE_RIGHT;
                            }
                            else
                            {
                                tempTile.PosOnTexture = TileMask.MIDDLE_CENTRE;
                                //tempTile.PosOnTexture = TileMask.EMPTY; //looks weird
                            }
                        }
                    }
                    else
                    if (tempTile.Type == TileType.EMPTY)
                    {
                    }
                    else
                    if (tempTile.Type == TileType.ONEWAY_PLATFORM)
                    {
                        tempTile.PosOnTexture = TileMask.ONE_WAY_PLATFORM;

                        /*
                         * cLight l = cLightSystem.GetEnvironLight(tileCenterTop, 32.0f, Color.White);
                         * l.Bleed = 2.6f;
                         * l.LinearizeFactor = 0.3f;
                         * pScene.LightMap.AddStaticLight(l);*/

                        //pScene.LightMap.AddStaticLight(cLightSystem.GetEnvironLight(this.ToWorldPos(tilePos), 50.0f, Color.Yellow));
                    }
                    else
                    if (tempTile.Type == TileType.LEVEL_START)
                    {
                        //top-left
                        Vector2f levelStartGroundPos = this.ToWorldPos(new Vector2i(x, y));

                        Texture t = cAssetManager.GetTexture("door1_sm");

                        Vector2f textureSize = new Vector2f(t.Size.X, t.Size.Y);

                        cAABB    bounds     = pScene.WolrdEnv.CalcBBOnGroundByTexture(levelStartGroundPos, textureSize);
                        Vector2f texturePos = bounds.topLeft;

                        bounds.Scale(new Vector2f(0.8f, 0.8f), new Vector2f(bounds.center.X, bounds.rightBottom.Y));

                        levelStartRegion = bounds;

                        pScene.WolrdEnv.PlaceOnGround(texturePos, t, bounds);



                        pScene.LightMap.AddStaticLight(cLightSystem.GetEnvironLight(bounds.center, bounds.halfDims.X * 3.0f, Color.Green));
                    }
                    else
                    if (tempTile.Type == TileType.LEVEL_END)
                    {
                        //top-left
                        Vector2f levelEndGroundPos = this.ToWorldPos(new Vector2i(x, y));

                        Texture t = cAssetManager.GetTexture("door1_sm");

                        Vector2f textureSize = new Vector2f(t.Size.X, t.Size.Y);

                        cAABB    bounds     = pScene.WolrdEnv.CalcBBOnGroundByTexture(levelEndGroundPos, textureSize);
                        Vector2f texturePos = bounds.topLeft;

                        bounds.Scale(new Vector2f(0.8f, 0.8f), new Vector2f(bounds.center.X, bounds.rightBottom.Y));

                        levelEndRegion = bounds;

                        pScene.WolrdEnv.PlaceOnGround(texturePos, t, bounds);


                        pScene.LightMap.AddStaticLight(cLightSystem.GetEnvironLight(bounds.center, bounds.halfDims.X * 3.0f, Color.Red));
                    }
                }
            }
        }