Exemplo n.º 1
0
        public static void GenCode3()
        {
            string     path   = AppDomain.CurrentDomain.BaseDirectory + @"\LeaveApplication.cs";
            EntityInfo entity = GetEntity(path);

            EntityEngine.GenAreasCode(AppDomain.CurrentDomain.BaseDirectory + @"\GinkgoCode\Templates", entity, 1);
        }
Exemplo n.º 2
0
        public TileEngine(Map m)
        {
            this.m = m;

            ee = new EntityEngine(new EntityEngineInterface(this));
            camera = new TileEngineCamera(m.width,m.height);

            foreach(Map.Entdef entdef in m.entdefs)
            {
                //todo
                //Entity e = ee.SpawnMapEntity(entdef);
                //mapEnts.add(e, entdef.descr, entdef.index);
            }

            foreach (Map.Zonedef zd in m.zonedefs)
            {
                Zone z = new Zone();
                z.bAdjacent = (zd.method == 1);
                z.chance = zd.percent / 255.0f;
                z.name = zd.name;
                z.script = zd.script;

                zones.Add(z);
            }

            ee.EntityActivated += new EntityEngine.EntityActivationHandler(ee_EntityActivated);
            ee.ZoneActivated += new EntityEngine.ZoneActivationHandler(ee_ZoneActivated);
        }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     thread = EntityEngine.GetRunLoopThread(entityEngine, true);
     if (thread == null)
     {
         return;
     }
     thread.Start();
     button1.Enabled = false;
     button2.Enabled = true;
 }
Exemplo n.º 4
0
        protected override void Initialize()
        {
            EntityEngine.Initialize();

            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.PreferMultiSampling            = false;
            graphics.PreferredBackBufferWidth       = 1280;
            graphics.PreferredBackBufferHeight      = 720;
            this.IsMouseVisible   = false;
            graphics.IsFullScreen = false;

            graphics.ApplyChanges();
            Window.Title = "Deep Engine v0.1 - " + graphics.PreferredBackBufferWidth + " x " + graphics.PreferredBackBufferHeight;

            base.Initialize();
        }
Exemplo n.º 5
0
        public static void TestGenCode()
        {
            //Assembly assembly = Assembly.LoadFrom("Fostor.Ginkgo.Core.dll");
            //object obj = assembly.CreateInstance("Fostor.Ginkgo.TaskSample.LeaveApplication");
            Type type = typeof(Fostor.Ginkgo.TaskSample.LeaveApplication);
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(type);
            EntityInfo entity = new EntityInfo();

            entity.FullName       = type.FullName;
            entity.Name           = type.Name;
            entity.ClassNameSpace = type.Namespace;
            entity.BaseClassName  = type.BaseType.ToString();
            var fields = new GinkgoCode.EntityMeta.FieldInfo[properties.Count];

            for (int i = 0; i < properties.Count; i++)
            {
                PropertyDescriptor property = properties[i];
                var field = new GinkgoCode.EntityMeta.FieldInfo();
                field.Name        = property.Name;
                field.TypeName    = (Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType).ToString();
                field.DisplayName = property.DisplayName;
                if (property.PropertyType.Name.Contains("Nullable"))
                {
                    field.Nullable = true;
                }
                foreach (var x in property.Attributes)
                {
                    if (x.GetType() == typeof(MaxLengthAttribute))
                    {
                        field.MaxLength = ((MaxLengthAttribute)x).Length;
                    }
                    if (x.GetType() == typeof(RequiredAttribute))
                    {
                        field.Required = true;
                    }
                }
                fields[i] = field;
            }
            entity.Fields = fields;
            //EntityEngine.GenApplicationCode(entity);
            EntityEngine.GenAreasCode(AppDomain.CurrentDomain.BaseDirectory + @"\GinkgoCode\Templates", entity, 1);
        }
Exemplo n.º 6
0
        protected override void LoadContent()
        {
            var assetManager = new MonoGameAssetManager(Content);

            var camera                 = new Camera();
            var deviceManager          = new MonoGameDeviceManager(GraphicsDevice, camera);
            var componentSystemFactory = new MonoGameComponentSystemFactory(deviceManager, camera);

            _engine = new EntityEngine(assetManager, componentSystemFactory);

            var scene = _engine.LoadScene("Scene1.scene");
            //var guiLayer = scene.GetLayer("GuiLayer");

            //var button = guiLayer.GetComponent<GuiButton>("PlayButton");
            //button.IsEnabled = true;
            //button.Click += PlayButton_Click;

            //var toggle = guiLayer.GetComponent<GuiToggleButton>("SoundToggle");
            //toggle.CheckChanged += ToggleOnCheckChanged;
        }
