Exemplo n.º 1
0
    private void SetCubeColor(Material[] cube, CubeColor color, FaceName face)
    {
        /* In order to set the color face we will take the face on which we wanna set the color*/
        switch (face)
        {
        case FaceName.Front:
            cube[5].color = GetMaterialForColor(color);
            break;

        case FaceName.Right:
            cube[4].color = GetMaterialForColor(color);
            break;

        case FaceName.Back:
            cube[3].color = GetMaterialForColor(color);
            break;

        case FaceName.Left:
            cube[2].color = GetMaterialForColor(color);
            break;

        case FaceName.Up:
            cube[1].color = GetMaterialForColor(color);
            break;

        case FaceName.Down:
            cube[0].color = GetMaterialForColor(color);
            break;
        }
    }
Exemplo n.º 2
0
    private void CalculateBoundPoint(FaceName face, Vector3 point, out Vector3 boundVector, out float distance)
    {
        switch (face)
        {
        case FaceName.backFace:
            boundVector = GetFaceRect(FaceName.backFace).center;
            distance    = Vector3.Distance(new Vector3(point.x, point.y, boundVector.z), point);
            return;

        case FaceName.upFace:
            boundVector = GetFaceRect(FaceName.upFace).center;
            distance    = Vector3.Distance(new Vector3(point.x, boundVector.y, point.z), point);
            return;

        case FaceName.frontFace:
            boundVector = GetFaceRect(FaceName.frontFace).center;
            distance    = Vector3.Distance(new Vector3(point.x, point.y, boundVector.z), point);
            return;

        case FaceName.downFace:
            boundVector = GetFaceRect(FaceName.downFace).center;
            distance    = Vector3.Distance(new Vector3(point.x, boundVector.y, point.z), point);
            return;

        case FaceName.leftFace:
            boundVector = GetFaceRect(FaceName.leftFace).center;
            distance    = Vector3.Distance(new Vector3(boundVector.x, point.y, point.z), point);
            return;
        }
        boundVector = GetFaceRect(FaceName.rightFace).center;
        distance    = Vector3.Distance(new Vector3(boundVector.x, point.y, point.z), point);
    }
Exemplo n.º 3
0
        void Initialize()
        {
            FamilyName = Fontface.name.Name;
            if (String.IsNullOrEmpty(FaceName) || FaceName.StartsWith("?"))
            {
                FaceName = FamilyName;
            }
            StyleName   = Fontface.name.Style;
            DisplayName = Fontface.name.FullFontName;
            if (String.IsNullOrEmpty(DisplayName))
            {
                DisplayName = FamilyName;
                if (String.IsNullOrEmpty(StyleName))
                {
                    DisplayName += " (" + StyleName + ")";
                }
            }

            // Bold, as defined in OS/2 table.
            IsBold = Fontface.os2.IsBold;
            // Debug.Assert(_isBold == (_fontface.os2.usWeightClass > 400), "Check font weight.");

            // Italic, as defined in OS/2 table.
            IsItalic = Fontface.os2.IsItalic;
        }
Exemplo n.º 4
0
 public static Face BuildTestFace(FaceName faceName, int offset)
 => new Face(
     faceName,
     new PuzzleColor[Face.Size, Face.Size]
 {
     { (PuzzleColor)offset, (PuzzleColor)(offset + 3), (PuzzleColor)(offset + 6) },
     { (PuzzleColor)(offset + 1), (PuzzleColor)(offset + 4), (PuzzleColor)(offset + 7) },
     { (PuzzleColor)(offset + 2), (PuzzleColor)(offset + 5), (PuzzleColor)(offset + 8) }
 });
Exemplo n.º 5
0
 public MaterialProperties(FaceName face, Color4 ambient, Color4 diffuse, Color4 specular, Color4 emission, float shininess, float opacity)
 {
     Face          = face;
     AmbientColor  = ambient;
     DiffuseColor  = diffuse;
     SpecularColor = specular;
     EmissionColor = emission;
     Shininess     = shininess;
     Opacity       = opacity;
 }
