Beispiel #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();
                }
            }
        }
Beispiel #2
0
        private void ExitPurchasingMode()
        {
            _currentBuyTransaction.PreviewPlatoons.Clear();

            _currentBuyTransaction = null;

            CurMouseMode = MouseMode.NORMAL;
        }
Beispiel #3
0
        public BuyTransaction Clone()
        {
            BuyTransaction clone = new BuyTransaction(Unit, Owner);

            int unitCount = (PreviewPlatoons.Count - 1) * MAX_PLATOON_SIZE + _smallestPlatoonSize;

            while (unitCount-- > 1)
            {
                clone.AddUnit();
            }

            return(clone);
        }
Beispiel #4
0
        /// <summary>
        ///     Called when a unit card from the buy menu is pressed.
        /// </summary>
        /// <param name="unit"></param>
        public void BuyCallback(Unit unit)
        {
            bool paid = _session.LocalPlayer.TryPay(unit.Price);

            if (!paid)
            {
                return;
            }

            if (_currentBuyTransaction == null)
            {
                _currentBuyTransaction = new BuyTransaction(unit, _localPlayer);
            }
            else
            {
                _currentBuyTransaction.AddUnit();
            }

            //buildUnit(UnitType.Tank);
            CurMouseMode = MouseMode.PURCHASING;
        }
Beispiel #5
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();
                }
            }
        }