Example #1
0
        private void CreateConstruct(ConstructStats constructStats)
        {
            Debug.Log("Created");
            Construct newConstruct = Instantiate(constructStats.prefab);

            newConstruct.Init(constructStats);
            newConstruct.FinishConstruction();
            ConstructionFinished(newConstruct);
        }
Example #2
0
 public void Init(ConstructStats stats)
 {
     _selectable = GetComponent <Selectable>();
     Stats       = stats;
     SetResources();
     SetProgressBar();
     GetComponent <Collider>().enabled = true;
     _nameText.text = stats.ConstructName;
     _bluePrint.gameObject.SetActive(true);
     _mainBuilding.gameObject.SetActive(false);
 }
Example #3
0
        public void CreateBlueprint(ConstructType type)
        {
            ConstructStats constructStats = null;

            foreach (var construct in _objectsLibrary.ConstructStats)
            {
                if (construct.Type == type)
                {
                    constructStats = construct;
                }
            }

            if (constructStats == null)
            {
                Debug.Log($" construct of type {type} was not found in library");
                return;
            }

            _newConstruct = Instantiate(constructStats.prefab, this.transform.position, Quaternion.identity);
            _newConstruct.Init(constructStats);
            _newConstruct.OnConstructionFinished += ConstructionFinished;
        }