private void Form1_Click(object sender, EventArgs e) { Panel btn = sender as Panel; BtnInfo bi = (BtnInfo)btn.Tag; // 배열 번호로 접근가능 btn.MouseHover -= Mouse_Hover; btn.MouseLeave -= Mouse_Leave; if (draw_Dol() > 0) { btn.BackgroundImage = b_bit; btn.BackgroundImageLayout = ImageLayout.Stretch; btn.Enabled = false; bi.Val = 0; // 흑돌은 0 if (checked_Five(bi.Row, bi.Col, bi.Val) == true) { winGame(bi.Val); } } else { btn.BackgroundImage = w_bit; btn.BackgroundImageLayout = ImageLayout.Stretch; btn.Enabled = false; bi.Val = 1; // 백돌은 1 if (checked_Five(bi.Row, bi.Col, bi.Val) == true) { winGame(bi.Val); } } }
private void Mouse_Leave(object sender, EventArgs e) { Panel btn = sender as Panel; BtnInfo bi = (BtnInfo)btn.Tag; btn.BackgroundImage = defalut; btn.BackgroundImageLayout = ImageLayout.Stretch; }
private void Mouse_Hover(object sender, EventArgs e) { Panel btn = sender as Panel; BtnInfo bi = (BtnInfo)btn.Tag; btn.BackColor = Color.Transparent; btn.BackgroundImage = Bubble; btn.BackgroundImageLayout = ImageLayout.Stretch; }
void Start_TouchFix() { float dpi = Screen.dpi; if (dpi == 0) { dpi = defDPI; } float size = dpi * defSIZE; joysize = size; { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.J; i.uv = CalcUI(joyback, 64 * 4, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 0, 64, 64); i.padstate = PadButton.Func; btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 2, -size / 3 * 2.5f + size / 3, size / 3, size / 3); i.id = KeyCode.K; i.uv = CalcUI(joyback, 64 * 4, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 64, 64, 64); i.padstate = PadButton.Func_Down; btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 2, -size / 3 * 2.5f - size / 3, size / 3, size / 3); i.id = KeyCode.I; i.uv = CalcUI(joyback, 64 * 6, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 6 + 64, 128, 64, 64); i.padstate = PadButton.Func_Up; btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.L; i.uv = CalcUI(joyback, 64 * 4, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 128, 64, 64); i.padstate = PadButton.Func_Forward; btnInfo.Add(i); } }
private void clear() { for (int i = 0; i < PAN_SIZE; i++) { for (int j = 0; j < PAN_SIZE; j++) { BtnInfo bi = new BtnInfo(i, j); bi.Val = -1;//선택 안된곳은 -1 dol_btns[i, j].BackgroundImage = defalut; dol_btns[i, j].BackgroundImageLayout = ImageLayout.Stretch; dol_btns[i, j].Enabled = true; } } }
private void draw() { for (int i = 0; i < PAN_SIZE; i++) { for (int j = 0; j < PAN_SIZE; j++) { dol_btns[i, j] = new Panel(); dol_btns[i, j].Size = new Size(BTN_SIZE, BTN_SIZE); dol_btns[i, j].Location = new Point(LEFT_MARGIN + j * (BTN_MARGIN), TOP_MARGIN + i * (BTN_MARGIN)); dol_btns[i, j].Click += Form1_Click; dol_btns[i, j].BackColor = Color.Transparent; dol_btns[i, j].MouseHover += Mouse_Hover; dol_btns[i, j].MouseLeave += Mouse_Leave; BtnInfo bi = new BtnInfo(i, j); bi.Val = -1; //선택 안된곳은 -1 dol_btns[i, j].Tag = bi; // ============코드 핵심=============== dol_btns[i, j].Parent = splitContainer1.Panel1; } } }
void Start() { { BtnInfo i = new BtnInfo(); i.dest = new Rect(0.1f, 0.6f, 0.2f, 0.2f); i.id = KeyCode.J; i.uv = CalcUI(joyback, 64 * 4, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 0, 64, 64); i.useHalfScreen =true; btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.rightSide = true; i.dest = new Rect(0.1f, 0.6f, 0.2f, 0.2f); i.id = KeyCode.K; i.uv = CalcUI(joyback, 64 * 4, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 64, 64, 64); i.useHalfScreen = true; btnInfo.Add(i); } }
void Start() { { BtnInfo i = new BtnInfo(); i.dest = new Rect(0.1f, 0.6f, 0.2f, 0.2f); i.id = KeyCode.J; i.uv = CalcUI(joyback, 64 * 4, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 0, 64, 64); i.useHalfScreen = true; btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.rightSide = true; i.dest = new Rect(0.1f, 0.6f, 0.2f, 0.2f); i.id = KeyCode.K; i.uv = CalcUI(joyback, 64 * 4, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 64, 64, 64); i.useHalfScreen = true; btnInfo.Add(i); } }
void Start() { float dpi = Screen.dpi; if (dpi == 0) { dpi = defDPI; } float size = dpi * defSIZE; joysize = size; { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.J; i.buttonid = "Fire2"; i.uv = CalcUI(joyback, 64 * 4, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 0, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 2, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.K; i.buttonid = "Fire1"; i.uv = CalcUI(joyback, 64 * 4, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 64, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.L; i.buttonid = "Jump"; i.uv = CalcUI(joyback, 64 * 4, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 128, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha1; i.buttonid = "Triger"; i.uv = CalcUI(joyback, 64 * 4 + 128, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 0, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3 * 2, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha2; i.buttonid = "L"; i.uv = CalcUI(joyback, 64 * 4 + 128, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 64, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3 * 3, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha3; i.buttonid = "R"; i.uv = CalcUI(joyback, 64 * 4 + 128, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 128, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3, size / 3 * 0.5f, size / 3 * 2, size / 3); i.screenpos = new Vector2(1, 0); i.id = KeyCode.Escape; i.buttonid = "Menu"; i.uv = CalcUI(joyback, 0, 256, 128, 64); i.uvdown = CalcUI(joyback, 128, 256, 128, 64); btnInfo.Add(i); } }
private bool checked_Five(int row, int col, int val) { const int SUB = 4; int max = 10;//최소 10번 검사 int get_val = val; int get_col = col; int get_row = row; int count = 0; bool count_five = false; bool win = false; get_col -= SUB; if (get_col < 0) { max += get_col; get_col += (SUB - col); } //가로 검사 for (int i = 0; i < max; i++) { if (get_col + i >= PAN_SIZE) { break; } BtnInfo info = (BtnInfo)dol_btns[get_row, get_col + i].Tag; if (info.Val == get_val) { count++; if (count == 5) { count_five = true; } else if (count > 5) { count_five = false; } } else { count = 0; } } get_col = col; // 위에서 만약 5 이하의 col 부분에서 호출 되면 get_col이 변질 됨 그렇기에 col로 한번더 초기화 하는것이 합리적 //세로 검사 count = 0; // count가 위에서 내려올때가 있음 get_row -= SUB; max = 10; if (get_row < 0) { max += get_row; // 왜 인지 5번 이상검사함(get_row -1 하면 5번만 검사할듯함) get_row += (SUB - row); // 0,0 배열 누르면 } for (int i = 0; i < max; i++) { if (get_row + i >= PAN_SIZE) { break; } BtnInfo info = (BtnInfo)dol_btns[get_row + i, get_col].Tag; if (info.Val == get_val) { count++; if (count == 5) { count_five = true; } else if (count > 5) { count_five = false; } } else { count = 0; } } //왼쪽 대각 검사 count = 0; // count가 위에서 내려올때가 있음 get_row = row; get_col = col; max = 10; get_row -= SUB; get_col -= SUB; if (get_row < 0) { max += get_row; // 수정 필요 if (row > col) { get_row += (SUB - col); get_col += (SUB - col); } else { get_row += (SUB - row); get_col += (SUB - row); } } else if (get_col < 0) { max += get_col; // 수정 필요 if (row > col) { get_row += (SUB - col); get_col += (SUB - col); } else { get_row += (SUB - row); get_col += (SUB - row); } } for (int i = 0; i < max; i++) { if ((get_row + i >= PAN_SIZE) || (get_col + i) >= PAN_SIZE) { break; } BtnInfo info = (BtnInfo)dol_btns[get_row + i, get_col + i].Tag; if (info.Val == get_val) { count++; if (count == 5) { count_five = true; } else if (count > 5) { count_five = false; } } else { count = 0; } } //오른쪽 대각 , 버그 검사해야함 count = 0; // count가 위에서 내려올때가 있음 get_row = row; get_col = col; max = 10; get_row += SUB; get_col -= SUB; if (get_row >= PAN_SIZE && get_col < 0) { if (get_row - (PAN_SIZE - 1) <= (SUB - col)) { get_row -= (SUB - col); get_col += (SUB - col); } else { get_row -= (get_row - (PAN_SIZE - 1)); get_col += (row - (PAN_SIZE - 1) + SUB); } } else if (get_row >= PAN_SIZE) { get_row -= (get_row - (PAN_SIZE - 1)); get_col += (row - (PAN_SIZE - 1) + SUB); } else if (get_col < 0) { get_row -= (SUB - col); get_col += (SUB - col); } for (int i = 0; i < max; i++) { if ((get_row - i < 0) || (get_col + i) >= PAN_SIZE)//여기 get_row 값 문제 { break; } BtnInfo info = (BtnInfo)dol_btns[get_row - i, get_col + i].Tag; //MessageBox.Show((get_row - i) + ", " + (get_col + i) + ", " + info.Val); if (info.Val == get_val) { count++; if (count == 5) { count_five = true; } else if (count > 5) { count_five = false; } } else { count = 0; } } if (count_five) { win = true; } return(win); }
void Start() { float dpi = Screen.dpi; if (dpi == 0) dpi = defDPI; float size = dpi * defSIZE; joysize = size; { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.J; i.buttonid = "Fire2"; i.uv = CalcUI(joyback, 64 * 4, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 0, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 2, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.K; i.buttonid = "Fire1"; i.uv = CalcUI(joyback, 64 * 4, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 64, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 * 3, -size / 3 * 2.5f, size / 3, size / 3); i.id = KeyCode.L; i.buttonid = "Jump"; i.uv = CalcUI(joyback, 64 * 4, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 64, 128, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha1; i.buttonid = "Triger"; i.uv = CalcUI(joyback, 64 * 4 + 128, 0, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 0, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3 * 2, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha2; i.buttonid = "L"; i.uv = CalcUI(joyback, 64 * 4 + 128, 64, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 64, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(size / 3 * -0.5f + size / 3 * 3, size / 3 * 0.5f, size / 3, size / 3); i.screenpos = Vector2.zero; i.id = KeyCode.Alpha3; i.buttonid = "R"; i.uv = CalcUI(joyback, 64 * 4 + 128, 128, 64, 64); i.uvdown = CalcUI(joyback, 64 * 4 + 192, 128, 64, 64); btnInfo.Add(i); } { BtnInfo i = new BtnInfo(); i.dest = new Rect(-size * 4.5f / 3 + size / 3 , size / 3 * 0.5f, size / 3*2, size / 3); i.screenpos = new Vector2(1, 0); i.id = KeyCode.Escape; i.buttonid = "Menu"; i.uv = CalcUI(joyback, 0, 256, 128, 64); i.uvdown = CalcUI(joyback, 128, 256, 128, 64); btnInfo.Add(i); } }