示例#1
0
    public void Reset()
    {
        gameover["Screen_GameOver"].SetActive(false);
        gameover["Screen_RestartQ"].SetActive(false);
        blackCounter = 0; whiteCounter = 0;
        Debug.Log(clickedObjects.Count);
        Debug.Log(curBoard.Count);
        clickedObjects.Clear();
        curBoard.Clear();
        Debug.Log(clickedObjects.Count);
        Debug.Log(curBoard.Count);
        clickedObjects.Add(28, buttonObjects["Btn_28"]);
        clickedObjects.Add(29, buttonObjects["Btn_29"]);
        clickedObjects.Add(36, buttonObjects["Btn_36"]);
        clickedObjects.Add(37, buttonObjects["Btn_37"]);
        curBoard.Clear();
        for (int i = 1; i <= GlobalVariables.slotAmount; i++)
        {
            curBoard.Add(GlobalEnums.SloState.Empty);
            buttonObjects["Btn_" + i].GetComponent <SC_Slot>().ChangeSlotState(GlobalEnums.SloState.Empty);
            buttonObjects["Btn_" + i].GetComponent <Button>().interactable = false;
        }
        int[] _basicIndex1 = { 28, 37 };
        foreach (int i in _basicIndex1)
        {
            buttonObjects["Btn_" + i].GetComponent <SC_Slot>().ChangeSlotState(GlobalEnums.SloState.Black);
            curBoard[i - 1] = GlobalEnums.SloState.Black;
        }
        int[] _basicIndex2 = { 29, 36 };
        foreach (int i in _basicIndex2)
        {
            buttonObjects["Btn_" + i].GetComponent <SC_Slot>().ChangeSlotState(GlobalEnums.SloState.White);
            curBoard[i - 1] = GlobalEnums.SloState.White;
        }
        OpenArea();
        if (GlobalVariables.curOpponent == GlobalEnums.Opponent.AI)
        {
            textCounterObjects["Text_TurnTimer"].GetComponent <Text>().text = string.Empty;
            if (Random.Range(0, 2) == 0)
            {   // AI
                curState = GlobalEnums.SloState.White;
                buttonObjects["Img_CurState"].GetComponent <Image>().sprite = tokenObjectWhite;

                int _idx = GetRandomSlot();
                PlacementLogic(_idx);
            }
            else
            {
                // Player
                curState = GlobalEnums.SloState.Black;
                buttonObjects["Img_CurState"].GetComponent <Image>().sprite = tokenObjectBlack;
            }
        }
    }
示例#2
0
 private void PassTurn()
 {
     if (curState == GlobalEnums.SloState.Black)
     {
         curState = GlobalEnums.SloState.White;
         buttonObjects["Img_CurState"].GetComponent <Image>().sprite = tokenObjectWhite;
     }
     else
     {
         curState = GlobalEnums.SloState.Black;
         buttonObjects["Img_CurState"].GetComponent <Image>().sprite = tokenObjectBlack;
     }
 }
示例#3
0
 private void OnGameStarted(string _Sender, string _RoomId, string _NextTurn)
 {
     Reset();
     startTimer  = Time.time;
     gameStarted = true;
     curTurn     = _NextTurn;
     curState    = GlobalEnums.SloState.Black;
     buttonObjects["Img_CurState"].GetComponent <Image>().sprite = tokenObjectBlack;
     if (curTurn == GlobalVariables.userID)
     {
         isMyTurn    = true;
         playerState = GlobalEnums.SloState.Black;
         buttonObjects["Img_MyCircle"].GetComponent <Image>().sprite = tokenObjectBlack;
     }
     else
     {
         isMyTurn    = false;
         playerState = GlobalEnums.SloState.White;
         buttonObjects["Img_MyCircle"].GetComponent <Image>().sprite = tokenObjectWhite;
     }
 }
示例#4
0
    // Start is called before the first frame update

    public void ChangeSlotState(GlobalEnums.SloState _CurSlot)
    {
        if (curImg == null)
        {
            Debug.LogError("cur Img is Null, pass reference");
        }
        else
        {
            switch (_CurSlot)
            {
            case GlobalEnums.SloState.Empty:
                curImg.enabled = false; break;

            case GlobalEnums.SloState.Black:
                curImg.sprite  = blackCircle;
                curImg.enabled = true;
                break;

            case GlobalEnums.SloState.White:
                curImg.sprite  = whiteCircle;
                curImg.enabled = true; break;
            }
        }
    }