예제 #1
0
        public async Task <Unit> Buy(Castle castle)
        {
            bool origin = R.input.lockInput;

            R.input.lockInput = true;
            currentCastle     = castle;
            PrepareToBuy();
            selectedUnitName = null;
            isCanceled       = false;
            scrollRect.gameObject.SetActive(true);
            cancelButton.gameObject.SetActive(true);
            var endTurn = Battle.endTurnCancel;

            while (!endTurn.IsCancellationRequested && !isCanceled && selectedUnitName == null)
            {
                await Task.Delay(1);
            }

            if (endTurn.IsCancellationRequested)
            {
                selectedUnitName = null;
            }
            cancelButton.gameObject.SetActive(false);
            scrollRect.gameObject.SetActive(false);
            var unit = selectedUnitName != null?currentCastle.Buy(selectedUnitName.Value) : null;

            await Task.Delay(1);

            R.input.lockInput = origin;
            return(unit);
        }