public void UpdateMeshes(MyScene scene) { try { gi.COREInterface.DisableSceneRedraw(); gi.COREInterface.EnableUndo(false); foreach (var m in scene.Items) { m.Skeleton = scene.Skeletons[m.SkeletonIndex]; Log.Add("Updating mesh " + m.Name, LogLevel.Debug); UpdateMeshData(m); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Caught exception in UpdateMeshes(): " + e.Message + e.TargetSite + e.StackTrace); } finally { gi.COREInterface.EnableUndo(true); gi.COREInterface.EnableSceneRedraw(); gi.COREInterface10.RedrawViewportsNow(gi.COREInterface.Time, MaxFlags.VP_DONT_SIMPLIFY); } }
public override Task EarlyUpdate() { return(Task.Run(() => { var cameras = MyScene.GetComponents <Graphics.Camera>(); foreach (var camera in cameras) { var transform = camera.MyEntity.GetComponent <Core.Transform>(); if (transform != null) { var position = transform.Position; if (Input.InputModule.IsKeyDown(Input.KeyCode.W)) { position.Z -= Time.DeltaTime * 2.0f; } if (Input.InputModule.IsKeyDown(Input.KeyCode.S)) { position.Z += Time.DeltaTime * 2.0f; } if (Input.InputModule.IsKeyDown(Input.KeyCode.D)) { position.X += Time.DeltaTime * 2.0f; } if (Input.InputModule.IsKeyDown(Input.KeyCode.A)) { position.X -= Time.DeltaTime * 2.0f; } transform.Position = position; } } })); }
// 現在のシーンを取得する public static MyScene MyGetScene() { string sceneName = SceneManager.GetActiveScene().name; scene = sceneDic[sceneName]; return(scene); }
/// <summary> /// Initialisation of MainWindow /// </summary> public MainWindow() { InitializeComponent(); modelList = new List <string>(); myScene = new MyScene(); foo.Content = myScene.Scene; }
public override Task <Observation> Reset(ServiceMessage request, ServerCallContext context) { return(WaveForegroundTask.Run(() => { var newScene = new MyScene(); WaveServices.ScreenContextManager.To(new ScreenContext(newScene), true); var tcs = new TaskCompletionSource <Observation>(); void StartedHandler(object sender, EventArgs args) { newScene.Started -= StartedHandler; WaveForegroundTask.Run(() => { this.service.SetScene(newScene); this.service.enginesComponent.ApplyInitialForce(); this.service.enginesComponent.ApplyEngineAction(EngineActions.None); this.service.scene.NextStep(TimeSpan.FromSeconds(1 / LunarConstants.FPS)); var actionResult = this.service.GetActionResult(EngineActions.None); tcs.SetResult(actionResult.Observation); }); } newScene.Started += StartedHandler; return tcs.Task; })); }
/// <summary> /// /// </summary> public override Task EarlyUpdate() => Task.Run(() => { // get all instaned meshes _instancedMeshes = Task.Run(() => { var instanced = new Dictionary <KeyValuePair <Material, Mesh>, List <MeshRenderer> >(); foreach (var meshRenderer in MyScene.GetComponents <MeshRenderer>()) { if (meshRenderer.Material.Instanced == false) { continue; } var key = new KeyValuePair <Material, Mesh>( meshRenderer.Material, meshRenderer.Mesh ); if (instanced.ContainsKey(key) == false) { instanced[key] = new List <MeshRenderer>(); } instanced[key].Add(meshRenderer); } return(instanced); }); });
public static void ChangeScense(MyScene fromSence, MyScene toScene) { UINotificationManager.Instance = null; previousSence = fromSence; currentSence = toScene; Application.LoadLevel(toScene.ToString()); Resources.UnloadUnusedAssets(); }
/// <summary> /// Called when system is disabled /// </summary> public override void OnDisable() { var audioSource = MyScene.GetComponents <AudioSource>(); foreach (var source in audioSource) { source.Stop(); } }
protected override void Update(TimeSpan gameTime) { inputService = WaveServices.Input; if (inputService.KeyboardState.IsConnected) { // Key F1 if (inputService.KeyboardState.F1 == ButtonState.Pressed && beforeKeyboardState.F1 != ButtonState.Pressed) { this.diagnostics = !this.diagnostics; WaveServices.ScreenContextManager.SetDiagnosticsActive(this.diagnostics); this.Owner.Scene.RenderManager.DebugLines = this.diagnostics; } // Key F5 else if (this.modeState != ModeState.EMITER && inputService.KeyboardState.F5 == ButtonState.Pressed && beforeKeyboardState.F5 != ButtonState.Pressed) { this.modeState = ModeState.EMITER; this.UpdateMode(this.modeState); } // Key F6 else if (this.modeState != ModeState.WALL && inputService.KeyboardState.F6 == ButtonState.Pressed && beforeKeyboardState.F6 != ButtonState.Pressed) { this.modeState = ModeState.WALL; this.UpdateMode(this.modeState); } // Key F7 else if (this.modeState != ModeState.BRIDGE && inputService.KeyboardState.F7 == ButtonState.Pressed && beforeKeyboardState.F7 != ButtonState.Pressed) { this.modeState = ModeState.BRIDGE; this.UpdateMode(this.modeState); } // Key G else if (inputService.KeyboardState.G == ButtonState.Pressed && beforeKeyboardState.G != ButtonState.Pressed) { gravityIndex++; this.Owner.Scene.PhysicsManager.Gravity3D = gravities[gravityIndex % gravities.Length]; } // Key H else if (inputService.KeyboardState.H == ButtonState.Pressed && beforeKeyboardState.H != ButtonState.Pressed) { MyScene scene = this.Owner.Scene as MyScene; scene.helpText.Entity.Enabled = !scene.helpText.Entity.Enabled; } } beforeKeyboardState = inputService.KeyboardState; }
/// <summary> /// Called when system is activated /// </summary> public override void OnEnable() { UpdatePositionVelocityAndOrientation(); var audioSource = MyScene.GetComponents <AudioSource>(); foreach (var source in audioSource) { source.Play(); } }
private void Travel(Room destination) { if (destination == null) { return; } MyScene.RemoveEntity(this); destination.AddEntity(this); Game.CurrentScene = destination; }
public void SKScene_InitWithSizeSuper() { if (IntPtr.Size != 8) // SpriteKit is 64-bit only on mac { return; } MyScene c = new MyScene(new CGSize(50, 50)); Assert.IsNotNull(c); }
private void MoveLeft() { if (!MyScene.GetCollision(X - 1, Y)) { X--; } else { _facing = Direction.North; } }
private void MoveRight() { if (!MyScene.GetCollision(X + 1, Y)) { X++; } else { _facing++; } }
private void MoveDown() { if (!MyScene.GetCollision(X, Y + 1)) { Y++; } else { _facing++; } }
private void MoveUp() { if (!MyScene.GetCollision(X, Y - 1)) { Y--; } else { _facing++; } }
private void MoveRight() { if (!MyScene.GetCollision(X + Speed, Y)) { XVelocity = Speed; } else { XVelocity = 0f; _facing++; } }
public void MoveDown(float deltaTime) { if (!MyScene.GetCollision(XAbsolute, Sprite.Bottom + Speed * deltaTime)) { yVelocity = Speed * deltaTime; } else { yVelocity = 0f; _facing = Direction.East; } }
public void MoveRight(float deltaTime) { if (!MyScene.GetCollision(YAbsolute, Sprite.right + Speed * deltaTime)) { xVelocity = Speed * deltaTime; } else { xVelocity = 0f; _facing = Direction.North; } }
private void MoveLeft() { if (!MyScene.GetCollision(X - Speed, Y)) { XVelocity = -Speed; } else { XVelocity = 0f; _facing = Direction.North; } }
private void MoveDown() { if (!MyScene.GetCollision(X, Y + Speed)) { YVelocity = Speed; } else { YVelocity = 0f; _facing++; } }
public void MoveLeft(float deltaTime) { if (!MyScene.GetCollision(YAbsolute, Sprite.Left - Speed * deltaTime)) { xVelocity = -Speed * deltaTime; } else { xVelocity = 0f; _facing = Direction.West; } }
internal static unsafe void InitSubsystems() { InitializeBlendStates(); InitializeRasterizerStates(); InitilizeSamplerStates(); MyScene.Init(); MyRender11.Init(); MyCommon.Init(); MyPipelineStates.Init(); MyTextures.Init(); MyVertexLayouts.Init(); MyShaders.Init(); MyRwTextures.Init(); MyHwBuffers.Init(); MyMeshes.Init(); MyMeshTableSRV.Init(); MyMergeInstancing.Init(); MyLightRendering.Init(); MyLinesRenderer.Init(); MySpritesRenderer.Init(); MyPrimitivesRenderer.Init(); MyOutline.Init(); MyBlur.Init(); MyFoliageComponents.Init(); MyBillboardRenderer.Init(); // hardcoded limits MyDebugRenderer.Init(); MyScreenDecals.Init(); MyEnvProbeProcessing.Init(); MyAtmosphereRenderer.Init(); MyCloudRenderer.Init(); MyAAEdgeMarking.Init(); MyScreenPass.Init(); MyCopyToRT.Init(); MyBlendTargets.Init(); MyFXAA.Init(); MyDepthResolve.Init(); MyBloom.Init(); MyLuminanceAverage.Init(); MyToneMapping.Init(); MySSAO.Init(); MyPlanetBlur.Init(); MyHdrDebugTools.Init(); MySceneMaterials.Init(); MyMaterials1.Init(); MyVoxelMaterials1.Init(); MyMeshMaterials1.Init(); }
public void MoveUP(float deltaTime) { if (!MyScene.GetCollision(XAbsolute, Sprite.Top - Speed * deltaTime)) { yVelocity = -Speed * deltaTime; } else { yVelocity = 0f; _facing = Direction.South; } }
protected override void OnStart() { var scene = new MyScene(); layer = new Layer2D(); var obj = new TextureObject2D { Texture = Engine.Graphics.CreateTexture2D(CloudTexturePath), }; layer.AddObject(obj); scene.AddLayer(layer); Engine.ChangeScene(scene); }
/// <summary> /// Initializes this instance. /// </summary> /// <param name="game">The game.</param> public void Initialize(SampleWPFProject.Game game) { this.game = game; this.scene = WaveServices.ScreenContextManager.CurrentContext[0] as MyScene; this.EarthRadius = this.scene.Earth.FindComponent <Transform3D>().Scale.X; this.EarthDayLength = this.scene.Earth.FindComponent <OrbitBehavior>().DayTime; this.MoonRadius = this.scene.Moon.FindComponent <Transform3D>().Scale.X; this.MoonDayLength = this.scene.Moon.FindComponent <OrbitBehavior>().DayTime; this.MoonOrbitLength = this.scene.Moon.FindComponent <OrbitBehavior>().YearTime; this.MoonOrbitRadius = this.scene.Moon.FindComponent <OrbitBehavior>().Radius; this.SunLightIntensity = this.scene.Sun.Color.R / 255f; this.SunFlareRadius = this.scene.Sun.LensFlare.Scale; }
//---------------------------------------------------------------------------------------------------- /// <summary> /// 現在シーンの処理 /// </summary> void CurrentSceneProcess() { m_countMaskTime -= Time.deltaTime; m_workColor = MaskImage.color; m_workColor.a = m_countMaskTime / m_maskTime; MaskImage.color = m_workColor; //マスク処理完了 if (MaskImage.color.a <= 0f) { MaskImage.raycastTarget = false; m_isChangeScene = false; m_pastScene = m_currentScene; } }
public override void ViewDidLoad() { base.ViewDidLoad (); // Configure the view. var skView = (SKView)View; skView.ShowsFPS = true; skView.ShowsNodeCount = true; // Create and configure the scene. var scene = new MyScene (skView.Bounds.Size); scene.ScaleMode = SKSceneScaleMode.AspectFill; // Present the scene. skView.PresentScene (scene); }
//Move one space up private void MoveDown() { if (Y + 1 >= MyScene.SizeY) { if (MyScene is Room) { Room dest = (Room)MyScene; Travel(dest.South); } Y = 0; } else if (!MyScene.GetCollision(X, Y + 1)) { Y++; } }
//Move one space up private void MoveUp() { if (Y - 1 < 0) { if (MyScene is Room) { Room dest = (Room)MyScene; Travel(dest.North); } Y = MyScene.SizeY - 1; } else if (!MyScene.GetCollision(X, Y - 1)) { Y--; } }
//Move one space to the left private void MoveLeft() { if (X - 1 < 0) { if (MyScene is Room) { Room dest = (Room)MyScene; Travel(dest.West); } X = MyScene.SizeX - 1; } else if (!MyScene.GetCollision(X - 1, Y)) { X--; } }
//Move one space to the right private void MoveRight() { if (X + 1 >= MyScene.SizeX) { if (MyScene is Room) { Room dest = (Room)MyScene; Travel(dest.East); } X = 0; } else if (!MyScene.GetCollision(X + 1, Y)) { X++; } }
/// <summary> /// Allows this instance to execute custom logic during its /// <c>Update</c>. /// </summary> /// <param name="gameTime">The game time.</param> /// <remarks> /// This method will not be executed if it are not /// <c>Active</c>. /// </remarks> protected override void Update(TimeSpan gameTime) { if (!this.initialized) { this.modelFactoryService = ModelFactoryService.Instance; this.playScene = this.Owner.Scene as MyScene; this.player = this.EntityManager.Find(this.PlayerSource); this.playerTransform = this.player.FindComponent<Transform3D>(); this.playerCollider = this.player.FindComponent<BoxCollider3D>(); this.playerBehavior = this.player.FindComponent<PlayerBehavior>(); this.tempBoundingBox = new BoundingBox(); this.initialized = true; } // Game Tri-state machine switch (GameState) { // Initial level state case GameState.INIT: // Loads the level // it can be done in everywhere we want, in scene too, but then we need to call a Reset method or similar this.LevelModel = ImportService.Instance.ImportLevel(WaveContent.Assets.Levels.level1A_level); // Restart Camera, Player states and positions this.player.FindComponent<PlayerBehavior>().Restart(); // put player over the first ground block // FIRST BLOCK OF LEVEL SHOULD BE A GROUND, logically this.playerTransform.Position = new Vector3(0f, this.modelFactoryService.Scale.Y, 0.0f); // fills the intiial Buffer, we need to load some elements prior playing float currentZ = 0; for (int i = 0; i < BlockBufferSize; i++) { // Create Column this.CreateNextColumnEntity(currentZ); currentZ += this.modelFactoryService.Scale.Z; } GameState = GameState.PLAY; break; // Playing State of game: case GameState.PLAY: // new player position, using acceleration, falling, etc... where applicable //// this.UpdatePlayerPosition(elapsedGameTime); // Check if dead by level platform falling down if (this.playerTransform.Position.Y <= UnderDeadLevel) { this.GameState = Enums.GameState.DIE; break; } // Selects the current and next column, selects the columns to free too. // the current column and next column are used to check collisions, only with those two columns, others are ignored for (int i = 0; i < this.ColumnCollection.Count - 1; i++) { Entity column = this.ColumnCollection[i]; var columnTransform = column.FindComponent<Transform3D>(); // Remove passedby columns by distance if (columnTransform.Position.Z < this.playerTransform.Position.Z - PasseByBlocksToDiscardColumn * this.modelFactoryService.Scale.Z) { ////// removes column this.modelFactoryService.FreeColumn(column); this.ColumnCollection.RemoveAt(i); ////// Create new column at the end this.CreateNextColumnEntity(columnTransform.Position.Z + BlockBufferSize * this.modelFactoryService.Scale.Z); } // check if player is over this column and sets current and next column else if (this.playerTransform.Position.Z < columnTransform.Position.Z + this.modelFactoryService.Scale.Z && this.playerTransform.Position.Z >= columnTransform.Position.Z) { this.CurrentColumn = column; this.NextColumn = this.ColumnCollection[i + 1]; // update the ground level for current and next columns this.CheckGroundPosition(); break; } } // if there are a current column checks the collision in current and next column if (this.CurrentColumn != null && !this.CurrentColumn.IsDisposed && this.NextColumn!=null && !this.NextColumn.IsDisposed) { // creates the union of each column entities List<Entity> collidableCollection = this.CurrentColumn.ChildEntities.ToList(); collidableCollection.AddRange(this.NextColumn.ChildEntities.ToList()); // check if collides foreach (Entity block in collidableCollection) { var blockTransform = block.FindComponent<Transform3D>(); var blockCollider = block.FindComponent<BoxCollider3D>(); // updates the block boundingbox to check collision this.tempBoundingBox.Max = blockTransform.Position + blockCollider.Size / 2; this.tempBoundingBox.Min = blockTransform.Position - blockCollider.Size / 2; // we use intersects of boundboxes cause collider class has not a Intersects with boundingboxes if (this.tempBoundingBox.Intersects(this.playerBehavior.PlayerBoundingBox)) { BlockTypeEnum blockType = BlockTypeEnum.EMPTY; Enum.TryParse<BlockTypeEnum>(block.Tag, out blockType); // if player colliders with the block, we must to check the block effect: switch (blockType) { case BlockTypeEnum.EMPTY: break; // ground and box obstacles can walk over they, but if crash horizontally player dies case BlockTypeEnum.GROUND: case BlockTypeEnum.BOX: if (this.playerBehavior.Collides(blockTransform)) { this.GameState = Enums.GameState.DIE; } break; case BlockTypeEnum.PYRAMID: // pyramid collision dies player this.GameState = Enums.GameState.DIE; break; case BlockTypeEnum.SPEEDERBLOCK: // if collide with speeder then player accelerates this.playerBehavior.Accelerate((float)gameTime.TotalSeconds); break; default: break; } } } } break; // player die state case GameState.DIE: // free every column entity and remove containers from entitymanager foreach (Entity column in this.ColumnCollection) { this.modelFactoryService.FreeColumn(column); } // clears the collection and colums this.ColumnCollection.Clear(); this.CurrentColumn = null; this.NextColumn = null; // just init GameState = GameState.INIT; break; } }
public string PrintMaterialProperties(MyScene scene) { List<String> lines = new List<string>(); foreach (MyMesh m in scene.Items) { lines.Add("-------------------------------------------"); lines.Add("Mesh Name: " + m.Name); lines.Add("-------------------------------------------"); foreach (var mat in m.Materials) { lines.Add(" ------------------- "); lines.Add("Material Name: " + mat.MaterialName); lines.Add("Material Index: " + mat.MaterialIndex); lines.Add("Material Type: " + mat.MaterialType); lines.Add(" ------------------- "); foreach (KeyValuePair<string, string> kvp in mat.MaterialProperties) { lines.Add(kvp.Key + ": " + kvp.Value); } lines.Add(" ------------------- "); } lines.Add("END"); } string final = ""; foreach (var s in lines) { final += (s + Environment.NewLine); } return final; }