CongaCat FindLeaderOf(CongaCat cat) { if (follower == cat) { return(this); } return(follower.FindLeaderOf(cat)); }
void ScatterCats() { targetPosition = spawnPosition; isMoving = true; gameObject.layer = LayerMask.NameToLayer("CatPickup"); if (follower) { follower.ScatterCats(); } follower = null; }
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(); }
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(); }
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); } }