Exemplo n.º 6
0
 public MaterialProperties()
 {
     Face          = FaceName.Front;
     AmbientColor  = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
     DiffuseColor  = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
     SpecularColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
     EmissionColor = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
     Shininess     = 0.0f;
     Opacity       = 1.0f;
 }
Exemplo n.º 7
0
 public static void Material(FaceName face, MaterialParamName pname, int[] param)
 {
     unsafe
     {
         fixed(int *ptr = param)
         {
             Delegates.Materialiv(face, pname, ptr);
         }
     }
 }
Exemplo n.º 8
0
 public static void Material(FaceName face, MaterialParamName pname, ref Color4 color)
 {
     unsafe
     {
         fixed(float *ptr = &color.R)
         {
             Delegates.Materialfv(face, pname, ptr);
         }
     }
 }
Exemplo n.º 9
0
    private List <GameObject> GetFaceCubes(FaceName faceName, Vector3 origin)
    {
        GameObject[]      faceCubes = GameObject.FindGameObjectsWithTag("Cube");
        List <GameObject> listCubes = new List <GameObject>();

        switch (faceName)
        {
        case FaceName.Front:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.z == -2).OrderBy((c) => c.transform.localPosition.x).OrderByDescending((c) => c.transform.localPosition.y).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        case FaceName.Back:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.z == 2).OrderByDescending((c) => c.transform.localPosition.x).OrderByDescending((c) => c.transform.localPosition.y).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        case FaceName.Up:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.y == 2).OrderBy((c) => c.transform.localPosition.x).OrderByDescending((c) => c.transform.localPosition.z).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        case FaceName.Down:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.y == -2).OrderBy((c) => c.transform.localPosition.x).OrderBy((c) => c.transform.localPosition.z).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        case FaceName.Right:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.x == 2).OrderBy((c) => c.transform.localPosition.z).OrderByDescending((c) => c.transform.localPosition.y).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        case FaceName.Left:
            foreach (GameObject cube in faceCubes.Where((c) => c.transform.localPosition.x == -2).OrderByDescending((c) => c.transform.localPosition.z).OrderByDescending((c) => c.transform.localPosition.y).ToList())
            {
                listCubes.Add(cube);
            }
            break;

        default:
            break;
        }
        return(listCubes);
    }
Exemplo n.º 10
0
 public Face(FaceName faceName, PuzzleColor color)
     : this(
         faceName,
         new PuzzleColor[Size, Size]
 {
     { color, color, color },
     { color, color, color },
     { color, color, color }
 })
 {
 }
Exemplo n.º 11
0
    private void EmojiSet(RectTransform rt, FaceName Info)
    {
        // Logger.LogError("Window_Chat:: Load emoji asset <b><color=#6C53FF>[{0}]</color></b> failed!");
        GameObject a = Level.GetPreloadObject(Info.head_icon);

        if (a == null)
        {
            return;
        }
        Util.AddChild(rt, a.transform);
    }
        internal static Constants.GLFace FaceToGLFace(FaceName face)
        {
            switch (face)
            {
            case FaceName.Front: return(Constants.GLFace.Front);

            case FaceName.Back: return(Constants.GLFace.Back);

            case FaceName.Both: return(Constants.GLFace.Both);
            }
            throw new InvalidEnumerationException();
        }
Exemplo n.º 13
0
    private void SetMaterial(FaceName faceName, Vector3 origin, Dictionary <FaceName, List <CubeColor> > rubikFaces)
    {
        List <GameObject> cubes = GetFaceCubes(faceName, origin);

        for (int i = 0; i < rubikFaces[faceName].Count; i++)
        {
            GameObject cube      = cubes[i];
            Material[] cubeMat   = cube.GetComponentInChildren <Renderer>().materials;
            var        cubeColor = rubikFaces[faceName][i];
            SetCubeColor(cubeMat, cubeColor, faceName);
        }
    }
