コード例 #1
0
        Texture2D GetTexture(TextrueType texType)
        {
            Texture2D sprites = (Texture2D)Resources.Load("0" + (int)texType, typeof(Texture2D));

            return(sprites);
        }
コード例 #2
0
        public Color GetPixel(int x, int y)
        {
            RotationType rotationType = RotationType.None;

            string[] dirs = Enum.GetNames(typeof(DirEnum));
            switch (roads.Count)
            {
                #region 一条路
            case 1:
                texType = TextrueType.ThreeSide;
                for (int i = 0; i < dirs.Length; i++)
                {
                    DirEnum temp = (DirEnum)Enum.Parse(typeof(DirEnum), dirs[i]);
                    if (roads.Contains(temp))
                    {
                        switch (temp)
                        {
                        case DirEnum.Up:
                            rotationType = RotationType.OppositesUpDown;
                            break;

                        case DirEnum.Down:
                            rotationType = RotationType.None;
                            break;

                        case DirEnum.Left:
                            rotationType = RotationType.ClockWise;
                            break;

                        case DirEnum.Right:
                            rotationType = RotationType.AntiClockWise;
                            break;

                        default:
                            Debug.LogError("=");
                            break;
                        }
                        break;
                    }
                }
                break;

                #endregion

                #region 2条路

            case 2:
                if (roads.Contains(DirEnum.Up) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideFaceToFace;
                    rotationType = RotationType.None;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Right))
                {
                    texType      = TextrueType.TwoSideFaceToFace;
                    rotationType = RotationType.ClockWise;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Up))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.ClockWise;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.None;
                }
                else if (roads.Contains(DirEnum.Right) && roads.Contains(DirEnum.Up))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.DuiJiaoRightTop;
                }
                else if (roads.Contains(DirEnum.Right) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.OppositesLeftRight;
                }
                break;

                #endregion

                #region 3条路
            case 3:
                texType = TextrueType.OneSide;
                for (int i = 0; i < dirs.Length; i++)
                {
                    DirEnum temp = (DirEnum)Enum.Parse(typeof(DirEnum), dirs[i]);
                    if (!roads.Contains(temp))
                    {
                        switch (temp)
                        {
                        case DirEnum.Up:
                            rotationType = RotationType.AntiClockWise;
                            break;

                        case DirEnum.Down:
                            rotationType = RotationType.ClockWise;
                            break;

                        case DirEnum.Left:
                            rotationType = RotationType.OppositesLeftRight;
                            break;

                        case DirEnum.Right:
                            rotationType = RotationType.None;
                            break;

                        default:
                            Debug.LogError("=");
                            break;
                        }
                        break;
                    }
                }
                break;
                #endregion

                #region 4条路
            case 4:
                texType      = TextrueType.NoSide;
                rotationType = RotationType.None;
                break;

                #endregion
            default:
                texType      = TextrueType.FourSide;
                rotationType = RotationType.None;
                break;
            }
            Texture2D tex = GetTexture(texType);
            if (tex == null)
            {
                return(Color.red);
            }
            return(GetColorWithRotation(tex, x, y, rotationType));
        }