public override void Initialize() { // F5 - Reload and restart the current screen. Engine.Commands.FunctionKeyActions[4] = () => { Level level = Engine.Scene as Level; if (level == null) { return; } AreaData.Areas[level.Session.Area.ID].Mode[(int)level.Session.Area.Mode].MapData.Reload(); Engine.Scene = new LevelLoader(level.Session, level.Session.RespawnPoint); }; // F6 - Open map editor for current level. Engine.Commands.FunctionKeyActions[5] = () => { Level level = Engine.Scene as Level; if (level == null) { return; } Engine.Scene = new MapEditor(level.Session.Area); Engine.Commands.Open = false; }; // Set up the touch input regions. TouchRegion touchTitleScreen = new TouchRegion { Position = new Vector2(1920f, 1080f) * 0.5f, Size = new Vector2(1920f, 1080f), Condition = _ => ((Engine.Scene as Overworld)?.IsCurrent <OuiTitleScreen>() ?? false) || (Engine.Scene is GameLoader) , Button = Input.MenuConfirm }; }
/// <summary> /// Create a visual representation of LEDs /// </summary> /// <param name="touchRegion"></param> /// <returns></returns> private DrawingVisual CreateTouchRegtionVisual(TouchRegion touchRegion) { var color1 = Brushes.LightBlue; var color2 = Brushes.Black; var dv = new DrawingVisual(); var dc = dv.RenderOpen(); dc.DrawEllipse(color1, null, new Point(touchRegion.X, touchRegion.Y), 8, 8); dc.DrawText(new FormattedText(touchRegion.number + "", new System.Globalization.CultureInfo("en-US"), new FlowDirection(), new Typeface("arial"), 7, color2), new Point(touchRegion.X - 2.5, touchRegion.Y - 4)); dc.Close(); return(dv); }
public override void Initialize() { // F5: Reload and restart the current screen. Engine.Commands.FunctionKeyActions[4] = () => { // CTRL + F5: Quick-restart the entire game. if (MInput.Keyboard.Check(Keys.LeftControl) || MInput.Keyboard.Check(Keys.RightControl)) { // block restarting while the game is starting up. this might lead to crashes if (!(Engine.Scene is GameLoader)) { Everest.QuickFullRestart(); } return; } Level level = Engine.Scene as Level; if (level == null) { return; } AssetReloadHelper.Do(Dialog.Clean("ASSETRELOADHELPER_RELOADINGMAP"), () => { AreaData.Areas[level.Session.Area.ID].Mode[(int)level.Session.Area.Mode].MapData.Reload(); }); AssetReloadHelper.ReloadLevel(); }; // F6: Open map editor for current level. Engine.Commands.FunctionKeyActions[5] = () => { Level level = Engine.Scene as Level; if (level == null) { return; } Engine.Scene = new MapEditor(level.Session.Area); Engine.Commands.Open = false; }; // Set up the touch input regions. TouchRegion touchTitleScreen = new TouchRegion { Position = new Vector2(1920f, 1080f) * 0.5f, Size = new Vector2(1920f, 1080f), Condition = _ => ((Engine.Scene as Overworld)?.IsCurrent <OuiTitleScreen>() ?? false) || (Engine.Scene is GameLoader) , Button = Input.MenuConfirm }; }
public override void Initialize() { // F5: Reload and restart the current screen. Engine.Commands.FunctionKeyActions[4] = () => { // CTRL + F5: Quick-restart the entire game. if (MInput.Keyboard.Check(Keys.LeftControl) || MInput.Keyboard.Check(Keys.RightControl)) { Scene scene = new Scene(); scene.HelperEntity.Add(new Coroutine(QuickFullRestartRoutine())); Engine.Scene = scene; return; } Level level = Engine.Scene as Level; if (level == null) { return; } AreaData.Areas[level.Session.Area.ID].Mode[(int)level.Session.Area.Mode].MapData.Reload(); Engine.Scene = new LevelLoader(level.Session, level.Session.RespawnPoint); }; // F6: Open map editor for current level. Engine.Commands.FunctionKeyActions[5] = () => { Level level = Engine.Scene as Level; if (level == null) { return; } Engine.Scene = new MapEditor(level.Session.Area); Engine.Commands.Open = false; }; // Set up the touch input regions. TouchRegion touchTitleScreen = new TouchRegion { Position = new Vector2(1920f, 1080f) * 0.5f, Size = new Vector2(1920f, 1080f), Condition = _ => ((Engine.Scene as Overworld)?.IsCurrent <OuiTitleScreen>() ?? false) || (Engine.Scene is GameLoader) , Button = Input.MenuConfirm }; }
public void Execute(System.Windows.Point startClick, System.Windows.Point endClick) { Animation a = Animation.getInstance(); // if (a.touchRegions.Count <= 12) // { TouchRegion t = new TouchRegion { X = endClick.X, Y = endClick.Y, number = a.touchRegions.Count + 1 }; _viewModel.TouchRegions.Add(t); a.addTouchRegion(t); // } }
/// <summary> /// Returns the information about the GameObject hit by the given pixel position. /// </summary> private RaycastHit2D GetHitInfo(Vector2 touchPosition) { // Shoot a ray from the touch point to the game and store the Ray ray = Camera.main.ScreenPointToRay(touchPosition); RaycastHit2D[] hits = Physics2D.RaycastAll(ray.origin, ray.direction, 1000f, TouchInfo.touchableLayers); // Stores the closest collider that was hit by the given touch coordinates RaycastHit2D closestHit = default(RaycastHit2D); // Cycle through each collider hit by the touch. Note that the hits are sorted from closest to the screen to the furthest from the screen. for (int i = 0; i < hits.Length; i++) { Collider2D touchedCollider = hits[i].collider; Debug.Log("Object touched: " + touchedCollider); // Retrieve the 'TouchRegion' component attached to the touched collider. Each touchable collider has a TouchRegion component. // It helps the 'TouchInfo' class determine information about the GameObject it touched. TouchRegion touchedRegion = touchedCollider.GetComponent <TouchRegion>(); Debug.Log("Region touched: " + touchedRegion); // If the region that was touched belongs to a player or an enemy if (touchedRegion.objectType == ObjectType.Player || touchedRegion.objectType == ObjectType.Enemy) { // Get the Character component of the character that was hit. Character touchedCharacter = touchedRegion.character; // If the touched character is not dead, he is elligible to be returned by this method. However, if the character is dead, // it should ignore user input. In this case, this character will be ignored by the raycast. if (!touchedCharacter.CharacterStats.IsDead()) { // Store this character as the closest GameObject touched by the given touch position. closestHit = hits[i]; // The object touched by the given touch position has been found. Break the loop and return the touched character. break; } } } // Return the information about the closest return(closestHit); }