Ejemplo n.º 1
0
    public void Attack(int attackPoints)
    {
        var message = new JsonMessageBuilder()
                      .Type("Attack")
                      .Set("attack", attackPoints)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 2
0
    public void ContainerRequest(Vector3 loc)
    {
        var message = new JsonMessageBuilder()
                      .Type("ContainerRequest")
                      .Set("loc", new { x = loc.x, y = loc.y, z = loc.z })
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 3
0
    public void SetDefense(int defensePoints)
    {
        var message = new JsonMessageBuilder()
                      .Type("SetDefense")
                      .Set("defense", defensePoints)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 4
0
    public void UnequipItem(int slotIndex)
    {
        var message = new JsonMessageBuilder()
                      .Type("UnequipItem")
                      .Set("slotIndex", slotIndex)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 5
0
    public void PickItemUse(int useIndex)
    {
        var message = new JsonMessageBuilder()
                      .Type("PickItemUse")
                      .Set("useIndex", useIndex)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 6
0
    public void SelectTarget(Creature creature)
    {
        var message = new JsonMessageBuilder()
                      .Type("SelectTarget")
                      .Set("id", creature != null ? creature.Id : 0)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 7
0
    public void Chat(String text)
    {
        var message = new JsonMessageBuilder()
                      .Type("Chat")
                      .Set("msg", text)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 8
0
    public void PerformAction(int actionId)
    {
        var message = new JsonMessageBuilder()
                      .Type("PerformAction")
                      .Set("id", actionId)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 9
0
    public void AdminMakeItem(Vector3 loc, int itemIndex)
    {
        var message = new JsonMessageBuilder()
                      .Type("AdminMakeItem")
                      .Set("loc", new { x = loc.x, y = loc.y, z = loc.z })
                      .Set("item", itemIndex)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 10
0
    public void AdminMakeFloor(Vector3 loc, int floorIndex)
    {
        var message = new JsonMessageBuilder()
                      .Type("AdminMakeFloor")
                      .Set("loc", new { x = loc.x, y = loc.y, z = loc.z })
                      .Set("floor", floorIndex)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 11
0
    public void Register(String username, String password)
    {
        var passwordHash = MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(password));
        var message      = new JsonMessageBuilder()
                           .Type("Register")
                           .Set("username", username)
                           .Set("passwordHash", passwordHash)
                           .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 12
0
    //outbound
    public void PlayerMove(Vector3 loc, bool onRaft, int timeForMovement)
    {
        var message = new JsonMessageBuilder()
                      .Type("PlayerMove")
                      .Set("loc", new { x = (int)loc.x, y = (int)loc.y, z = (int)loc.z }) // :(
                      .Set("onRaft", onRaft)
                      .Set("timeForMovement", timeForMovement)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 13
0
    public void UseItem(int source, int dest, int sourceIndex, int destIndex)
    {
        var message = new JsonMessageBuilder()
                      .Type("UseItem")
                      .Set("source", source)
                      .Set("dest", dest)
                      .Set("si", sourceIndex)
                      .Set("di", destIndex)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 14
0
    public void MoveItem(int source, int dest, int sourceIndex, int destIndex, int quantity = -1)
    {
        var message = new JsonMessageBuilder()
                      .Type("MoveItem")
                      .Set("source", source)
                      .Set("dest", dest)
                      .Set("si", sourceIndex)
                      .Set("di", destIndex)
                      .Set("quantity", quantity)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 15
0
        public void ShouldReadResponseWithSimpleStringCorrectly()
        {
            var responseByteString = "42696E010000000B0000000300000003426C61";
            var responseStream     = BinaryUtils.CreateByteStream(responseByteString);

            var converter = new MessageConverter();
            var output    = new StringWriter();
            var builder   = new JsonMessageBuilder(output);

            converter.Convert(new HmBinaryMessageReader(responseStream), builder);

            var response = output.ToString();

            response.ShouldBe("\"Bla\"");
        }
Ejemplo n.º 16
0
    public void CreatureRequest(int id)
    {
        if (_creaturesRequested.Contains(id))
        {
            return;
        }
        //Debug.LogError("no creature of id: " + id); // :(
        _creaturesRequested.Add(id);

        var message = new JsonMessageBuilder()
                      .Type("CreatureRequest")
                      .Set("id", id)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 17
0
        public void ShouldReadResponseWithVoidContent()
        {
            var voidString         = "0000000300000000";
            var responseByteString = "42696E0100000008" + voidString;
            var responseStream     = BinaryUtils.CreateByteStream(responseByteString);


            var converter = new MessageConverter();
            var output    = new StringWriter();
            var builder   = new JsonMessageBuilder(output);

            converter.Convert(new HmBinaryMessageReader(responseStream), builder);

            var response = output.ToString();

            response.ShouldBe("\"\"");
        }
Ejemplo n.º 18
0
    public void SectorRequest(int x, int y, int z)
    {
        if (_sectorsRequested.Contains(new Vector3(x, y, z)))
        {
            return;
        }
        _sectorsRequested.Add(new Vector3(x, y, z));

        var message = new JsonMessageBuilder()
                      .Type("SectorRequest")
                      .Set("x", x)
                      .Set("y", y)
                      .Set("z", z)
                      .Build();

        _socketHandler.Send(message);
    }
Ejemplo n.º 19
0
        public void StringResponsesAreWrittenCorrectly()
        {
            var input  = new MemoryStream();
            var writer = new HmBinaryMessageWriter(input);

            writer.BeginMessage(MessageType.Request);
            writer.BeginContent();
            writer.SetMethod("newDevices");
            writer.BeginArray(1);
            writer.BeginItem();

            //parameter 1
            writer.BeginArray(2);

            writer.BeginItem();
            writer.BeginStruct(2);
            writer.BeginItem();
            writer.WritePropertyName("CHILDREN");
            var items = 3;

            writer.BeginArray(items);
            for (; items > 0; items--)
            {
                writer.BeginItem();
                writer.WriteStringValue("value " + items);
                writer.EndItem();
            }
            writer.EndArray();
            writer.EndItem();
            writer.BeginItem();
            writer.WritePropertyName("FIRMWARE");
            writer.WriteStringValue("1.505");
            writer.EndItem();
            writer.EndStruct();
            writer.EndItem();

            writer.BeginItem();
            writer.BeginStruct(3);
            writer.BeginItem();
            writer.WritePropertyName("ADDRESS");
            writer.WriteStringValue("BidCoS-RF");
            writer.EndItem();
            writer.BeginItem();
            writer.WritePropertyName("CHILDREN");
            var items2 = 5;

            writer.BeginArray(items2);
            for (; items2 > 0; items2--)
            {
                writer.BeginItem();
                writer.WriteStringValue("value " + items2);
                writer.EndItem();
            }
            writer.EndArray();
            writer.EndItem();
            writer.BeginItem();
            writer.WritePropertyName("FIRMWARE");
            writer.WriteStringValue("1.505");
            writer.EndItem();
            writer.EndStruct();
            writer.EndItem();

            //end parameter 1
            writer.EndArray();
            writer.EndItem();

            //end params
            writer.EndArray();
            writer.EndContent();
            writer.EndMessage();
            var result = BinaryUtils.FormatMemoryStream(input);

            input.Seek(0, SeekOrigin.Begin);
            var converter    = new MessageConverter();
            var outputReader = new JsonMessageBuilder();

            converter.Convert(new HmBinaryMessageReader(input), outputReader);

            result.ShouldBe("42696E00000001180000000A6E6577446576696365730000000100000100000000020000010100000002000000084348494C4452454E0000010000000003000000030000000776616C75652033000000030000000776616C75652032000000030000000776616C75652031000000084649524D574152450000000300000005312E353035000001010000000300000007414444524553530000000300000009426964436F532D5246000000084348494C4452454E0000010000000005000000030000000776616C75652035000000030000000776616C75652034000000030000000776616C75652033000000030000000776616C75652032000000030000000776616C75652031000000084649524D574152450000000300000005312E353035");
        }