Beispiel #1
0
        public void UpdateUniforms(CoreEngine engine, Entity entity, PointLight light)
        {
            SetUniform("projection", engine.RenderingEngine.Camera.Projection);
            SetUniform("transformation", entity.Transformation.GetTransformation());

            SetUniform("eyePosition", engine.RenderingEngine.Camera.Parent.Transformation.Position);

            SetUniform("specularIntensity", entity.Material.SpecularIntensity);
            SetUniform("specularExponent", entity.Material.SpecularExponent);

            SetUniform("displacementScale", entity.Material.DisplacementScale);
            SetUniform("displacementBias", -(entity.Material.DisplacementScale / 2f) + (entity.Material.DisplacementScale / 2f) * entity.Material.DisplacementOffset);

            SetUniform("useDisplacementMap", entity.Material.DisplacementMap.Initialized ? 1 : 0);
            SetUniform("displacementMap", 0);

            SetUniform("useNormalMap", entity.Material.NormalMap.Initialized ? 1 : 0);
            SetUniform("normalMap", 1);

            SetUniform("light.base.color", new Vector4(light.Base.Color.R, light.Base.Color.G, light.Base.Color.B, light.Base.Color.A));
            SetUniform("light.base.intensity", light.Base.Intensity);
            SetUniform("light.attenuation.constant", light.Attenuation.Constant);
            SetUniform("light.attenuation.linear", light.Attenuation.Linear);
            SetUniform("light.attenuation.exponent", light.Attenuation.Exponent);
            SetUniform("light.position", light.Position);
            SetUniform("light.range", light.Range);
        }
Beispiel #2
0
        //TODO: Weird heap corruption bug happens sometimes. -1073740940
        static void Main(string[] args)
        {
            CoreEngine.Initialize();
            CoreEngine.targetFps = 0;

            Asset.LoadAssetPackage("data/assets.dat");

            //Physics.Settings.Gravity = Vector3.Zero;

            InitializeWorld();

            Profiler.ProfilingEnabled = true;

            Physics.Settings.Gravity = Vector3.Zero;
            Physics.Settings.solverIterationCount = 2;

            CoreEngine.Update += delegate
            {
                if (CoreEngine.FrameNumber == 500)
                {
                    Profiler.WriteToFile(@"D:\ecs_profile_speedscope.json", ProfilingFormat.SpeedScope, FrameSelection.Shortest);
                    Profiler.WriteToFile(@"D:\ecs_profile_chrometracing_95.json", ProfilingFormat.ChromeTracing, FrameSelection.Percentile95);
                    Profiler.WriteToFile(@"D:\ecs_profile_chrometracing_median.json", ProfilingFormat.ChromeTracing, FrameSelection.Median);
                    Profiler.WriteToFile(@"D:\ecs_profile_chrometracing_shortest.json", ProfilingFormat.ChromeTracing, FrameSelection.Shortest);
                }
            };

            CoreEngine.Run();
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     using (CoreEngine gioco = new CoreEngine())
     {
         gioco.Run(60.0);
     }
 }
Beispiel #4
0
        public ProgramEngine(CoreEngine engine) : base(engine)
        {
            pbr     = new PhysicallyBasedRenderer(engine.Device);
            sbr     = new SkyboxRenderer(engine.Device);
            control = new TrackballControl
            {
                CameraPosition = new Vector3(0, 0, -50),
                ZoomEnabled    = true,
                RotateEnabled  = true,
                Screen         = new Rectangle(0, 0, engine.Form.ClientSize.Width, engine.Form.ClientSize.Height),
                Enabled        = true,
                Up             = new Vector3(0, 1, 0)
            };

            control.Bind(engine.Form);
            engine.Form.Resize += HandleResize;
            HandleResize(null, null);

            Simulator.Scene = Scene;

            // Inputs
            Simulator.Stages.Add(new SensorStage(Scene));

            // Process
            Simulator.Stages.Add(new LogicStage(Scene));

            // Outputs
            Simulator.Stages.Add(new PhysicsStage(Scene));
        }
