Ejemplo n.º 1
0
 public void Spawn(ISpawnable s)
 {
     if (spawned.Count < maxSpawns)
     {
         float x = transform.position.x + (2 * Random.Range(0, radius) - radius);
         float z = transform.position.z + (2 * Random.Range(0, radius) - radius);
         spawned.Add(s.Spawn(x, z));
     }
 }
Ejemplo n.º 2
0
 private void OnCooldown()
 {
     foreach (string entity in SpawnSettingsGetter.GetEntitiesToSpawn())
     {
         GameObject prefab     = PrefabProvideGetter.GetPrefab(entity);
         Vector3    spawnPoint = SpawnPointProviderGetter.GetSpawnPoint();
         SpawnView.Spawn(prefab, spawnPoint);
     }
 }
Ejemplo n.º 3
0
 public void ReturnToSchedule(ISpawnable ing)
 {
     foreach (var ingridientZoneBase in _spawnZones)
     {
         if (ingridientZoneBase.GetHoldedSpawnable() == ing)
         {
             ing.Spawn(ingridientZoneBase.transform);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a clone of the agent at a bigger size and destroys the original.
        /// </summary>
        void IMoltable.Molt()
        {
            ITrait sizeTrait = (Agent as IStatsCollection).GetStat(TraitsUtil.sizeTraitId);

            int size = sizeTrait != null ? sizeTrait.Quantity : 0;

            // If the size is less than one, then simply destroy the agent without molting.
            if (size < 1)
            {
                GameObject.Destroy(AgentGameObject);
                return;
            }

            int newSize = (int)(size * moltPercentage);

            newSize            = Mathf.Max(newSize, size + 1);
            sizeTrait.Quantity = newSize;

            Vector3 scale = AgentTransform.localScale;

            scale *= moltPercentage;

            Vector3 position = Agent.Position;

            int health = TraitsUtil.GetHealth(Agent) + 1;

            Agent.RemoveFromMap();

            GameObject instance = spawnable.Spawn(position, scale);

            IAgent instanceAgent = instance.GetComponentInChildren <IAgent>();

            if (instanceAgent != null)
            {
                instanceAgent.Data        = Agent.Data.Copy();
                instanceAgent.DisplayName = Agent.DisplayName;
                instanceAgent.Description = "";
                instanceAgent.GroupId     = Agent.GroupId;
                TraitsUtil.SetHealth(instanceAgent, health);
            }

            Tweener tweener = instance.GetComponentInChildren <Tweener>();

            if (tweener != null)
            {
                tweener.TweenOnStart = TweenerMethod.None;
            }

            GameObject.Destroy(AgentGameObject);
        }
 public virtual void Spawn(ISpawnable spawnObject)
 {
     _ingridientTemplate = spawnObject;
     _ingridientTemplate.Spawn(transform);
 }