コード例 #1
0
    protected override void Execute(List <InputEntity> entities)
    {
        var moversList = new List <GameEntity>(_movers.GetEntities());
        var clientId   = _client.ConnectionId.Id.ToString();
        var curMover   = moversList.Find(m => m.moverID.value == clientId);
        var curTick    = _gameContext.tick.CurrentTick;

        if (curMover != null)
        {
            var iceCommand = new ClientCreateIceCommand
            {
                Tick      = curTick + 1,
                LastsTick = 150
            };
            var iceAction = new IceAction(iceCommand, clientId);
            GameUtil.AddLocalActionList(_gameContext, iceAction);
            _client.EnqueueCommand(iceCommand);
            return;
        }

        foreach (var e in entities)
        {
            var position      = e.mouseDown.position;
            var direction     = Random.Range(0, 360);
            var createCommand = new ClientCreateBeeCommand
            {
                Position = position, Direction = direction,
                Tick     = curTick + 1, Sprite = "bee"
            };
            var createAction = new CreateAction(createCommand, clientId);
            Debug.Log($"createAction : ${position.x:f5},{position.y:f5}");
            GameUtil.AddLocalActionList(_gameContext, createAction);
            _client.EnqueueCommand(createCommand);
        }
    }
コード例 #2
0
    public static void Execute(IServerHandler handler, BitBuffer buffer, ushort commandCount)
    {
        for (int i = 0; i < commandCount; i++)
        {
            var commandId = buffer.ReadUShort();
            switch (commandId)
            {
            case 0:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientCreateIceCommand");

                var c = new  ClientCreateIceCommand();
                c.Deserialize(buffer);
                handler.HandleCreateIceCommand(ref c);
                break;
            }


            case 1:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientBeeMoveCommand");

                var c = new  ClientBeeMoveCommand();
                c.Deserialize(buffer);
                handler.HandleBeeMoveCommand(ref c);
                break;
            }


            case 2:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientChatMessageCommand");

                var c = new  ClientChatMessageCommand();
                c.Deserialize(buffer);
                handler.HandleChatMessageCommand(ref c);
                break;
            }


            case 3:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientCreateBeeCommand");

                var c = new  ClientCreateBeeCommand();
                c.Deserialize(buffer);
                handler.HandleCreateBeeCommand(ref c);
                break;
            }


            case 4:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientRequestCharacterCommand");

                var c = new  ClientRequestCharacterCommand();
                c.Deserialize(buffer);
                handler.HandleRequestCharacterCommand(ref c);
                break;
            }


            case 5:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientSetTickrateCommand");

                var c = new  ClientSetTickrateCommand();
                c.Deserialize(buffer);
                handler.HandleSetTickrateCommand(ref c);
                break;
            }


            case 6:
            {
                Logger.I.Log("ServerCommandExecutor", "Executing ClientTestCommand");

                var c = new  ClientTestCommand();
                c.Deserialize(buffer);
                handler.HandleTestCommand(ref c);
                break;
            }
            }
        }
    }
コード例 #3
0
 public CreateAction(ClientCreateBeeCommand command, string moverId) : base(command, command.Tick,
                                                                            ActionType.Create, moverId)
 {
 }
コード例 #4
0
 public void HandleCreateBeeCommand(ref ClientCreateBeeCommand command)
 {
     Logger.I.Log(this, $"Create-{CurrentClientId}: {command.Position.x:F4},{command.Position.y:F4}, {command.Direction}");
     GameUtil.AddLocalActionList(_game, new CreateAction(command, CurrentClientId.ToString()));
 }