Пример #1
0
    /*
     * private void Update()
     * {
     *  if(Input.GetKeyUp(KeyCode.L))
     *  {
     *      StartCoroutine(CreateLevel());
     *  }
     *
     *  if (Input.GetKeyUp(KeyCode.K))
     *  {
     *      readyToBuild = true;
     *  }
     * }
     */
    #endregion

    /// <summary>
    /// Initializes a new Level and sets up all needed values
    /// </summary>
    public void InitLevel()
    {
        //Set up
        if (GameVars.instance)
        {
            GameVars.instance.crawlManager = this;
            if (GameVars.instance.currentCrawlLevel > 0)
            {
                playerStartingHealth = GameVars.instance.currentCrawlHealth;
            }
        }
        /* if (GameVars.instance) { levelIndex = GameVars.instance.currentCrawlLevel; } */
        worldArray        = new GameObject[(int)tilesPerLine, (int)tilesPerLine];
        WORLD_SIZE        = new Vector2(gridSpotSize * tilesPerLine, gridSpotSize * tilesPerLine);
        emptyTileIndices  = new List <Vector2>();
        doorTileIndices   = new List <Vector2>();
        propTileIndices   = new List <Vector2>();
        entityTileIndices = new List <Vector2>();

        roomItems   = new List <GameObject>();
        roomEnemies = new List <GameObject>();

        if (GameVars.instance && GameVars.instance.currentCrawlLevel == 0)
        {
            chosenWorldMat = wallTextures[0];
        }
        else
        {
            if (wallTextures != null && wallTextures.Count > 0)
            {
                do
                {
                    foreach (WallTexture wallTexture in wallTextures)
                    {
                        if (wallTexture.RollChance(wallTexture.chosenPercent))
                        {
                            chosenWorldMat = wallTexture;
                        }
                    }
                } while (chosenWorldMat == null);
            }
        }
    }
Пример #2
0
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            Name = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.I32)
                        {
                            GroundTexture = (GroundTexture)iprot.ReadI32();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.I32)
                        {
                            WallTexture = (WallTexture)iprot.ReadI32();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
Пример #3
0
        /// <summary>
        /// Standard constructor of OsmData
        /// </summary>
        public OsmData()
        {
            fileInfo  = new FileInfo(OSMFILE);
            xmlSource = new XmlOsmStreamSource(fileInfo.OpenRead());

            nodes     = new Dictionary <long, OsmSharp.Osm.Node>();
            buildings = new List <Building>();
            landuses  = new List <Landuse>();

            /* Declare the colors of the brushes*/

            // Create Wallbrush
            WallTexture texture = new WallTexture(100, 1);
            Bitmap      bitmap  = texture.DrawTexture();

            using (MemoryStream memory = new MemoryStream())
            {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                bitmapImage     = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
            }

            Rect rect = new Rect(0, 0, bitmapImage.PixelWidth, bitmapImage.PixelHeight);

            WALLBRUSH               = new ImageBrush(bitmapImage);
            WALLBRUSH.Viewport      = rect;
            WALLBRUSH.ViewportUnits = BrushMappingMode.Absolute;
            WALLBRUSH.Stretch       = Stretch.None;
            WALLBRUSH.AlignmentX    = AlignmentX.Left;
            WALLBRUSH.AlignmentY    = AlignmentY.Top;
            WALLBRUSH.TileMode      = TileMode.Tile;


            // Create GrassBrush
            DiamondSquare textureGrass = new DiamondSquare(1, 256, 256);
            Bitmap        bitmapGrass  = textureGrass.getPoints("green");

            using (MemoryStream memory = new MemoryStream())
            {
                bitmapGrass.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                bitmapImage     = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memory;
                bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                bitmapImage.EndInit();
            }

            Rect rectGrass = new Rect(0, 0, bitmapImage.PixelWidth, bitmapImage.PixelHeight);

            GRASSBRUSH               = new ImageBrush(bitmapImage);
            GRASSBRUSH.Viewport      = rectGrass;
            GRASSBRUSH.ViewportUnits = BrushMappingMode.Absolute;
            GRASSBRUSH.Stretch       = Stretch.None;
            GRASSBRUSH.AlignmentX    = AlignmentX.Left;
            GRASSBRUSH.AlignmentY    = AlignmentY.Top;
            GRASSBRUSH.TileMode      = TileMode.Tile;

            // Define rest of brushes
            SURFACEBRUSH            = new SolidColorBrush(Colors.Black);
            LANDUSECOMMERCIALBRUSH  = new SolidColorBrush(Colors.LightPink);
            LANDUSECOSTRUCIONBRUSH  = new SolidColorBrush(Colors.DarkOliveGreen);
            LANDUSEFARMLANDBRUSH    = new SolidColorBrush(Colors.LightYellow);
            LANDUSEFORESTBRUSH      = new SolidColorBrush(Colors.LightGreen);
            LANDUSEGARAGESBRUSH     = new SolidColorBrush(Colors.Gray);
            LANDUSEGRASSBRUSH       = new SolidColorBrush(Colors.LawnGreen);
            LANDUSEINDUSTRIALBRUSH  = new SolidColorBrush(Colors.MediumPurple);
            LANDUSERAILWAYBRUSH     = new SolidColorBrush(Colors.Black);
            LANDUSERESIDENTIALBRUSH = new SolidColorBrush(Colors.WhiteSmoke);
            LANDUSEDEFAULTBRUSH     = new SolidColorBrush(Colors.Orange);

            getBounds();                // declares the object map
            getNodes();                 // fills the dictonary nodes
            getBuildingsAndLanduses();  // fills the lists buildings and landuses
        }