Beispiel #5
0
        public void TestCoreEngineQuery()
        {
            var core   = new CoreEngine(prov, null);
            var result = core.Query <Person>("myperson", new { Age = 30 });

            Assert.AreNotEqual(0, result.Count(), "查询引擎失败");
        }
Beispiel #6
0
        public void LoadTexture(CoreEngine engine, Stream stream)
        {
            int width;
            int height;

            IntPtr data = IOUtils.LoadTexture(stream, out width, out height);

            texture = GL.GenTexture();

            GL.BindTexture(TextureTarget.Texture2D, texture);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, engine.RenderingEngine.AnisotropicFiltering);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, data);

            GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);

            GL.BindTexture(TextureTarget.Texture2D, 0);

            initialized = true;
        }
Beispiel #7
0
    //
    void Awake()
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);

        ConstructManagers();
    }
Beispiel #8
0
        private void CancelTrailing()
        {
            if (Item == null)
            {
                return;
            }
            CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! CancelBeforeBuyOrder cancel code : " + Item.itemCode);
            CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! CancelBeforeBuyOrder cancel orderNum : " + Item.buyOrderNum);
            CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! CancelBeforeBuyOrder cancel quantity : " + (Item.buyQnt - Item.curQnt).ToString());
            //form1.CancelBuyOrder(Item.itemCode, Item.buyOrderNum);
            if (tradingStrategy != null)
            {
                List <TradingItem> tradeItemListAll = tradingStrategy.tradingItemList.FindAll(o => (o.itemCode == Item.itemCode));

                foreach (TradingItem tradeItem in tradeItemListAll)
                {
                    if (tradeItem.state == TRADING_ITEM_STATE.AUTO_TRADING_STATE_SEARCH_AND_CATCH)
                    {
                        tradeItem.SetBuyCancelComplete();
                        PopMartinGailItem(0);
                        return;
                    }
                }
            }
        }
Beispiel #9
0
 public AIEngine(CoreEngine core)
 {
     this.core = core;
     mesh = new List<MeshNode>();
     pickupNodes = new List<MeshNode>();
     agents = new List<AIAgent>();
     random = new Random();
 }
Beispiel #10
0
        public Random random;           //a random for AI agents to use

        public AIEngine(CoreEngine core)
        {
            this.core   = core;
            mesh        = new List <MeshNode>();
            pickupNodes = new List <MeshNode>();
            agents      = new List <AIAgent>();
            random      = new Random();
        }
Beispiel #11
0
 public PickUpGen(CoreEngine c, Vector3 p, PickUp.PickUpType t)
 {
     core = c;
     pos = p;
     itemType = t;
     held = null;
     genTime = 300;
 }
Beispiel #12
0
        public void Setup()
        {
            CreateScene();
            CreateStoryBoard();

            _engine = new CoreEngine(new WpfUpdater(), _canvas, _scene, _storyBoard,
                                     new StoryManager(new NullLoggerFactory(), RefreshRate.Normal));
        }
Beispiel #13
0
        public void Should_Not_Resolve_Service_Dependency()
        {
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            Assert.Throws <InvalidOperationException>(() => engine.Resolve <ITransientService>());
        }
Beispiel #14
0
 public PickUpGen(CoreEngine c, Vector3 p, PickUp.PickUpType t)
 {
     core     = c;
     pos      = p;
     itemType = t;
     held     = null;
     genTime  = 300;
 }
Beispiel #15
0
        private void OnReceiveConditionResult(object sender, OnReceiveStrateyStateResultArgs e)
        {
            Item = new MartinGailItem();

            Item.itemState = e.State;
            Item.itemCode  = e.ItemCode;
            startOrderTime = DateTime.Now;
            CoreEngine.GetInstance().SendLogMessage("!!!!! 마틴게일 아이템 :" + e.State.ToString());
        }
