Inheritance: MonoBehaviour
Example #1
0
 protected void OnTriggerExit(Collider other)
 {
     if (other.gameObject == gameController.boundOuter)
     {
         Bouncer.Bounce(body, other.transform, Bouncer.BounceTowards.Inwards);
     }
 }
Example #2
0
        public void Handle3(MessageOne message)
        {
            var result = Bouncer.ForMessages(() => message).Assert().Results;

            this.Content = result.ToList().Count.ToString();
            this.CountOfEvents++;
        }
Example #3
0
        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"));
        }
Example #4
0
        public void ContractContextInsert(AttributedSampleClass sample)
        {
            var result = Bouncer.ForMessages(() => sample).Assert().Results;

            this.Content = result.ToList().Count.ToString();
            this.CountOfEvents++;
        }
Example #5
0
        public void IsNotValidWhenNull_NotNull_True()
        {
            var validator = Bouncer.For <Person>(model => model.BlockNull());
            var person    = new Person();

            Assert.IsTrue(validator.Validate(person).Success);
        }
Example #6
0
        public void IsNotValidWhenNull_Null_False()
        {
            var validator = Bouncer.For <Person>(model => model.BlockNull());
            var person    = default(Person);

            Assert.IsFalse(validator.Validate(person).Success);
        }
Example #7
0
        public void IsValidWhenNull_Null_True()
        {
            var validator = Bouncer.For <Person>(model => model.EnsureNull());
            var person    = default(Person);

            Assert.IsTrue(validator.Validate(person).Success);
        }
Example #8
0
        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);
        }
Example #11
0
    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;
    }
Example #12
0
        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;
                });
            }
        }
Example #13
0
 // 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;
 }
Example #14
0
    //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
        }
    }
Example #15
0
    //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;
        }
    }
Example #16
0
        /// <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);
            }
Example #18
0
 public Task GetConversations()
 {
     return(Bouncer.StartSingleTask(() =>
     {
         Threads = _chattingService.GetGroupThreads(_contextGroup.Id);
         //OnPropertyChanged("Threads");
     }));
 }
Example #19
0
        /// <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));
        }
Example #20
0
 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);
        }
Example #22
0
 public Task GetMessagesForThread([NotNull] PrivateConversation thread)
 {
     return(Bouncer.StartSingleTask(() =>
     {
         Messages = _chattingService.GetThreadMessages(thread);
         OnPropertyChanged("Messages");
     }));
 }
Example #23
0
        /// <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);
        }
Example #24
0
        public void CheckRuleSet2()
        {
            var messages = Bouncer
                           .ForMessages(() => MessageOneFailRegEx)
                           .ForMessages(() => MessageOneFailRegEx2)
                           .Assert();

            Assert.AreEqual(6, messages.Results.ToList().Count);
        }
Example #25
0
        /// <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));
        }
Example #26
0
        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);
                        }
                    }
                }
            }
        }
Example #27
0
        /// <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));
        }
Example #28
0
        /// <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);
        }
Example #29
0
        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);
        }
Example #31
0
        public IEnumerable <RuleValidationResult> CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer)
        {
            var results = Bouncer
                          .ForMessages(() => customerId)
                          .ForMessages(() => amount)
                          .ForMessages(() => theCustomer)
                          .Assert().Results;

            return(results);
        }
Example #32
0
 protected void DrawLine(DrawingContext context, Bouncer.MovingPoint[] line)
 {
     Assert.Assigned(line);
     context.DrawLine(BlackPen.Instance, line[0].Position, line[1].Position);
 }
Example #33
0
 protected void BounceLine(Bouncer.MovingPoint[] line)
 {
     Cycle.Forward(
         0,
         line.Length,
         (i) =>
         {
             bouncer.Move(
                 line[i],
                 this.GetActualSize(),
                 (double)sinceLastFrameStartedTime / 1000
             );
         }
     );
 }