Exemplo n.º 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);
        }
    }
 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()));
 }
 public void HandleBeeMoveCommand(ref ClientBeeMoveCommand command)
 {
     Logger.I.Log(this, $"Move-{CurrentClientId}: tar: {command.Target.x:F4},{command.Target.y:F4} tick: {command.Tick}");
     GameUtil.AddLocalActionList(_game, new MoveAction(command, CurrentClientId.ToString()));
 }
 public void HandleCreateIceCommand(ref ClientCreateIceCommand command)
 {
     GameUtil.AddLocalActionList(_game, new IceAction(command, CurrentClientId.ToString()));
 }