Beispiel #16
0
        public void Engine_Http_Client_Is_Singleton()
        {
            var engine = new CoreEngine();

            HttpClient httpClient = engine.HttpClient;

            Assert.Equal(httpClient, Singleton <HttpClient> .Instance);
            Assert.Equal(httpClient, BaseSingleton.AllSingletons[typeof(HttpClient)]);
        }
Beispiel #17
0
 public CoreGUI(CoreEngine _engine, GameWindow _window, float graphicsScale)
 {
     windows = new List <Window>();
     engine  = _engine;
     window  = _window;
     scale   = graphicsScale;
     ImGui.LoadDefaultFont();
     MapInput();
 }
Beispiel #18
0
        public void Should_Resolve_Unregistered_Service_Dependency()
        {
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.ResolveUnregistered(typeof(UnregisteredService));

            Assert.NotNull(requiredService);
        }
Beispiel #19
0
        public static void Main(string[] args)
        {
            var engine         = new CoreEngine();
            var zonePlaceables = OEQZoneReader.Read(args[0]);

            foreach (var placeable in zonePlaceables)
            {
                engine.AddPlaceable(placeable);
            }
            engine.Run();
        }
Beispiel #20
0
        public void Should_Resolve_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.Resolve <ITransientService>();

            Assert.NotNull(requiredService);
        }
Beispiel #21
0
        void Update()
        {
            if (Item != null)
            {
                if (Item.itemState == TRADING_ITEM_STATE.AUTO_TRADING_STATE_SEARCH_AND_CATCH)
                {
                    if ((DateTime.Now - startOrderTime).TotalSeconds > Wait_And_CancelValue)
                    {
                        CoreEngine.GetInstance().SendLogMessage("트레일링 취소");
                        CancelTrailing();
                    }
                }
                if (Item.itemState == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_NOT_COMPLETE ||
                    Item.itemState == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_NOT_COMPLETE_OUTCOUNT)
                {
                    //Console.WriteLine((DateTime.Now - startOrderTime).ToString());
                    //Console.WriteLine(tradingStrategyGridView.GetProfitRate((double)Item.curPrice, (double)Item.buyPrice).ToString());

                    if (Item.itemState == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_NOT_COMPLETE_OUTCOUNT)
                    {
                        if (using_Outstand_UpAndCancel && Form1.GetProfitRate((double)Item.curPrice, (double)Item.buyPrice) > OutStand_And_CancelValue)
                        {
                            CoreEngine.GetInstance().SendLogWarningMessage("!!!!!!!!!!!!using_Outstand_UpAndCancel!!!!!!!!!!!!!!");
                            CancelBuyOrderAll();
                            SellAllClear(); //청산
                        }
                    }
                    else
                    {
                        if (using_Up_And_Cancel && Form1.GetProfitRate((double)Item.curPrice, (double)Item.buyPrice) > Up_And_CancelValue)
                        {
                            CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!!using_Up_And_Cancel Pop MartinGail Item!!!!!!!!!!!!!!");
                            CancelBuyOrderAll();
                        }
                    }

                    if (using_WaitAndCancel && (DateTime.Now - startOrderTime).TotalSeconds > Wait_And_CancelValue)
                    {
                        CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!!using_WaitAndCancel Pop MartinGail Item!!!!!!!!!!!!!!");
                        CancelBuyOrderAll();
                    }
                }

                if (Item.itemState == TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_BEFORE_ORDER)
                {
                    //Console.WriteLine("주문접수성공 대기 : " + (DateTime.Now - startOrderTime).ToString());
                    if ((DateTime.Now - startOrderTime).TotalSeconds > Wait_And_CancelValue)
                    {
                        CoreEngine.GetInstance().SendLogMessage("주문접수성공 실패");
                        CancelBeforeBuyOrder();
                    }
                }
            }
        }
