public void Button_Click(NeoAxis.UIButton sender) { foreach (var itm in SimulationApp.PlayerInv.items) { ScreenMessages.Add("test - " + itm.Name + ", " + itm.Index + ", " + itm.Current + ", " + itm.Max); } }
public void OpenOrCloseLevelWindow() { if (menuWindow != null && menuWindow.Disposed) { menuWindow = null; } if (menuWindow == null) { // If any UIWindow is opened, then can't open MenuWindow. if (ParentRoot.GetComponent <UIWindow>(true, true) == null) { ScreenMessages.Add("1"); menuWindow = ResourceManager.LoadSeparateInstance <UIWindow>(@"Store\AndreyKorolev\5MinGame\NextLevelMenu.ui", false, true); if (menuWindow != null) { AddComponent(menuWindow); } } } else { ScreenMessages.Add("2"); menuWindow.Dispose(); menuWindow = null; } }
private void log(String msg) { if (DebugMessages) { ScreenMessages.Add(msg); } }
protected override void OnEnabledInSimulation() { if (!Init(0)) { ScreenMessages.Add("Error: init failed"); this.Dispose(); } PSMoveConnectionType conn = this.ConnectionType; if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB) { ScreenMessages.Add("Error: Disconnect USB, only bluetooth"); this.Dispose(); } InitOrientation(); ResetOrientation(); // Start all controllers with a white LED SetLED(new Color(0f, 0.9f, 0f)); SetRumble(0); ScreenMessages.Add("init OK"); initok = true; base.OnEnabledInSimulation(); }
public void ButtonNextLevel_Click(UIButton sender) { // Get next level file name. string nextLevel; { var currentLevel = VirtualPathUtility.NormalizePath( Component_Scene.First.HierarchyController.CreatedByResource.Owner.Name ); var fileName = Path.GetFileName( VirtualPathUtility.NormalizePath( currentLevel ) ); string numberStr = new String(fileName.Where(Char.IsDigit).ToArray()); int number = int.Parse(numberStr) + 1; nextLevel = Path.Combine(Path.GetDirectoryName(currentLevel), $"SimpleGameLevel{number}.scene"); //nextLevel = @"Samples\Simple Game\SimpleGameLevel2.scene"; } if (VirtualFile.Exists(nextLevel)) { // Load next level without changing current GUI screen. if (PlayScreen.Instance.Load(nextLevel, false)) { InitializeSceneEvents(); } } else ScreenMessages.Add("No more levels."); }
protected override bool OnMouseDown(EMouseButtons button) { if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Simulation && button == EMouseButtons.Left) { // Get viewport. var viewport = ParentContainer.Viewport; // Get object by the cursor. var obj = GetObjectByCursor(viewport); if (obj != null) { // Destroy the object. obj.RemoveFromParent(false); // Show screen messages. var objectsLeft = GetObjectsThanCanBeSelected().Count; ScreenMessages.Add($"Objects left: {objectsLeft}"); if (objectsLeft == 0) { ScreenMessages.Add("You won!"); } } } return(base.OnMouseDown(button)); }
public void UpdateProc(float delta) { if (disconnected) { ScreenMessages.Add("disconnected"); return; } // we want to update the previous buttons outside the update restriction so, // we only get one button event pr. unity update frame prevButtons = currentButtons; timeElapsed += timeElapsed + delta; // Here we manually enforce updates only every updateRate amount of time // The reason we don't just do this in FixedUpdate is so the main program's FixedUpdate rate // can be set independently of the controllers' update rate. if (timeElapsed < updateRate) { return; } else { timeElapsed = 0.0f; } //Console.WriteLine("Update"); uint buttons = 0; // NOTE! There is potentially data waiting in queue. // We need to poll *all* of it by calling psmove_poll() until the queue is empty. Otherwise, data might begin to build up. while (psmove_poll(handle) > 0) { // We are interested in every button press between the last update and this one: buttons = buttons | psmove_get_buttons(handle); // The events are not really working from the PS Move Api. So we do our own with the prevButtons //psmove_get_button_events(handle, ref pressed, ref released); currentButtons = buttons; } // For acceleration, gyroscope, and magnetometer values, we look at only the last value in the queue. // We could in theory average all the acceleration (and other) values in the queue for a "smoothing" effect, but we've chosen not to. ProcessData(); // Send a report to the controller to update the LEDs and rumble. if (psmove_update_leds(handle) == 0) { // If it returns zero, the controller must have disconnected (i.e. out of battery or out of range), // so we should fire off any events and disconnect it. OnControllerDisconnected(this, new EventArgs()); Disconnect(); return; } OnDataUpdate?.Invoke(0, this); }
public static void ShowMsg(string msg) { var sc = Component_Scene.First; var txtcomp = (Component_Text2D)sc?.GetComponentByPath("Text 2D"); if (txtcomp == null) { ScreenMessages.Add("No Text 2D"); return; } txtcomp.Text = msg; }
private void mouseDown(NeoAxis.UIControl sender, NeoAxis.EMouseButtons button) { if (!drag) { drag = true; dragparent = (UIWindow)sender.Parent; windFrom = dragparent.Name; indxFrom = sender.Name; ScreenMessages.Add("windFrom = " + windFrom + ", indxFrom = " + indxFrom); var imagePath = InvUtils.getImagePath(SimulationApp.PlayerInv, int.Parse(indxFrom)); showdimg((UIImage)sender, true, imagePath); dragsx = MousePosition.X; dragsy = MousePosition.Y; dragox = dragsx - ((UIImage)sender).GetScreenPosition().X; dragoy = dragsy - ((UIImage)sender).GetScreenPosition().Y; //ScreenMessages.Add("MouseDown " + dragsx + ", " + dragsy + ", " + sender.GetPathFromRoot()); } else { indxTo = sender.Name; windTo = sender.Parent?.Name; ScreenMessages.Add("windTo = " + windTo + ", indxTo = " + indxTo); if (windFrom == "Window 1" && windTo == "Window 1" && indxFrom != "" && indxTo != "") { /*var prevName = SimulationApp.PlayerInv.items[int.Parse(indxFrom)].Name; * var prevcur = SimulationApp.PlayerInv.items[int.Parse(indxFrom)].Current; * var res1 = InvUtils.GetItems(SimulationApp.PlayerInv, SimulationApp.PlayerInv.items[int.Parse(indxFrom)].Name, int.Parse(indxFrom), SimulationApp.PlayerInv.items[int.Parse(indxFrom)].Current); * if(res1 >= 0) { * var res2 = InvUtils.AddItems(SimulationApp.PlayerInv, prevName, int.Parse(indxTo), prevcur); * }*/ var res = InvUtils.tryMoveItems(SimulationApp.PlayerInv, int.Parse(indxFrom), int.Parse(indxTo)); if (res >= 0) { var res1 = InvUtils.MoveItems(SimulationApp.PlayerInv, int.Parse(indxFrom), int.Parse(indxTo)); } } windFrom = ""; windTo = ""; indxFrom = ""; indxTo = ""; showdimg((UIImage)sender, false, ""); dragparent = null; drag = false; RedrawImages(); //ScreenMessages.Add("MouseDown1" + ", " + sender.GetPathFromRoot()); } }
public void LoadSc(String sc) { string nextLevel = "Store\\AndreyKorolev\\5MinGame\\" + sc + ".scene"; if (VirtualFile.Exists(nextLevel)) { PlayScreen.Instance.Load(nextLevel, false); ResetCmr(); } else { ScreenMessages.Add("No scene"); } }
public void LoadGame(String filename) { if (!VirtualFile.Exists("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata")) { ScreenMessages.Add("No file"); return; } TextBlock block = TextBlockUtility.LoadFromVirtualFile("Store\\AndreyKorolev\\5MinGame\\Saves\\" + filename + ".lvldata"); EnemiesKill = int.Parse(block.FindChild("EnemiesKill").Data); ScreenMessages.Add("EnemiesKill = " + EnemiesKill); Level = int.Parse(block.FindChild("Level").Data); ScreenMessages.Add("Level = " + Level); CheckPoint = block.FindChild("CheckPoint").Data; ScreenMessages.Add("CheckPoint = " + CheckPoint); hasWeapon = bool.Parse(block.FindChild("hasWeapon").Data); ScreenMessages.Add("hasWeapon = " + hasWeapon); ShowWin(false); AddEK(0); if (Level == 1) { LoadSc("File"); } else if (Level == 2) { LoadSc("File2"); } else { ScreenMessages.Add("No level"); } var sc = Component_Scene.First; var chpoint = (Component_Sensor)sc?.GetComponentByPath(CheckPoint); var chr = (Component_Character)sc?.GetComponentByPath("Character"); var chrcol = (Component_RigidBody)sc?.GetComponentByPath("Character\\Collision Body"); chrcol.Transform = chrcol.TransformV.UpdatePosition(new Vector3(chpoint.TransformV.Position.X, chpoint.TransformV.Position.Y, chr.TransformV.Position.Z)); GetWeapon(sc, chr, hasWeapon); ScreenMessages.Add("Load Done"); }
//Orientation //Don't forget to calibrate the magnetometer beforehand with the API's tool //Call this and ResetOrientation before you use access orientation, or it won't work public void InitOrientation() { if (!HasOrientation()) { if (!HasCalibration()) { //Debug.Log("Move is not calibrated, cannot use orientation"); //Console.WriteLine("Move is not calibrated, cannot use orientation"); ScreenMessages.Add("Move is not calibrated, cannot use orientation"); } else { //Debug.Log("Move does not have orientation set up, enabling..."); //Console.WriteLine("Move does not have orientation set up, enabling..."); ScreenMessages.Add("Move does not have orientation set up, enabling..."); EnableOrientation(); } } }
void ClickToDestroy() { // Get viewport. var viewport = ParentContainer.Viewport; // Get object by the cursor. var obj = GetObjectByCursor( viewport ); if( obj != null ) { // Destroy the object. obj.RemoveFromParent( false ); // Show screen messages. var objectsLeft = GetObjectsThanCanBeSelected().Count; ScreenMessages.Add( $"Objects left: {objectsLeft}" ); if( objectsLeft == 0 ) ScreenMessages.Add( "You won!" ); } }
void OKButton_Click(UIButton sender) { ((UIWindow)Components["Window"]).Visible = false; var filename = ((UIEdit)(((UIWindow)Components["Window"]).Components["FileNameEdit"])).Text; var uips = SimulationApp.CurrentUIScreen as Project.PlayScreen; var ui = uips.UIControl as Project.File; if (CurOp == 1) { ui.LoadGame(filename); } else if (CurOp == 2) { ui.SaveGame(filename); } ScreenMessages.Add("OK, filename = " + filename); Dispose(); }
public void LoadNext() { if (Level > 1) { ScreenMessages.Add("No next scene"); return; } string nextLevel = "Store\\AndreyKorolev\\5MinGame\\File2.scene"; if (VirtualFile.Exists(nextLevel)) { Level = 2; PlayScreen.Instance.Load(nextLevel, false); ResetCmr(); } else { ScreenMessages.Add("No scene"); } }
// public void showdimg(NeoAxis.UIImage img, bool show, String imagePath) // { // var dimg = (UIImage)this.GetComponentByPath("DragImage"); // if(show) { // dragimg = img; // dimg.Margin = cpos; // dimg.SourceImage = ReferenceUtility.MakeReference<Component_Image>(imagePath); // dimg.Enabled = true; // //ScreenMessages.Add("showdimg true, " + img?.GetPathFromRoot()); // } else { // dragimg = null; // dimg.Margin = cpos; // var imagePath1 = InvUtils.getImagePath(SimulationApp.PlayerInv, "Empty"); // dimg.SourceImage = ReferenceUtility.MakeReference<Component_Image>(imagePath1); // dimg.Enabled = false; // //ScreenMessages.Add("showdimg false, " + img?.GetPathFromRoot()); // } // } private void mouseDown(NeoAxis.UIControl sender, NeoAxis.EMouseButtons button) { if (!drag) { drag = true; dragparent = (UIWindow)sender.Parent; windFrom = dragparent.Name; indxFrom = sender.Name; ScreenMessages.Add("windFrom = " + windFrom + ", indxFrom = " + indxFrom); //var imagePath = InvUtils.getImagePath(SimulationApp.PlayerInv, int.Parse(indxFrom)); showdimg((UIImage)sender, true); dragsx = MousePosition.X; dragsy = MousePosition.Y; dragox = dragsx - ((UIImage)sender).GetScreenPosition().X; dragoy = dragsy - ((UIImage)sender).GetScreenPosition().Y; //ScreenMessages.Add("MouseDown " + dragsx + ", " + dragsy + ", " + sender.GetPathFromRoot()); } else { indxTo = sender.Name; windTo = sender.Parent?.Name; ScreenMessages.Add("windTo = " + windTo + ", indxTo = " + indxTo); windFrom = ""; windTo = ""; indxFrom = ""; indxTo = ""; showdimg((UIImage)sender, false); dragparent = null; drag = false; RedrawImages(); //ScreenMessages.Add("MouseDown1" + ", " + sender.GetPathFromRoot()); } }
void ButtonSave_Click(UIButton sender) { ScreenMessages.Add("Save"); ((UIWindow)Components["Window"]).Visible = true; CurOp = 2; }
void ButtonLoad_Click(UIButton sender) { ScreenMessages.Add("Load"); ((UIWindow)Components["Window"]).Visible = true; CurOp = 1; }