Esempio n. 1
0
    public void OnClick(CursorController player)
    {
        Debug.Log($"{player.cursorManager.username} entered OnClick for {username}'s cup");

        //Forces player to click off the cup before clicking on another cup
        if (!clickable)
        {
            return;
        }
        clickable = false;

        Debug.Log($"{player.cursorManager.username} continued OnClick for {username}'s cup");

        //Add offclick to background
        GameManager.instance.offClick.onClick.AddListener(OffClick);

        //Set the pills
        tempFakePill   = player.GetPillFake();
        tempPoisonPill = player.GetPillPoison();
        //Debug.Log($"Fake Pill Colors: Pill: {tempFakePill.pillColor}, Player {tempFakePill.playerColor} ");
        //Debug.Log($"Real Pill Colors: Pill: {tempPoisonPill.pillColor}, Player {tempPoisonPill.playerColor} ");

        //Checks that pills are valid
        if (tempFakePill == null || tempPoisonPill == null)
        {
            Debug.Log($"One of {player.cursorManager.username}'s pills are invalid");
        }

        //Swap button position randomly
        GameManager.instance.SwapPillPosition();

        //Center the buttons
        Vector2 objPos = Camera.main.WorldToScreenPoint(transform.position);

        //Enable the canvas
        GameManager.instance.canvas.SetActive(true);

        //Add listeners
        GameManager.instance.poisonClick.onClick.AddListener(AddPoisonPill);
        GameManager.instance.fakeClick.onClick.AddListener(AddFakePill);
        GameManager.instance.buttonParent.anchoredPosition = objPos - GameManager.instance.canvasRectTransform.anchoredPosition + GameManager.instance.offset;
    }