Esempio n. 1
0
    public void PlaceToken(int column)
    {
        Arrow.SetActive(value: false);
        HighlightBar.SetActive(value: false);
        currentToken.transform.localPosition = new Vector3((float)column * GridSpacing.x, PlacementPositionHeight, 0f);
        int num = 0;

        for (int i = 0; i < numRows; i++)
        {
            if (grid[column, i] == 0)
            {
                num = i;
                break;
            }
        }
        int[,] array = grid;
        int num2 = num;

        FindFour.FindFourTokenColor num3 = currentTokenColor + 1;
        array[column, num2] = (int)num3;
        Vector3 vector = new Vector3((float)column * GridSpacing.x, (float)num * GridSpacing.y, 0f);

        if (currentToken != null)
        {
            Hashtable args = iTween.Hash("name", "PlaceToken", "position", vector, "time", TokenPlaceAnimTime, "easetype", TokenPlaceAnimEaseType, "islocal", true, "oncomplete", "placeAnimComplete", "oncompletetarget", base.gameObject);
            iTween.MoveTo(currentToken, args);
        }
        if (checkForWin(column, num))
        {
            CoroutineRunner.Start(showWinEffects(), this, "ShowFindFourWinEffects");
        }
        currentTokenColumn = 0;
        if (currentTokenColor == FindFour.FindFourTokenColor.RED)
        {
            EventManager.Instance.PostEvent(Player1TokenDropSFXTrigger, EventAction.PlaySound);
        }
        else
        {
            EventManager.Instance.PostEvent(Player2TokenDropSFXTrigger, EventAction.PlaySound);
        }
    }
Esempio n. 2
0
    public void CreateNewToken(FindFour.FindFourTokenColor color, bool isLocalPlayer = false, int column = -1)
    {
        if (column == -1)
        {
            column = definition.DefaultColumn;
        }
        if (grid[column, numRows - 1] != 0)
        {
            column = findNextAvailableColumn(column, FindFour.FindFourMoveDirection.RIGHT, wrap: true);
        }
        GameObject original = redTokenPrefab;

        if (color == FindFour.FindFourTokenColor.BLUE)
        {
            original = blueTokenPrefab;
        }
        currentTokenColor  = color;
        currentTokenColumn = column;
        if (isLocalPlayer && currentMouseColumn > -1 && isColumnAvailable(currentMouseColumn))
        {
            currentTokenColumn = currentMouseColumn;
        }
        currentToken = UnityEngine.Object.Instantiate(original, TokenContainer.transform, worldPositionStays: false);
        currentToken.transform.localPosition = new Vector3((float)currentTokenColumn * GridSpacing.x, PlacementPositionHeight, 0f);
        if (!hasSetLocalPlayerColors)
        {
            FindFour.FindFourTokenColor findFourTokenColor = (!isLocalPlayer) ? ((color == FindFour.FindFourTokenColor.RED) ? FindFour.FindFourTokenColor.BLUE : FindFour.FindFourTokenColor.RED) : color;
            Service.Get <EventDispatcher>().DispatchEvent(new FindFourEvents.ColorChanged(findFourTokenColor));
            Material material = (findFourTokenColor == FindFour.FindFourTokenColor.RED) ? RedMaterial : BlueMaterial;
            HighlightBar.GetComponentInChildren <MeshRenderer>().material = material;
            hasSetLocalPlayerColors = true;
        }
        if (isLocalPlayer)
        {
            HighlightBar.SetActive(value: true);
            updateHighlightBarAndArrow();
        }
    }
Esempio n. 3
0
 public ColorChanged(FindFour.FindFourTokenColor color)
 {
     Color = color;
 }