Пример #1
0
        /// <summary>
        ///     Purchase units if there is a buy selection.
        /// </summary>
        /// <param name="closestSpawn"></param>
        private void MaybePurchaseGhostUnits(SpawnPointBehaviour closestSpawn)
        {
            if (Input.GetMouseButtonUp(0))
            {
                bool noUIcontrolsInUse = EventSystem.current.currentSelectedGameObject == null;

                if (!noUIcontrolsInUse)
                {
                    return;
                }

                if (_currentBuyTransaction == null)
                {
                    return;
                }

                closestSpawn.BuyPlatoons(_currentBuyTransaction.PreviewPlatoons);

                if (Input.GetKey(KeyCode.LeftShift))
                {
                    // We turned the current ghosts into real units, so:
                    _currentBuyTransaction = _currentBuyTransaction.Clone();
                }
                else
                {
                    ExitPurchasingMode();
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Purchase units if there is a buy selection.
        /// </summary>
        /// <param name="closestSpawn"></param>
        private void MaybePurchaseGhostUnits(SpawnPointBehaviour closestSpawn)
        {
            if (Input.GetMouseButtonUp(0))
            {
                bool noUIcontrolsInUse = EventSystem.current.currentSelectedGameObject == null;

                if (!noUIcontrolsInUse)
                {
                    return;
                }

                if (_currentBuyTransaction == null)
                {
                    return;
                }

                foreach (GhostPlatoonBehaviour ghost in _currentBuyTransaction.PreviewPlatoons)
                {
                    CommandConnection.Connection.CmdEnqueuePlatoonPurchase(
                        _currentBuyTransaction.Owner.Id,
                        _currentBuyTransaction.Unit.CategoryId,
                        _currentBuyTransaction.Unit.Id,
                        ghost.UnitCount,
                        closestSpawn.Id,
                        ghost.transform.position,
                        ghost.FinalHeading);
                    ghost.Destroy();
                }

                if (Input.GetKey(KeyCode.LeftShift))
                {
                    // We turned the current ghosts into real units, so:
                    _currentBuyTransaction = _currentBuyTransaction.Clone();
                }
                else
                {
                    ExitPurchasingMode();
                }
            }
        }