예제 #1
0
    private void Update()
    {
        if (begin)
        {
            Begin(port);
            begin = false;
        }

        if (!isActiveAndEnabled)
        {
            return;
        }
        try
        {
            _dataStream = _stream.ReadExisting();

            if (!_dataStream.Equals("") && !_dataStream.Equals(_oldString))
            {
                Debug.Log($"DataStream: {_dataStream}");
                _oldString = _dataStream;
                string[] tempStringArray = _dataStream.Split(':');
                id             = tempStringArray[1];
                id             = id.Trim();
                methodSelected = tempStringArray[0];
                if (methodSelected.Equals("add"))
                {
                    _block.AddBlock(id);
                }

                if (methodSelected.Equals("swap"))
                {
                    //TODO: trigger swap function
                    _playerController.CreateTrade(_block.GetDirectionFromId(id), PlayerTags.Blue);
                }

                if (methodSelected.Equals("sequence"))
                {
                    //TODO: trigger add move to sequence
                    print($"direction: {_block.GetDirectionFromId(id)}");
                    GameHandler.Current.AddMoveToSequence(_playerController.playerTags, _block.GetDirectionFromId(id), _block.GetIndexFromId(id));
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }