public bool CheckNeedShowDevelopmentDataOfAreaAndPoints(ViewportRenderingContext context, GetRenderSceneDataMode mode) { if (EnabledInHierarchy && VisibleInHierarchy && mode == GetRenderSceneDataMode.InsideFrustum) { if (ParentScene.GetDisplayDevelopmentDataInThisApplication() && ParentScene.DisplayAreas) { return(true); } var context2 = context.objectInSpaceRenderingContext; if (context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this) { return(true); } foreach (var point in GetPoints()) { if (context2.selectedObjects.Contains(point) || context2.canSelectObjects.Contains(point) || context2.objectToCreate == point) { return(true); } } } return(false); }
/// <summary> /// Public override method which is launched at each frame. /// </summary> public override void Update() { // Sees if the player as not died or finish the level if (!player.Gameover) { framesForTime++; // At each 50 frames, the time goes down by 1 if (framesForTime == 50) { Timing--; framesForTime = 0; /* Actualizes the render of the game object with the * actualized score */ ParentGameObject.GetComponent <RenderableStringComponent>(). SwitchString(() => "Time: " + Timing.ToString()); } // Returns to the menu if the time's up. if (Timing == 0) { ParentScene.Terminate(); Menu menu = new Menu(); menu.Run(); } } }
void ModelCountChange() { ModelValue[] NewModels = new ModelValue[ModelCount.get()]; for (int i = 0; i < Math.Max(ModelCount.get(), ModelCountPrevious); i++) { if (i < ModelCount.get()) { if (i < ModelCountPrevious) { NewModels[i] = Models[i]; } else { Level.ReferenceObject = this; NewModels[i] = new ModelValue("Model " + i.ToString()); } } else { RemoveValue(Models[i]); } } Models = NewModels; Items = new LineModelItem[ModelCount.get()]; ModelCountPrevious = ModelCount.get(); #if EDITOR && WINDOWS if (ParentLevel.LevelForEditing) { ParentScene.UpdateSelected(); } #endif }
/// <summary> /// Player update levels and victory/defeat conditions /// </summary> public override void Update() { base.Update(); // Player directions _playerLeft = new Vector2((int)selfTrans.Pos.X - 1, (int)selfTrans.Pos.Y); _playerRight = new Vector2((int)selfTrans.Pos.X + 1, (int)selfTrans.Pos.Y); _playerDown = new Vector2((int)selfTrans.Pos.X, (int)selfTrans.Pos.Y + 1); _playerUp = new Vector2((int)selfTrans.Pos.X, (int)selfTrans.Pos.Y - 1); _playerPos = new Vector2((int)selfTrans.Pos.X, (int)selfTrans.Pos.Y); // Level up LevelUp(Role); // Check if dead if (Life <= 0) { // End game, You died ParentScene.Terminate(); } }
//Lägger till alla alternativ som GameObjects i Inputfönstret, renderar dem och tar bort dem //(de behövs bara renderas engång, efter som spelaren gör sitt val innan nästa rendering) public void DisplayChoises(Choice[] choices) { for (int i = 0; i < choices.Length; i++) { GameObject gameObject = new GameObject("text"); Text textComponent = gameObject.GetComponent <Text>(); textComponent.Wrapper = (uint)(GetComponent <Sprite>()._transform.w - (_textMargin * 2)); textComponent.Message = (i + 1) + ". " + choices[i].Text; gameObject.SetParent(this); gameObject.SetParentScene(ParentScene); gameObject._transform.y = _textMargin + (i * textComponent._transform.h); gameObject._transform.x = _textMargin; _gameObjects.Add(gameObject); ParentScene.AddGameObject(gameObject); } RenderEngine.Render(); foreach (GameObject gameObject in _gameObjects) { gameObject.Dispose(); SceneManager.RemoveGameObject(gameObject); } }
public void ApplySnap(bool ApplyToChildren) { if (ParentScene != null && ParentScene.GetType().IsSubclassOf(typeof(Basic2DScene))) { Basic2DScene s = (Basic2DScene)ParentScene; if (s.GridSize != null) { Vector2 GridSize = s.GridSize.get(); Vector2 Pos = Position.get(); Position.set(new Vector2((float)Math.Round(Position.get().X / s.GridSize.get().X), (float)Math.Round(Position.get().Y / s.GridSize.get().Y)) * s.GridSize.get()); } } if (ApplyToChildren) { foreach (GameObject g in HierarchyChildren) #if EDITOR && WINDOWS { if (!ParentLevel.LevelForEditing || !g.EditorSelected) #endif { if (g.GetType().IsSubclassOf(typeof(Basic2DObject))) { Basic2DObject b = (Basic2DObject)g; b.ApplySnap(true); } } } }
/// <summary> /// Override method of base class Start() /// </summary> public override void Start() { base.Start(); _selfTrans = GetComponent <Transform>(); plr = ParentScene.FindGameObjectByName("Player") as Player; _plrTrans = plr.GetComponent <Transform>(); }
/// <summary> /// Public override method which initiates at the first frame. /// </summary> public override void Start() { Scoring = 3000; framesForTime = 0; player = ParentScene .FindGameObjectByName("Player") .GetComponent <Player>(); }
protected override bool OnEnabledSelectionByCursor() { if (!ParentScene.GetDisplayDevelopmentDataInThisApplication() || !ParentScene.DisplayLabels) { return(false); } return(base.OnEnabledSelectionByCursor()); }
/// <summary> /// Dungeon update with base, checks if enemies exist, /// if not, terminate game /// </summary> public override void Update() { base.Update(); if (CheckAliveDead()) { // End game, victory screen ParentScene.Terminate(); } }
public void SetShield(ShieldType shieldType, float secs) { if (shieldComponent != null) { ParentScene.RemoveObject(shieldComponent); shieldComponent = null; } if (shieldComponentFront != null) { ParentScene.RemoveObject(shieldComponentFront); shieldComponentFront = null; } if (shieldType == ShieldType.None) { shieldTime = 0f; return; } shieldTime = secs * Time.FramesPerSecond; switch (shieldType) { case ShieldType.Fire: shieldComponent = new ShieldComponent(shieldType, false); shieldComponent.OnAttach(new ActorInstantiationDetails { Api = api }); shieldComponent.Parent = this; shieldComponentFront = new ShieldComponent(shieldType, true); shieldComponentFront.OnAttach(new ActorInstantiationDetails { Api = api }); shieldComponentFront.Parent = this; break; case ShieldType.Water: shieldComponentFront = new ShieldComponent(shieldType, true); shieldComponentFront.OnAttach(new ActorInstantiationDetails { Api = api }); shieldComponentFront.Parent = this; break; case ShieldType.Lightning: // ToDo break; case ShieldType.Laser: // ToDo break; } }
public override void Update() { foreach (ConsoleKey key in keyObserver.GetCurrentKeys()) { if (key == ConsoleKey.Escape) { Console.WriteLine("Bye :("); ParentScene.Terminate(); } } }
public override void Create() { MoveSpeed = new FloatValue("Move Speed", 10); ResizeSpeed = new FloatValue("Resize Speed", 10); base.Create(); AddTag(GameObjectTag.Update); AddTag(GameObjectTag._2DForward); FormChildren = ParentScene.GetList(GameObjectTag.Form); }
private void PositionChange() { if (ParentScene != null && ParentScene.GetType().IsSubclassOf(typeof(Basic2DScene))) { Basic2DScene s = (Basic2DScene)ParentScene; if (s.UseGrid.get()) { ApplySnap(false); } } }
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ParentScene livingRoom = MainCanvasManager.Instance.GetParentScene(NavigationSystem.NameOfLivingRoom); bool isAtHome = scene.name == livingRoom.name || livingRoom.ContainsChild(scene.name); background.enabled = isAtHome; for (int i = 0; i < elements.Length; i++) { elements[i].gameObject.SetActive(isAtHome); } }
private void OnTransitionStarted(string nameOfSceneLoading, LoadSceneMode mode) { string nameOfActiveScene = SceneManager.GetActiveScene().name; ParentScene supermarketScene = MainCanvasManager.Instance.GetParentScene(nameOfSupermarketParent); bool isNotLoadingSupermarket = supermarketScene.name != nameOfSceneLoading && !supermarketScene.ContainsChild(nameOfSceneLoading) && nameOfSceneLoading != nameOfPaymentScene; bool isInSupermarket = supermarketScene.name == nameOfActiveScene || supermarketScene.ContainsChild(nameOfActiveScene) || nameOfActiveScene == nameOfPaymentScene; if (isNotLoadingSupermarket && isInSupermarket) { propertiesAsset.GetProperty <GroceryProperty>(nameOfGroceryProperty).Restore(); } }
/// <summary> /// Public override method which is launched at each frame. /// </summary> public override void Update() { // Gets the position in Y of the indicator y = position.Pos.Y; /* Sees what key is pressed and depending of the keys pressed * the indicator can go up and down or initiate another scene*/ foreach (ConsoleKey key in keyObserver.GetCurrentKeys()) { if (key == ConsoleKey.UpArrow && option != 0) { y -= 2; option--; } else if (key == ConsoleKey.DownArrow && option != 3) { y += 2; option++; } else if (key == ConsoleKey.Enter) { if (option == 0) { ParentScene.Terminate(); Level1 level1 = new Level1(); level1.Run(); } if (option == 1) { ParentScene.Terminate(); Level2 level2 = new Level2(); level2.Run(); } else if (option == 2) { ParentScene.Terminate(); Help helpMenu = new Help(); helpMenu.Run(); } else { ParentScene.Terminate(); } } } // The position of the gameobject actualizes with the new values position.Pos = new Vector3(x, y, position.Pos.Z); }
public override bool RayCast(GameTime gameTime) { if (MouseManager.MouseClicked && !EditorSelected) { if (Logic.Rect(Position.get(), Size.get(), Parent2DScene.DrawCamera.ViewMatrix).Contains(WorldViewer.self.RelativeMousePoint)) { if (!KeyboardManager.ControlPressed()) { if (!KeyboardManager.ShiftPressed()) { ParentScene.ClearSelected(); } ParentScene.AddSelected(this); } else { if (EditorSelected) { ParentScene.RemoveSelected(this); } else { ParentScene.AddSelected(this); } } ParentLevel.ModifyWindows(); return(true); } } else if (MouseManager.RMouseClicked) { if (Logic.Rect(Position.get(), Size.get(), Parent2DScene.DrawCamera.ViewMatrix).Contains(WorldViewer.self.RelativeMousePoint)) { if (!KeyboardManager.AltPressed()) { ParentScene.ClearSelected(); ParentScene.AddSelected(this); RightClick(gameTime); ParentLevel.ModifyWindows(); } else { Destroy(); } return(true); } } return(false); }
public override void OnGetRenderSceneData(ViewportRenderingContext context, GetRenderSceneDataMode mode) { base.OnGetRenderSceneData(context, mode); if (mode == GetRenderSceneDataMode.InsideFrustum) { var context2 = context.objectInSpaceRenderingContext; //context. bool show = (ParentScene.GetDisplayDevelopmentDataInThisApplication() && ParentScene.DisplayCameras) || context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this; if (show) { var skip = false; var cameraSettings = context.Owner.CameraSettings; //!!!! if ((cameraSettings.Position - TransformV.Position).Length() < 0.5) { skip = true; } if (!skip && context2.displayCamerasCounter < context2.displayCamerasMax) { context2.displayCamerasCounter++; ColorValue color; if (context2.selectedObjects.Contains(this)) { color = ProjectSettings.Get.SelectedColor; } else if (context2.canSelectObjects.Contains(this)) { color = ProjectSettings.Get.CanSelectColor; } else { color = ProjectSettings.Get.SceneShowLightColor; } var viewport = context.Owner; viewport.Simple3DRenderer.SetColor(color, color * ProjectSettings.Get.HiddenByOtherObjectsColorMultiplier); DebugDraw(viewport); } } //if( !show ) // context.disableShowingLabelForThisObject = true; } }
public override void OnGetRenderSceneData(ViewportRenderingContext context, GetRenderSceneDataMode mode, Component_Scene.GetObjectsInSpaceItem modeGetObjectsItem) { base.OnGetRenderSceneData(context, mode, modeGetObjectsItem); if (mode == GetRenderSceneDataMode.InsideFrustum) { var context2 = context.objectInSpaceRenderingContext; if (!ParentScene.GetDisplayDevelopmentDataInThisApplication()) { context2.disableShowingLabelForThisObject = true; } } }
/// <summary> /// Public override method which is launched at each frame. /// </summary> public override void Update() { /* Sees what key is pressed and depending of the keys pressed * the indicator initiate the menu scene */ foreach (ConsoleKey key in keyObserver.GetCurrentKeys()) { if (key == ConsoleKey.Enter) { ParentScene.Terminate(); Menu menu = new Menu(); menu.Run(); } } }
public override void OnGetRenderSceneData(ViewportRenderingContext context, GetRenderSceneDataMode mode) { base.OnGetRenderSceneData(context, mode); //if( WhenUpdate.Value.HasFlag( WhenUpdateEnum.Render ) ) // Update(); if (EnabledInHierarchy && VisibleInHierarchy && mode == GetRenderSceneDataMode.InsideFrustum) { var context2 = context.objectInSpaceRenderingContext; bool show = (ParentScene.GetDisplayDevelopmentDataInThisApplication() && ParentScene.DisplaySensors) || context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this; if (show) { if (context2.displaySensorsCounter < context2.displaySensorsMax) { context2.displaySensorsCounter++; var displayColor = DisplayColor.Value; if (displayColor.Alpha != 0) { context.Owner.Simple3DRenderer.SetColor(displayColor, displayColor * ProjectSettings.Get.HiddenByOtherObjectsColorMultiplier); RenderShape(context2); } } if (DisplayObjects) { var color = DisplayObjectsColor.Value; if (color.Alpha != 0) { context.Owner.Simple3DRenderer.SetColor(color, color * ProjectSettings.Get.HiddenByOtherObjectsColorMultiplier); //foreach( var refObject in Objects ) //{ // var obj = refObject.Value; // if( obj != null && obj.EnabledInHierarchy ) // context.viewport.Simple3DRenderer.AddBounds( obj.SpaceBounds.CalculatedBoundingBox ); //} foreach (var item in CalculateObjects()) { RenderItem(context.Owner.Simple3DRenderer, item); } } } } } }
public void Init() { _textMessages = new List <GameObject>(); //Genererar sender is Typing GameObjectet (ser alltid lika dant ut) /*-------------------------------------------------------------------*/ _isTyping = new GameObject("text"); _isTyping._transform.y = GetComponent <Sprite>()._transform.h; _isTyping._transform.x = _textMarginX; _isTyping.SetParent(this); _isTyping.SetParentScene(ParentScene); ParentScene.AddGameObject(_isTyping); /*-------------------------------------------------------------------*/ }
private void Scene_GetRenderSceneData(Component_Scene scene, ViewportRenderingContext context) { var context2 = context.objectInSpaceRenderingContext; bool display = false; ColorValue color = Color; if (VisibleInHierarchy) { if ((ParentScene.GetDisplayDevelopmentDataInThisApplication() /*&& ParentScene.DisplayLights */) || context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this) { if (context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this)) { display = true; if (context2.selectedObjects.Contains(this)) { color = ProjectSettings.Get.SelectedColor; } else { color = ProjectSettings.Get.CanSelectColor; } } if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Editor && DisplayCurveInEditor) { display = true; } } if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Simulation && DisplayCurveInSimulation) { display = true; } } if (display) { Render(context2, color); } if (!ParentScene.GetDisplayDevelopmentDataInThisApplication()) { context2.disableShowingLabelForThisObject = true; } }
public override void OnGetRenderSceneData(ViewportRenderingContext context, GetRenderSceneDataMode mode, Component_Scene.GetObjectsInSpaceItem modeGetObjectsItem) { base.OnGetRenderSceneData(context, mode, modeGetObjectsItem); if (EnabledInHierarchy && VisibleInHierarchy) { var item = new Component_RenderingPipeline.RenderSceneData.TransparentRenderingAddOffsetWhenSortByDistanceVolumeItem(); item.Box = GetBox(); context.FrameData.RenderSceneData.TransparentRenderingAddOffsetWhenSortByDistanceVolumes.Add(item); } if (EnabledInHierarchy && VisibleInHierarchy && mode == GetRenderSceneDataMode.InsideFrustum) { var context2 = context.objectInSpaceRenderingContext; bool show = (ParentScene.GetDisplayDevelopmentDataInThisApplication() && ParentScene.DisplayVolumes) || context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this; if (show) { //if( context2.displayVolumesCounter < context2.displayVolumesMax ) //{ // context2.displayVolumesCounter++; ColorValue color; if (context2.selectedObjects.Contains(this)) { color = ProjectSettings.Get.SelectedColor; } else if (context2.canSelectObjects.Contains(this)) { color = ProjectSettings.Get.CanSelectColor; } else { color = ProjectSettings.Get.SceneShowVolumeColor; } if (color.Alpha != 0) { context.Owner.Simple3DRenderer.SetColor(color, color * ProjectSettings.Get.HiddenByOtherObjectsColorMultiplier); RenderShape(context2); } //} } } }
public override bool TriggerEvent(EventType Event, string[] args) { if (Event == EventType.SendTo) { FormSection s = (FormSection)ParentScene.FindObject(args[0], typeof(FormSection)); if (s == null) { return(false); } s.Visible.set(true); LastMarker.SetCurrentForm(s.GetCenterForm()); return(true); } return(base.TriggerEvent(Event, args)); }
private void CountChange() { EventValue[] NewEvents = new EventValue[EventCount.get()]; IntValue[] NewTimes = new IntValue[EventCount.get()]; for (int i = 0; i < Math.Max(EventCount.get(), EventCountPrevious); i++) { if (i < EventCount.get()) { if (i < EventCountPrevious) { NewEvents[i] = Events[i]; NewTimes[i] = Times[i]; } else { Level.ReferenceObject = this; NewTimes[i] = new IntValue("Time " + i.ToString(), i * 1000); NewTimes[i].ChangeEvent = TimeChange; NewEvents[i] = new EventValue("Event " + i.ToString()); } } else { RemoveValue(Times[i]); RemoveValue(Events[i]); } } Events = NewEvents; Times = NewTimes; EventCountPrevious = EventCount.get(); #if EDITOR && WINDOWS if (ParentLevel.LevelForEditing) { ParentScene.UpdateSelected(); } #endif }
public override void OnGetRenderSceneData(ViewportRenderingContext context, GetRenderSceneDataMode mode) { base.OnGetRenderSceneData(context, mode); //if( EnabledInHierarchyAndIsNotResource ) // Update(); if (mode == GetRenderSceneDataMode.InsideFrustum) { var context2 = context.objectInSpaceRenderingContext; bool show = (ParentScene.GetDisplayDevelopmentDataInThisApplication() && ParentScene.DisplaySoundSources) || context2.selectedObjects.Contains(this) || context2.canSelectObjects.Contains(this) || context2.objectToCreate == this; if (show) { if (context2.displaySoundSourcesCounter < context2.displaySoundSourcesMax) { context2.displaySoundSourcesCounter++; ColorValue color; if (context2.selectedObjects.Contains(this)) { color = ProjectSettings.Get.SelectedColor; } else if (context2.canSelectObjects.Contains(this)) { color = ProjectSettings.Get.CanSelectColor; } else { color = ProjectSettings.Get.SceneShowSoundSourceColor; } var viewport = context.Owner; viewport.Simple3DRenderer.SetColor(color, color * ProjectSettings.Get.HiddenByOtherObjectsColorMultiplier); DebugDraw(viewport); } } } }
public override void Create() { Position = new Vector2Value("Position", EditType.Average); Size = new Vector2Value("Size", Vector2.One, EditType.Scalar); Rotation = new FloatValue("Angle", RotationChange); MoveValuetoFront(Position, Size, Rotation); #if EDITOR && WINDOWS if (ParentScene != null && ParentScene.GetType().IsSubclassOf(typeof(Basic2DScene))) { Basic2DScene s = (Basic2DScene)ParentScene; if (s.GridSize != null) { Size.set(s.GridSize.get()); } } #endif base.Create(); }
public void DrawShadows() { Game1.graphicsDevice.BlendState = BlendState.Opaque; Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default; Transfer.LightPosition = Position.get(); Transfer.LightDistance = Scale.get() / 2; for (int i = 0; i < 6; i++) { CubeMapFace CurrentFace = (CubeMapFace)(i); Game1.graphicsDevice.SetRenderTarget(ShadowCube.Value, CurrentFace); Game1.graphicsDevice.Clear(Color.White); foreach (GameObject g in ParentScene.GetList(GameObjectTag._3DShadow)) { g.Draw3D(ShadowCameras[i], GameObjectTag._3DShadow); } } Game1.graphicsDevice.SetRenderTarget(null); }