protected void OnTriggerExit(Collider other) { if (other.gameObject == gameController.boundOuter) { Bouncer.Bounce(body, other.transform, Bouncer.BounceTowards.Inwards); } }
public void Handle3(MessageOne message) { var result = Bouncer.ForMessages(() => message).Assert().Results; this.Content = result.ToList().Count.ToString(); this.CountOfEvents++; }
public void ThrowOrDefault_InvalidPerson_PersonValidationException() { var validator = Bouncer.For <Person>(model => model.Block(p => p.FirstName == null)); var person = new Person(); Assert.That.Throws <DynamicException>(() => validator.Validate(person).ThrowIfInvalid(), filter => filter.When(name: "PersonValidationException")); }
public void ContractContextInsert(AttributedSampleClass sample) { var result = Bouncer.ForMessages(() => sample).Assert().Results; this.Content = result.ToList().Count.ToString(); this.CountOfEvents++; }
public void IsNotValidWhenNull_NotNull_True() { var validator = Bouncer.For <Person>(model => model.BlockNull()); var person = new Person(); Assert.IsTrue(validator.Validate(person).Success); }
public void IsNotValidWhenNull_Null_False() { var validator = Bouncer.For <Person>(model => model.BlockNull()); var person = default(Person); Assert.IsFalse(validator.Validate(person).Success); }
public void IsValidWhenNull_Null_True() { var validator = Bouncer.For <Person>(model => model.EnsureNull()); var person = default(Person); Assert.IsTrue(validator.Validate(person).Success); }
public void IsValidWhenNull_NotNull_False() { var validator = Bouncer.For <Person>(model => model.EnsureNull()); var person = new Person(); Assert.IsFalse(validator.Validate(person).Success); }
public void AddRuleForTypeMustFailRegExCollect4() { var messages = Bouncer.ForMessages("hello", "theValue").Assert(new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8))).Results; var actual = messages.First().Message; Assert.AreEqual(messages.First().ToString(), actual); }
public void AddRuleForTypeMustFailRegExCollect3() { var messages = Bouncer.ForMessages("hello", "theValue").Assert(new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8))).Results; var actual = messages.First().Message; Assert.AreEqual("The rule Sem.GenericHelpers.Contracts.Rules.ConfigurationValidatorBaseRule`1 did fail for value name >>theValue<<: The validator System.Configuration.StringValidator did throw an exception.", actual); }
IEnumerator Aim(GameObject selected) { Bouncer selectedBouncer = selected.GetComponent <Bouncer>(); Transform selectedOrigin; Vector3 lookAngle; float aimStrength = 0f; selectedBouncer.EnableAimReticule(true); selectedBouncer.aiming = true; while (!Input.GetMouseButtonUp(0)) { selectedOrigin = selected.GetComponent <Transform>(); //Face select to opposite of mouse lookAngle = -(getMousePointInWorld() - selectedOrigin.position); selectedOrigin.LookAt(new Vector3(lookAngle.x * 100f, selectedOrigin.position.y, lookAngle.z * 100f)); //Creating a float to lock the max pull based on stamina allowance float maxPullAllowByStamina = Mathf.Clamp(selectedBouncer.stamina.currentValue / gameSettings.maxAttackPower, 0f, 1f); //Change aim reticule size and set aim strength aimStrength = Mathf.Clamp(Vector3.Distance(getMousePointInWorld(), selectedOrigin.position) / gameSettings.maxPullDistance, 0f, maxPullAllowByStamina); selectedBouncer.AdjustAimReticuleSizeAndColor(aimStrength); yield return(null); } //Release attack selectedBouncer.LaunchBouncer(aimStrength); selectedBouncer.EnableAimReticule(false); selectedBouncer.aiming = false; }
private static void AddLogging(string message) { Console.ForegroundColor = ConsoleColor.Gray; Console.Clear(); Console.WriteLine(message); var input = Console.ReadLine(); if (input == null) { return; } if (input.ToUpperInvariant() == "L") { Bouncer.AddAfterInvokeAction(x => { var c = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( @"LOG: " + x.RuleType.Name + @" => " + x.Result + @" for " + x.ValueName + @" ... " + x.Message); Console.ForegroundColor = c; }); } }
// Use this for initialization void Start() { saw = gameObject.transform; rigidB = GetComponent <Rigidbody2D> (); controlScript = control.GetComponent <Controller>(); scrollBar = GameObject.Find("Control Image Scrollbar").GetComponent <Scrollbar>(); scrollRect = GameObject.Find("Scroll View").GetComponent <ScrollRect>(); baseImage = GameObject.Find("Seesaw Base Image"); cartScript = baseImage.GetComponent <SeesawCartWheels> (); sawObjL = Instantiate(sawImageL, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y + .045f), Quaternion.identity); //Create the seesaw image prefabs sawObjR = Instantiate(sawImageR, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y + .045f), Quaternion.identity); sawObjL.transform.parent = saw; //Assign as children of teeterbase sawObjR.transform.parent = saw; source = GetComponent <AudioSource>(); handle = GameObject.Find("Handle"); controlEmpty = GameObject.Find("Control Empty 1").transform; dudeOnSaw = controlScript.attachedDude.gameObject; if (dudeOnSaw != null) { bouncerScript = dudeOnSaw.GetComponent <Bouncer> (); } teeterSide = 'l'; //rEdge = 3.275f; rEdge = 3.18f; //lEdge = -3.279f; lEdge = -3.18f; botEdge = .93f; }
//After collision with a falling dude, bounce the other dude and set up conditions/variables for each dude private void bounceDude(Collision2D col) { // ParticleSystem ps; // if(teeterSide == 'l'){ // ps = Instantiate(landingPS, new Vector2(transform.position.x + .2f, transform.position.y + .1f), Quaternion.identity); // }else{ // ps = Instantiate(landingPS, new Vector2(transform.position.x - .2f, transform.position.y + .1f), Quaternion.identity); // } // Destroy (ps, .4f); checkHit(col); //Saw 1/2 if (!controlScript.gameOver) { bouncerScript.setAttached('l', false); bouncerScript.setAttached('r', false); bouncerScript.setParent(null); bungieScript.dude = dudeOnSaw; dudeOnSaw = col.gameObject; bouncerScript = dudeOnSaw.GetComponent <Bouncer> (); bouncerScript.setParent(saw); bouncerScript.setTeeterCol(false); bouncerScript.setBalloonCol(false); bouncerScript.switchPlatformCollider(false); if (teeterSide == 'l') { bouncerScript.setAttached('l', true); } else { bouncerScript.setAttached('r', true); } source.PlayOneShot(bounceSound, .75f); // Play the bounce sound } }
//maybe have these based on ground instead. private void OnCollisionEnter(Collision collision) { if (falling && !_controller.dead) { StartCoroutine("Recover", 3); } if (!_inLauncher && _currentLauncher != null) { _movementEnabled = true; _currentLauncher = null; } if (!_inBouncer && _currentBouncer != null) { _currentBouncer = null; _groundJumpActive = true; } if (!_onMovingObject && _movingRb != null) { _movingRb = null; _movingObjectDirection = Vector3.zero; } }
/// <summary> /// Send a request of connection to all peers that are contained in the all XML-Lists if them aren't already connected with this client. /// Then deletes all XML-Lists. /// </summary> /// <param name="n">Max number of connections that will be opened. Set 0 to open all possible connections.</param> public static void ConnToPeers(int n = 0) { string[] lists = Directory.GetFiles((Global.TempDirectory + @"List\"), "List_*.xml", SearchOption.AllDirectories); foreach (string listPath in lists) { XmlDocument list = new XmlDocument(); // load the Xml-List while (true) { try { list.Load(listPath); break; } catch (IOException) { } catch (Exception ex) { Debug.WriteLine("Error to load a XML-List from " + listPath + " : " + ex.Message, "Error"); throw new IOException("Error to load a XML-List from " + listPath + " : " + ex.Message); } } XmlNodeList nodes = list.DocumentElement.GetElementsByTagName("Peers"); // get the single peers from the list int i = 0; foreach (XmlNode node in nodes) { if (i < n) { string IP = node.SelectSingleNode("IP").InnerText; // control if this peer is already connected with this client if (PeersList.GetPeerByIP(IP) == null) { string RequestConnectionMessage = Bouncer.RequestMessage(IP); MessageSender.SendConnectionRequest(RequestConnectionMessage, IP); } if (n != 0) { i++; } } else { break; } } // delete the list File.Delete(listPath); } }
public void ReturnsBouncer() { // Arrange -> Act var bouncer = new Bouncer(); // Assert Assert.IsAssignableFrom <Bouncer>(bouncer); }
public Task GetConversations() { return(Bouncer.StartSingleTask(() => { Threads = _chattingService.GetGroupThreads(_contextGroup.Id); //OnPropertyChanged("Threads"); })); }
/// <summary> /// Creates an instance for a specific type /// </summary> /// <param name="type">The type the instance should be created for</param> /// <returns>the instance</returns> public static object CreateTypeInstance(Type type) { Bouncer .ForCheckData(() => type) .Assert(new IsNotNullRule <Type>()); return(GetMock(type.FullName) ?? Activator.CreateInstance(type)); }
void Awake() { nite = FindObjectOfType(typeof(NiteOpenNet)) as NiteOpenNet; selectShape = FindObjectOfType(typeof(SelectShape)) as SelectShape; userGui = FindObjectOfType(typeof(UserGuiDeformatory)) as UserGuiDeformatory; bouncer = FindObjectOfType(typeof(Bouncer)) as Bouncer; ballAnimator = FindObjectOfType(typeof(BallAnimator)) as BallAnimator; }
public void AddRuleForTypeMustSucceedRegExCollect4() { var configurationValidatorBaseRule = new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8)); var messages = Bouncer.ForMessages("hello I have more than 8 chars", "theValue").Assert(configurationValidatorBaseRule).Results; var actual = messages.ToList().Count; Assert.AreEqual(0, actual); }
public Task GetMessagesForThread([NotNull] PrivateConversation thread) { return(Bouncer.StartSingleTask(() => { Messages = _chattingService.GetThreadMessages(thread); OnPropertyChanged("Messages"); })); }
/// <summary> /// Strong typed rule invocation. /// </summary> /// <typeparam name="TParameter">The type of the rule parameter.</typeparam> /// <param name="rule">The rule to be evaluated.</param> /// <param name="ruleParameter">The parameter for invoking the rule.</param> /// <param name="valueName">The name of the data to be checked.</param> /// <returns>True if the rule check is ok, false if the rule is violated.</returns> public bool ExecuteRuleExpression <TParameter>(RuleBase <TData, TParameter> rule, TParameter ruleParameter, string valueName) { // if there is no rule, we cannot say that the rule is validated if (rule == null) { return(true); } // let the concrete execution class decide if we want to execute the expression if (!this.BeforeInvoke(rule, ruleParameter, valueName)) { return(true); } var validationResult = false; try { // execute the expression validationResult = rule.CheckExpression(this.Value, ruleParameter); } catch (NullReferenceException) { } catch (Exception ex) { if (!this.HandleInvokeException(ex, rule, ruleParameter, valueName)) { throw; } } var ruleType = rule.GetType(); var result = new RuleValidationResult( ruleType, string.Format( CultureInfo.CurrentCulture, Resources.RuleValidationResultStandardMessage, ruleType.Namespace + "." + ruleType.Name, valueName, string.Format(CultureInfo.CurrentCulture, rule.Message, ruleParameter, valueName)), valueName, validationResult); foreach (var action in Bouncer.GetAfterInvokeActions()) { action.Invoke(result); } this.AfterInvoke(result); if (this.PreviousExecuter != null) { this.PreviousExecuter.AssertAll(); } return(validationResult); }
public void CheckRuleSet2() { var messages = Bouncer .ForMessages(() => MessageOneFailRegEx) .ForMessages(() => MessageOneFailRegEx2) .Assert(); Assert.AreEqual(6, messages.Results.ToList().Count); }
/// <summary> /// Creates an instance for a specific type /// </summary> /// <param name="type">The type the instance should be created for</param> /// <param name="param1">The type of the 1st ctor parameter for instanciating the class</param> /// <typeparam name="TCtorParam1">The parameter value for instanciating the class</typeparam> /// <returns>the instance</returns> public static object CreateTypeInstance <TCtorParam1>(Type type, TCtorParam1 param1) { Bouncer .ForCheckData(() => type) .Assert(new IsNotNullRule <Type>()); return(GetMock(string.Join(":", type.FullName, typeof(TCtorParam1).FullName)) ?? Activator.CreateInstance(type, param1)); }
public void Update(GameTime gameTime, SpriteBatch spriteBatch) { time += gameTime.ElapsedGameTime; Camera.CameraInput(); WorldObjects.Update(gameTime); GenerateWorms(); foreach (var worm in Worms) { worm.Update(gameTime, Camera.CameraPos); worm.WorldObjectCollision(WorldObjects.donkeyRec); if (RectangleCollision.PixelIntersect(worm.WormRectangle, worm.textureData, WorldObjects.donkeyRec, WorldObjects.textureData)) { Console.WriteLine("Touched"); } //Tilemap Collision foreach (var tile in Map.CollisionList) { //if (worm.BreakingAnimation.IsDead) // tile.TileActive = false; if (tile.tileActive) { worm.Collision(spriteBatch, gameTime, tile.TileRectangle, tile); } //if (WeldingActive) //{ // tile.WeldTile(); // WeldingActive = false; //} } //Blocker Collision if (worm.state == Worm.wormState.Blocking) { foreach (var Blocker in Worms) { if (Blocker.state == Worm.wormState.Walking) { Blocker.BlockerCollision(worm.WormRectangle, worm.DirectionRight); } } } //Bouncer Collision if (worm.state == Worm.wormState.Bouncing) { foreach (var Bouncer in Worms) { if (Bouncer.state == Worm.wormState.Walking) { Bouncer.BouncerCollision(worm.WormRectangle, worm.DirectionRight); } } } } }
/// <summary> /// We need to use the type MySaveCustomer in order to correctly resolve type inference for /// Bouncer.ForCheckData(() => customer).Assert(); /// </summary> /// <param name="customer">this customer type does have rule-attributes attached to its properties</param> internal new void WriteCustomerProperties(MyCustomer customer) { Bouncer.ForCheckData(() => customer).Assert(); Console.WriteLine( "calling customer {0} with Id {1}", GetTheName(customer), FormatTheId(customer)); }
/// <summary> /// processes a class name to make it full qualifies include in the assembly name /// </summary> /// <param name="className">The class name that may need processing.</param> /// <returns>The processed full qualified class name.</returns> public string EnrichClassName(string className) { Bouncer.ForCheckData(() => className) .Assert(new StringNotNullOrEmptyRule()); var returnValue = new StringBuilder(); var isFirstFragement = true; var names = className.Split(new[] { " of " }, StringSplitOptions.None); foreach (var name in names) { if (!isFirstFragement) { returnValue.Append(" of "); } if (!name.Contains(",")) { string assemblyName; if (!name.Contains(".")) { if (string.IsNullOrEmpty(this.DefaultNamespace)) { throw new ConfigurationErrorsException("This factory class needs a DefaultNamespace set by the constructor of the DefaultNamespace property to add the default namespace to class names."); } assemblyName = this.DefaultNamespace.Trim(); returnValue.Append(assemblyName).Append("."); if (className == "StdContact" || className == "StdContact") { returnValue.Append("DetailData."); } } else { assemblyName = name.Substring(0, name.LastIndexOf(".", StringComparison.Ordinal)).Trim(); } returnValue.Append(name.Trim()).Append(", ").Append(assemblyName); } else { returnValue.Append(name.Trim()); } isFirstFragement = false; } var result = returnValue.ToString(); if (result.StartsWith("{", StringComparison.Ordinal) && result.EndsWith("}", StringComparison.Ordinal)) { result = ConfigurationManager.AppSettings["factoryName-" + result.Substring(1, result.Length - 2)]; } return(result); }
public void CheckIntValid0Ax() { const string SomeParameter = ""; Bouncer.ForCheckData(SomeParameter, "someParameter") .Assert(new IsNotNullRule <string>()) .Assert(x => x.ToString() != "0000-00-00") .Assert(new ImplementsInterfaceRule <string>(), typeof(IComparable <>)); }
public void CheckRuleForCheckMultipleFail2() { var x = Bouncer .ForCheckData(() => MessageOneFailRegEx) .ForCheckData(() => MessageOneOk) .Assert(); Assert.IsNotNull(x); }
public IEnumerable <RuleValidationResult> CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer) { var results = Bouncer .ForMessages(() => customerId) .ForMessages(() => amount) .ForMessages(() => theCustomer) .Assert().Results; return(results); }
protected void DrawLine(DrawingContext context, Bouncer.MovingPoint[] line) { Assert.Assigned(line); context.DrawLine(BlackPen.Instance, line[0].Position, line[1].Position); }
protected void BounceLine(Bouncer.MovingPoint[] line) { Cycle.Forward( 0, line.Length, (i) => { bouncer.Move( line[i], this.GetActualSize(), (double)sinceLastFrameStartedTime / 1000 ); } ); }