// カードを引く(外部ボタンと連携) public void PullAction() { StartCoroutine(PullCard()); m_ActionMode = ACTION_MODE.PULL; m_IsPlaying = true; SetPullButton(false); }
private void PassAction() { if (GetFieldCardNum() <= 1) { return; } if (Input.GetMouseButtonDown(0)) { m_StartPosition = Input.mousePosition; Ray ray = Camera.main.ScreenPointToRay(m_StartPosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { CardController card = hit.collider.gameObject.GetComponent <CardController>(); if (card) { int endcard = m_Cards[m_Cards.Length - 1].GetComponent <CardController>().GetCardIndex(); if (endcard == card.GetCardIndex()) { m_IsSwipe = true; Debug.Log("パス可能なカードです"); } } Debug.Log(hit.collider.gameObject.name); } } if (Input.GetMouseButtonUp(0)) { m_EndPosition = Input.mousePosition; if (m_IsSwipe) { float dis = Vector2.Distance(m_StartPosition, m_EndPosition); if (dis > SWIPE_LENGTH) { m_ActionMode = ACTION_MODE.PASS; m_IsPlaying = true; SetPullButton(false); } } m_IsSwipe = false; } }
//--------------------------------------------------------------- /* * @brief 移動モードの設定 */ //--------------------------------------------------------------- public void SetMoveMode(ACTION_MODE actMode) { m_actMode = actMode; }
void OnGUI() { // Do autoresizing of GUI layer GUIResizer.AutoResize(); // Check whether a country or city is selected, then show a label with the entity name and its neighbours (new in V4.1!) if (map.cellHighlighted != null) { int cellIndex = map.cellHighlightedIndex; string text = "Cell index = " + cellIndex + ", row = " + map.cells [cellIndex].row + ", col = " + map.cells [cellIndex].column + ", center = " + map.cells [cellIndex].center; // shadow float x, y; x = Screen.width / 2.0f; y = Screen.height - 40; GUI.Label(new Rect(x - 1, y - 1, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 1, y + 2, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 2, y + 3, 0, 10), text, labelStyleShadow); GUI.Label(new Rect(x + 3, y + 4, 0, 10), text, labelStyleShadow); // texst face GUI.Label(new Rect(x, y, 0, 10), text, labelStyle); } // Assorted options to show/hide frontiers, cities, Earth and enable country highlighting GUI.Box(new Rect(5, 0, 175, 180), ""); map.showGrid = GUI.Toggle(new Rect(10, 20, 170, 30), map.showGrid, "Toggle Grid"); map.enableCellHighlight = GUI.Toggle(new Rect(10, 50, 170, 30), map.enableCellHighlight, "Enable Cell Highlighting"); if (GUI.Toggle(new Rect(10, 80, 170, 30), mode == ACTION_MODE.FadeOut, "Toggle Fade Circle")) { mode = ACTION_MODE.FadeOut; } if (GUI.Toggle(new Rect(10, 110, 170, 30), mode == ACTION_MODE.Flash, "Toggle Flash Circle")) { mode = ACTION_MODE.Flash; } if (GUI.Toggle(new Rect(10, 140, 170, 30), mode == ACTION_MODE.Blink, "Toggle Blink Circle")) { mode = ACTION_MODE.Blink; } if (GUI.Toggle(new Rect(10, 170, 170, 30), mode == ACTION_MODE.Paint, "Toggle Colorize Cell")) { mode = ACTION_MODE.Paint; } if (GUI.Toggle(new Rect(10, 200, 170, 30), mode == ACTION_MODE.FadeCountry, "Toggle Fade Country")) { mode = ACTION_MODE.FadeCountry; } // buttons background color GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Clear painted cells if (GUI.Button(new Rect(10, 230, 160, 30), " Clear Cells", buttonStyle)) { map.HideCellSurfaces(); } // Add buttons to show the color picker and change colors for the cells if (GUI.Button(new Rect(10, 265, 160, 30), " Change Grid Color", buttonStyle)) { colorPicker.showPicker = true; } if (colorPicker.showPicker) { map.gridColor = colorPicker.setColor; } // Slider to show the new set zoom level API in V4.1 GUI.Button(new Rect(10, 300, 85, 30), " Cells", buttonStyle); GUI.backgroundColor = Color.white; int prevCellsCount = (int)cellsCount; cellsCount = (int)GUI.HorizontalSlider(new Rect(100, 315, 80, 30), cellsCount, 32, 512, sliderStyle, sliderThumbStyle); if ((int)cellsCount != prevCellsCount) { map.gridColumns = (int)cellsCount; map.gridRows = map.gridColumns / 2; cellsCount = map.gridColumns; } GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); // Slider to show the new set zoom level API in V4.1 GUI.Button(new Rect(10, 335, 85, 30), " Zoom Level", buttonStyle); float prevZoomLevel = zoomLevel; GUI.backgroundColor = Color.white; zoomLevel = GUI.HorizontalSlider(new Rect(100, 350, 80, 30), zoomLevel, 0, 1, sliderStyle, sliderThumbStyle); GUI.backgroundColor = new Color(0.1f, 0.1f, 0.3f, 0.95f); if (zoomLevel != prevZoomLevel) { prevZoomLevel = zoomLevel; map.SetZoomLevel(zoomLevel); } }
// ゲームループ private IEnumerator GameLoop() { // プレイヤーの動作待ち(引くorパス) NextPlayerInfo(); NextTrunPlayer(); if (IsDoubleJudg()) { yield return(new WaitForSeconds(OTHERS_WAITTIME)); SetAnnouncePanel(true, true); // プレイヤーの操作入力待ち while (!IsJudgColor()) { yield return(null); } } SetPullButton(true); // プレイヤーの操作入力待ち while (!m_IsPlaying) { PassAction(); yield return(null); } SetPullButton(false); // 念のため m_IsPlaying = false; yield return(new WaitForSeconds(CARD_MOVE_WAITTIME)); // Doubleカード出現時 if (IsDoubleChallenge()) { if (m_DeckNum > 2) { yield return(new WaitForSeconds(CARD_MOVE_WAITTIME)); // ダブルカードが重なった時に表示が早い SetAnnouncePanel(true); m_DoubleMode = DOUBLE_MODE.JUGDMENT; yield return(new WaitForSeconds(DOUBLE_CHALLENGE_MESSAGE_WAITTIME)); } } else if (IsDoubleJudg()) { SearchFieldCard(); yield return(new WaitForSeconds(PICK_FAILURE_WAITTIME)); yield return(new WaitForSeconds(PICK_FAILURE_WAITTIME)); yield return(PenaltyScore()); yield return(ResetField()); m_DoubleMode = DOUBLE_MODE.NONE; m_JudgColor = JUDG_COLOR.NONE; } else { if (m_ActionMode == ACTION_MODE.PULL) { // 成功or失敗の確認 SearchFieldCard(); if (!IsSuccess()) { yield return(new WaitForSeconds(PICK_FAILURE_WAITTIME)); yield return(PenaltyScore()); yield return(ResetField()); } else { yield return(new WaitForSeconds(PICK_FAILURE_WAITTIME)); } } else if (m_ActionMode == ACTION_MODE.PASS) { SearchFieldCard(); yield return(PassPenalty()); } } // ゲーム終了の確認 yield return(new WaitForSeconds(NEXT_TURM_WAITTIME)); m_ActionMode = ACTION_MODE.NONE; SetAnnouncePanel(false); if (!IsFinish()) { m_Turn++; StartCoroutine(GameLoop()); } else { WhoWins(); } }