Exemple #1
0
    public void SetFaces(DiceFace[] facesRef)
    {
        m_Faces = facesRef;

        Renderer renderer = this.GetComponent<Renderer>();
        renderer.material.color = m_Faces[0].DieColour;

        Canvas[] faces = this.GetComponentsInChildren<Canvas>();
        for(int i = 0; i < m_Faces.Length; i++)
        {
            Text[] text = faces[i].GetComponentsInChildren<Text>();
            text[0].text = m_Faces[i].Level.ToString();
            text[0].color = m_Faces[i].TextColour;
            text[1].color = m_Faces[i].TextColour;
            text[2].color = m_Faces[i].TextColour;

            Image image = faces[i].GetComponentInChildren<Image>();
            image.sprite = m_Faces[i].Image;
            image.color = m_Faces[i].TextColour;

            if (m_Faces[i].Face == FaceType.Play)
            {
                PlayFace playFace = (PlayFace)m_Faces[i];
                text[1].text = playFace.Attack.ToString();
                text[2].text = playFace.Toughness.ToString();
            }
            else if(m_Faces[i].Face == FaceType.Special)
            {
                text[1].text = "";
                text[2].text = "";
            }
        }
    }
Exemple #2
0
    public static void Load()
    {
        string[] files = Directory.GetFiles(DIR, "*.json", SearchOption.AllDirectories);

        Faces = new Dictionary <string, DiceFace>();

        foreach (string file in files)
        {
            StreamReader reader = new StreamReader(file);

            string   content = reader.ReadToEnd();
            FaceInfo first   = JsonUtility.FromJson <FaceInfo>(content);
            if (first.Face == FaceType.Play)
            {
                PlayFace playFace = new PlayFace(first);
                Faces.Add(playFace.Name, playFace);
            }
            else if (first.Face == FaceType.Special)
            {
                SpecialFace specialFace = new SpecialFace(first);
                Faces.Add(specialFace.Name, specialFace);
            }

            reader.Close();
        }
    }
Exemple #3
0
    public FaceInfo(DiceFace faceRef)
    {
        if (faceRef.Face == FaceType.Play)
        {
            PlayFace newFace = (PlayFace)faceRef;

            Level      = newFace.Level;
            Face       = newFace.Face;
            TextColour = newFace.TextColour;
            DieColour  = newFace.DieColour;
            Name       = newFace.Name;

            Attack    = newFace.Attack;
            Toughness = newFace.Toughness;

            SpecialName = "None";

            if (newFace.Image != null)
            {
                SpriteName = newFace.Image.name;
            }
            else
            {
                SpriteName = "None";
            }
        }
        else if (faceRef.Face == FaceType.Special)
        {
            SpecialFace newFace = (SpecialFace)faceRef;

            Level      = newFace.Level;
            Face       = newFace.Face;
            TextColour = newFace.TextColour;
            DieColour  = newFace.DieColour;
            Name       = newFace.Name;

            Attack    = 0;
            Toughness = 0;

            SpecialName = newFace.Special.Name;

            if (newFace.Image != null)
            {
                SpriteName = newFace.Image.name;
            }
            else
            {
                SpriteName = "None";
            }
        }
    }