예제 #1
0
        void SetupConfigs()
        {
            IUnitConfigDataProvider database;

            //todo guard
            if (LSDatabaseManager.TryGetDatabase(out database))
            {
                ConfigElementData = database.UnitConfigElementData;
                ConfigElementMap  = new Dictionary <string, UnitConfigElementDataItem> ();
                for (int i = 0; i < ConfigElementData.Length; i++)
                {
                    var item = ConfigElementData [i];
                    ConfigElementMap.Add(item.Name, item);
                }
                ConfigData = database.UnitConfigData;
                for (int i = 0; i < ConfigData.Length; i++)
                {
                    IUnitConfigDataItem item  = ConfigData [i];
                    LSAgent             agent = ResourceManager.GetAgentTemplate(item.Target);
                    for (int j = 0; j < item.Stats.Length; j++)
                    {
                        Stat stat = item.Stats [j];
                        //todo guard
                        var       element   = ConfigElementMap [stat.ConfigElement];
                        Component component = agent.GetComponent(element.ComponentType);
                        SetField(component, element.Field, stat.Value);
                    }
                }
            }
        }
예제 #2
0
 protected void ProcessBuildQueue()
 {
     currentSpawnProgress += spawnIncrement;
     if (currentSpawnProgress > _maxSpawnProgress)
     {
         if (PlayerManager.MainController.Commander)
         {
             //if (audioElement != null)
             //{
             //    audioElement.Play(finishedJobSound);
             //}
             Vector2d spawnOutside = new Vector2d(this.transform.position);
             LSAgent  agent        = PlayerManager.MainController.CreateAgent(buildQueue.Dequeue(), spawnOutside);
             RTSAgent newUnit      = agent.GetComponent <RTSAgent>();
             if (newUnit && spawnPoint != rallyPoint)
             {
                 newUnit.GetAbility <Move>().StartMove(rallyPoint.ToVector2d());
             }
         }
         currentSpawnProgress = 0;
     }
 }