/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="texture">The texture.</param> /// <param name="color">The color.</param> /// <param name="spriteFont">The sprite font.</param> /// <param name="text">The text.</param> /// <param name="textColor">Color of the text.</param> public Button(Texture2D texture, Color color, SpriteFont spriteFont, String text, Color textColor) : base(texture, color, new Vector2(0, 0), new Vector2(1, 1), 0f) { _textLabel = new Label(spriteFont, text, textColor, new Vector2(0, 0), new Vector2(1, 1), 0); _state = BState.Up; _timer = 2f; }
public void Update() { MouseState mus = Mouse.GetState(); if (mus.X >= rect.X && mus.X <= (rect.X + rect.Width) && mus.Y >= rect.Y && mus.Y <= (rect.Y + rect.Height)) { state = BState.hover; } else { state = BState.normal; } if (marked == false) { if (state == BState.hover) { transparency = new Color(210, 210, 210, 160); } else { transparency = new Color(155, 155, 155, 185); } } else { transparency = new Color(255, 255, 255, 185); } }
void UpdateCreditsButton() { if (HitImageAlpha(backButtonRectangle, backButtonTexture, (int)inputManager.Mouse.Position.X, (int)inputManager.Mouse.Position.Y)) { if (mousePressed) { backButtonState = BState.DOWN; backButtonColor = Color.DarkOliveGreen; } else if (!mousePressed && prevMousePressed) { if (backButtonState == BState.DOWN) { backButtonState = BState.JUST_RELEASED; } } else { backButtonState = BState.HOVER; backButtonColor = Color.DarkKhaki; } } else { backButtonState = BState.UP; backButtonColor = Color.White; } if (backButtonState == BState.JUST_RELEASED) { BackButtonAction(); } }
/// <summary> /// Utwórz przycisk z tekstem znajdującym się na nim. /// Nie obracaj przycisku, ustaw pozycję startową na 0,0 /// a skalę na 1,1 /// </summary> /// <param name="texture">tło przycisku</param> /// <param name="color">kolor przycisku</param> /// <param name="spriteFont">czcionka napisu</param> /// <param name="text">napis</param> /// <param name="textColor">kolor tekstu znajdującego się na przycisku</param> public Button(Texture2D texture, Color color, SpriteFont spriteFont, String text, Color textColor) : base(texture, color, new Vector2(0, 0), new Vector2(1, 1), 0f) { _textLabel = new Label(spriteFont, text, textColor, new Vector2(0, 0), new Vector2(1, 1), 0); _state = BState.Up; _timer = 2f; }
/// <summary> /// /// </summary> public AggregateState(BState i, long time, TAggState state) : base(i) { this.curState = state; this.prevState = state; this.syncTime = time; this.ready = false; }
/* decides if the states are equivalent */ internal static int all_btrans_match(BState a, BState b) { BTrans s, t; if (((a.final == b_accept) || (b.final == b_accept)) && (a.final + b.final != 2 * b_accept) && a.incoming >=0 && b.incoming >=0) return 0; /* the states have to be both final or both non final */ for (s = a.trans.nxt; s != a.trans; s = s.nxt) { /* all transitions from a appear in b */ copy_btrans(s, b.trans); t = b.trans.nxt; while(same_btrans(s, t) == 0) t = t.nxt; if(t == b.trans) return 0; } for (s = b.trans.nxt; s != b.trans; s = s.nxt) { /* all transitions from b appear in a */ copy_btrans(s, a.trans); t = a.trans.nxt; while(same_btrans(s, t) == 0) t = t.nxt; if(t == a.trans) return 0; } return 1; }
private void RefreshStates() { cboState.Items.Add(""); foreach (var vItem in BState.GetMexicosStates().OrderBy(s => s.stat_name__nvarchar)) { cboState.Items.Add(vItem.stat_name__nvarchar); } }
public void LoadContent() { buttonTexture = content.Load<Texture2D>(buttonName); buttonRectangle = new Rectangle((int)buttonPosition.X, (int)buttonPosition.Y, buttonTexture.Width, buttonTexture.Height); buttonColor = Color.Tomato; bState = BState.UP; timer = 0.0f; }
/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="state">The state.</param> /// <param name="texture">The texture.</param> /// <param name="color">The color.</param> /// <param name="position">The position.</param> /// <param name="scale">The scale.</param> /// <param name="angle">The angle.</param> /// <param name="timer">The timer.</param> /// <param name="textColor">Color of the text.</param> /// <param name="spriteFont">The sprite font.</param> /// <param name="text">The text.</param> public Button(BState state, Texture2D texture, Color color, Vector2 position, Vector2 scale, float angle, double timer, Color textColor, SpriteFont spriteFont = null, String text = "") : base(texture, color, position, scale, angle) { _textLabel = new Label(spriteFont, text, textColor, position, scale, angle); _state = state; _timer = timer; }
public Button(String name, int x, int y, int width, int height) { this.name = name; this.rectangle = new Rectangle(x, y, width, height); state = BState.UP; mpressed = false; prev_mpressed = false; }
/// <summary> /// Utwórz nowy przycisk z napisem na nim. /// </summary> /// <param name="state">stan startowy przycisku <example>Wciśnięty</example></param> /// <param name="texture">tło przycisku</param> /// <param name="color">kolor przycisku</param> /// <param name="position">pozycja przycisku</param> /// <param name="scale">skala rozmiaru przycisku</param> /// <param name="angle">kąt nachylenia przycisku</param> /// <param name="timer">najkrótszy czas od jednej zmiany stanu przycisku do drugiej</param> /// <param name="spriteFont">czcionka napisu na przycisku</param> /// <param name="text">napis na przycisku</param> /// <param name="textColor">kolor tekstu na przycisku</param> public Button(BState state, Texture2D texture, Color color, Vector2 position, Vector2 scale, float angle, double timer, Color textColor, SpriteFont spriteFont = null, String text = "") : base(texture, color, position, scale, angle) { _textLabel = new Label(spriteFont, text, textColor, position, scale, angle); _state = state; _timer = timer; }
private void btnCancel_Click(object sender, EventArgs e) { BPrincipalCompany.EnableToEdit(objPrincipalCompany.prco_uuid__uniqueidentifier); objPrincipalCompany = BPrincipalCompany.FindByUUID(objPrincipalCompany.prco_uuid__uniqueidentifier); txtRFC.Enabled = false; txtCompany.Enabled = false; txtAddress.Enabled = false; txtPhone.Enabled = false; txtEmail.Enabled = false; txtFacebook.Enabled = false; cboState.Enabled = false; cboCity.Enabled = false; pcbLogo.Enabled = false; cboMode.Enabled = false; nudHoursToBackup.Enabled = false; nudHoursToBackup.Enabled = false; txtRFC.Text = objPrincipalCompany.prco_rfc__nvarchar; txtCompany.Text = objPrincipalCompany.prco_name__nvarchar; txtAddress.Text = objPrincipalCompany.prco_address__nvarchar; txtPhone.Text = objPrincipalCompany.prco_phone__nvarchar; txtEmail.Text = objPrincipalCompany.prco_email__nvarchar; txtFacebook.Text = objPrincipalCompany.prco_facebook__nvarchar; cboState.Items.Clear(); cboCity.Items.Clear(); RefreshStates(); if (objPrincipalCompany.city_uuid__uniqueidentifier != null) { var vCity = BCity.FindByUUID(objPrincipalCompany.city_uuid__uniqueidentifier.Value); cboState.Text = BState.FindByUUID(vCity.stat_uuid__uniqueidentifier).stat_name__nvarchar; cboCity.Text = vCity.city_name__nvarchar; RefreshCities(); } pcbLogo.Image = objPrincipalCompany.reso_uuid_logo__uniqueidentifier != null?Tools.ConvertirByteAImagen(BResource.FindByUUID(objPrincipalCompany.reso_uuid_logo__uniqueidentifier.Value).reso_value__varbinary) : null; cboMode.SelectedIndex = objPrincipalCompany.prco_developmentmode__bit == true ? 0 : 1; nudHoursToBackup.Value = objPrincipalCompany.prco_hoursbetweenbackups__int; nudDaysToDelete.Value = objPrincipalCompany.prco_daysdeletbackups__int; btnAccept.Visible = btnCancel.Visible = false; btnEdit.Visible = true; btnClose.Enabled = true; btnEdit.Focus(); byAction = 0; }
public ButtonObject(Texture2D Texture) : base(Texture) { button_state = BState.UP; button_color = Color.White; button_timer = 0.0; Scale = 1f; GrowAm = 0.03f; IsButton = true; }
protected virtual void Succes() { StateChanged(); m_ParentSuccess(); m_State = BState.Success; foreach (var dec in m_Decorators) { dec.NodeSuccess(); } }
protected virtual void Failure() { StateChanged(); m_ParentFailure(); m_State = BState.Failure; foreach (var dec in m_Decorators) { dec.NodeFailure(); } }
public Button(Object texture, int x, int y) : base(x, y) { this.sprite = texture; Texture2D t = (Texture2D) this.sprite; this.rectangle = new Rectangle(x, y, t.Width, t.Height); state = BState.UP; mpressed = false; prev_mpressed = false; }
// determine state and color of button public bool update_buttons(GameTime gameTime) { if (inputBool) { inputKeyboard(); } MouseState mouse_state = Mouse.GetState(); prev_mpressed = mpressed; mpressed = mouse_state.LeftButton == ButtonState.Pressed; frame_time = gameTime.ElapsedGameTime.Milliseconds / 1000.0; if (hit_image_alpha( button_rectangle, button_texture, mouse_state.X, mouse_state.Y)) { button_timer = 0.0; if (mpressed) { // mouse is currently down button_state = BState.DOWN; button_color = Color.Red; } else if (!mpressed && prev_mpressed) { // mouse was just released if (button_state == BState.DOWN) { // button i was just down button_state = BState.JUST_RELEASED; } } else { button_state = BState.HOVER; button_color = Color.LightBlue; } } else { button_state = BState.UP; if (button_timer > 0) { button_timer = button_timer - frame_time; } else { button_color = Color.White; } } if ((!button_oneClick && button_state == BState.DOWN) || (button_oneClick && button_state == BState.JUST_RELEASED)) { return(true); } return(false); }
private void CalcButtonSize() { int BUTTON_HEIGHT = Window.ClientBounds.Height / 9; int BUTTON_WIDTH = Window.ClientBounds.Width / 5; int x = Window.ClientBounds.Width / 2 - BUTTON_WIDTH / 2; int y = (Window.ClientBounds.Height / 2 - NumberOfMenuButtons / 2 * BUTTON_HEIGHT - (NumberOfMenuButtons % 2) * BUTTON_HEIGHT / 2) + BUTTON_HEIGHT; for (int i = 0; i < NumberOfMenuButtons; i++) { menuButtonState[i] = BState.UP; menuButtonColor[i] = Color.White; menuButtonRectangle[i] = new Rectangle(x, y, BUTTON_WIDTH, BUTTON_HEIGHT); y += BUTTON_HEIGHT + 20; } y = (2 * Window.ClientBounds.Height / 3 - NumberOfDeadButtons / 2 * BUTTON_HEIGHT - (NumberOfDeadButtons % 2) * BUTTON_HEIGHT / 2) + BUTTON_HEIGHT; for (int i = 0; i < NumberOfDeadButtons; i++) { deadButtonState[i] = BState.UP; deadButtonColor[i] = Color.White; deadButtonRectangle[i] = new Rectangle(x, y, BUTTON_WIDTH, BUTTON_HEIGHT); y += BUTTON_HEIGHT + 20; } x = (Window.ClientBounds.Width / 2 - 4 / 2 * BUTTON_WIDTH - (4 % 2) * BUTTON_WIDTH / 2); y = 2 * BUTTON_HEIGHT; for (int i = 0; i < 4; i++) { menuOptionButtonState[i] = BState.UP; menuOptionButtonColor[i] = Color.White; menuOptionButtonRectangle[i] = new Rectangle(x, y, BUTTON_WIDTH, BUTTON_HEIGHT); x += BUTTON_WIDTH + 20; } y += BUTTON_HEIGHT + 20; menuOptionButtonState[FullscreenButtonIndex] = BState.UP; menuOptionButtonColor[FullscreenButtonIndex] = Color.White; x = Window.ClientBounds.Width / 2 - BUTTON_WIDTH / 2; menuOptionButtonRectangle[FullscreenButtonIndex] = new Rectangle(x, y, BUTTON_WIDTH, BUTTON_HEIGHT); y = (Window.ClientBounds.Height / 2) + BUTTON_HEIGHT; for (int i = 5; i < 7; i++) { menuOptionButtonState[i] = BState.UP; menuOptionButtonColor[i] = Color.White; menuOptionButtonRectangle[i] = new Rectangle(menuOptionButtonRectangle[i - 5].X, y, BUTTON_WIDTH, BUTTON_HEIGHT); } y = (Window.ClientBounds.Height) - 2 * BUTTON_HEIGHT; for (int i = 7; i < 9; i++) { menuOptionButtonState[i] = BState.UP; menuOptionButtonColor[i] = Color.White; menuOptionButtonRectangle[i] = new Rectangle(menuOptionButtonRectangle[i - 5].X, y, BUTTON_WIDTH, BUTTON_HEIGHT); } y = (Window.ClientBounds.Height / 2 - NumberOfMenuButtons / 2 * BUTTON_HEIGHT - (NumberOfMenuButtons % 2) * BUTTON_HEIGHT / 2) + BUTTON_HEIGHT; backButtonState = BState.UP; backButtonColor = Color.White; backButtonRectangle = menuButtonRectangle[NumberOfMenuButtons - 1]; }
/// <summary> /// /// </summary> /// <param name="state"></param> /// <returns></returns> public void Next(BState state) { while (!IsDone(state)) { _Next((TState)state); if (IsReady(state)) { break; } } }
public void UpdateData(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; button_state = BState.UP; button_color = Color.White; button_timer = 0.0; button_rectangle = new Rectangle(this.x, this.y, this.width, this.height); }
public Button(Object texture, int x, int y) : base(x, y) { this.sprite = texture; Texture2D t = (Texture2D)this.sprite; this.rectangle = new Rectangle(x, y, t.Width, t.Height); state = BState.UP; mpressed = false; prev_mpressed = false; }
public virtual void Reset() { m_State = BState.Ready; StateChanged(); OnReset(); //Debug.Log(ToString()); foreach (var dec in m_Decorators) { dec.NodeStateChanged(); } }
public BNode(string name = "default") { if (name == "default") { NodeName = ToString(); } else { NodeName = name; } m_State = BState.Ready; m_Decorators = new List <BDecorator>(); }
public void Launch(BLaunchWindow launcher, BState startState) { Launcher = launcher; CurrentState = startState; // Setup window GameWindow = new GameWindow(AppSettings.SETTING_WIDTH, AppSettings.SETTING_HEIGHT); GameWindow.Title = AppInfo.APP_TITLE; if (AppSettings.SETTING_FULLSCREEN) { GameWindow.WindowState = WindowState.Fullscreen; if (AppSettings.SETTING_VSYNC) { GameWindow.VSync = VSyncMode.Adaptive; } else { GameWindow.VSync = VSyncMode.Off; } } else { GameWindow.WindowState = WindowState.Normal; } // Graphics Stuff GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); // Frames GameWindow.Load += (object obj, EventArgs e) => { OnLoad(); }; GameWindow.UpdateFrame += (object obj, FrameEventArgs args) => { Tick(args.Time); }; GameWindow.RenderFrame += (object obj, FrameEventArgs args) => { Render(); }; // Input BKeyboardListener.Initialize(); BMouseListener.Initialize(); GameWindow.KeyDown += (object sender, KeyboardKeyEventArgs e) => BKeyboardListener.UpdateKey((BKey)e.Key, true); GameWindow.KeyUp += (object sender, KeyboardKeyEventArgs e) => BKeyboardListener.UpdateKey((BKey)e.Key, false); GameWindow.MouseDown += (object sender, MouseButtonEventArgs e) => BMouseListener.UpdateButton((BMouseButton)e.Button, new System.Numerics.Vector2(e.X, e.Y), true); GameWindow.MouseUp += (object sender, MouseButtonEventArgs e) => BMouseListener.UpdateButton((BMouseButton)e.Button, new System.Numerics.Vector2(e.X, e.Y), false); GameWindow.MouseMove += (object sender, MouseMoveEventArgs e) => BMouseListener.UpdateLocation(e.Position); GameWindow.MouseWheel += (object sender, MouseWheelEventArgs e) => { BMouseListener.UpdateScrollWheel(e.Delta); }; // Run the window GameWindow.Run(AppSettings.SETTING_UPS, AppSettings.SETTING_FPS); }
protected void Execute() { if (m_State != BState.Updating) { FirstExecute(); m_State = BState.Updating; } else { OnExecute(); } //Debug.Log(ToString()); }
/// <summary> /// Uaktualnij widok przycisku w zależności od położenia myszki na ekranie. /// </summary> /// <param name="mx">współrzędna x myszki na ekranie</param> /// <param name="my">współrzędna y myszki na ekranie</param> /// <param name="frameTime">czas trwania gry</param> /// <param name="mPressed">stan myszki <true>wciśnięta</true></param> /// <param name="prevMPressed">poprzedni stan myszki <value>true</value> wciśnięta</param> public void Update(int mx, int my, double frameTime, bool mPressed, bool prevMPressed) { _mx = mx; _my = my; _frameTime = frameTime; _mpressed = mPressed; _prevMpressed = prevMPressed; if (CheckIfButtonContainsPoint(_mx, _my)) { _timer = 0.0; if (_mpressed) { _state = BState.Down; Color = _pressedColor; } else if (!_mpressed && _prevMpressed) { if (_state == BState.Down) { _state = BState.JustReleased; } } else { _state = BState.Hover; Color = _hoverColor; } } else { _state = BState.Up; if (_timer > 0) { _timer = _timer - _frameTime; } else { Color = _normalColor; } } if (_state == BState.JustReleased) { OnClick(_timer); } if (_textLabel != null && _textLabel.Text.Length > 0) { _textLabel.Position = new Vector2(Position.X - Texture.Width * Scale.X / 2, Position.Y - Texture.Height * Scale.Y / 2); } }
public bool Update(GameTime gameTime, int mx, int my, bool mpressed, bool prev_mpressed) { frameTimer = gameTime.ElapsedGameTime.Milliseconds / 1000.0; if (hitImageAlpha(buttonRectangle, buttonTexture, mx, my)) { timer = 0.0; if (mpressed) { // mouse is currently down bState = BState.DOWN; buttonColor = Color.LightSkyBlue; } else if (!mpressed && prev_mpressed) { // mouse was just released if (bState == BState.DOWN) { // button i was just down bState = BState.RELEASED; } } else { bState = BState.HOVER; buttonColor = Color.LightBlue; } } else { bState = BState.UP; if (timer > 0) { timer = timer - frameTimer; } else { buttonColor = Color.White; } } if (bState == BState.RELEASED) { return true; } return false; }
// Update is called once per frame void Update() { gameObject.renderer.material.color = new Color(bunnies.PaletteColor[colorIndex].r, bunnies.PaletteColor[colorIndex].g, bunnies.PaletteColor[colorIndex].b, gameObject.renderer.material.color.a); BlobColor = gameObject.renderer.material.color; light.intensity = Mathf.Clamp(0.22f * alpha, 0, 0.22f); light.color = gameObject.renderer.material.color; if (state == BState.Done) { if (BlobColor.a < 0.05f) { bunnies.Blobs.Remove(this); Destroy(gameObject); } else { BlobColor = gameObject.renderer.material.GetColor("_Color"); BlobColor.a = alpha = Mathf.Lerp(alpha, 0, 0.2f); gameObject.renderer.material.SetColor("_Color", BlobColor); } } if (state == BState.Approaching) { ScaleMultiplier = 1; gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, Target, 0.35f); if ((gameObject.transform.position - Target).magnitude < 0.05f) { state = BState.Splat; } } if (state == BState.Splat) { ScaleMultiplier = 1 + (SCALE_MULT_BASE * 2 * UpperLimit(3.5f * SplatFrame, 4f) / (SplatFrame - 1)); if (SplatFrame > 20) { SplatFrame = 0; state = BState.Done; } SplatFrame++; } if (state != BState.Done) { gameObject.transform.localScale = Vector3.Lerp(gameObject.transform.localScale, scale * Mathf.Clamp(ScaleMultiplier, 0, 10), 0.26f); } }
public BState updateState() { MouseState mouse_state = Mouse.GetState(); int mx = mouse_state.X; int my = mouse_state.Y; prev_mpressed = mpressed; mpressed = mouse_state.LeftButton == ButtonState.Pressed; // raton encima del boton if (hit_button(this.rectangle, this.scale, mx, my)) { // si se esta presionando el boton if (mpressed) { state = BState.DOWN; this.color = Color.Red; } // si ha habido un click y el boton estaba pulsado else if (!mpressed && prev_mpressed) { if (state == BState.DOWN) { state = BState.JUST_RELEASED; //this.color = Color.Green; } } // si el raton esta encima del boton else { state = BState.HOVER; this.color = Color.White * 0.7f; } } // si el raton no esta sobre el boton else { state = BState.UP; this.color = Color.White; } return(state); }
internal static int bdfs(BState s) { BTrans t; BScc c; BScc scc = new BScc(); scc.bstate = s; scc.rank = rank; scc.theta = rank++; scc.nxt = scc_stack; scc_stack = scc; s.incoming = 1; for (t = s.trans.nxt; t != s.trans; t = t.nxt) { if (t.to.incoming == 0) { int result = bdfs(t.to); scc.theta = Math.Min(scc.theta, result); } else { for (c = scc_stack.nxt; c != null; c = c.nxt) if (c.bstate == t.to) { scc.theta = Math.Min(scc.theta, c.rank); break; } } } if (scc.rank == scc.theta) { if (scc_stack == scc) { /* s is alone in a scc */ s.incoming = -1; for (t = s.trans.nxt; t != s.trans; t = t.nxt) if (t.to == s) s.incoming = 1; } scc_stack = scc.nxt; } return scc.theta; }
private void RefreshCities() { if (cboState.SelectedIndex > -1) { var vCountry = BCountry.FindByCode("MX"); var vState = BState.FindByName(cboState.SelectedItem.ToString(), vCountry); if (vState != null) { var vCities = BCity.GetCities(vState); if (vCities != null) { foreach (var vItem in vCities.OrderBy(c => c.city_name__nvarchar)) { cboCity.Items.Add(vItem.city_name__nvarchar); } } } } }
public BState updateState() { MouseState mouse_state = Mouse.GetState(); int mx = mouse_state.X; int my = mouse_state.Y; prev_mpressed = mpressed; mpressed = mouse_state.LeftButton == ButtonState.Pressed; // raton encima del boton if(hit_button(this.rectangle, mx, my)) { // si se esta presionando el boton if (mpressed) { state = BState.DOWN; } // si ha habido un click y el boton estaba pulsado else if (!mpressed && prev_mpressed) { if (state == BState.DOWN) { state = BState.JUST_RELEASED; } } // si el raton esta encima del boton else { state = BState.HOVER; } } // si el raton no esta sobre el boton else { state = BState.UP; } return state; }
public BLaunchWindow(BState startState) { InitializeComponent(); this.startState = startState; if (!Directory.Exists(SETTINGS_PATH)) { Directory.CreateDirectory(SETTINGS_PATH); } if (!File.Exists(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json"))) { this.CloseBox.Checked = this.close; this.FullscreenBox.Checked = AppSettings.SETTING_FULLSCREEN; this.VsyncBox.Checked = AppSettings.SETTING_VSYNC; this.VsyncBox.Enabled = AppSettings.SETTING_FULLSCREEN; this.FpsBox.Text = AppSettings.SETTING_FPS.ToString(); this.WidthBox.Text = AppSettings.SETTING_WIDTH.ToString(); this.HeightBox.Text = AppSettings.SETTING_HEIGHT.ToString(); settings = new LaunchSettings(false, AppSettings.SETTING_FULLSCREEN, AppSettings.SETTING_VSYNC, AppSettings.SETTING_FPS, AppSettings.SETTING_WIDTH, AppSettings.SETTING_HEIGHT); settings.Save(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json")); } else { settings = LaunchSettings.Load(Path.Combine(SETTINGS_PATH, $"{AppInfo.APP_FILESAFENAME}.json")); this.close = settings.CloseOnLaunch; this.CloseBox.Checked = settings.CloseOnLaunch; this.FullscreenBox.Checked = settings.Fullscreen; this.VsyncBox.Checked = settings.Vsync; this.VsyncBox.Enabled = settings.Fullscreen; this.FpsBox.Text = settings.Fps.ToString(); this.WidthBox.Text = settings.WindowWidth.ToString(); this.HeightBox.Text = settings.WindowHeight.ToString(); } this.Text = $"Made with BEngine2D - {AppInfo.APP_NAME}"; }
public void RefreshMainValues() { objPrincipalCompany = null; var vPrincipalCompany = BPrincipalCompany.Get(); if (vPrincipalCompany != null) { objPrincipalCompany = vPrincipalCompany; RefreshStates(); RefreshModes(); txtRFC.Text = vPrincipalCompany.prco_rfc__nvarchar; txtCompany.Text = vPrincipalCompany.prco_name__nvarchar; txtAddress.Text = vPrincipalCompany.prco_address__nvarchar; txtPhone.Text = vPrincipalCompany.prco_phone__nvarchar; txtEmail.Text = vPrincipalCompany.prco_email__nvarchar; txtFacebook.Text = vPrincipalCompany.prco_facebook__nvarchar; if (vPrincipalCompany.city_uuid__uniqueidentifier != null) { var vCity = BCity.FindByUUID(vPrincipalCompany.city_uuid__uniqueidentifier.Value); cboState.Text = BState.FindByUUID(vCity.stat_uuid__uniqueidentifier).stat_name__nvarchar; cboCity.Text = vCity.city_name__nvarchar; RefreshCities(); } pcbLogo.Image = vPrincipalCompany.reso_uuid_logo__uniqueidentifier != null?Tools.ConvertirByteAImagen(BResource.FindByUUID(vPrincipalCompany.reso_uuid_logo__uniqueidentifier.Value).reso_value__varbinary) : null; cboMode.SelectedIndex = vPrincipalCompany.prco_developmentmode__bit ? 0 : 1; nudHoursToBackup.Value = objPrincipalCompany.prco_hoursbetweenbackups__int; nudDaysToDelete.Value = objPrincipalCompany.prco_daysdeletbackups__int; } }
/* creates all the transitions from a state */ internal static void make_btrans(BState s) { int state_trans = 0; GTrans t; BTrans t1; BState s1; if (s.gstate.trans != null) for (t = s.gstate.trans.nxt; t != s.gstate.trans; t = t.nxt) { int fin = next_final(t.final, (s.final == b_accept) ? 0 : s.final); BState to = find_bstate( ref t.to, fin, s); for (t1 = s.trans.nxt; t1 != s.trans; ) { if (main.tl_simp_fly != 0 && (to == t1.to) && set.included_set(t.pos, t1.pos, 1) != 0 && set.included_set(t.neg, t1.neg, 1) != 0) { /* t1 is redondant */ BTrans free = t1.nxt; t1.to.incoming--; t1.to = free.to; set.copy_set(free.pos, t1.pos, 1); set.copy_set(free.neg, t1.neg, 1); t1.nxt = free.nxt; if (free == s.trans) s.trans = t1; mem.free_btrans(free, null, 0); state_trans--; } else if (main.tl_simp_fly != 0 && (t1.to == to) && set.included_set(t1.pos, t.pos, 1) != 0 && set.included_set(t1.neg, t.neg, 1) != 0) /* t is redondant */ break; else t1 = t1.nxt; } if (t1 == s.trans) { BTrans trans = mem.emalloc_btrans(); trans.to = to; trans.to.incoming++; set.copy_set(t.pos, trans.pos, 1); set.copy_set(t.neg, trans.neg, 1); trans.nxt = s.trans.nxt; s.trans.nxt = trans; state_trans++; } } if (main.tl_simp_fly != 0) { if (s.trans == s.trans.nxt) { /* s has no transitions */ mem.free_btrans(s.trans.nxt, s.trans, 1); s.trans = null; s.prv = null; s.nxt = bremoved.nxt; bremoved.nxt = s; for (s1 = bremoved.nxt; s1 != bremoved; s1 = s1.nxt) if (s1.prv == s) s1.prv = null; return; } bstates.trans = s.trans; bstates.final = s.final; s1 = bstates.nxt; while (all_btrans_match(s, s1) == 0) s1 = s1.nxt; if (s1 != bstates) { /* s and s1 are equivalent */ mem.free_btrans(s.trans.nxt, s.trans, 1); s.trans = null; s.prv = s1; s.nxt = bremoved.nxt; bremoved.nxt = s; for (s1 = bremoved.nxt; s1 != bremoved; s1 = s1.nxt) if (s1.prv == s) s1.prv = s.prv; return; } } s.nxt = bstates.nxt; /* adds the current state to 'bstates' */ s.prv = bstates; s.nxt.prv = s; bstates.nxt = s; btrans_count += state_trans; bstate_count++; }
/// <summary> /// ������� /// </summary> public void Reset() { stagelist = StageBind.LoadLevels(); Can = GameObject.Find("Canvas"); Bindbg(); xmlpath = Application.dataPath + "/Match3Sample/Scripts/GateCon.xml"; if (boardSize < 3) boardSize = 8; theBoardState = BState.RESETING; jewelMapPosition = new GameObject[boardSize, boardSize]; planeMapPosition = new GameObject[boardSize, boardSize]; obsMapPosition = new GameObject[boardSize, boardSize]; mouseClickY = -1; mouseClickX = -1; CurrentlyMovingJewels = 0; needToDropJewels = false; totalRemovedJewels = 0; validateSwap = false; hintTimer = 0; hintDelay = 5; baseScore = 100; longestChain = 0; isActive = true; canSwap = true; hintJewels = new List<GameObject>(16); jewelRemains = new List<GameObject>(16); FourHJewels = new List<GameObject>(16); FourVJewels = new List<GameObject>(16); FiveJewels = new List<GameObject>(16); SquareJewels = new List<GameObject>(16); TLJewels = new List<GameObject>(16); // Randomize the jewels do { ResetPlane(); ResetObs(); ResetJewelss(); } while ((movesLeft = HowManyMovesLeft()) == 0); theBoardState = BState.PLAYING; }
internal static void mk_buchi() { /* generates a Buchi automaton from the generalized Buchi automaton */ int i; BState s = new BState(); GTrans t; BTrans t1; b_accept = generalized.final[0] - 1; // if(tl_stats) getrusage(RUSAGE_SELF, &tr_debut); bstack = new BState(); /* sentinel */ bstack.nxt = bstack; bremoved = new BState(); /* sentinel */ bremoved.nxt = bremoved; bstates = new BState(); /* sentinel */ bstates.nxt = s; bstates.prv = s; s.nxt = bstates; /* creates (unique) inital state */ s.prv = bstates; s.id = -1; s.incoming = 1; s.final = 0; s.gstate = null; s.trans = mem.emalloc_btrans(); /* sentinel */ s.trans.nxt = s.trans; for (i = 0; i < generalized.init_size; i++) if (generalized.init[i] != null) for (t = generalized.init[i].trans.nxt; t != generalized.init[i].trans; t = t.nxt) { int fin = next_final(t.final, 0); BState to = find_bstate(ref t.to, fin, s); for (t1 = s.trans.nxt; t1 != s.trans; ) { if (main.tl_simp_fly != 0 && (to == t1.to) && set.included_set(t.pos, t1.pos, 1) != 0 && set.included_set(t.neg, t1.neg, 1) != 0) { /* t1 is redondant */ BTrans free = t1.nxt; t1.to.incoming--; t1.to = free.to; set.copy_set(free.pos, t1.pos, 1); set.copy_set(free.neg, t1.neg, 1); t1.nxt = free.nxt; if (free == s.trans) s.trans = t1; mem.free_btrans(free, null, 0); } else if (main.tl_simp_fly != 0 && (t1.to == to) && set.included_set(t1.pos, t.pos, 1) != 0 && set.included_set(t1.neg, t.neg, 1) != 0) /* t is redondant */ break; else t1 = t1.nxt; } if (t1 == s.trans) { BTrans trans = mem.emalloc_btrans(); trans.to = to; trans.to.incoming++; set.copy_set(t.pos, trans.pos, 1); set.copy_set(t.neg, trans.neg, 1); trans.nxt = s.trans.nxt; s.trans.nxt = trans; } } while (bstack.nxt != bstack) { /* solves all states in the stack until it is empty */ s = bstack.nxt; bstack.nxt = bstack.nxt.nxt; if (s.incoming == 0) { free_bstate(s); continue; } make_btrans(s); } retarget_all_btrans(); /* if(tl_stats) { getrusage(RUSAGE_SELF, &tr_fin); timeval_subtract (&t_diff, &tr_fin.ru_utime, &tr_debut.ru_utime); fprintf(tl_out, "\nBuilding the Buchi automaton : %i.%06is", t_diff.tv_sec, t_diff.tv_usec); fprintf(tl_out, "\n%i states, %i transitions\n", bstate_count, btrans_count); }*/ //if(tl_verbose) { // fprintf(tl_out, "\nBuchi automaton before simplification\n"); // print_buchi(bstates.nxt); // if(bstates == bstates.nxt) // fprintf(tl_out, "empty automaton, refuses all words\n"); //} if (main.tl_simp_diff != 0) { simplify_btrans(); if (main.tl_simp_scc != 0) simplify_bscc(); while (simplify_bstates() != 0) { /* simplifies as much as possible */ simplify_btrans(); if (main.tl_simp_scc != 0) simplify_bscc(); } // if(tl_verbose) { // fprintf(tl_out, "\nBuchi automaton after simplification\n"); // print_buchi(bstates.nxt); // if(bstates == bstates.nxt) //fprintf(tl_out, "empty automaton, refuses all words\n"); // fprintf(tl_out, "\n"); // } } //print_spin_buchi(); }
/// <summary> /// ������� /// </summary> public void Reset() { if (boardSize < 3) boardSize = 8; theBoardState = BState.RESETING; jewelMapPosition = new GameObject[boardSize, boardSize]; mouseClickY = -1; mouseClickX = -1; CurrentlyMovingJewels = 0; needToDropJewels = false; totalRemovedJewels = 0; validateSwap = false; hintTimer = 0; hintDelay = 5; baseScore = 100; longestChain = 0; isActive = true; canSwap = true; hintJewels = new List<GameObject>(16); jewelRemains = new List<GameObject>(16); // Randomize the jewels do { ResetJewels(); } while ((movesLeft = HowManyMovesLeft()) == 0); theBoardState = BState.PLAYING; }
/// <summary> /// ������ /// </summary> void Update() { Text(); if (theBoardState == BState.RESETING) return; //�鿴��嵱ǰ״̬ UpdateJewelRemains(); //���±�ʯ״̬ //�ж�����Ƿ��ڼ���״̬ if (!isActive) return; //��崦���ƶ�״̬ʱ����δ����״̬ //�жϵ�ǰ���ƶ��ı�ʯ�м��� //if (CurrentlyMovingJewels > 0) return; // delayDropʱ���ʯ��ʼ���� if (delayDrop > 0) { delayDrop -= (float)Time.deltaTime; return; } // ����ƶ���ʯ����0 if (CurrentlyMovingJewels > 0) theBoardState = BState.DROP_JEWELS; else { if (needToCheckCascades) { CheckForCascades(); needToCheckCascades = false; } //Debug.Log(swapping.jewelBx + "" + swapping.jewelBy); if (validateSwap)//�����˽������ { // �����Ժ���֤��ʯλ���Ƿ������3 int count = CountMatch3(); if (count == 0) { SwapJewels(swapping); // ��������ھͻ���ȥ // Play a sound //do something due illegal move } else { RemoveTriplets(count); } validateSwap = false; } if (swapping.isActive) theBoardState = BState.SWAPPING; else theBoardState = BState.PLAYING; } if (theBoardState != BState.PLAYING && theBoardState != BState.SWAPPING) return; // �ж��û��Ƿ���Խ��н��� if (theBoardState == BState.PLAYING) { // Increase the hint timer if there's no action on the board hintTimer += (float)Time.deltaTime; if (hintTimer >= hintDelay) // Reset the hint delay ShowRandomHint(); } if (Input.GetMouseButton(0)) { // Check if there is a touch or mouse on some tile Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 30)) { if (hit.transform.tag != "Untagged") { mouseClickX = (int)hit.transform.localPosition.x; mouseClickY = (int)hit.transform.localPosition.y; //SelectedJewel.transform.position = new Vector3(hit.transform.position.x,hit.transform.position.y,-1.02f); } else { mouseClickY = -1; mouseClickX = -1; //SelectedJewel.transform.position = new Vector3(-6,-6,-1.02f); } } } //if (swapping.twiceClick == true && swapping.isActive) //{ // swapping.jewelBx = mouseClickX; // swapping.jewelBy = mouseClickY; // //Debug.Log("di san ci"+swapping.jewelBx + "" + swapping.jewelBy); //} if (canSwap && mouseClickX > -1 && Input.GetMouseButton(0)) { // Start to swap if some jewel is clicked if (theBoardState != BState.SWAPPING && !mouseLeftDown) { swapping.Init(); swapping.isActive = true; swapping.jewelAx = mouseClickX; swapping.jewelAy = mouseClickY; theBoardState = BState.SWAPPING; mouseLeftDown = true; } else { //Debug.Log("di si ci"+swapping.jewelBx + "" + swapping.jewelBy); swapping.jewelBx = mouseClickX; swapping.jewelBy = mouseClickY; int dx = swapping.jewelAx - swapping.jewelBx; int dy = swapping.jewelAy - swapping.jewelBy; if (Mathf.Abs(dx) > 1 || Mathf.Abs(dy) > 1) { swapping.isActive = false; theBoardState = BState.PLAYING; } } } if (canSwap && Input.GetMouseButton(0)) { // When the mouse button or touch is released.. mouseLeftDown = false; if (tip) { tip.alpha = false; tip = null; } if (theBoardState == BState.SWAPPING) { // If we have released on the same jewel use alternate swapping method (two clicks) if (mouseClickX == swapping.jewelAx && mouseClickY == swapping.jewelAy) { //swapping.twiceClick = true; } else if (!IsLegalSwap()) { //Cancels Swap swapping.isActive = false; theBoardState = BState.PLAYING; //SelectedJewel.transform.localPosition = new Vector3(-6,-6,-1.02f); } else if (!swapping.twiceClick) { //Swap GetComponent<AudioSource>().pitch = 1; GetComponent<AudioSource>().PlayOneShot(SwapSound); swapping.isActive = false; SwapJewels(swapping); validateSwap = true; // Need to validate it //SelectedJewel.transform.localPosition = new Vector3(-6,-6,-1.02f); } mouseClickY = -1; mouseClickX = -1; //SelectedJewel.transform.localPosition = new Vector3(-6,-6,-1.02f); } } if (needToDropJewels && delayDrop <= 0) { // Check for drop jewels needToDropJewels = false; CheckForFallingJewels(); } if (CurrentlyMovingJewels > 0) { //do something when the jewels are moving } //Debug.Log("di wu ci"+swapping.jewelBx + "" + swapping.jewelBy); }
private void AMouseDown(object sender, MouseEventExtArgs e) { if (_bdoWindow.Ws != BdoWindow.WindowState.Main || _getImg || _state != State.On) { return; } if (_exec) { return; } if (AbsC(Gmax).Contains(e.X, e.Y)) { _bmax = !_bmax; Emax.Fill = _bmax ? new SolidColorBrush(Color.FromArgb(255, 0x33, 0xcc, 0x33)) : new SolidColorBrush(Color.FromArgb(255, 0xcc, 0x33, 0x33)); } if (new Rectangle(AbsC(Gsp).X, AbsC(Gsp).Y, AbsC(Gsp).Width - 50, AbsC(Gsp).Height).Contains(e.X, e.Y)) { if (_speed > 0) { _speed--; } Dispatcher.Invoke(() => { Lbsp.Content = _speed.ToString(); }); _dControl.Sett(_speed); } if (new Rectangle(AbsC(Gsp).X + 50, AbsC(Gsp).Y, AbsC(Gsp).Width - 50, AbsC(Gsp).Height).Contains(e.X, e.Y)) { if (_speed < 11) { _speed++; } Dispatcher.Invoke(() => { Lbsp.Content = _speed.ToString(); }); _dControl.Sett(_speed); } if (AbsC(Items).Contains(e.X, e.Y)) { for (var i = 0; i < _bitems.Count; i++) { if (AbsC(_bitems[i].ImgX).Contains(e.X, e.Y)) { DelItem(i); } } } if (AbsC(IResume).Contains(e.X, e.Y)) { Dispatcher.Invoke(() => { IResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.resumeg); IDResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delres); IStop.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delall); }); _bstate = BState.Res; } if (AbsC(IDResume).Contains(e.X, e.Y)) { Dispatcher.Invoke(() => { IResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.resume); IDResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delresg); IStop.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delall); }); _bstate = BState.DelRes; } if (AbsC(IStop).Contains(e.X, e.Y)) { Dispatcher.Invoke(() => { IResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.resume); IDResume.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delres); IStop.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.delallg); }); _bstate = BState.Stop; } if (AbsC(IDela).Contains(e.X, e.Y)) { DelAllItem(); } if (AbsC(IStartBack).Contains(e.X, e.Y)) { if (_listByuing) { _listByuing = false; Dispatcher.Invoke(() => { LABSS.Content = "[Выкл]"; LABSS.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0xee, 0x22, 0x22)); IStartBack.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.startback); }); } else { _listByuing = true; new Thread(() => { BuyingProc(); }).Start(); Dispatcher.Invoke(() => { LABSS.Content = "[Вкл]"; LABSS.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x22, 0xcc, 0x22)); IStartBack.Source = ImgHelpers.BitmapToImageSource(Properties.Resources.startbackp); }); } } if (AbsC(IAddUn).Contains(e.X, e.Y)) { AddItem(); } var pos = GetLotPos(e.X, e.Y); if (pos == -1) { return; } if (e.Button == MouseButtons.Left) { e.Handled = true; new Thread(() => { Exec(pos); }).Start(); } if (e.Button != MouseButtons.Right) { return; } e.Handled = true; new Thread(() => { AddItem(GetItemImg(pos)); }).Start(); }
/// <summary> Builds the output objects from the internal state list.</summary> /// <throws> IllegalArgumentException if formula has invalid syntax </throws> private static BuchiAutomata BuildBA() { List <string> initial = new List <string>(4); PAT.Common.Classes.DataStructure.Set <string> states = new PAT.Common.Classes.DataStructure.Set <string>(); List <Transition> transitions = new List <Transition>(); List <string> accept = new List <string>(); Dictionary <String, string> statesHash = new Dictionary <String, string>(); //in the following, all "System.IntPtr" values are actually pointers in C ! //dummy node in the circular list of states BState root = ltl2ba.main.GetBstates(); //int count = 0; //if there was no error and so we have states if (root != null) { int id = ltl2ba.main.GetSymtemID(); string[] allLabels = new string[id]; for (int i = 0; i < id; i++) { allLabels[i] = ltl2ba.main.GetSystemString(i).Trim('"'); } //iterate over state list for (BState pSourceState = root.nxt; pSourceState != ltl2ba.main.GetBstates(); pSourceState = pSourceState.nxt) { bool isInitial = (pSourceState.id == STATE_ID_INITIAL_STATE); bool isFinal = pSourceState.final == ltl2ba.main.GetAccept(); string label = pSourceState.id + (isInitial ? Constants.INIT_STATE : "") + (isFinal ? Constants.ACCEPT_STATE : ""); string sourceState; //take care that equal states are unique if (statesHash.ContainsKey(label)) { sourceState = statesHash[label]; } else { sourceState = label; //new State(, isFinal, isInitial); statesHash.Add(label, sourceState); states.Add(sourceState); if (isInitial) { initial.Add(sourceState); } if (isFinal) { accept.Add(sourceState); } } BTrans troot = pSourceState.trans; for (BTrans pTransition = troot.nxt; pTransition != troot; pTransition = pTransition.nxt) { BState pTargetState = pTransition.to; isInitial = (pTargetState.id == STATE_ID_INITIAL_STATE); isFinal = (pTargetState.final == ltl2ba.main.GetAccept()); label = pTargetState.id + (isInitial ? Constants.INIT_STATE : "") + (isFinal ? Constants.ACCEPT_STATE : ""); string targetState; //take care that equal states are unique if (statesHash.ContainsKey(label)) { targetState = statesHash[label]; } else { targetState = label; // new State(label, isFinal, isInitial); statesHash.Add(label, targetState); states.Add(targetState); if (isInitial) { initial.Add(targetState); } if (isFinal) { accept.Add(targetState); } } //it is hashset in java before PAT.Common.Classes.DataStructure.Set <Proposition> labels = new PAT.Common.Classes.DataStructure.Set <Proposition>(); if (ltl2ba.main.BtransPos(pTransition) == 0 && ltl2ba.main.BtransNeg(pTransition) == 0) { // we have a "Sigma" edge labels.Add(SIGMA_PROPOSITION); } else { for (int i = 0; i < allLabels.Length; i++) { if ((ltl2ba.main.BtransPos(pTransition) & (1 << i)) > 0) { labels.Add(new Proposition(allLabels[i], false)); } if ((ltl2ba.main.BtransNeg(pTransition) & (1 << i)) > 0) { Proposition l = new Proposition(allLabels[i], true); labels.Add(l); } } } PersonComparer p = new PersonComparer(); labels.Sort(p); Transition transition = new Transition(labels, sourceState, targetState); transitions.Add(transition); } } } else { throw new ArgumentException("invalid formula"); } //fair.Add(accept); return(new BuchiAutomata(initial, states.ToArray(), transitions.ToArray(), accept.ToArray())); }
/// <summary> /// /// </summary> public UnaryBState(BState i) { this.i = i; }
/* removes a state */ internal static BState remove_bstate(BState s, BState s1) { BState prv = s.prv; s.prv.nxt = s.nxt; s.nxt.prv = s.prv; mem.free_btrans(s.trans.nxt, s.trans, 0); s.trans = null; s.nxt = bremoved.nxt; bremoved.nxt = s; s.prv = s1; for (s1 = bremoved.nxt; s1 != bremoved; s1 = s1.nxt) if (s1.prv == s) s1.prv = s.prv; return prv; }
void update_buttons() { if ( hit_image_alpha(new Rectangle((int)Position.X, (int)Position.Y, (int)(Texture.Width*Scale), (int)(Texture.Height*Scale)), Texture, mx, my)) { button_timer = 0.0; if (mpressed) { // mouse is currently down button_state = BState.DOWN; MainColor = Color.Yellow; } else if (!mpressed && prev_mpressed) { // mouse was just released if (button_state == BState.DOWN) { // button i was just down button_state = BState.JUST_RELEASED; } } else { //Mouse is over the button button_state = BState.HOVER; MainColor = Color.Wheat; if (!IsHovered) { //scl_base = bcScale; if (frst) { Scale = Scale + GrowAm; frst = false; IsHovered = true; PrevPos = Position; Position = new Vector2(Position.X - ((Texture.Width * Scale - Texture.Width) / 2), Position.Y - ((Texture.Height * Scale - Texture.Height) / 2)); } if (Hovered != null) { EventArgs ar = new EventArgs(); Hovered(this, ar); } } } } else { //Mouse is far away from a button button_state = BState.UP; if (!frst) { Scale -= GrowAm; frst = true; IsHovered = false; if (PrevPos != null && PrevPos != Vector2.Zero) Position = PrevPos; } if (button_timer > 0) { button_timer = button_timer - frame_time; } else { MainColor = Color.White; } } if (button_state == BState.JUST_RELEASED) { //Taking action after buttonclick take_action_on_button(); } }
/// <summary> /// Updates the state of button depends of mouse position on screen. /// </summary> /// <param name="mx">The mx of mouse position.</param> /// <param name="my">My of mouse position.</param> /// <param name="frameTime">The frame time.</param> /// <param name="mPressed">if set to <c>true</c> [mouse pressed].</param> /// <param name="prevMPressed">if set to <c>true</c> [previous mouse pressed].</param> public void Update(int mx, int my, double frameTime, bool mPressed, bool prevMPressed) { _mx = mx; _my = my; _frameTime = frameTime; _mpressed = mPressed; _prevMpressed = prevMPressed; if (CheckIfButtonContainsPoint(_mx, _my)) { _timer = 0.0; if (_mpressed) { _state = BState.Down; Color = _pressedColor; } else if (!_mpressed && _prevMpressed) { if (_state == BState.Down) { _state = BState.JustReleased; } } else { _state = BState.Hover; Color = _hoverColor; } } else { _state = BState.Up; if (_timer > 0) { _timer = _timer - _frameTime; } else { Color = _normalColor; } } if (_state == BState.JustReleased) { OnClick(_timer); } if (_textLabel != null && _textLabel.Text.Length > 0) { _textLabel.Position = new Vector2(Position.X - Texture.Width * Scale.X / 2, Position.Y - Texture.Height * Scale.Y / 2); } }
public static game_err_code _add_bstate_to_ply(int bstate_id, IBaseUnit ply) { long cur_tm_s = DateTime.Now.ToBinary(); var bstate_conf = Utility.get_bstate_desc(bstate_id); if (bstate_conf == null) { return game_err_code.CONFIG_ERR; } BState cur_exist_bstate = null; //var ret_state = null; IMapUnit pl = ply.get_pack_data(); if (pl.bstates != null) { foreach (var bstate in pl.bstates) { if (bstate.conf.id == bstate_id) { // 已经有这个祝福状态了 cur_exist_bstate = bstate; break; } if (bstate.conf.uni_tp == bstate_conf.uni_tp) { //// 有相同类型的祝福状态(但id不同),不能添加 //return game_err_code.BSTATE_SAME_TP_BSTATE_EXIST; // 移除相同类型不同id的祝福状态 pl.bstates.Remove(bstate); // send bstate_change msg //::send_rpc(ply.pinfo.sid, 19, { rmvid = bstate.id}); break; } } } else { pl.bstates = new List<BState>(); } if (cur_exist_bstate != null) { // 已有同一祝福状态,增加持续时间,更改参数 //ret_state = { id = bstate_conf.id}; if (bstate_conf.eff.maxpar > 0) { if (cur_exist_bstate.par + bstate_conf.eff.par > bstate_conf.eff.maxpar) { // 超出允许叠加参数上限 return game_err_code.MAX_BSTATE_PAR_REACHED; } cur_exist_bstate.par += bstate_conf.eff.par; //ret_state.par < -cur_exist_bstate.par; } if (bstate_conf.merg_tm == 1) { cur_exist_bstate.end_tm = cur_exist_bstate.end_tm + bstate_conf.tm; // 延迟持续时间 } else { cur_exist_bstate.end_tm = cur_tm_s + bstate_conf.tm; // 延迟持续时间 } //ret_state.end_tm < -cur_exist_bstate.end_tm; } else { long ticktm = 0; if (bstate_conf.eff.ticktm > 0) { ticktm = cur_tm_s + bstate_conf.eff.ticktm; } BState bstate = new BState() { id = bstate_conf.id, par = bstate_conf.eff.par, end_tm = cur_tm_s + bstate_conf.tm, ticktm = ticktm, conf = bstate_conf }; pl.bstates.push(bstate); //ret_state = bstate; } // send bstate_change msg //::send_rpc(ply.pinfo.sid, 19, { mod = ret_state}); return game_err_code.RES_OK; }
/* frees a state and its transitions */ internal static void free_bstate(BState s) { mem.free_btrans(s.trans.nxt, s.trans, 1); mem.tfree(s); }
public void Approach(Vector3 _target) { Target = _target; state = BState.Approaching; Active = true; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Instantiate Tetris logic IBoard board = new Board(); Score score = new Score(board); // Add to board's GameOver event board.GameOver += gameOver; // Instantiate sprite classes int size = 25; boardSprite = new BoardSprite(this, board, size); shapeSprite = new ShapeSprite(this, board, score, size); scoreSprite = new ScoreSprite(this, score); // Add sprite classes Components.Add(boardSprite); Components.Add(shapeSprite); Components.Add(scoreSprite); // Set height and width of screen graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 500; graphics.ApplyChanges(); // Initialize font font = Content.Load<SpriteFont>("scoreFont"); base.Initialize(); //Create button int x = 5; int y = 200; button_state = BState.UP; button_color = Color.White; button_timer = 0.0; button_rectangle = new Rectangle(x, y, 100, 40); IsMouseVisible = true; background_color = Color.Black; /**Music Song song = Content.Load<Song>("music"); MediaPlayer.Play(song); */ }
/// <summary> /// ��û�п����ƶ��ı�ʯ��ʱ�� /// ���ñ�ʯ /// </summary> private void PopulateWithNewJewels() { CurrentlyMovingJewels = 0; theBoardState = BState.PLAYING; needToDropJewels = false; canSwap = true; // Destroy the old jewels for (int y = 0; y < boardSize; y++) { for (int x = 0; x < boardSize; x++) { if (IsJewelAt(x, y)) { GameObject j = (GameObject)jewelMapPosition[x, y]; Material ma = j.GetComponent<Renderer>().material; if (ma.mainTexture.name == "Jewels") { Jewel jj = j.gameObject.GetComponent<Jewel>(); jewelMapPosition[x, y] = null; jj.Die(); jewelRemains.Add(j); } } } } GetComponent<AudioSource>().PlayOneShot(explodeSound); // Randomize new jewels do { ResetJewels(); } while ((movesLeft = HowManyMovesLeft()) == 0); // Hide them from the view, and start an animation that drops down the // jewels, piece by piece for (int y = 0; y < boardSize; y++) { for (int x = 0; x < boardSize; x++) { GameObject pl = (GameObject)planeMapPosition[x, y]; GameObject ob = (GameObject)obsMapPosition[x, y]; if (pl != null && ob == null) { GameObject j = jewelMapPosition[x, y]; Jewel jj = j.gameObject.GetComponent<Jewel>(); j.transform.localPosition = new Vector3(j.transform.localPosition.x, j.transform.localPosition.y - boardSize, j.transform.localPosition.z); jj.Move(3, boardSize); } } } }
public BLauncher(BState startState) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new BLaunchWindow(startState)); }
internal static BState find_bstate(ref GState state, int final, BState s) { /* finds the corresponding state, or creates it */ if ((s.gstate == state) && (s.final == final)) return s; /* same state */ s = bstack.nxt; /* in the stack */ bstack.gstate = state; bstack.final = final; while (!(s.gstate == state) || !(s.final == final)) s = s.nxt; if (s != bstack) return s; s = bstates.nxt; /* in the solved states */ bstates.gstate = state; bstates.final = final; while (!(s.gstate == state) || !(s.final == final)) s = s.nxt; if (s != bstates) return s; s = bremoved.nxt; /* in the removed states */ bremoved.gstate = state; bremoved.final = final; while (!(s.gstate == state) || !(s.final == final)) s = s.nxt; if (s != bremoved) return s; s = new BState(); /* creates a new state */ s.gstate = state; s.id = (state).id; s.incoming = 0; s.final = final; s.trans = mem.emalloc_btrans(); /* sentinel */ s.trans.nxt = s.trans; s.nxt = bstack.nxt; bstack.nxt = s; return s; }
/// <summary> /// Helper method for updating the cardsprite /// </summary> /// <param name="state">The current mouse state</param> private void UpdateMovement(MouseState state) { var mx = state.X; var my = state.Y; prevmousepressed = mousepressed; mousepressed = state.LeftButton == ButtonState.Pressed && PsGame.Active && state.X >= 0 && state.X < PsGame.Width && state.Y >= 0 && state.Y < PsGame.Height; if(Func.HitAlpha(Rect, cardSprite, mx, my)) { timer = 0.0; if(mousepressed) { State = BState.Down; } else if(!mousepressed && prevmousepressed && State == BState.Down) { State = BState.JustReleased; } else { State = BState.Hover; } } else { State = BState.Up; if(timer > 0) { timer = timer - frametime; } else { Color = Color.White; } } if(State == BState.JustReleased) { var curClick = DateTime.Now; if((curClick - lastClick).TotalSeconds <= 1.0) { clickCount++; }else { clickCount = 0; } lastClick = curClick; } }
internal static void remove_btrans(BState to) { /* redirects transitions before removing a state from the automaton */ BState s; BTrans t; int i; for (s = bstates.nxt; s != bstates; s = s.nxt) for (t = s.trans.nxt; t != s.trans; t = t.nxt) if (t.to == to) { /* transition to a state with no transitions */ BTrans free = t.nxt; t.to = free.to; set.copy_set(free.pos, t.pos, 1); set.copy_set(free.neg, t.neg, 1); t.nxt = free.nxt; if (free == s.trans) s.trans = t; mem.free_btrans(free, null, 0); } }
/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> public Button() { Color = _normalColor; _state = BState.Up; _timer = 0.0; }
/// <summary> /// Determine state and color of button /// </summary> void UpdateButtons() { if (HitImage(button_rectangle, button_texture[0], mx, my)) { button_timer = 0.0; if (mpressed) { // mouse is currently down button_state = BState.DOWN; button_color = Color.Blue; } else if (!mpressed && prev_mpressed) { // mouse was just released if (button_state == BState.DOWN) { // button i was just down button_state = BState.JUST_RELEASED; } } else { button_state = BState.HOVER; button_color = Color.LightBlue; } } else { button_state = BState.UP; if (button_timer > 0) { button_timer = button_timer - frame_time; } else { button_color = Color.White; } } if (button_state == BState.JUST_RELEASED) { RestartGame(); } }