Inheritance: MonoBehaviour
Example #1
0
 public void Does_not_cause_activation_before_EnableSpatialOSBehaviours()
 {
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForCurrentWorker>().enabled);
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForOtherWorker>().enabled);
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForCurrentWorkerWithReader>().enabled);
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForOtherWorkerWithReader>().enabled);
 }
Example #2
0
 protected override void PopulateBehaviours()
 {
     TestGameObject.AddComponent <TestBehaviourForCurrentWorker>();
     TestGameObject.AddComponent <TestBehaviourForCurrentWorkerWithReader>();
     TestGameObject.AddComponent <TestBehaviourForOtherWorker>();
     TestGameObject.AddComponent <TestBehaviourForOtherWorkerWithReader>();
 }
        protected override void ValidateRequirablesNotNull()
        {
            var testBehaviour = TestGameObject.GetComponent <TestBehaviourWithReaderAndWriter>();

            Assert.IsNotNull(testBehaviour.PositionReader);
            Assert.IsNotNull(testBehaviour.PositionReader);
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        TestGameObject myTarget = (TestGameObject)target;

        // myTarget.startMoveEvent = EditorGUILayout.IntField("Experience", myTarget.startMoveEvent);
    }
Example #5
0
 public void Does_not_deactivate_behaviour_when_authority_is_not_lost()
 {
     ActivationManager.AddComponent(PositionComponentId);
     ActivationManager.ChangeAuthority(PositionComponentId, Authority.Authoritative);
     ActivationManager.EnableSpatialOSBehaviours();
     ActivationManager.DisableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithReader>().enabled,
                   "Behaviour should not be disabled if authority is not lost");
 }
 public void Does_not_activate_behaviour_when_component_is_not_present()
 {
     Assert.IsFalse(TestGameObject.GetComponent <TBehaviour>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsFalse(TestGameObject.GetComponent <TBehaviour>().enabled,
                    "Behaviour should not be enabled after EnableSpatialOSBehaviours is called" +
                    " because it has no components");
 }
        private void AssertRequirablesNotNull()
        {
            var testBehaviour = TestGameObject.GetComponent <TestBehaviourWithCommandSender>();

            Assert.IsNotNull(testBehaviour.CommandRequestSender);
            Assert.IsNotNull(testBehaviour.CommandResponseHandler);
            Assert.IsNotNull(testBehaviour.WorldCommandRequestSender);
            Assert.IsNotNull(testBehaviour.WorldCommandResponseHandler);
        }
Example #8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            GameObject gameObject = new TestGameObject(GraphicsDevice);

            world.AddComponent(gameObject);
            // TODO: use this.Content to load your game content here
        }
Example #9
0
 public void Activates_behaviour_when_authority_is_present()
 {
     ActivationManager.AddComponent(PositionComponentId);
     ActivationManager.ChangeAuthority(PositionComponentId, Authority.Authoritative);
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourWithReader>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called even if authority is gained");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithReader>().enabled,
                   "Behaviour should be enabled after EnableSpatialOSBehaviours is called");
 }
 public void Does_not_deactivate_behaviour_when_authority_is_not_lost()
 {
     ActivationManager.AddComponent(ComponentId);
     ActivationManager.ChangeAuthority(ComponentId, Authority.Authoritative);
     ActivationManager.EnableSpatialOSBehaviours();
     ActivationManager.DisableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TBehaviour>().enabled,
                   "Behaviour should not be disabled if authority is not lost");
     ValidateRequirablesNotNull();
 }
 public void Does_not_activate_behaviour_when_authority_is_not_present()
 {
     ActivationManager.AddComponent(ComponentId);
     Assert.IsFalse(TestGameObject.GetComponent <TBehaviour>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsFalse(TestGameObject.GetComponent <TBehaviour>().enabled,
                    "Behaviour should not be enabled after EnableSpatialOSBehaviours is called" +
                    " because authority is not present");
 }
 public void Activates_behaviour_when_component_is_not_present()
 {
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                   "Behaviour should be enabled after EnableSpatialOSBehaviours is called" +
                   " even if it has no PlayerCreator component");
     AssertRequirablesNotNull();
 }
