public frmMain2() { SceneFileExt = "cws";// default to creation workshop CWS files m_lsttabs = new List <tabview>(); m_logSB = new StringBuilder(); InitializeComponent(); UVDLPApp.Instance().m_mainform = this; m_manctl = ManualControl.Instance(); // late intialization happens here after the UVDLP app Singleton is initiated. RegisterCallbacks(); RegisterGUI(); SetButtonStatuses(); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus); UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent); UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer); UVDLPApp.Instance().Engine3D.UpdateGrid(); ctl3DView1.UpdateView(); // initial update // set up initial log data in form foreach (string lg in DebugLogger.Instance().GetLog()) { //txtLog.Text = lg + "\r\n" + txtLog.Text; AddtoLog(lg); } //RearrangeGui AddButtons(); AddControls(); SetupTabs(); //set the default tab m_viewtype = -1; // start with the first tab added ShowView(0); // 3d tab ctl3DView1.RearrangeGui(); ctl3DView1.Enable3dView(true); // test new gui config system GuiConfigDB gconfdb = new GuiConfigDB(); gconfdb.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig); UVDLPApp.Instance().m_gui_config.ApplyConfiguration(gconfdb); gconfdb.SaveConfiguration("GuiConfigTest"); //ctlSliceGCodePanel1.ctlSliceViewctl.DlpForm = m_frmdlp; // set the dlp form for direct control SetMainMessage(""); SetTimeMessage(""); #if (DEBUG) ShowLogPanel(true); #else ShowLogPanel(false); pluginTesterToolStripMenuItem.Visible = false; testToolStripMenuItem.Visible = false; testMachineControlToolStripMenuItem.Visible = false; loadGUIConfigToolStripMenuItem.Visible = false; #endif SetTitle(); UVDLPApp.Instance().PerformPluginCommand("MainFormLoadedCommand", true); }
private Status controlStatus; // Controller Status. // Use this for initialization protected override void Awake() { base.Awake(); controlStatus = Status.IDLE; int[] sizes = mapWorld.GetMapSize(); rsize = sizes[0]; csize = sizes[1]; myMap = new char[rsize * csize]; // Initialize to " " space. for (int i = 0; i < rsize; i++) { for (int j = 0; j < csize; j++) { myMap[i * csize + j] = ' '; } } // -- objectInFov = new List <GameObject>(); botActions = gameObject.GetComponent <BotActions>(); deliberator = gameObject.GetComponent(deliberatorName) as IBotDeliberator; // Disable deliberator if deliberator exist or manual control is enabled. ManualControl mc = gameObject.GetComponent <ManualControl>(); deliberatorOn = (deliberator != null) && (mc != null) && !gameObject.GetComponent <ManualControl>().enabled; // Update current position in myMap Vector3 current = gameObject.transform.position; int[] idxs = mapWorld.GetIndexesFromWorld(current.x, current.z); mapWorld.CopyRegion(myMap, idxs[0] - 1, idxs[1] - 1, 3, 3); // Run Thread Function Every `n` second InvokeRepeating("ThinkLoop", 3, thinkTick); }
private void SceneInitial() { tank = new TankSinTur("tank", new GameObjInfo("Tank", "Player"), TankSinTur.M60TexPath, TankSinTur.M60Data, 170, MathHelper.PiOver4, Color.Yellow, 0f, 80, 60, 0.6f * MathHelper.Pi, 0.5f * MathHelper.Pi, MathHelper.Pi, 2f, new Vector2(100, 50), 0, 0); AutoShootAI autoShoot = new AutoShootAI(); autoShoot.OrderServer = tank; ManualControl manualControl = new ManualControl(); manualControl.OrderServer = tank; //tank.SetTankAI( manualControl ); tank.SetTankAI(autoShoot); tank.onShoot += new Tank.ShootEventHandler(Tank_onShoot); tank.ShellSpeed = shellSpeed; //ItemCommon item = new ItemCommon( "item", "Scorpion", Path.Combine( Directories.ContentDirectory, "GameObjs\\scorpion" ), new Vector2( 128, 128 ), 0.031f, new Vector2[] { new Vector2( 128, 128 ) }, // new Vector2( 150, 50 ), 0f, Vector2.Zero, 0 ); Ball ball = new Ball("ball", 0.031f, new Vector2(150, 50), 0, Vector2.Zero, 0); ball.OnCollided += new OnCollidedEventHandler(item_OnCollided); smoke = new SmokeGenerater(0, 50, Vector2.Zero, 0.3f, 0f, true, ball); sceneMgr.AddGroup(string.Empty, new TypeGroup <TankSinTur>("tank")); sceneMgr.AddGroup(string.Empty, new TypeGroup <Ball>("ball")); sceneMgr.AddGroup(string.Empty, new TypeGroup <SmartTank.PhiCol.Border>("border")); sceneMgr.AddGroup(string.Empty, new TypeGroup <ShellNormal>("shell")); sceneMgr.PhiGroups.Add("tank"); sceneMgr.PhiGroups.Add("ball"); sceneMgr.PhiGroups.Add("shell"); sceneMgr.ColPairGroups.Add(new SceneMgr.Pair("tank", "ball")); sceneMgr.ColPairGroups.Add(new SceneMgr.Pair("tank", "border")); sceneMgr.ColPairGroups.Add(new SceneMgr.Pair("ball", "border")); sceneMgr.ColPairGroups.Add(new SceneMgr.Pair("shell", "border")); sceneMgr.ColPairGroups.Add(new SceneMgr.Pair("shell", "ball")); sceneMgr.ShelterGroups.Add(new SceneMgr.MulPair("tank", new List <string>())); sceneMgr.VisionGroups.Add(new SceneMgr.MulPair("tank", new List <string>(new string[] { "ball" }))); sceneMgr.AddGameObj("tank", tank); sceneMgr.AddGameObj("ball", ball); sceneMgr.AddGameObj("border", new SmartTank.PhiCol.Border(mapSize)); //camera.Focus( tank ); }
public frmMain2() { InitializeComponent(); m_viewtype = eViewTypes.eNone; UVDLPApp.Instance().m_mainform = this; m_manctl = ManualControl.Instance(); // late intialization happens here after the UVDLP app Singleton is initiated. ctlTitle3dView.Checked = true; // set it as checked ctlTitle3dView_Click(null, null); // and click the button RegisterCallbacks(); RegisterGUI(); SetButtonStatuses(); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus); UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent); UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer); UVDLPApp.Instance().Engine3D.UpdateGrid(); ctl3DView1.UpdateView(); // initial update // set up initial log data in form foreach (string lg in DebugLogger.Instance().GetLog()) { txtLog.Text = lg + "\r\n" + txtLog.Text; } //RearrangeGui AddButtons(); AddControls(); ctl3DView1.RearrangeGui(); ctl3DView1.Enable3dView(true); UVDLPApp.Instance().m_gui_config.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig); //ctlSliceGCodePanel1.ctlSliceViewctl.DlpForm = m_frmdlp; // set the dlp form for direct control SetMainMessage(""); SetTimeMessage(""); #if (DEBUG) ShowLogPanel(true); #else ShowLogPanel(false); pluginTesterToolStripMenuItem.Visible = false; testToolStripMenuItem.Visible = false; testMachineControlToolStripMenuItem.Visible = false; #endif SetTitle(); UVDLPApp.Instance().PerformPluginCommand("MainFormLoadedCommand", true); }
ManualControl AttachMovementInput(ViewEngineBase view, bool EnableMouse, bool Visualize) { var mc = new ManualControl(); var stage = this.stage; if (stage == null) throw new Exception("stage is null"); var snapcontainer = new Shape(); var vectorized = new Shape(); var delta = new Shape { alpha = 0.5 }; if (Visualize) { snapcontainer.AttachTo(this); vectorized.AttachTo(this); delta.AttachTo(this); } var mouseDown_args = default(Point); var mouseUp_fadeOut = default(Timer); uint color = 0; var snap_radius = 64; mc.down = p => { if (!MovementEnabled) return; color = 0; // snap to old point if (!mc.disable_join) if (mouseDown_args != null) if (snapcontainer.alpha > 0) if ((mouseDown_args - p).length < snap_radius) { color = 0xff; p = mouseDown_args; } mouseDown_args = p; mc.disable_join = false; }; if (EnableMouse) stage.mouseDown += e => { mc.down(e.ToStagePoint()); //Write("down ", new { e.localX, e.localY, e.buttonDown }); }; Action<Shape, double, double, uint> DrawArrow = (s, x, y, c) => { if (Visualize) { s.graphics.lineStyle(2, c, 1); s.graphics.moveTo(mouseDown_args.x, mouseDown_args.y); s.graphics.lineTo(x, y); s.graphics.drawCircle(x, y, 4); } }; var mouseMove_args = default(Point); var delta_pos = 0.0; mc.move = p => { if (!MovementEnabled) return; if (mouseDown_args == null) return; mouseMove_args = p; if (mouseUp_fadeOut != null) mouseUp_fadeOut.stop(); vectorized.alpha = 1; vectorized.graphics.clear(); snapcontainer.alpha = 1; snapcontainer.graphics.clear(); snapcontainer.graphics.lineStyle(2, 0xff, 1); snapcontainer.graphics.drawCircle(mouseDown_args.x, mouseDown_args.y, snap_radius); DrawArrow(vectorized, mouseMove_args.x, mouseMove_args.y, color); }; if (EnableMouse) stage.mouseMove += e => { if (e.buttonDown) { mc.move(e.ToStagePoint()); } }; mc.up += delegate { if (mouseUp_fadeOut != null) mouseUp_fadeOut.stop(); var _vectorized = vectorized; var _snapcontainer = snapcontainer; mouseUp_fadeOut = 50.AtInterval( t => { if (vectorized.alpha < 0) { t.stop(); return; } _vectorized.alpha -= 0.02; _snapcontainer.alpha -= 0.04; } ); }; if (EnableMouse) stage.mouseUp += delegate { mc.up(); }; (1000 / 24).AtInterval( t => { if (mouseDown_args == null) return; if (mouseMove_args == null) return; delta.graphics.clear(); if (vectorized.alpha == 1) { delta_pos += mc.delta_acc; mc.delta_acc += mc.delta_acc_acc; } else { mc.delta_acc -= mc.delta_acc_acc * 3; if (mc.delta_acc < mc.delta_acc_min) mc.delta_acc = mc.delta_acc_min; delta_pos -= mc.delta_acc; } delta_pos = delta_pos.Min(1).Max(0); var u = (mouseMove_args - mouseDown_args) * delta_pos; var z = mouseDown_args + u; var Q1 = mouseDown_args.y < DefaultControlHeight * 1 / 6; var Q4 = mouseDown_args.y > DefaultControlHeight * 5 / 6; var IsPan = Q1 || Q4; if (delta_pos > 0) if (!IsPan) { NextViewDirection += u.x * 0.0004; NextViewPosition = NextViewPosition.MoveToArc(NextViewDirection, -u.y.Max(-snap_radius * 2).Min(snap_radius * 2) * 0.001); } else { NextViewPosition = NextViewPosition.MoveToArc(u.GetRotation() + NextViewDirection + 270.DegreesToRadians(), -(u.length.Min(snap_radius * 2)) * 0.001); } DrawArrow(delta, z.x, z.y, 0xff00); } ); return mc; }
/* * Set the handler for update event */ void Start() { rb = GetComponent <Rigidbody>(); controller = GameObject.FindObjectOfType(typeof(ManualControl)) as ManualControl; EmoEngine.Instance.EmoStateUpdated += new EmoEngine.EmoStateUpdatedEventHandler(engine_EmoStateUpdated); }
ManualControl AttachMovementInput(ViewEngineBase view, bool EnableMouse, bool Visualize) { var mc = new ManualControl(); var stage = this.stage; if (stage == null) { throw new Exception("stage is null"); } var snapcontainer = new Shape(); var vectorized = new Shape(); var delta = new Shape { alpha = 0.5 }; if (Visualize) { snapcontainer.AttachTo(this); vectorized.AttachTo(this); delta.AttachTo(this); } var mouseDown_args = default(Point); var mouseUp_fadeOut = default(Timer); uint color = 0; var snap_radius = 64; mc.down = p => { if (!MovementEnabled) { return; } color = 0; // snap to old point if (!mc.disable_join) { if (mouseDown_args != null) { if (snapcontainer.alpha > 0) { if ((mouseDown_args - p).length < snap_radius) { color = 0xff; p = mouseDown_args; } } } } mouseDown_args = p; mc.disable_join = false; }; if (EnableMouse) { stage.mouseDown += e => { mc.down(e.ToStagePoint()); //Write("down ", new { e.localX, e.localY, e.buttonDown }); } } ; Action <Shape, double, double, uint> DrawArrow = (s, x, y, c) => { if (Visualize) { s.graphics.lineStyle(2, c, 1); s.graphics.moveTo(mouseDown_args.x, mouseDown_args.y); s.graphics.lineTo(x, y); s.graphics.drawCircle(x, y, 4); } }; var mouseMove_args = default(Point); var delta_pos = 0.0; mc.move = p => { if (!MovementEnabled) { return; } if (mouseDown_args == null) { return; } mouseMove_args = p; if (mouseUp_fadeOut != null) { mouseUp_fadeOut.stop(); } vectorized.alpha = 1; vectorized.graphics.clear(); snapcontainer.alpha = 1; snapcontainer.graphics.clear(); snapcontainer.graphics.lineStyle(2, 0xff, 1); snapcontainer.graphics.drawCircle(mouseDown_args.x, mouseDown_args.y, snap_radius); DrawArrow(vectorized, mouseMove_args.x, mouseMove_args.y, color); }; if (EnableMouse) { stage.mouseMove += e => { if (e.buttonDown) { mc.move(e.ToStagePoint()); } } } ; mc.up += delegate { if (mouseUp_fadeOut != null) { mouseUp_fadeOut.stop(); } var _vectorized = vectorized; var _snapcontainer = snapcontainer; mouseUp_fadeOut = 50.AtInterval( t => { if (vectorized.alpha < 0) { t.stop(); return; } _vectorized.alpha -= 0.02; _snapcontainer.alpha -= 0.04; } ); }; if (EnableMouse) { stage.mouseUp += delegate { mc.up(); } } ; (1000 / 24).AtInterval( t => { if (mouseDown_args == null) { return; } if (mouseMove_args == null) { return; } delta.graphics.clear(); if (vectorized.alpha == 1) { delta_pos += mc.delta_acc; mc.delta_acc += mc.delta_acc_acc; } else { mc.delta_acc -= mc.delta_acc_acc * 3; if (mc.delta_acc < mc.delta_acc_min) { mc.delta_acc = mc.delta_acc_min; } delta_pos -= mc.delta_acc; } delta_pos = delta_pos.Min(1).Max(0); var u = (mouseMove_args - mouseDown_args) * delta_pos; var z = mouseDown_args + u; var Q1 = mouseDown_args.y < DefaultControlHeight * 1 / 6; var Q4 = mouseDown_args.y > DefaultControlHeight * 5 / 6; var IsPan = Q1 || Q4; if (delta_pos > 0) { if (!IsPan) { NextViewDirection += u.x * 0.0004; NextViewPosition = NextViewPosition.MoveToArc(NextViewDirection, -u.y.Max(-snap_radius * 2).Min(snap_radius * 2) * 0.001); } else { NextViewPosition = NextViewPosition.MoveToArc(u.GetRotation() + NextViewDirection + 270.DegreesToRadians(), -(u.length.Min(snap_radius * 2)) * 0.001); } } DrawArrow(delta, z.x, z.y, 0xff00); } ); return(mc); }