Наследование: SectionWeapon
Пример #1
0
 public void Nothingから値を取り出そうとするとNullReferenceExceptionが送出されること()
 {
     var nothing = new Nothing<int>();
     var value = 0;
     Assert.Throws<NullReferenceException>(() => value = nothing.Value);
     Assert.Throws<NullReferenceException>(() => Maybe<int>.FromJust(nothing));
 }
Пример #2
0
        protected override void _Start()
        {
            grid.ResetTiles();

            Process p = new Nothing();

            int i = 0;

            foreach( Unit unit in allUnits ) {
                if( !subjectUnit.team.IsAlly( unit ) && targetType == TargetType.Ally )
                    continue;

                if( !subjectUnit.team.IsEnemy( unit ) && targetType == TargetType.Enemy )
                    continue;

                if( onlyVisible && !subjectUnit.CanSee( unit.currentTile ) )
                    continue;

                unit.currentTile.MakeSelectable();
                unit.collider.enabled = true;

                SelectionManager.MarkTargetable( unit );

                i++;

            }

            print( i + " targetable units found." );

            End();
        }
Пример #3
0
        protected override void _Start()
        {
            Process p = new Nothing();

            processManager.AddImmediately( p );

            p = path.Aggregate( p , ( current , tile ) => current.Enqueue( new UnitMoveToTile( subjectUnit , tile ) ) );

            p.eventEnded += End;

            subjectUnit.model.animator.moving = true;
        }
Пример #4
0
 public void NothingShouldBindToNothing()
 {
     var nothing = new Nothing<int>();
     Assert.IsType<Nothing<int>>(nothing.Bind(x => (x + 1).ToMaybe()));
 }
Пример #5
0
 public void NothingShouldReturnDefaultValue()
 {
     var nothing = new Nothing<string>();
     Assert.Null(nothing.Return());
 }
Пример #6
0
 public void Nothing_FMap_ReturnsNothing()
 {
     var nothing = new Nothing<int>();
     var result = nothing.FMap<string>(a => a.ToString());
     Assert.IsInstanceOf<Nothing<string>>(result);
 }
Пример #7
0
 public void Nothing_Bind_ReturnsNothing()
 {
     var nothing = new Nothing<string>();
     var result = nothing.Bind<string>(a => new Just<string>(a));
     Assert.IsInstanceOf<Nothing<string>>(result);
 }
Пример #8
0
 static Maybe<Distance> Distance(Nothing<Location> a, Nothing<Location> b)
 {
     return new Nothing<Distance>();
 }
Пример #9
0
        public void TestMethod2()
        {
            ISomething something = new Something();
            var tasks = new List<Task>();
            var rwlock = new ReaderWriterLockSlim();

            for (var i = 0; i < 100; i++)
            {
                // These threads should never see "nothing"....
                tasks.Add(Task.Run(() =>
                {
                    for (var x = 0; x < 1000000; x++)
                    {
                        rwlock.EnterReadLock();
                        try
                        {
                            Thread.Sleep(100);
                            Assert.That(something.IsNothing, Is.False);
                        }
                        finally
                        {
                            rwlock.ExitReadLock();
                        }
                    }
                }));
            }

            // ... even though this one keeps setting it to nothing
            tasks.Add(Task.Run(() =>
            {
                for (var x = 0; x < 1000000; x++)
                {
                    rwlock.EnterWriteLock();
                    try
                    {
                        something = new Nothing();
                        Thread.Sleep(100);
                        something = new Something();
                    }
                    finally
                    {
                        rwlock.ExitWriteLock();
                    }
                }
            }));

            Task.WhenAll(tasks).Wait();
        }
Пример #10
0
        protected override void _Start()
        {
            grid.ResetTiles();

            Process p = new Nothing();

            foreach( GridTile tile in grid.GetAllTiles() )
                if( subjectUnit.CanSee( tile ) && tile.transform.position.IsInRange( subjectUnit.transform.position, range ) )
                //if( subjectUnit.CanSee( tile ) && subjectUnit.GetDistance( tile ) < range )
                    tile.MakeSelectable();

            End();
        }