Esempio n. 1
0
        // --- Messages ---

        /// <summary>
        /// Attaches handlers to the goals
        /// </summary>
        private void Start()
        {
            playerOneScore = 0;
            playerTwoScore = 0;

            var p1Goal = Goals.FindPlayerOneGoal().GetComponent <TriggerObservable>();

            p1Goal.TriggerEnter += Goals.OnBallGoal(_ => playerOneScore += 1);
            p1Goal.TriggerEnter += Goals.OnBallGoal(OnGoal);

            var p2Goal = Goals.FindPlayerTwoGoal().GetComponent <TriggerObservable>();

            p2Goal.TriggerEnter += Goals.OnBallGoal(_ => playerOneScore += 1);
            p2Goal.TriggerEnter += Goals.OnBallGoal(OnGoal);
        }
Esempio n. 2
0
        public void OnBallGoal()
        {
            var check  = false;
            var action = Goals.OnBallGoal(_ => check = true);

            var go       = new GameObject("Foo");
            var collider = go.AddComponent <SphereCollider>();

            action(collider);
            Assert.IsFalse(check);

            collider.name = Ball.Name;
            action(collider);
            Assert.IsTrue(check);

            Object.DestroyImmediate(go);
        }