// Load the rigs and their animations on to this screen. public void LoadRigs (int[] characterIndices, HandlePositionPairSet[][] animations) { Transform container = transform.Find ("Stage"); container.DestroyAllChildren (); rigs = new Dictionary<int, PosingController> (); for (int i = 0; i < characterIndices.Length; i++) { int characterIndex = characterIndices [i]; // Display the bird and its animation. Bird bird = GameController.GetBird (characterIndex); PosingController rig = Instantiate (bird.rig); rig.transform.SetParent (container); rig.transform.localScale = Vector3.one; rig.transform.position = new Vector3 (i * characterSpacing, 0, 0); rig.PlayAnimation (animations [i]); rigs.Add (characterIndex, rig); // Display the select mate button. Button selectButton = Instantiate (selectMateButtonPrefab); selectButton.transform.SetParent (container); selectButton.transform.localScale = Vector3.one; selectButton.transform.position = new Vector3 (i * characterSpacing, selectMateButtonPrefab.transform.position.y, 0); selectButton.onClick.AddListener (() => OnSelectMate (characterIndex)); } cameraEndBound = characterSpacing * (characterIndices.Length - 1); }
// Collect the set of handle position pairs. public HandlePositionPairSet CollectHandlePositions () { HandlePositionPairSet pairs = new HandlePositionPairSet (); for (int i = 0; i < handles.Length; i++) { HandleController handle = handles [i]; pairs.handlePositionPairs.Add ( new HandlePositionPair { handleID = handle.id, position = handle.transform.position, } ); } return pairs; }
// Play an animation given a bunch of handle-position pairs and frames. public void PlayAnimation (HandlePositionPairSet[] pairs) { // Can't see handles while playing. SetAllHandlesVisible (false); // Check if there are actually pairs to work with. if (pairs == null || pairs.Length <= 0) { return; } // Copy pairs and start playing. playingKeyframes = pairs; playing = true; }