Beispiel #22
0
 private void CancelBuyOrderAll()
 {
     if (Item == null)
     {
         return;
     }
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! cancel code : " + Item.itemCode);
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! cancel orderNum : " + Item.buyOrderNum);
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! cancel quantity : " + (Item.buyQnt - Item.curQnt).ToString());
     form1.CancelBuyOrder(Item.itemCode, Item.buyOrderNum);
 }
Beispiel #23
0
 private void SellAllClear()
 {
     if (Item == null)
     {
         return;
     }
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! SellAllClear code : " + Item.itemCode);
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! SellAllClear orderNum : " + Item.buyOrderNum);
     CoreEngine.GetInstance().SendLogMessage("!!!!!!!!!!!! SellAllClear quantity : " + Item.curQnt.ToString());
     form1.SellAllClear(Item.itemCode, (int)Item.curQnt, form1.ReceiveSellAllClear);
 }
        public async Task <MessageResponse> LeaveGroup(UserGroupActionModel action)
        {
            CoreEngine core = new CoreEngine();

            var msg = await core.LeaveGroup(_repo, action.User, action.Group);

            var response = new MessageResponse {
                Message = msg
            };

            return(response);
        }
        public async Task <MessageResponse> UserLogin(UserLoginRequest user)
        {
            CoreEngine core = new CoreEngine();

            var msg = await core.UserLogin(_repo, user.UserName, TestingSettings.DEFAULT_COUNTRY);

            var response = new MessageResponse {
                Message = msg
            };

            return(response);
        }
Beispiel #26
0
        public void Should_Resolve_All_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService1));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.ResolveAll <ITransientService>();

            Assert.Equal(2, requiredService.Count());
        }
Beispiel #27
0
        public Window(Scene scene, CoreEngine core) :
            base(WindowType.Toplevel)
        {
            this.core = core;
            Build();
            DeleteEvent += delegate { Application.Quit(); };
            var disable = new Gdk.Color(10, 200, 10);

            DrawScene(scene);
            //SetAnimator(anim);
            //CreateWindow();
        }
Beispiel #28
0
        public void Should_Replace_An_Instance()
        {
            var engine = EngineContext.Create();

            engine.ConfigureServices();
            var newEngine = new CoreEngine();

            EngineContext.Replace(newEngine);

            Assert.Equal(EngineContext.Current, newEngine);
            Assert.Equal(EngineContext.Current.ServiceCollection.Count, newEngine.ServiceCollection.Count);
            Assert.NotEqual(EngineContext.Current.ServiceCollection.Count, engine.ServiceCollection.Count);
        }
Beispiel #29
0
        public RenderingEngine(CoreEngine engine)
        {
            this.engine = engine;

            camera = new Camera();

            anisotropicFiltering = 4;

            guis = new List <GUI>();

            directionalLights = new List <DirectionalLight>();
            pointLights       = new List <PointLight>();
            spotLights        = new List <SpotLight>();
        }
Beispiel #30
0
        public static void StartEngine()
        {
            try
            {
                ConfigurationBag.LoadConfiguration();
                LogEngine.Init();
                Debug.WriteLine(
                    $"Version {Assembly.GetExecutingAssembly().GetName().Version}",
                    ConsoleColor.Green);

                Debug.WriteLine("--GrabCaster Sevice Initialization--Start Engine.", ConsoleColor.Green);
                _delegate = delegateActionEventEmbedded;
                CoreEngine.StartEventEngine(_delegate);
                engineLoaded = true;
                Thread.Sleep(Timeout.Infinite);
            }
            catch (NotImplementedException ex)
            {
                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    "Error in " + MethodBase.GetCurrentMethod().Name,
                    Constant.LogLevelError,
                    Constant.TaskCategoriesError,
                    ex,
                    Constant.LogLevelError);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(
                    ConfigurationBag.EngineName,
                    "Error in " + MethodBase.GetCurrentMethod().Name,
                    Constant.LogLevelError,
                    Constant.TaskCategoriesError,
                    ex,
                    Constant.LogLevelError);
                Environment.Exit(0);
            } // try/catch
            finally
            {
                //Spool log queues
                if (LogEngine.QueueAbstractMessage != null)
                {
                    LogEngine.QueueAbstractMessageOnPublish(LogEngine.QueueAbstractMessage.ToArray().ToList());
                }
                if (LogEngine.QueueConsoleMessage != null)
                {
                    LogEngine.QueueConsoleMessageOnPublish(LogEngine.QueueConsoleMessage.ToArray().ToList());
                }
            }
        }