Example #13
0
        public void WallCollider_CollidesAny(double x1, double y1, int r1, double x2, double y2, int r2, bool expected)
        {
            var object1 = new TestWallObject(r1, new Vector(x1, y1));
            var object2 = new TestGameObject(r2, new Vector(x2, y2));

            LevelUtil.CreateLevel(new GameObject[] { object1, object2 });

            var result = object1.Collider.CollidesAny(object1.Location, true);

            Assert.AreEqual(expected, result);
        }
 public void Activate_behaviour_when_authority_is_not_present()
 {
     ActivationManager.AddComponent(ComponentId);
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                   "Behaviour should be enabled after EnableSpatialOSBehaviours is called" +
                   " even if authority is not present");
     AssertRequirablesNotNull();
 }
 public void Activates_behaviour_when_authority_is_present()
 {
     ActivationManager.AddComponent(ComponentId);
     ActivationManager.ChangeAuthority(ComponentId, Authority.Authoritative);
     Assert.IsFalse(TestGameObject.GetComponent <TBehaviour>().enabled,
                    "Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TBehaviour>().enabled,
                   "Behaviour should be enabled after EnableSpatialOSBehaviours is called");
     ValidateRequirablesNotNull();
 }
Example #16
0
 public void Activates_behaviours_only_for_current_worker()
 {
     ActivationManager.AddComponent(PositionComponentId);
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForOtherWorker>().enabled,
                    "TestBehaviourForOtherWorker should not be enabled after EnableSpatialOSBehaviours is called" +
                    " because it does not match the worker type");
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForOtherWorkerWithReader>().enabled,
                    "TestBehaviourForOtherWorkerWithReader should not be enabled after EnableSpatialOSBehaviours is called" +
                    " even if it has the components because it does not match the worker type");
     Assert.IsNull(TestGameObject.GetComponent <TestBehaviourForOtherWorkerWithReader>().PositionReader);
 }
Example #17
0
        public void Activate_behaviour_when_authority_is_not_present()
        {
            ActivationManager.AddComponent(PositionComponentId);
            var testBehaviourWithReader = TestGameObject.GetComponent <TestBehaviourWithReader>();

            Assert.IsFalse(testBehaviourWithReader.enabled,
                           "Behaviour should not be enabled before EnableSpatialOSBehaviours is called even if it has components");
            ActivationManager.EnableSpatialOSBehaviours();
            Assert.IsTrue(testBehaviourWithReader.enabled,
                          "Behaviour should be enabled after EnableSpatialOSBehaviours is called" +
                          " even if authority is not present");
            Assert.IsNotNull(testBehaviourWithReader.PositionReader);
        }
Example #18
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            world = new World(this);
            TestGameObject testGame = new TestGameObject(world, null);

            camera        = new Camera(testGame, GraphicsDevice);
            world.Camera  = camera;
            camera.Follow = testGame;

            map       = new TileMap("Content/map1.tmx", world);
            world.Map = map;
            // TODO: use this.Content to load your game content here
        }
Example #19
0
 public void Activate_only_reader_behaviour_when_authority_is_not_present()
 {
     ActivationManager.AddComponent(PositionComponentId);
     Assert.IsFalse(TestGameObject.GetComponent <ReaderBehaviour>().enabled,
                    "Reader Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     Assert.IsFalse(TestGameObject.GetComponent <WriterBehaviour>().enabled,
                    "Writer Behaviour should not be enabled before EnableSpatialOSBehaviours is called");
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <ReaderBehaviour>().enabled,
                   "Reader Behaviour should be enabled after EnableSpatialOSBehaviours is called" +
                   " even if authority is not present");
     Assert.IsFalse(TestGameObject.GetComponent <WriterBehaviour>().enabled,
                    "Writer Behaviour should not be enabled after EnableSpatialOSBehaviours is called" +
                    " because authority is not present");
 }
 public void Does_not_deactivate_behaviour_when_authority_is_lost()
 {
     ActivationManager.AddComponent(ComponentId);
     ActivationManager.ChangeAuthority(ComponentId, Authority.Authoritative);
     ActivationManager.EnableSpatialOSBehaviours();
     ActivationManager.ChangeAuthority(ComponentId, Authority.NotAuthoritative);
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                   "Behaviour should not be disabled after DisableSpatialOSBehaviours is called" +
                   " even if authority is lost");
     ActivationManager.DisableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourWithCommandSender>().enabled,
                   "Behaviour should not be disabled after DisableSpatialOSBehaviours is called" +
                   " even if authority is lost");
     AssertRequirablesNotNull();
 }
