private void ChangeOwnership() { for (var i = 0; i < scoreTrackers.Count; i++) { ScoreTracker tracker = scoreTrackers[i]; TileVisitor trackerVisitor = tracker.gameObject.GetComponent <TileVisitor>(); if (trackerVisitor.CurrentlyVisiting.GetTotalNumberOfVisitors(tagForPoints) > 0) { foreach (TileVisitor otherOccupant in trackerVisitor.CurrentlyVisiting.GetVisitorsOfTag(tagForPoints)) { PointsGiver pointsGiver = otherOccupant.gameObject.GetComponent <PointsGiver>(); if (pointsGiver != null) { if (pointsGiver.OwnedBy != tracker) { //TODO: Handle line of sight exclusion! pointsGiver.OwnedBy = tracker; animationManager.AddNewTakeOver(tracker, pointsGiver); } } else { Debug.LogError("Gameobject: " + otherOccupant.gameObject.name + " is tagged as " + tagForPoints + " but doesn't have a pointsgiver object!"); } } } } }
public IEnumerator PlayTakeOverAnimations() { foreach (KeyValuePair <ScoreTracker, PointsGiver> entry in takeOvers) { ScoreTracker tracker = entry.Key; PointsGiver pointsGiver = entry.Value; yield return(StartCoroutine(MoveCameraToPosition(tracker.GetComponent <TileVisitor> ().CurrentlyVisiting.transform.position))); yield return(StartCoroutine(ZoomCamera(highlightZoomWidth))); tracker.GetComponent <CharacterAnimationController>().ApplyState(StateType.Sticker, pointsGiver.GetComponent <HumanAnimationController>()); GetComponent <AudioSource> ().PlayOneShot(stickerNoise); yield return(new WaitForSeconds(timePerStickerAnim)); yield return(StartCoroutine(ZoomCamera(defaultCameraWidth))); } yield return(StartCoroutine(MoveCameraToPosition(defaultCameraPos))); takeOvers.Clear(); objectsToAnimate.Clear(); }
public void AddNewTakeOver(ScoreTracker tracker, PointsGiver target) { takeOvers.Add(tracker, target); }