Beispiel #31
0
        public void PopMartinGailItem(long profit)
        {
            CoreEngine.GetInstance().SendLogMessage("PopMartinGailItem");
            Item = null;
            if (martinGailStack.Count == 0)
            {
                CoreEngine.GetInstance().SendLogWarningMessage("!!!!!!!!!!empty stack!!!!!!");
                RestartSameStep();
                return;
            }
            MartinGailItem itempop = martinGailStack.Pop();

            TodayAllTry++;

            if (profit > 0)
            {
                if (itempop != null)
                {
                    itempop.martinState = MARTIN_RESULT.WIN;
                    winCount++;
                    Restart();
                }
            }
            else if (profit == 0)
            {
                drawCount++;
                if (itempop != null)
                {
                    itempop.martinState = MARTIN_RESULT.DRAW;
                    RestartSameStep();
                }
            }
            else
            {
                loseCount++;
                if (itempop != null)
                {
                    itempop.martinState = MARTIN_RESULT.LOSE;

                    if (itempop.step >= MARTIN_MAX_STEP)
                    {
                        Restart();
                    }
                    else
                    {
                        GoNext();
                    }
                }
            }
        }
Beispiel #32
0
        public void Should_Register_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            using (var serviceScope = engine.ServiceProvider.CreateScope())
            {
                var requiredService = serviceScope.ServiceProvider.GetService <ITransientService>();

                Assert.NotNull(requiredService);
            }
        }
 public void StartAnalysisProcessTest()
 {
     CoreEngine target = new CoreEngine(); // TODO: Initialize to an appropriate value
     StrategyFormulizer strategyFormulizer = new StrategyFormulizer(target);
     DateTime startTime = new DateTime(2000,1,7); // TODO: Initialize to an appropriate value
     DateTime endTime = new DateTime(2010,1,15); // TODO: Initialize to an appropriate value
     //IEnumerable<TradeRecord> expected = null; // TODO: Initialize to an appropriate value
     //IEnumerable<TradeRecord> actual;
     DateTime startTimerTime = DateTime.Now;
     target.StartAnalysisProcess(startTime, endTime);
     DateTime endTimerTime = DateTime.Now;
     //Assert.AreEqual(expected, actual);
     Assert.Inconclusive(String.Format("It takes {0}ms to execute the engine", (endTimerTime - startTimerTime).Milliseconds));
 }