Example #21
0
 public void Does_not_alter_component_dependent_activation()
 {
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourForCurrentWorker>().enabled,
                   "TestBehaviourForCurrentWorker should be enabled after EnableSpatialOSBehaviours is called" +
                   " because it matches the worker type");
     Assert.IsFalse(TestGameObject.GetComponent <TestBehaviourForCurrentWorkerWithReader>().enabled,
                    "TestBehaviourForCurrentWorkerWithReader should not be enabled after EnableSpatialOSBehaviours is called" +
                    " even if it matches the worker type because it has no components");
     Assert.IsNull(TestGameObject.GetComponent <TestBehaviourForCurrentWorkerWithReader>().PositionReader);
     ActivationManager.AddComponent(PositionComponentId);
     ActivationManager.EnableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <TestBehaviourForCurrentWorkerWithReader>().enabled,
                   "TestBehaviourForCurrentWorkerWithReader should be enabled after EnableSpatialOSBehaviours is called" +
                   " because it has the right components");
     Assert.IsNotNull(TestGameObject.GetComponent <TestBehaviourForCurrentWorkerWithReader>().PositionReader);
 }
Example #22
0
 public void Does_not_deactivate_reader_behaviour_when_authority_is_lost()
 {
     ActivationManager.AddComponent(PositionComponentId);
     ActivationManager.ChangeAuthority(PositionComponentId, Authority.Authoritative);
     ActivationManager.EnableSpatialOSBehaviours();
     ActivationManager.ChangeAuthority(PositionComponentId, Authority.NotAuthoritative);
     Assert.IsTrue(TestGameObject.GetComponent <ReaderBehaviour>().enabled,
                   "Reader Behaviour should not be disabled before DisableSpatialOSBehaviours is called" +
                   " even if authority is lost");
     Assert.IsTrue(TestGameObject.GetComponent <WriterBehaviour>().enabled,
                   "Writer Behaviour should not be disabled before DisableSpatialOSBehaviours is called" +
                   " even if authority is lost");
     ActivationManager.DisableSpatialOSBehaviours();
     Assert.IsTrue(TestGameObject.GetComponent <ReaderBehaviour>().enabled,
                   "Reader Behaviour should not be disabled after DisableSpatialOSBehaviours is called" +
                   " even if authority is lost");
     Assert.IsFalse(TestGameObject.GetComponent <WriterBehaviour>().enabled,
                    "Writer Behaviour should not be disabled after DisableSpatialOSBehaviours is called" +
                    " after authority is lost");
 }
 protected override void PopulateBehaviours()
 {
     TestGameObject.AddComponent <TBehaviour>();
 }
Example #24
0
 public void SetUp()
 {
     _position = new Vector2(12f, 5.5f);
     _gameObject = new TestGameObject(_position, 30f, 200f);
     _gameTime = new GameTime(new TimeSpan(10000000), new TimeSpan(200000));
 }
 protected override void ValidateRequirablesNotNull()
 {
     Assert.IsNotNull(TestGameObject.GetComponent <TestBehaviourWithWriter>().PositionWriter);
 }
Example #26
0
 protected override void PopulateBehaviours()
 {
     TestGameObject.AddComponent <ReaderBehaviour>();
     TestGameObject.AddComponent <WriterBehaviour>();
 }
 protected override void ValidateRequirablesNotNull()
 {
     Assert.IsNotNull(TestGameObject.GetComponent <TestBehaviourWithCommandHandlers>().CommandRequestHandler);
 }
 protected override void PopulateBehaviours()
 {
     TestGameObject.AddComponent <TestBehaviourWithCommandSender>();
 }