示例#1
0
 public void Initialize(ISceneSettings settings)
 {
     Root          = Rules.CreateWorld(this, settings);
     DrawerFactory = new DrawerFactory(Root);
     PhysicalManager.InitializeEngine(PhysicalEngines.Farseer, Root);
     Logger = new ReplayLogger(Root, 0.1);
 }
示例#2
0
 public void Initialize(ISceneSettings settings)
 {
     Root = Rules.CreateWorld(this, settings);
     DrawerFactory = new DrawerFactory(Root);
     PhysicalManager.InitializeEngine(PhysicalEngines.Farseer, Root);
     Logger = new ReplayLogger(Root, 0.1);
 }
 public void LoadScene(string name, ISceneSettings settings, bool restrictToSingleScene)
 {
     if (restrictToSingleScene &&
         (LoadedScenes.Any(p => p.Name == name) || ScenesQueue.Any(p => p.Name == name) ||
          Application.loadedLevelName == name)) return;
     this.QueueSceneLoad(name, settings);
     this.ExecuteLoad();
 }
 public void QueueSceneLoad(string sceneName, ISceneSettings settings)
 {
     ScenesQueue.Enqueue(new SceneQueueItem()
     {
         Loader = LoadSceneInternal(sceneName),
         Name = sceneName,
         Settings = settings
     });
 }
 public void QueueSceneLoad(string sceneName, ISceneSettings settings)
 {
     ScenesQueue.Enqueue(new SceneQueueItem()
     {
         Loader   = LoadSceneInternal(sceneName),
         Name     = sceneName,
         Settings = settings
     });
 }
 public void LoadSceneIfNotAlready(string name, ISceneSettings settings)
 {
     if (LoadedScenes.Any(p => p.Name == name) || ScenesQueue.Any(p => p.Name == name) ||
         Application.loadedLevelName == name)
     {
         return;
     }
     this.QueueSceneLoad(name, settings);
     this.ExecuteLoad();
 }
 public void LoadScene(string name, ISceneSettings settings, bool restrictToSingleScene)
 {
     if (restrictToSingleScene &&
         (LoadedScenes.Any(p => p.Name == name) || ScenesQueue.Any(p => p.Name == name) ||
          Application.loadedLevelName == name))
     {
         return;
     }
     this.QueueSceneLoad(name, settings);
     this.ExecuteLoad();
 }
        public void LoadScene(string name, ISceneSettings settings, bool restrictToSingleScene)
        {
            if (restrictToSingleScene &&
                (LoadedScenes.Any(p => p.Name == name) || ScenesQueue.Any(p => p.Name == name) ||
//                 Application.loadedLevelName == name)) return;
                 UnityEngine.SceneManagement.SceneManager.GetSceneAt(UnityEngine.SceneManagement.SceneManager.sceneCount - 1).name == name))
            {
                return;
            }
            this.QueueSceneLoad(name, settings);
            this.ExecuteLoad();
        }
 public void QueueSceneLoadIfNotAlready(string sceneName, ISceneSettings settings)
 {
     if (LoadedScenes.Any(p => p.Name == sceneName) || ScenesQueue.Any(p => p.Name == sceneName) ||
         Application.loadedLevelName == sceneName)
     {
         return;
     }
     ScenesQueue.Enqueue(new SceneQueueItem()
     {
         Loader   = LoadSceneInternal(sceneName),
         Name     = sceneName,
         Settings = settings
     });
 }
 public void QueueSceneLoadIfNotAlready(string sceneName, ISceneSettings settings)
 {
     if (LoadedScenes.Any(p => p.Name == sceneName) || ScenesQueue.Any(p => p.Name == sceneName) ||
         Application.loadedLevelName == sceneName)
     {
         return;
     }
     ScenesQueue.Enqueue(new SceneQueueItem()
     {
         Loader = LoadSceneInternal(sceneName),
         Name = sceneName,
         Settings = settings
     });
 }
