Ejemplo n.º 1
0
        private void OnEnable()
        {
            this.currentResources      = Random.Range(this.minResources, this.maxResources);
            this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, Random.Range(0f, 360f), this.transform.eulerAngles.z);

            // Initialize all the harvester positions
            var angle = 360f / maxUnitsHarvesting;

            for (int i = 0; i < maxUnitsHarvesting; i++)
            {
                _harvestPositions[i] = CircleHelpers.GetPointOnCircle(this.transform.position, harvestRadius, angle, i);
            }
        }
Ejemplo n.º 2
0
        private void OnEnable()
        {
            this.currentHealth = _maxHealth;
            StartCoroutine(BuildInitialUnits());

            // Initialize all the harvester positions
            var angle = 360f / maxUnitsReturning;

            for (int i = 0; i < maxUnitsReturning; i++)
            {
                _returnPositions[i] = CircleHelpers.GetPointOnCircle(this.transform.position, returnHarvestRadius / 2f, angle, i);
            }
        }
Ejemplo n.º 3
0
        private void InternalBuildUnit(UnitType type)
        {
            var pos  = CircleHelpers.GetPointOnCircle(this.transform.position, _spawnDistance, _anglePerSpawn, _lastSpawnIndex++);
            var unit = _entityPools[type].Get(pos, Quaternion.identity);

            unit.nest = this;

            // color unit
            var color     = this.controller.color;
            var renderers = unit.GetComponentsInChildren <Renderer>();

            for (int i = 0; i < renderers.Length; i++)
            {
                if (renderers[i].GetComponent <ParticleSystem>() == null)
                {
                    renderers[i].material.color = color;
                }
            }

            // Give unit a unique name
            unit.gameObject.name += string.Concat(" ", this.units.Count);

            _units.Add(unit);
        }