Esempio n. 1
0
 public void RegisterSpawnPoint(SpawnPointBehaviour s)
 {
     if (!_spawnPointList.Contains(s))
     {
         _spawnPointList.Add(s);
     }
 }
Esempio n. 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;
                }

                closestSpawn.BuyPlatoons(_currentBuyTransaction.PreviewPlatoons);

                if (Input.GetKey(KeyCode.LeftShift))
                {
                    // We turned the current ghosts into real units, so:
                    _currentBuyTransaction = _currentBuyTransaction.Clone();
                }
                else
                {
                    ExitPurchasingMode();
                }
            }
        }
Esempio n. 3
0
        private void ShowGhostUnitsAndMaybePurchase(RaycastHit terrainHover)
        {
            // Show ghost units under mouse:
            SpawnPointBehaviour closestSpawn = GetClosestSpawn(terrainHover.point);

            _currentBuyTransaction.PreviewPurchase(
                terrainHover.point,
                2 * terrainHover.point - closestSpawn.transform.position);

            MaybePurchaseGhostUnits(closestSpawn);
        }
Esempio n. 4
0
        private SpawnPointBehaviour GetClosestSpawn(Vector3 p)
        {
            var pointList = _spawnPointList.Where(
                x => x.Team == _localPlayer.Team).ToList();

            SpawnPointBehaviour go = pointList.First();
            float distance         = Single.PositiveInfinity;

            foreach (var s in pointList)
            {
                if (Vector3.Distance(p, s.transform.position) < distance)
                {
                    distance = Vector3.Distance(p, s.transform.position);
                    go       = s;
                }
            }
            return(go);
        }
Esempio n. 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();
                }
            }
        }