Beispiel #34
0
 public void AddPrice(double _price)
 {
     if (curSaveIndex >= saveCount)
     {
         CoreEngine.GetInstance().SendLogErrorMessage("저장갯수초과");
         return;
     }
     sumPrice += _price;
     curSaveIndex++;
     if (lowest == 0 || lowest > _price)
     {
         lowest = _price;
     }
     average = CalAverage();
 }
        public virtual void Configure(CoreEngine engine, ContainerManager containerManager)
        {
            //other dependencies
            //ContainerBuilder builder = new ContainerBuilder();
            //builder.RegisterGeneric(typeof(CoreEngine)).As(new List<Type> { typeof(CoreEngine) }.ToArray()).SingleInstance();
            //builder.Update(containerManager.Container);

            //containerManager.AddComponentInstance<CoreEngine>(engine, "core.engine");
            //containerManager.AddComponentInstance<ContainerConfigurer>(this, "core.containerConfigurer");

            //type finder
            containerManager.AddComponent<ITypeFinder, WebAppTypeFinder>("core.typeFinder");

            //register dependencies provided by other assemblies
            var typeFinder = containerManager.Resolve<ITypeFinder>();
            containerManager.UpdateContainer(x =>
            {
                var drTypes = typeFinder.FindClassesOfType<IDependencyRegistrar>();
                var drInstances = new List<IDependencyRegistrar>();
                foreach (var drType in drTypes)
                    drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
                //sort
                drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
                foreach (var dependencyRegistrar in drInstances)
                    dependencyRegistrar.Register(x, typeFinder);
            });

            //event broker
            //containerManager.AddComponentInstance(broker);

            //service registration
            //containerManager.AddComponent<DependencyAttributeRegistrator>("nop.serviceRegistrator");
            //var registrator = containerManager.Resolve<DependencyAttributeRegistrator>();
            //var services = registrator.FindServices();
            //var configurations = GetComponentConfigurations(configuration);
            //services = registrator.FilterServices(services, configurations);
            //registrator.RegisterServices(services);
        }
Beispiel #36
0
 public PickUpEngine(CoreEngine c)
 {
     gens = new List<PickUpGen>();
     core = c;
 }
Beispiel #37
0
 public AIAgent(CoreEngine c, Vector3 position)
     : this(c, position, new Vector2(1, 0))
 {
 }
