Ejemplo n.º 1
0
//  Undefined user interaction, mouse click or touch, starts here

    public void UserActionStart(Vector2 point)
    {
        noAction = false;

        int x = Mathf.CeilToInt(point.x / (Screen.width / Map.maxColumns)) - 1;
        int y = Mathf.CeilToInt(point.y / (Screen.height / (Map.maxRows + 1))) - 1;

//      Processing user interaction

        if (y <= 1)
        {
            if (x <= 2)
            {
                mainUI.ActivateMenu();
            }

/*          else if (x > 6)
 *          {
 *              LevelUp();
 *              FPSDisplay.active = !FPSDisplay.active;
 *              noAction = true;
 *          }
 */
            else
            {
                noAction = true;
            }
        }

        else if (beamsCount > 0 && map.HitLocation(point, out x, out y))
        {
            beamsCount--;
            mainUI.ProgressBell();

//          Adding points

            map.AddPoints(x, y, 1);

            for (int c = 1; x + c < Map.maxColumns; c++)
            {
                map.AddPoints(x + c, y, c + 1);
                if (map.mTable[x + c, y].bonus)
                {
                    break;
                }
            }
            for (int c = 1; x - c >= 0 && x - c < Map.maxColumns; c++)
            {
                map.AddPoints(x - c, y, c + 1);
                if (map.mTable[x - c, y].bonus)
                {
                    break;
                }
            }
            for (int c = 1; y + c < Map.maxRows; c++)
            {
                map.AddPoints(x, y + c, c + 1);
                if (map.mTable[x, y + c].bonus)
                {
                    break;
                }
            }
            for (int c = 1; y - c >= 0 && y - c < Map.maxRows; c++)
            {
                map.AddPoints(x, y - c, c + 1);
                if (map.mTable[x, y - c].bonus)
                {
                    break;
                }
            }

            if (x < Map.maxColumns && x >= 0 && y >= 0 && y < Map.maxRows)
            {
                StartCoroutine(BeamOn(new Vector2Int(x, y)));
            }
        }
        else
        {
            noAction = true;
        }
    }