Exemplo n.º 7
0
        public void CreateSystems(string rngSeed)
        {
            ScriptExecutor = new ScriptExecutor(this);
            EventSystem    = new EventSystem.EventSystem();

            MessageSystem  = new MessageSystem();
            ActivitySystem = new ActivitySystem();
            PlayerSystem   = new PlayerSystem(ActivitySystem);
            MapSystem      = new MapSystem();


            RendererSystem = new RendererSystem(PlayerSystem, ActivitySystem, _renderer);

            EntityEngine = new EntityEngine(_prototypeEntityDataProvider, _additionalComponentTypes);

            StatSystem = new StatSystem(EntityEngine);

            PositionSystem = new PositionSystem(MapSystem, EntityEngine, new AStarPathfindingAlgorithm());
            EntityEngine.Register(PositionSystem);

            Random          = new RNG(rngSeed);
            AnimationRandom = new RNG(rngSeed);

            TimeSystem = new TimeSystem(this);
            EntityEngine.Register(TimeSystem);

            FighterSystem = new FighterSystem(EntityEngine, MessageSystem, EventSystem, TimeSystem, StatSystem);
            EntityEngine.Register(FighterSystem);

            PrototypeSystem = new PrototypeSystem(EntityEngine, PositionSystem, this);
            EntityEngine.Register(PrototypeSystem);

            ItemSystem = new ItemSystem(EntityEngine, PrototypeSystem, ScriptExecutor, MessageSystem, EventSystem);
            EntityEngine.Register(ItemSystem);

            SkillSystem = new SkillSystem(this);
            EntityEngine.Register(SkillSystem);

            AnimationSystem = new AnimationSystem(new EncapsulatedStopwatch(), AnimationRandom);
            EntityEngine.Register(AnimationSystem);

            AnimatedMovementSystem = new AnimatedMovementSystem(EntityEngine, new EncapsulatedStopwatch());
            EntityEngine.Register(AnimatedMovementSystem);

            ParticleSystem = new ParticleSystem(AnimationSystem, EntityEngine);
            EntityEngine.Register(ParticleSystem);

            SoundSystem = new SoundSystem();
            EntityEngine.Register(SoundSystem);

            InteractableSystem = new InteractionSystem(PositionSystem);
            EntityEngine.Register(InteractableSystem);

            Seed = rngSeed;

            EquipmentSystem = new EquipmentSystem(this);

            TargetingSystem = new TargetingSystem(this);

            FactionSystem = new FactionSystem();

            ControlSystem = new ControlSystem(this, _keyBindingsDataProvider);

            SaveSystem = new SaveSystem(this, new WorldGenerator(_worldEntityDataProvider, _playerEntityDataProvider, _vaultDataProvider));


            EntityEngine.Initialise(this);
            ControlSystem.Initialise();

            Verify();
        }
Exemplo n.º 8
0
        public static void GenCode2()
        {
            string path         = AppDomain.CurrentDomain.BaseDirectory + @"\LeaveApplication.cs";
            string modelContent = File.ReadAllText(path, Encoding.UTF8);

            modelContent = modelContent.Substring(modelContent.IndexOf("namespace "));
            //namespace
            Regex  regNS = new Regex(@"^((\s)*)namespace(\b)(.+)$", RegexOptions.Multiline);
            string ns    = regNS.Match(modelContent).Value.Replace("namespace", "").Trim();
            //class
            Regex  regClass = new Regex(@"^((\s)*)(.+)class(\b)(.+)$", RegexOptions.Multiline);
            string cls      = regClass.Match(modelContent).Value.Replace(" public ", " ").Replace(" class ", " ").Trim();

            if (cls.IndexOf(':') > 0)
            {
                cls = cls.Substring(0, cls.IndexOf(':')); //去掉继承的基类
            }
            EntityInfo entity = new EntityInfo();

            entity.FullName       = ns + "." + cls;
            entity.Name           = cls;
            entity.ClassNameSpace = ns;
            //fields
            string fds = modelContent.Substring(modelContent.IndexOf("class "));

            fds = fds.Substring(fds.IndexOf("{") + 1);
            fds = fds.Substring(0, fds.LastIndexOf("}"));
            fds = fds.Substring(0, fds.LastIndexOf("}")).Trim();
            fds = fds.Replace("}", "}|");
            fds = fds.Substring(0, fds.LastIndexOf('|'));
            var fs     = fds.Split('|');
            var fields = new GinkgoCode.EntityMeta.FieldInfo[fs.Length];

            for (int i = 0; i < fs.Length; i++)
            {
                var    field   = new GinkgoCode.EntityMeta.FieldInfo();
                string content = fs[i];
                Regex  regReq  = new Regex(@"^((\s)*)(\[)Required(.*)$", RegexOptions.Multiline);
                if (regReq.IsMatch(content))
                {
                    field.Required = true;
                }
                Regex regMax = new Regex(@"^((\s)*)(\[)MaxLength(.+)$", RegexOptions.Multiline);
                if (regMax.IsMatch(content))
                {
                    string maxL      = regMax.Match(content).Value.Replace("[MaxLength(", "").Replace(")", "").Replace("]", "").Replace("\r\n", "").Trim();
                    int    maxLength = 0;
                    if (int.TryParse(maxL, out maxLength))
                    {
                        field.MaxLength = maxLength;
                    }
                }
                Regex  regFd  = new Regex(@"^((\s)*)public(\b)(.+)$", RegexOptions.Multiline);
                string fdLine = regFd.Match(content).Value;
                fdLine = fdLine.Replace(" virtual ", " ").Replace("public ", " ")
                         .Replace("get;", "").Replace("set;", "").Replace("{", "").Replace("}", "").Trim();
                string typeName = fdLine.Substring(0, fdLine.IndexOf(" "));
                string fname    = fdLine.Replace(typeName, "").Trim();
                field.Name     = fname;
                field.TypeName = typeName;
                fields[i]      = field;
            }

            entity.Fields = fields;
            //EntityEngine.GenApplicationCode(AppDomain.CurrentDomain.BaseDirectory+ @"\GinkgoCode\Templates",entity);
            EntityEngine.GenAreasCode(AppDomain.CurrentDomain.BaseDirectory + @"\GinkgoCode\Templates", entity, 1);
        }