Ejemplo n.º 1
0
        public void TestTargetBack()
        {
            var client = ServerMocker.GetClient();
            var player = client.FullLoginSequence(_player);

            var skeleton = new Skeleton()
            {
                Position = new Position(0, 1)
            };

            skeleton.AggroBehaviuor = BehaviourPool.Get <TargetBack>();

            Server.Events.Call(new EntitySpawnEvent()
            {
                Entity   = skeleton,
                Position = skeleton.Position
            });

            var chunk = player.GetChunk();

            client.SendToServer(new EntityTargetPacket()
            {
                TargetUuid = skeleton.UID,
                WhoUuid    = player.UID
            });

            Assert.That(skeleton.Target == player);
        }
Ejemplo n.º 2
0
 private void Init()
 {
     if (pool == null)
     {
         pool = new BehaviourPool <ParticleSystem>(CreateInstance);
         pool.WarmUp(capacity);
     }
 }
Ejemplo n.º 3
0
        public void TestMonsterMovingCollision()
        {
            var client = ServerMocker.GetClient();

            client.FullLoginSequence(_player);

            var skeleton = new Skeleton();

            skeleton.Position          = new Position(1, 1);
            skeleton.MovementBehaviour = BehaviourPool.Get <LeftRightWalk>();

            Server.Map.GetTile(2, 1).TileId = 2; // block

            var originalX = skeleton.Position.X;

            Server.Events.Call(new EntitySpawnEvent()
            {
                Entity   = skeleton,
                Position = skeleton.Position
            });

            client.SendToServer(new EntityMovePacket()
            {
                To  = new Position(_player.X, _player.Y + 1),
                UID = _player.UserId,
            });

            client.RecievedPackets.Clear();

            skeleton.MovementTick();

            Assert.That(skeleton.Position.X == originalX,
                        "Skeleton couldnt have moved as he was in between 2 obstacles");

            Assert.That(client.RecievedPackets.Count == 0,
                        "Player should not recieve monster move packets if the monster didnt moved");
        }
Ejemplo n.º 4
0
 public Skeleton()
 {
     this.Name = "Skeleton";
     this.MovementBehaviour = BehaviourPool.Get <LeftRightWalk>();
     this.AggroBehaviuor    = BehaviourPool.Get <TargetBack>();
 }
Ejemplo n.º 5
0
 public Skeleton()
 {
     this.Name = "Skeleton";
     this.MovementBehaviour = BehaviourPool.Get <RandomWalk>();
 }
Ejemplo n.º 6
0
 public Skeleton()
 {
     this.Name = "Skeleton";
     this.MovementBehaviour = BehaviourPool.Get <LeftRightWalk>();
 }
Ejemplo n.º 7
0
 void Awake()
 {
     _colliderPool = new BehaviourPool <BoxCollider2D>(gameObject, int.MaxValue);
 }