public void Modifier(KeyboardState p_kbs, ref float p_es_deltaX, ref float p_es_deltaY, ref TypeDirection p_direction) { if (p_kbs.IsKeyDown(Keys.Left)) { --p_es_deltaX; p_direction = TypeDirection.Gauche; } if (p_kbs.IsKeyDown(Keys.Right)) { ++p_es_deltaX; p_direction = TypeDirection.Droite; } if (p_kbs.IsKeyDown(Keys.Up)) { --p_es_deltaY; p_direction = TypeDirection.Haut; } if (p_kbs.IsKeyDown(Keys.Down)) { ++p_es_deltaY; p_direction = TypeDirection.Bas; } }
public String Convert(String value, String min, String max, TypeDirection direction) { //y = mx + b // //Where: //y = scaled output //m = slope (scaled max. -scaled min.)/(input max. -input min.) //x = input value //b = offset (y intercept) = scaled min - (input min. X slope) double valueOut; double minOut; double maxOut; if (double.TryParse(value, out valueOut) && double.TryParse(min, out minOut) && double.TryParse(max, out maxOut)) { if (direction == TypeDirection.ToDataSource) { double raw = double.Parse(value); double raw_min = double.Parse(min); double raw_max = double.Parse(max); double scaled_min = 0; double scaled_max = 16383; double m = ((scaled_max - (-scaled_min)) / (raw_max - (-raw_min))); double x = raw; double b = scaled_min - (raw_min * (m)); double scaled = (m * x) + b; return(string.Format("{0:F0}", scaled)); } else { double raw = double.Parse(value); double raw_min = 0; double raw_max = 16383; double scaled_min = double.Parse(min); double scaled_max = double.Parse(max); double m = ((scaled_max - (-scaled_min)) / (raw_max - (-raw_min))); double x = raw; double b = scaled_min - (raw_min * (m)); double scaled = (m * x) + b; return(string.Format("{0:F0}", scaled)); } } else { return(value); } }
public String Convert(String value, String min, String max, TypeDirection direction) { //y = mx + b // //Where: //y = scaled output //m = slope (scaled max. -scaled min.)/(input max. -input min.) //x = input value //b = offset (y intercept) = scaled min - (input min. X slope) double valueOut; double minOut; double maxOut; if (double.TryParse(value, out valueOut) && double.TryParse(min, out minOut) && double.TryParse(max, out maxOut)) { if (direction == TypeDirection.ToDataSource) { double raw = double.Parse(value); double raw_min = double.Parse(min); double raw_max = double.Parse(max); double scaled_min = 0; double scaled_max = 16383; double m = ((scaled_max - (-scaled_min)) / (raw_max - (-raw_min))); double x = raw; double b = scaled_min - (raw_min * (m)); double scaled = (m * x) + b; return string.Format("{0:F0}", scaled); } else { double raw = double.Parse(value); double raw_min = 0; double raw_max = 16383; double scaled_min = double.Parse(min); double scaled_max = double.Parse(max); double m = ((scaled_max - (-scaled_min)) / (raw_max - (-raw_min))); double x = raw; double b = scaled_min - (raw_min * (m)); double scaled = (m * x) + b; return string.Format("{0:F0}", scaled); } } else { return value; } }
/// <summary> /// Umwandlung in eine CSS-Klasse /// </summary> /// <param name="direction">Die Anordnung, welches umgewandelt werden soll</param> /// <returns>Die zur Anordnung gehörende CSS-KLasse</returns> public static string ToClass(this TypeDirection direction) { switch (direction) { case TypeDirection.Vertical: return("flex-column"); case TypeDirection.VerticalReverse: return("flex-column-reverse"); case TypeDirection.Horizontal: return("flex-row"); case TypeDirection.HorizontalReverse: return("flex-row-reverse"); } return(string.Empty); }
public static string stringFromDirection(TypeDirection the_enum) { switch (the_enum) { case TypeDirection.Direction_North: return("North"); case TypeDirection.Direction_East: return("East"); case TypeDirection.Direction_South: return("South"); case TypeDirection.Direction_West: return("West"); case TypeDirection.Direction_None: return("None"); default: Debug.Assert(false); return(null); } }
private void ChangeRandomDirection() { _direction = CGERandom.GetRandomDirection(); }
protected override void DoUpdate(GameTime p_gameTime, Rectangle p_limites, float p_portionTemps) { KeyboardState kbs = Keyboard.GetState(); GamePadState gps = GamePad.GetState(PlayerIndex.One); float deltaX = 0.0F; float deltaY = 0.0F; m_direction = TypeDirection.NulPart; StratégieClavier.Modifier(kbs, ref deltaX, ref deltaY, ref m_direction); StratégieManette.Modifier(gps, ref deltaX, ref deltaY); switch (m_direction) { case TypeDirection.Haut: RangéÀAfficher = RANGÉ_IMAGE_HAUT; EnMouvement = true; break; case TypeDirection.Bas: RangéÀAfficher = RANGÉ_IMAGE_BAS; EnMouvement = true; break; case TypeDirection.Gauche: RangéÀAfficher = RANGÉ_IMAGE_GAUCHEDROITE; Effet = SpriteEffects.FlipHorizontally; EnMouvement = true; break; case TypeDirection.Droite: RangéÀAfficher = RANGÉ_IMAGE_GAUCHEDROITE; EnMouvement = true; Effet = SpriteEffects.None; break; case TypeDirection.NulPart: EnMouvement = false; break; } float posX = Position.X + Vitesse.X * p_portionTemps * deltaX; float posY = Position.Y + Vitesse.Y * p_portionTemps * deltaY; // Corrections des positions Position = new Vector2(Math.Min(Math.Max(0, posX), p_limites.Width - EspaceOccupé.Width), Math.Min(Math.Max(0, posY), p_limites.Height - EspaceOccupé.Height)); }
protected override void handle_result(TypeDirection result) { top.value.Add(result); }
protected override void handle_result(TypeDirection result) { //@@@ Debug.Assert(!have_value); have_value = true; value = result; }
protected abstract void handle_result(TypeDirection result);
public void setDirection(TypeDirection new_value) { flagHasDirection = true; storeDirection = new_value; }