Exemplo n.º 14
0
    private void EmojiClick(RectTransform rt, FaceName info)
    {
        if (info == null)
        {
            return;
        }

        if (m_teamToggle.isOn)
        {
            moduleChat.SendFriendMessage(info.head_icon, 1, moduleAwakeMatch.TeamFriend, 2);
            emoticons.SetActive(false);
            return;
        }
        WordMySend(1, info.head_icon);
        emoticons.SetActive(false);
    }
Exemplo n.º 15
0
        public static string ToNameString(this FaceName faceName)
        {
            switch (faceName)
            {
            case FaceName.Jack:
                return("valete");

            case FaceName.Queen:
                return("dama");

            case FaceName.King:
                return("rei");

            default:
                return("");
            }
        }
Exemplo n.º 16
0
    public Rect GetFaceRect(FaceName faceName)
    {
        switch (faceName)
        {
        case FaceName.upFace:
            return(objectFace [0]);

        case FaceName.frontFace:
            return(objectFace [1]);

        case FaceName.downFace:
            return(objectFace [2]);

        case FaceName.backFace:
            return(objectFace [3]);

        case FaceName.leftFace:
            return(objectFace [4]);
        }
        return(objectFace [5]);
    }
Exemplo n.º 17
0
        public static Material Load(DomNode node, string fileName)
        {
            foreach (DomAttribute attr in node.Attributes)
            {
                switch (attr.Name.ToLower())
                {
                case "src":  return(Load(attr.Value.ToPath()));

                case "relsrc": return(Load(attr.Value.RelativeTo(fileName)));
                }
            }

            int                       unit, maxUnit = -1;
            string                    path;
            Texture                   tex;
            MaterialProperties        prop;
            Dictionary <int, Texture> textures   = null;
            List <MaterialProperties> properties = new List <MaterialProperties>();
            Material                  obj        = new Material();

            foreach (DomNode child in node)
            {
                switch (child.Name.ToLower())
                {
                case "textures":
                    foreach (DomNode texNode in child)
                    {
                        if (!texNode.Name.ToLower().Equals("texture"))
                        {
                            continue;
                        }
                        if (int.TryParse(texNode["unit"], out unit))
                        {
                            if (unit >= 0)
                            {
                                if (!texNode["relsrc"].Equals(""))
                                {
                                    path = texNode["relsrc"].RelativeTo(fileName);
                                }
                                else
                                {
                                    path = texNode["src"].ToPath();
                                }
                                tex = Texture.Cache(path);
                                if (tex != null)
                                {
                                    if (maxUnit < unit)
                                    {
                                        maxUnit = unit;
                                    }
                                    if (textures == null)
                                    {
                                        textures = new Dictionary <int, Texture>();
                                    }
                                    textures.Add(unit, tex);
                                }
                                else
                                {
                                    GameDebugger.Log(LogLevel.Error, "Failed loading texture '{0}' specified in '{1}'", path, fileName);
                                }
                            }
                        }
                    }
                    break;

                case "properties":
                    prop = new MaterialProperties();

                    if (!FaceName.TryParse(child["face"], true, out prop.Face))
                    {
                        prop.Face = FaceName.FrontAndBack;
                        GameDebugger.Log(LogLevel.Error, "Failed parsing material face '{0}' for properties in '{1}'", child["face"], fileName);
                    }

                    foreach (DomNode propNode in child)
                    {
                        switch (propNode.Name.ToLower())
                        {
                        case "ambient":
                            if (!Color4.TryParse(propNode["color"], out prop.AmbientColor))
                            {
                                prop.AmbientColor = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
                                GameDebugger.Log(LogLevel.Error, "Failed parsing ambient color '{0}' in '{1}'", propNode["color"], fileName);
                            }
                            else
                            {
                                prop.AmbientColor.A = 1.0f;
                            }
                            break;

                        case "diffuse":
                            if (!Color4.TryParse(propNode["color"], out prop.DiffuseColor))
                            {
                                prop.DiffuseColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
                                GameDebugger.Log(LogLevel.Error, "Failed parsing diffuse color '{0}' in '{1}'", propNode["color"], fileName);
                            }
                            break;

                        case "specular":
                            if (!Color4.TryParse(propNode["color"], out prop.SpecularColor))
                            {
                                prop.SpecularColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
                                GameDebugger.Log(LogLevel.Error, "Failed parsing specular color '{0}' in '{1}'", propNode["color"], fileName);
                            }
                            else
                            {
                                prop.SpecularColor.A = 1.0f;
                            }
                            break;

                        case "emission":
                            if (!Color4.TryParse(propNode["color"], out prop.EmissionColor))
                            {
                                prop.EmissionColor = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
                                GameDebugger.Log(LogLevel.Error, "Failed parsing emission color '{0}' in '{1}'", propNode["color"], fileName);
                            }
                            else
                            {
                                prop.EmissionColor.A = 1.0f;
                            }
                            break;

                        case "shininess":
                            if (!float.TryParse(propNode["value"], out prop.Shininess))
                            {
                                prop.Shininess = 0.0f;
                                GameDebugger.Log(LogLevel.Error, "Failed parsing shininess '{0}' in '{1}'", propNode["value"], fileName);
                            }
                            break;

                        case "opacity":
                            if (!float.TryParse(propNode["value"], out prop.Opacity))
                            {
                                prop.Opacity = 1.0f;
                                GameDebugger.Log(LogLevel.Error, "Failed parsing opacity '{0}' in '{1}'", propNode["value"], fileName);
                            }
                            break;
                        }
                    }
                    properties.Add(prop);
                    break;

                case "shader":
                    if (obj.Shader != null)
                    {
                        obj.Shader.Dispose();
                    }
                    obj.Shader = Shader.Load(child, fileName);
                    if (obj.Shader == null)
                    {
                        GameDebugger.Log(LogLevel.Error, "Failed loading shader in '{0}'", fileName);
                    }
                    break;
                }
            }

            if (maxUnit >= 0)
            {
                obj.Textures = new Texture[maxUnit + 1];
                foreach (KeyValuePair <int, Texture> texPair in textures)
                {
                    obj.Textures[texPair.Key] = texPair.Value;
                }
            }

            if (properties.Count > 0)
            {
                obj.Properties = properties.ToArray();
            }

            return(obj);
        }