示例#11
0
        public void QueueSceneLoadIfNotAlready(string sceneName, ISceneSettings settings)
        {
            if (LoadedScenes.Any(p => p.Name == sceneName) || ScenesQueue.Any(p => p.Name == sceneName) ||
//			    Application.loadedLevelName == sceneName) {
                UnityEngine.SceneManagement.SceneManager.GetSceneAt(UnityEngine.SceneManagement.SceneManager.sceneCount - 1).name == sceneName)
            {
                return;
            }
            ScenesQueue.Enqueue(new SceneQueueItem()
            {
                Loader   = LoadSceneInternal(sceneName),
                Name     = sceneName,
                Settings = settings
            });
        }
	private void SwitchScene(string fromScene, string toScene, ISceneSettings settings, bool restrictToSingleScene, string translateEffect = null)
	{
		//TODO:translateEffect

		Debug.Assert (toScene != null, "toscene should not be none");
		UnloadScene(fromScene);
		LoadScene (toScene, settings, restrictToSingleScene);

		// OnEvent<SceneLoaderEvent>().Where(_ => 
		// 	_.State == SceneState.Loaded && _.SceneRoot.Name == toScene
		// ).Subscribe((_)=>{
		// 	if (!string.IsNullOrEmpty (fromScene)) {
		// 		UnloadScene (fromScene);
		// 	}
		// });


	}
示例#13
0
        public Body CreateWorld(ICvarcEngine engine, ISceneSettings _settings)
        {
            Settings = (SceneSettings)_settings;
            var root = new Body();

            var first = new Cylinder
            {
                Height              = 20,
                RTop                = 10,
                RBottom             = 10,
                Location            = new Frame3D(-150 + 25 - 10, 100 - 25 + 10, 3),
                DefaultColor        = Color.DarkViolet,
                IsMaterial          = true,
                Density             = Density.Iron,
                FrictionCoefficient = 0,
                Top = new PlaneImageBrush {
                    Image = new Bitmap(GetResourceStream("red.png"))
                },
                Type = "Robot"
            };
            var second = new Cylinder
            {
                Height              = 20,
                RTop                = 10,
                RBottom             = 10,
                Location            = new Frame3D(150 - 25 + 10, 100 - 25 + 10, 3, Angle.Zero, Angle.Pi, Angle.Zero),
                DefaultColor        = Color.DarkViolet,
                IsMaterial          = true,
                Density             = Density.Iron,
                FrictionCoefficient = 0,
                Top = new PlaneImageBrush {
                    Image = new Bitmap(GetResourceStream("blue.png"))
                },
                Type = "Robot"
            };

            root.Add(first);
            root.Add(second);

            first.Collision  += body => engine.RaiseOnCollision(first.Id.ToString(), body.Id.ToString(), CollisionType.RobotCollision);
            second.Collision += body => engine.RaiseOnCollision(second.Id.ToString(), body.Id.ToString(), CollisionType.RobotCollision);

            root.Add(new Box
            {
                XSize        = 300,
                YSize        = 200,
                ZSize        = 3,
                DefaultColor = Color.White,
                Top          = new SolidColorBrush {
                    Color = Color.Yellow
                },
                IsStatic = true,
                Type     = "floor",
            });

            foreach (var detail in Settings.Details)
            {
                Color  color = Color.White;
                string name  = "D";
                switch (detail.Color)
                {
                case DetailColor.Red: color = Color.Red; name += "R"; break;

                case DetailColor.Blue: color = Color.Blue; name += "B"; break;

                case DetailColor.Green: color = Color.Green; name += "G"; break;
                }

                var box = new Box
                {
                    XSize               = 15,
                    YSize               = 15,
                    ZSize               = 15,
                    Location            = new Frame3D(-150 + 25 + detail.Location.X * 50, 100 - 25 - 50 * detail.Location.Y, 0),
                    DefaultColor        = color,
                    Type                = name,
                    IsMaterial          = true,
                    IsStatic            = false,
                    FrictionCoefficient = 8
                };
                root.Add(box);

                box.Collision += body =>
                {
                    if (box.Parent.Id == first.Id && body.Id == second.Id)
                    {
                        engine.RaiseOnCollision(second.Id.ToString(), first.Id.ToString(), CollisionType.RobotCollision);
                    }
                    if (box.Parent.Id == second.Id && body.Id == first.Id)
                    {
                        engine.RaiseOnCollision(first.Id.ToString(), second.Id.ToString(), CollisionType.RobotCollision);
                    }
                };
            }

            CreateWalls(root, Settings.HorizontalWalls, 50, 10, 15, "HW", (x, y) => new Point(-150 + 25 + x * 50, 100 - (y + 1) * 50));
            CreateWalls(root, Settings.VerticalWalls, 10, 50, 14, "VW", (x, y) => new Point(-150 + (x + 1) * 50, 100 - 25 - y * 50));


            CreateBorders(root);

            return(root);
        }
 public void LoadScene(string name, ISceneSettings settings)
 {
     this.QueueSceneLoad(name, settings);
     this.ExecuteLoad();
 }
        public void LoadScene(string name, ISceneSettings settings, bool restrictToSingleScene)
        {
            if (restrictToSingleScene &&
                (LoadedScenes.Any(p => p.Name == name) || ScenesQueue.Any(p => p.Name == name) ||
                SceneManager.GetSceneByName(name).isLoaded)) return;

            this.QueueSceneLoad(name, settings);
            this.ExecuteLoad();
        }