Beispiel #38
0
        public MapEngine(CoreEngine c, String filename, Dictionary<String, Texture2D> textures)
        {
            core = c;
            this.textures = textures;
            brushes = new List<Brush>();
            lights = new List<Light>();
            playerPoss = new List<Vector3>();

            //load the map
            using (System.IO.StreamReader sr = System.IO.File.OpenText(filename)) {
                string s = "";
                int level = 0;
                Brush curBrush = null;
                Dictionary<String, String> keyVals = new Dictionary<string, string>();
                while ((s = sr.ReadLine()) != null) {
                    if (s.StartsWith("{")) {
                        level++;
                        if (level == 2)
                            curBrush = new Brush();
                    }
                    else if (s.StartsWith("}")) {
                        level--;
                        if (level == 1 && curBrush != null && keyVals["classname"] == "worldspawn") {
                            curBrush.generateFaces();
                            brushes.Add(curBrush);
                            //Console.WriteLine("Added brush with " + curBrush.verts + " vertices and " + curBrush.faces.Count + " faces");
                        }
                        if (level <= 1)
                            curBrush = null;
                        if (level == 0) {
                            if (keyVals["classname"] == "info_player_start" && keyVals.ContainsKey("origin")) {
                                string [] d = Regex.Split(keyVals["origin"], @"\s+");
                                //core.renderEngine.cameraPosition = toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2])+56));
                                //core.players[0].position = toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2])));
                                playerPoss.Add(toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))));
                                //Console.WriteLine("set player's position to " + core.players[0].position);
                            }
                            else if (keyVals["classname"] == "light" && keyVals.ContainsKey("light") && keyVals.ContainsKey("origin"))
                            {
                                string[] d = Regex.Split(keyVals["origin"], @"\s+");
                                //figure out the colour
                                string[] col = Regex.Split(keyVals["colour"], @"\s+");
                                Vector4 colour = new Vector4(1, 1, 1, 1);
                                if (col.Length > 0)
                                    colour.X = float.Parse(col[0]);
                                if (col.Length > 1)
                                    colour.Y = float.Parse(col[1]);
                                if (col.Length > 2)
                                    colour.Z = float.Parse(col[2]);
                                if (col.Length > 3)
                                    colour.W = float.Parse(col[3]);
                                lights.Add(new Light(toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))),
                                                    colour,
                                                    float.Parse(keyVals["light"])));
                            }
                            else if (keyVals["classname"] == "item_health" && keyVals.ContainsKey("origin"))
                            {
                                string[] d = Regex.Split(keyVals["origin"], @"\s+");
                                core.pickupEngine.gens.Add(new PickUpGen(core, toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))), PickUp.PickUpType.HEALTH));
                            }
                            else if (keyVals["classname"] == "item_armor_body" && keyVals.ContainsKey("origin"))
                            {
                                string[] d = Regex.Split(keyVals["origin"], @"\s+");
                                core.pickupEngine.gens.Add(new PickUpGen(core, toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))), PickUp.PickUpType.AMMO));
                            }
                            else if (keyVals["classname"] == "ammo_bfg" && keyVals.ContainsKey("origin"))
                            {
                                string[] d = Regex.Split(keyVals["origin"], @"\s+");
                                core.pickupEngine.gens.Add(new PickUpGen(core, toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))), PickUp.PickUpType.LEFT));
                            }
                            else if (keyVals["classname"] == "item_flight" && keyVals.ContainsKey("origin"))
                            {
                                string[] d = Regex.Split(keyVals["origin"], @"\s+");
                                core.pickupEngine.gens.Add(new PickUpGen(core, toWorldSpace(new Vector3(float.Parse(d[0]), float.Parse(d[1]), float.Parse(d[2]))), PickUp.PickUpType.RIGHT));
                            }
                            keyVals = new Dictionary<string, string>();
                        }
                    }
                    else if (level == 1 && s.StartsWith("\"")) {
                        string key = s.Substring(1);
                        key = key.Substring(0, key.IndexOf("\""));
                        string val = s.Substring(key.Length + 4);
                        val = val.Substring(0, val.Length-1);
                        keyVals[key] = val;
                    }
                    else if (level == 2 && keyVals["classname"] == "worldspawn") {
                        string[] d = Regex.Split(s, @"\s+");
                        Emergence.Map.Plane p = new Emergence.Map.Plane(new Vector3(float.Parse(d[1]), float.Parse(d[2]), float.Parse(d[3])),
                                                                                     new Vector3(float.Parse(d[6]), float.Parse(d[7]), float.Parse(d[8])),
                                                                                     new Vector3(float.Parse(d[11]), float.Parse(d[12]), float.Parse(d[13])),
                                                                                     textures[d[15]], //the texture name
                                                                                     double.Parse(d[16]),
                                                                                     double.Parse(d[17]),
                                                                                     double.Parse(d[18]),
                                                                                     double.Parse(d[19]),
                                                                                     double.Parse(d[20]));
                        curBrush.planes.Add(p);
                    }
                }
            }

            /*if (playerPoss.Count > 0) {
                core.players = new Player[playerPoss.Count];
                for (int i = 0; i < core.players.Length; i++)
                    core.players[i] = new Player(core, PlayerIndex.One + i, playerPoss[i]);
                core.renderEngine = new RenderEngine(core, RenderEngine.Layout.ONE + (playerPoss.Count - 1));
            }*/

            //Send Lights to shader
            Vector3[] poses = new Vector3[lights.Count];
            Vector4[] colours = new Vector4[lights.Count];
            float[] radii = new float[lights.Count];

            for(int i = 0; i < lights.Count; ++i){

                poses[i] = lights[i].position;
                colours[i] = lights[i].colour;
                radii[i] = lights[i].radius;
                Console.WriteLine(lights[i].position + " " + lights[i].radius);

            }

            core.lighting.Parameters["lightPoses"].SetValue(poses);
            core.lighting.Parameters["lightColours"].SetValue(colours);
            core.lighting.Parameters["lightRadii"].SetValue(radii);
        }
Beispiel #39
0
 public void TestCoreEngineQuery()
 {
     var core = new CoreEngine(prov, null);
     var result = core.Query<Person>("myperson", new { Age = 30 });
     Assert.AreNotEqual(0, result.Count(), "查询引擎失败");
 }
