Пример #1
0
        private GameObject AddTowerPart(ElementPrototype elementPrototype, TowerSlotType slotType, Vector3 position, GameObject instance)
        {
            var    stat       = elementPrototype.ElementStats.FirstOrDefault(s => s.InSlot == slotType);
            string prefabName = "tower:base";

            if (stat == null)
            {
                Debug.LogWarningFormat("AddTowerPart Failed for {0} part not found {1}", elementPrototype.Name, slotType);
            }
            else
            {
                prefabName = stat.ModelPrefab;
            }
            var prefab       = PrefabManager.Instance.GetPrefab(prefabName);
            var part         = Instantiate(prefab, position, Quaternion.identity, instance.transform);
            var partRenderer = part.GetComponent <MeshRenderer>();
            var albedo       = partRenderer.material.GetTexture("_MainTex");

            partRenderer.material = Instantiate(PrefabManager.Instance.ProgressMaterial);
            partRenderer.material.SetColor("_Color", Color.white);
            partRenderer.material.SetTexture("_MainTex", albedo);
            partRenderer.material.SetFloat("shiftY", 30f);
            return(part);
        }
Пример #2
0
        private static void AggregateSingleElement(Action <ElementPrototypeStat> onStat, string uri, TowerSlotType slot)
        {
            if (!string.IsNullOrEmpty(uri))
            {
                var prototype = PrototypeManager.Instance.GetPrototype <ElementPrototype>(uri);

                if (prototype != null)
                {
                    foreach (var elementPrototypeStat in prototype.ElementStats.Where(s => s.InSlot == slot))
                    {
                        onStat(elementPrototypeStat);
                    }
                }
            }
        }