// Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            snapping = !snapping;
        }

        holdingToken = heldToken != null;
        if (holdingToken)
        {
            heldToken.transform.position  = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
            heldToken.transform.position += Vector3.back * cam.transform.position.z;
            if (snapping)
            {
                Vector3 pos = heldToken.transform.position + Vector3.zero;
                heldToken.transform.position = new Vector3(Mathf.RoundToInt(pos.x / gridSize) * gridSize, Mathf.RoundToInt(pos.y / gridSize) * gridSize, 0);
            }
            if (Input.GetMouseButtonUp(0))
            {
                heldToken.isPlaced = true;
                heldToken          = null;
                holdingToken       = false;
            }
            if (Input.GetMouseButtonDown(1))
            {
                ResetToken(heldToken.id);
                //Destroy(heldToken.gameObject);
            }
        }
    }
    public static void ResetToken(int id)
    {
        TokenManager.FindToken(id).inPlace = false;
        PlacedToken token = FindToken(id);

        tokens.Remove(token);
        Destroy(token.gameObject);
    }
    public static void SelectCharacter(MenuToken character)
    {
        if (!holdingToken && !character.inPlace)
        {
            heldToken = Instantiate(blankToken).GetComponent <PlacedToken>();
            heldToken.GetComponent <SpriteRenderer>().sprite = character.GetComponent <Image>().sprite;
            heldToken.transform.position   = Vector3.left * 100;
            heldToken.transform.localScale = Vector3.one * scale;
            heldToken.id = character.id;
            tokens.Add(heldToken);

            character.inPlace = true;
        }
    }
예제 #4
0
 private static bool IsAlive(this PlacedToken token) => token is not null && !token.IsLocked();
예제 #5
0
 private static bool IsDead(this PlacedToken token) => token is null;
예제 #6
0
 private static PlacedToken Unlocked(this PlacedToken token) => token.IsLocked() ? new PlacedToken(token.Emoji, false) : token;
예제 #7
0
 private static bool IsScoreToken(PlacedToken token) => token.Scored;
예제 #8
0
 private static PlacedToken ScoreToken(PlacedToken src) => new PlacedToken(src.Emoji, true);
 public static void PickupToken(PlacedToken token)
 {
     heldToken = token;
 }