Beispiel #1
0
    CongaCat FindLeaderOf(CongaCat cat)
    {
        if (follower == cat)
        {
            return(this);
        }

        return(follower.FindLeaderOf(cat));
    }
Beispiel #2
0
    void ScatterCats()
    {
        targetPosition   = spawnPosition;
        isMoving         = true;
        gameObject.layer = LayerMask.NameToLayer("CatPickup");

        if (follower)
        {
            follower.ScatterCats();
        }

        follower = null;
    }
Beispiel #3
0
    void OnPlayerMoved(Vector2 newPosition)
    {
        if (!IsLeader)
        {
            return;
        }

        if (newPosition == (Vector2)previousPosition && follower)
        {
            follower.ScatterCats();
            follower = null;
        }

        MoveCongaLine(new Vector3(newPosition.x, newPosition.y, -1));
        OnStep?.Invoke();
    }
Beispiel #4
0
    public void OnAction(InputAction.CallbackContext context)
    {
        if (!context.started || !IsLeader || !follower)
        {
            return;
        }

        var last = FindLast();

        MoveCongaLine(last.targetPosition);

        IsLeader = false;
        follower.WillBeLeader = true;
        last.follower         = this;
        follower = null;
        isMoving = true;
        OnStep?.Invoke();
    }
Beispiel #5
0
    void Update()
    {
        var      catCollider = Physics2D.OverlapCircle(transform.position, 0.1f, playerMask);
        CongaCat cat         = null;

        if (catCollider)
        {
            cat = catCollider.GetComponent <CongaCat>();
        }
        bool isChonker = cat && cat.Type == CatType.Chonk;

        if (!isChonker && !active && pressed)
        {
            StartCoroutine(ButtonPressedCoroutine());
        }
        else if (isChonker && !pressed)
        {
            pressed = true;
            anim.SetBool("Pressed", true);
            OnButtonPressed?.Invoke(id, true);
        }
    }