Ejemplo n.º 1
0
    private void SelectOtherTexture(SupportedTexture newTextureToBuildWith)
    {
        BuildTool buildTool = tools[0] as BuildTool;
        PaintTool paintTool = tools[2] as PaintTool;
        Texture   newTexture;

        switch (newTextureToBuildWith)
        {
        case SupportedTexture.DIRT:
            newTexture = textures[0];
            break;

        case SupportedTexture.SAND:
            newTexture = textures[1];
            break;

        case SupportedTexture.STONE:
            newTexture = textures[2];
            break;

        case SupportedTexture.COBBLESTONE:
            newTexture = textures[3];
            break;

        case SupportedTexture.PLANKS_OAK:
        default:
            newTexture = textures[4];
            break;
        }
        buildTool.currentTexture = newTexture;
        paintTool.texture        = newTexture;
        Debug.Log("Selecting new texture: " + newTexture);
    }
Ejemplo n.º 2
0
    public void BlockSelect(Sprite selectedImage)
    {
        selectionBlock.GetComponent <Image>().sprite = selectedImage;

        selectionPanel.SetActive(false);
        selectionBlock.SetActive(true);

        bool             isRemovalTexture      = selectedImage.name.Equals("cube remove"); //TODO: determine this value based on Sprite
        SupportedTexture newTextureToBuildWith = GetSupportedTexture(selectedImage.name);  //TODO: map Sprites to Enum values for supported textures

        if (isRemovalTexture)
        {
            if (OnDestroyToolSelected != null)
            { //check for null, if no one registered to this event its null.
                OnDestroyToolSelected();
            }
        }
        else
        {
            if (OnBuildToolSelected != null)
            {  //check for null, if no one registered to this event its null.
                OnBuildToolSelected();
            }

            if (OnTextureChanged != null)
            { //check for null, if no one registered to this event its null.
                OnTextureChanged(newTextureToBuildWith);
            }
        }
        Debug.Log("ShowBlockSelection");
    }