示例#16
0
        public Body CreateWorld(ICvarcEngine engine, ISceneSettings _settings)
        {
            Settings = (SceneSettings)_settings;
            var root = new Body();

            var first = new Cylinder
            {
                Height = 20,
                RTop = 10,
                RBottom = 10,
                Location = new Frame3D(-150 + 25 - 10, 100 - 25 + 10, 3),
                DefaultColor = Color.DarkViolet,
                IsMaterial = true,
                Density = Density.Iron,
                FrictionCoefficient = 0,
                Top = new PlaneImageBrush { Image = new Bitmap(GetResourceStream("red.png")) },
                Type = "Robot"
            };
            var second = new Cylinder
            {
                Height = 20,
                RTop = 10,
                RBottom = 10,
                Location = new Frame3D(150 - 25 + 10, 100 - 25 + 10, 3, Angle.Zero, Angle.Pi, Angle.Zero),
                DefaultColor = Color.DarkViolet,
                IsMaterial = true,
                Density = Density.Iron,
                FrictionCoefficient = 0,
                Top = new PlaneImageBrush { Image = new Bitmap(GetResourceStream("blue.png")) },
                Type = "Robot"
            };
            root.Add(first);
            root.Add(second);

            first.Collision += body => engine.RaiseOnCollision(first.Id.ToString(), body.Id.ToString(), CollisionType.RobotCollision);
            second.Collision += body => engine.RaiseOnCollision(second.Id.ToString(), body.Id.ToString(), CollisionType.RobotCollision);
            
            root.Add(new Box
            {
                XSize = 300,
                YSize = 200,
                ZSize = 3,
                DefaultColor = Color.White,
                Top = new SolidColorBrush { Color = Color.Yellow },
                IsStatic = true,
                Type = "floor",
            });

            foreach (var detail in Settings.Details)
            {
                Color color = Color.White;
                string name = "D";
                switch (detail.Color)
                {
                    case DetailColor.Red: color = Color.Red; name += "R"; break;
                    case DetailColor.Blue: color = Color.Blue; name += "B"; break;
                    case DetailColor.Green: color = Color.Green; name += "G"; break;
                }

                var box = new Box
                {
                    XSize = 15,
                    YSize = 15,
                    ZSize = 15,
                    Location = new Frame3D(-150 + 25 + detail.Location.X * 50, 100 - 25 - 50 * detail.Location.Y, 0),
                    DefaultColor = color,
                    Type = name,
                    IsMaterial = true,
                    IsStatic = false,
                    FrictionCoefficient = 8
                };
                root.Add(box);

                box.Collision += body =>
                    {
                        if (box.Parent.Id == first.Id && body.Id == second.Id)
                            engine.RaiseOnCollision(second.Id.ToString(), first.Id.ToString(), CollisionType.RobotCollision);
                        if (box.Parent.Id == second.Id && body.Id == first.Id)
                            engine.RaiseOnCollision(first.Id.ToString(), second.Id.ToString(), CollisionType.RobotCollision);
                    };
            }

            CreateWalls(root, Settings.HorizontalWalls, 50, 10, 15, "HW", (x, y) => new Point(-150 + 25 + x * 50, 100 - (y + 1) * 50));
            CreateWalls(root, Settings.VerticalWalls, 10, 50, 14, "VW", (x, y) => new Point(-150 + (x + 1) * 50, 100 - 25 - y * 50));


            CreateBorders(root);

            return root;
        }