コード例 #1
0
ファイル: LevelEditor.cs プロジェクト: nick-yangzj/MyMatch1
        bool DrawSlotButton(int x, int y, Rect r, LevelProfile lp)
        {
            defaultColor = GUI.backgroundColor;
            Color  color = Color.white;
            string label = "";
            bool   btn   = false;
            int    block = lp.GetBlock(x, y);
            int    jelly = lp.GetJelly(x, y);
            int    chip  = lp.GetChip(x, y);

            if (!lp.GetSlot(x, y))
            {
                color *= 0;
            }
            else
            {
                if (block == 0)
                {
                    if (chip == 9)
                    {
                        color *= buttonColor;
                        lp.SetPowerup(x, y, 0);
                    }
                    else if (chip > 0)
                    {
                        if (chip > lp.CardCount)
                        {
                            lp.SetChip(x, y, -1);
                        }

                        color *= chipColor[chip - 1];
                    }
                }

                if (block == 5)
                {
                    if (chip > 0)
                    {
                        if (chip > lp.CardCount)
                        {
                            lp.SetChip(x, y, -1);
                        }
                        color *= chipColor[chip - 1];
                    }
                }
                if (block == 0 && chip == -1 && lp.GetPowerup(x, y) == 0)
                {
                    color *= unpressedColor;
                }
                if (block == 0 && lp.GetPowerup(x, y) > 0)
                {
                    label += (label.Length == 0 ? "" : "\n");
                    label += powerupLabelNew[lp.GetPowerup(x, y)];
                }

                if (block > 0 && block <= 3)
                {
                    label += (label.Length == 0 ? "" : "\n") + "B:" + block.ToString();
                }
                if (block == 4)
                {
                    label += (label.Length == 0 ? "" : "\n") + "Weed";
                }
                if (block == 5)
                {
                    label += (label.Length == 0 ? "" : "\n") + "Brch";
                }

                if (block >= 6 && block <= 9)
                {
                    label += (label.Length == 0 ? "" : "\n") + "Boss" + (block - 5).ToString();
                }
//				if (jelly > 0 && lp.Target == E_FieldTarget.Jelly) {
//					label += (label.Length == 0 ? "" : "\n");
//					switch (jelly) {
//						case 1: label += "JS"; break;
//						case 2: label += "JT"; break;
//					}
//				}

                if (block >= 10 && block < 20)
                {
                    label += (label.Length == 0 ? "" : "\n") + "漩涡" + (block - 9).ToString();
                }

                if (block >= 20 && block < 30)
                {
                    label += (label.Length == 0 ? "" : "\n") + "风车";
                }

                if (block >= 30 && block < 40)
                {
                    label += (label.Length == 0 ? "" : "\n") + "发射器" + (block - 29).ToString();
                }
            }

            GUI.backgroundColor = color;
            btn = GUI.Button(new Rect(r.xMin + x * (cellSize + slotOffect), r.yMin + y * (cellSize + slotOffect), cellSize, cellSize), label, slotStyle);

            float cursor = -2;

            if (lp.GetSlot(x, y) && lp.GetGenerator(x, y))
            {
                GUI.backgroundColor = Color.black;
                GUI.Box(new Rect(r.xMin + x * (cellSize + slotOffect) + cursor, r.yMin + y * (cellSize + slotOffect) - 2, 10, 10), "G", iconStyle);
                cursor += 10 + 2;
            }

//			if (lp.target == E_FieldTarget.SugarDrop && lp.GetSlot(x, y) && lp.GetSugarDrop(x, y)) {
//				GUI.backgroundColor = Color.black;
//				GUI.Box(new Rect(r.xMin + x * (cellSize + slotOffect) + cursor, r.yMin + y * (cellSize + slotOffect) - 2, 10, 10), "S", iconStyle);
//				cursor += 10 + 2;
//			}

            if (lp.GetSlot(x, y))
            {
                GUI.backgroundColor = Color.black;
                GUI.Box(new Rect(r.xMin + x * (cellSize + slotOffect) + cursor, r.yMin + y * (cellSize + slotOffect) - 2, 10, 10), gravityLabel[profile.GetGravity(x, y)], iconStyle);
                cursor += 10 + 2;
            }

            if (lp.GetSlot(x, y) && lp.GetTeleport(x, y) > 0)
            {
                GUI.backgroundColor = Color.black;
                GUI.Box(new Rect(r.xMin + x * (cellSize + slotOffect) + cursor, r.yMin + y * (cellSize + slotOffect) - 2, cellSize - 12, 10), "T:" + lp.GetTeleport(x, y).ToString(), iconStyle);
            }

            if (lp.GetSlot(x, y))
            {
                GUI.backgroundColor = transparentColor;
                GUI.Box(new Rect(r.xMin + x * (cellSize + slotOffect), r.yMin + y * (cellSize + slotOffect) + cellSize - 10, 20, 10), (y * 12 + x + 1).ToString(), slotStyle);
            }

            GUI.backgroundColor = defaultColor;
            return(btn);
        }
コード例 #2
0
ファイル: LevelEditor.cs プロジェクト: nick-yangzj/MyMatch1
        void DrawBlock()
        {
            for (int x = 0; x < profile.Width; x++)
            {
                for (int y = 0; y < profile.Height; y++)
                {
                    if (DrawSlotButton(x, y, rect, profile))
                    {
                        switch (toolID)
                        {
                        case "Simple Block":
                            profile.SetBlock(x, y, profile.GetBlock(x, y) + 1);
                            if (profile.GetBlock(x, y) > 3)
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        case "Weed":
                            if (profile.GetBlock(x, y) != 4)
                            {
                                profile.SetBlock(x, y, 4);
                            }
                            else
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        case "Branch":
                            if (profile.GetBlock(x, y) != 5)
                            {
                                profile.SetBlock(x, y, 5);
                            }
                            else
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        case "Boss":
                            profile.SetBlock(x, y, Mathf.Max(profile.GetBlock(x, y) + 1, 6));
                            if (profile.GetBlock(x, y) > 9)
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        //10~19
                        case "XuanWo":
                            profile.SetBlock(x, y, Mathf.Max(profile.GetBlock(x, y) + 1, 10));
                            if (profile.GetBlock(x, y) > 19)
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        //20
                        case "FengChe":
                            profile.SetBlock(x, y, Mathf.Max(profile.GetBlock(x, y) + 1, 20));
                            if (profile.GetBlock(x, y) > 20)
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;

                        //30~39
                        case "ZhangAiFaSheQi":
                            profile.SetBlock(x, y, Mathf.Max(profile.GetBlock(x, y) + 1, 30));
                            if (profile.GetBlock(x, y) > 39)
                            {
                                profile.SetBlock(x, y, 0);
                            }
                            break;
                        }
                    }
                }
            }
            DrawWallPreview(rect, profile);
        }