Exemplo n.º 18
0
 protected abstract void SetMaterialParameterInternal(FaceName face, MaterialParameterName parm, float value);
Exemplo n.º 19
0
 public Face(FaceName faceName, PuzzleColor[,] colors)
 {
     this.FaceName = faceName;
     this.colors   = colors;
 }
Exemplo n.º 20
0
 protected override void SetMaterialParameterInternal(FaceName face, MaterialParameterName parm, float value)
 {
     Internal.OpenGL.Methods.glMaterialf(OpenGLEngine.FaceToGLFace(face), OpenGLEngine.MaterialParameterNameToGLConst(parm), value);
 }
Exemplo n.º 21
0
 public void SetMaterialParameter(FaceName face, MaterialParameterName parm, float value)
 {
     SetMaterialParameterInternal(face, parm, value);
 }
Exemplo n.º 22
0
 public static void ColorMaterial(FaceName face, ColorMaterialMode mode)
 {
     Delegates.ColorMaterial(face, mode);
 }
 public FaceCard(FaceName faceName, Suit suit, int value) : base(suit, value) => this.faceName = faceName;
Exemplo n.º 24
0
 public Location(FaceName faceName, Point3D point)
 {
     this.FaceName = faceName;
     this.Point3D  = point;
 }
Exemplo n.º 25
0
 public Face this[FaceName faceName]
 => this.faces[(int)faceName];
Exemplo n.º 26
0
 public static void Material(FaceName face, MaterialParamName pname, int param)
 {
     Delegates.Materiali(face, pname, param);
 }
Exemplo n.º 27
0
 public static void Material(FaceName face, MaterialParamName pname, Color4 color)
 {
     unsafe { Delegates.Materialfv(face, pname, &color.R); }
 }
Exemplo n.º 28
0
 public Location(FaceName faceName, int x, int y, int z)
     : this(faceName, new Point3D(x, y, z))
 {
 }