Ejemplo n.º 1
0
        private void BuildVegetation(SimWorld world)
        {
            float[,] treeMap = new float[Width, Height];

            for (int i = 0; i < 1; i++)
            {
                NoiseGenerator noiseGenerator = new NoiseGenerator();
                NoiseGenerator.Frequency = 0.06;
                NoiseGenerator.Octaves   = 10;

                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        TileInfo tileInfo = world.getTileInfo <GeoLayer>(x, y);
                        if (noiseGenerator.Noise(x, y) < 0)
                        {
                            if (tileInfo.Terrain == TileInfo.TerrainType.Land)
                            {
                                RLNET.RLColor color = new RLNET.RLColor(0, tileInfo.TerrainHeight + (0.2f), 0);
                                _visibleCellManager.getNewCell(world.getTileInfo <GeoLayer>(tileInfo.X, tileInfo.Y).VisibleCell.Character,
                                                               tileInfo.X, tileInfo.Y, color, 1);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Dictionary <int, List <Components.Component> > LoadEntities()
        {
            Dictionary <int, List <Components.Component> > returnDict
                = new Dictionary <int, List <Components.Component> >();

            string inputJson = System.IO.File.ReadAllText("ents.json");

            Dictionary <int, Dictionary <Core.ComponentTypes, List <Dictionary <string, string> > > > output
                = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <int, Dictionary <Core.ComponentTypes, List <Dictionary <string, string> > > > >(inputJson);

            foreach (KeyValuePair <int, Dictionary <Core.ComponentTypes, List <Dictionary <string, string> > > > entry in output)
            {
                int         eid = entry.Key;
                Core.Entity ent = new Core.Entity(eid);

                List <Components.Component> componentList = new List <Components.Component>();

                Dictionary <Core.ComponentTypes, List <Dictionary <string, string> > > compDict
                    = entry.Value;

                foreach (KeyValuePair <Core.ComponentTypes, List <Dictionary <string, string> > > inner in compDict)
                {
                    if (inner.Key == Core.ComponentTypes.Position)
                    {
                        List <Dictionary <string, string> > comps = inner.Value;
                        foreach (Dictionary <string, string> cDict in comps)
                        {
                            int x = Int32.Parse(cDict["X"]);
                            int y = Int32.Parse(cDict["Y"]);

                            Components.PositionComp pc = new Components.PositionComp(x, y);
                            componentList.Add(pc);
                        }
                    }
                    else if (inner.Key == Core.ComponentTypes.Render)
                    {
                        List <Dictionary <string, string> > comps = inner.Value;
                        foreach (Dictionary <string, string> cDict in comps)
                        {
                            char          glyph = cDict["Glyph"][0];
                            float         r     = float.Parse(cDict["ColorR"]);
                            float         g     = float.Parse(cDict["ColorG"]);
                            float         b     = float.Parse(cDict["ColorB"]);
                            RLNET.RLColor c     = new RLNET.RLColor(r, g, b);

                            Components.RenderComp rc = new Components.RenderComp(glyph, c);
                            componentList.Add(rc);
                        }
                    }
                    //else if (inner.Key == Core.ComponentTypes.Health)
                    //{
                    //    List<Dictionary<string, string>> comps = inner.Value;
                    //    foreach (Dictionary<string, string> cDict in comps)
                    //    {
                    //        int h = Int32.Parse(cDict["Health"]);
                    //        int mh = Int32.Parse(cDict["MaxHealth"]);

                    //        Components.HealthComp msc = new Components.HealthComp();
                    //        msc.Health = h;
                    //        msc.MaxHealth = mh;

                    //        componentList.Add(msc);
                    //    }
                    //}
                    //else if (inner.Key == Core.ComponentTypes.Attributes)
                    //{
                    //    List<Dictionary<string, string>> comps = inner.Value;
                    //    foreach (Dictionary<string, string> cDict in comps)
                    //    {
                    //        int aw = Int32.Parse(cDict["Awareness"]);

                    //        Components.AttributesComp msc = new Components.AttributesComp(aw);

                    //        componentList.Add(msc);
                    //    }
                    //}
                    //else if (inner.Key == Core.ComponentTypes.AI)
                    //{
                    //    List<Dictionary<string, string>> comps = inner.Value;
                    //    foreach (Dictionary<string, string> cDict in comps)
                    //    {
                    //        bool aw = bool.Parse(cDict["HasAI"]);

                    //        Components.AIComp msc = new Components.AIComp();
                    //        msc.HasAI = aw;
                    //        componentList.Add(msc);
                    //    }
                    //}
                }
                returnDict.Add(eid, componentList);
            }
            return(returnDict);
        }
Ejemplo n.º 3
0
 public RenderComp(char c, RLNET.RLColor color)
 {
     CompType = Core.ComponentTypes.Render;
     Glyph    = c;
     Colour   = color;
 }