Beispiel #40
0
 public PickUpEngine(CoreEngine c, PickUpGen[] g)
     : this(c)
 {
     foreach (PickUpGen gg in g)
         gens.Add(gg);
 }
Beispiel #41
0
        public RenderEngine(CoreEngine c, PlayerIndex[] players)
        {
            core = c;
            lasers = new List<Laser>();
            projectiles = new List<Projectile>();
            explosions = new List<Explosion>();
            rockets = new List<Rocket>();
            Layout l = Layout.ONE + (players.Length - 1);
            curLayout = l;
            ports = new Viewport[(int)l];
            //defaultView = core.GraphicsDevice.Viewport;
            playerMap = new Dictionary<PlayerIndex, int>();
            int index = 0;
            foreach (PlayerIndex pi in players)
                playerMap.Add(pi, index++);

            cameras = new Matrix[(int)l];

            //Single player
            if (l == Layout.ONE) {

                ports[0] = defaultView;

            }
            //Two players
            else if (l == Layout.TWO) {

                ports[0] = defaultView;
                ports[0].Width /= 2;

                ports[1] = ports[0];
                ports[1].X += ports[0].Width;

            }
            //Three players
            else if (l == Layout.THREE)
            {

                ports[0] = defaultView;
                ports[0].Width /= 2;
                ports[0].Height /= 2;

                ports[1] = ports[0];
                ports[1].X += ports[0].Width;

                ports[2] = ports[0];
                ports[2].X += ports[2].Width / 2;
                ports[2].Y += ports[2].Height;

            }
            //Four players
            else {

                ports[0] = defaultView;
                ports[0].Width /= 2;
                ports[0].Height /= 2;

                ports[1] = ports[0];
                ports[1].X += ports[0].Width;

                ports[2] = ports[0];
                ports[2].Y += ports[0].Height;

                ports[3] = ports[1];
                ports[3].Y += ports[1].Height;

            }

            //initialise the basicEffect and vertex declaration
            vertexDecl = new VertexDeclaration(
                core.GraphicsDevice,
                VertexPositionNormalTexture.VertexElements);

            basicEffect = new BasicEffect(core.GraphicsDevice, null);
            basicEffect.World = Matrix.Identity;

            if(curLayout == Layout.TWO)
                basicEffect.Projection = halfMatrix;
            else
                basicEffect.Projection = fullMatrix;

            frustums = new BoundingFrustum[(int)curLayout];
            for (int i = 0; i < (int)curLayout; ++i)
                frustums[i] = new BoundingFrustum(Matrix.Identity);
        }
 public void StartAnalysisProcessTest2()
 {
     CoreEngine target = new CoreEngine(); // TODO: Initialize to an appropriate value
     StrategyFormulizer strategyFormulizer = new StrategyFormulizer(target);
     DateTime startTime = new DateTime(2000,1,7); // TODO: Initialize to an appropriate value
     DateTime endTime = new DateTime(2010,1,15); // TODO: Initialize to an appropriate value
     target.StartAnalysisProcess(startTime, endTime);
     var usdRecords = TradeRecordsCollection.UniqueInstance.TradeRecords.Where(r => r.CurrencyToTrade.Name == "USD");
     var targetRecord = usdRecords.Where(r => r.StartTime == startTime && r.EndTime == startTime.AddDays(7 * 12));
     Assert.IsTrue(targetRecord.Count() == 1);
     //Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
 public void StrategyFormulizerConstructorTest()
 {
     CoreEngine coreEngine = new CoreEngine(); // TODO: Initialize to an appropriate value
     StrategyFormulizer target = new StrategyFormulizer(coreEngine);
     
 }
Beispiel #44
0
        float timeSinceLastShot = 5; //the time since we last shot at the agent because we could see them

        #endregion Fields

        #region Constructors

        //State state = State.SearchForPickup;
        public AIAgent(CoreEngine c, Vector3 position, Vector2 direction)
            : base(c, position, direction)
        {
            speed = 300f;
        }