public void OnBuildTypeChange(Buildable.TYPE type)
 {
     if (_currentItem)
     {
         _currentItem.ToggleItem(false);
     }
     if (_buildItems.ContainsKey(type))
     {
         _currentItem = _buildItems[type];
         _currentItem.ToggleItem(true);
     }
 }
Ejemplo n.º 2
0
        public void SetBuildType(Buildable.TYPE type)
        {
            _currentBuildType = type;

            //morph hologram
            BuildConfig.BuildableBlueprint blueprint = _buildConfig.GetBuildableBlueprint(type);
            _buildHologram.SetMesh(blueprint.hollogramMesh);
            _buildHologram.SetMaterial(blueprint.hologramMat);
            _buildHologram.SetScale(blueprint.hologramScale);
            _buildHologram.UpdateHologram(false, _buildConfig.hologramData);

            _collisionDetectionEnabled = blueprint.enableCollisionDetection;
            _buildRechargeRate         = blueprint.buildRechargeRate;

            _buildViewController.OnBuildTypeChange(type);
            Singleton.instance.audioSystem.PlaySound(SoundBank.Type.BuildSwitch);
        }
        public float GetOffset(Buildable.TYPE type)
        {
            if (_buildableLookup.Count == 0)
            {
                InitCharacteristics();
            }

            if (_buildableLookup.ContainsKey(type))
            {
                return(_buildableLookup[type].hologramOffset);
            }
            else
            {
                Debug.LogWarning("No buildables of type " + type + " found in buildables blueprint");
                return(0);
            }
        }
        public int GetCost(Buildable.TYPE type)
        {
            if (_buildableLookup.Count == 0)
            {
                InitCharacteristics();
            }

            if (_buildableLookup.ContainsKey(type))
            {
                return(_buildableLookup[type].currencyCost);
            }
            else
            {
                Debug.LogWarning("No buildables of type " + type + " found in buildables blueprint");
                return(0);
            }
        }
        public string GetBuildable(Buildable.TYPE type)
        {
            if (_buildableLookup.Count == 0)
            {
                InitCharacteristics();
            }

            if (_buildableLookup.ContainsKey(type))
            {
                return(_buildableLookup[type].GetKey());
            }
            else
            {
                Debug.LogWarning("No buildables of type " + type + " found in buildables blueprint");
                return("");
            }
        }
        private void InitCharacteristics()
        {
            int i      = 0;
            int length = buildables.Length;

            for (i = 0; i < length; i++)
            {
                BuildableBlueprint blueprint = buildables[i];
                Buildable.TYPE     type      = blueprint.key;
                if (_buildableLookup.ContainsKey(type))
                {
                    Debug.LogWarning("Multiple types: " + type + " added to " + name + " config");
                }
                else
                {
                    _buildableLookup.Add(type, blueprint);
                }
            }
        }