예제 #1
0
    // Use this for initialization
    public void Setup()
    {
        cachedCommander = GetComponentInParent <AgentCommander>();
        if (cachedCommander && cachedCommander.human)
        {
            resourceValues = new Dictionary <ResourceType, long>();
            resourceLimits = new Dictionary <ResourceType, long>();
            resourceImages = new Dictionary <ResourceType, Texture2D>();
            for (int i = 0; i < resources.Length; i++)
            {
                switch (resources[i].name)
                {
                case "Gold":
                    resourceImages.Add(ResourceType.Gold, resources[i]);
                    resourceValues.Add(ResourceType.Gold, 0);
                    resourceLimits.Add(ResourceType.Gold, 0);
                    break;

                case "Ore":
                    resourceImages.Add(ResourceType.Ore, resources[i]);
                    resourceValues.Add(ResourceType.Ore, 0);
                    resourceLimits.Add(ResourceType.Ore, 0);
                    break;

                case "Stone":
                    resourceImages.Add(ResourceType.Stone, resources[i]);
                    resourceValues.Add(ResourceType.Stone, 0);
                    resourceLimits.Add(ResourceType.Stone, 0);
                    break;

                case "Wood":
                    resourceImages.Add(ResourceType.Wood, resources[i]);
                    resourceValues.Add(ResourceType.Wood, 0);
                    resourceLimits.Add(ResourceType.Wood, 0);
                    break;

                case "Crystal":
                    resourceImages.Add(ResourceType.Crystal, resources[i]);
                    resourceValues.Add(ResourceType.Crystal, 0);
                    resourceLimits.Add(ResourceType.Crystal, 0);
                    break;

                case "Food":
                    resourceImages.Add(ResourceType.Food, resources[i]);
                    resourceValues.Add(ResourceType.Food, 0);
                    resourceLimits.Add(ResourceType.Food, 0);
                    break;

                case "Army":
                    resourceImages.Add(ResourceType.Provision, resources[i]);
                    resourceValues.Add(ResourceType.Provision, 0);
                    resourceLimits.Add(ResourceType.Provision, 0);
                    break;

                default: break;
                }
            }

            Dictionary <ResourceType, Texture2D> resourceHealthBarTextures = new Dictionary <ResourceType, Texture2D>();
            for (int i = 0; i < resourceHealthBars.Length; i++)
            {
                switch (resourceHealthBars[i].name)
                {
                case "ore":
                    resourceHealthBarTextures.Add(ResourceType.Ore, resourceHealthBars[i]);
                    break;

                case "stone":
                    resourceHealthBarTextures.Add(ResourceType.Stone, resourceHealthBars[i]);
                    break;

                case "gold":
                    resourceHealthBarTextures.Add(ResourceType.Gold, resourceHealthBars[i]);
                    break;

                case "crystal":
                    resourceHealthBarTextures.Add(ResourceType.Crystal, resourceHealthBars[i]);
                    break;

                case "food":
                    resourceHealthBarTextures.Add(ResourceType.Food, resourceHealthBars[i]);
                    break;

                case "wood":
                    resourceHealthBarTextures.Add(ResourceType.Wood, resourceHealthBars[i]);
                    break;

                default: break;
                }
            }
            GameResourceManager.SetResourceHealthBarTextures(resourceHealthBarTextures);
            GameResourceManager.StoreSelectBoxItems(selectBoxSkin, healthy, damaged, critical);
            GameResourceManager.StoreConstructionMaterials(allowedMaterial, notAllowedMaterial);
            buildAreaHeight = Screen.height - RESOURCE_BAR_HEIGHT - SELECTION_NAME_HEIGHT - 2 * BUTTON_SPACING;
            SetCursorState(CursorState.Select);

            List <AudioClip> sounds  = new List <AudioClip>();
            List <float>     volumes = new List <float>();
            sounds.Add(clickSound);
            volumes.Add(clickVolume);
            audioElement = new AudioElement(sounds, volumes, "HUD", null);
        }
    }