You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
4.4 KiB

7 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using DentedPixel;
  4. public class GeneralAdvancedTechniques : MonoBehaviour {
  5. public GameObject avatarRecursive;
  6. public GameObject avatar2dRecursive;
  7. public RectTransform wingPersonPanel;
  8. public RectTransform textField;
  9. public GameObject avatarMove;
  10. public Transform[] movePts;
  11. public GameObject[] avatarSpeed;
  12. public GameObject[] avatarSpeed2;
  13. private Vector3[] circleSm = new Vector3[]{ new Vector3(16f,0f,0f), new Vector3(14.56907f,8.009418f,0f), new Vector3(15.96541f,4.638379f,0f), new Vector3(11.31371f,11.31371f,0f), new Vector3(11.31371f,11.31371f,0f), new Vector3(4.638379f,15.96541f,0f), new Vector3(8.009416f,14.56908f,0f), new Vector3(-6.993822E-07f,16f,0f), new Vector3(-6.993822E-07f,16f,0f), new Vector3(-8.009419f,14.56907f,0f), new Vector3(-4.63838f,15.9654f,0f), new Vector3(-11.31371f,11.31371f,0f), new Vector3(-11.31371f,11.31371f,0f), new Vector3(-15.9654f,4.63838f,0f), new Vector3(-14.56908f,8.009415f,0f), new Vector3(-16f,-1.398764E-06f,0f), new Vector3(-16f,-1.398764E-06f,0f), new Vector3(-14.56907f,-8.009418f,0f), new Vector3(-15.9654f,-4.638382f,0f), new Vector3(-11.31371f,-11.31371f,0f), new Vector3(-11.31371f,-11.31371f,0f), new Vector3(-4.638381f,-15.9654f,0f), new Vector3(-8.009413f,-14.56908f,0f), new Vector3(1.907981E-07f,-16f,0f), new Vector3(1.907981E-07f,-16f,0f), new Vector3(8.00942f,-14.56907f,0f), new Vector3(4.638381f,-15.9654f,0f), new Vector3(11.31371f,-11.3137f,0f), new Vector3(11.31371f,-11.3137f,0f), new Vector3(15.96541f,-4.638378f,0f), new Vector3(14.56907f,-8.009418f,0f), new Vector3(16f,2.797529E-06f,0f) };
  14. private Vector3[] circleLrg = new Vector3[]{ new Vector3(25f,0f,0f), new Vector3(22.76418f,12.51472f,0f), new Vector3(24.94595f,7.247467f,0f), new Vector3(17.67767f,17.67767f,0f), new Vector3(17.67767f,17.67767f,0f), new Vector3(7.247467f,24.94595f,0f), new Vector3(12.51471f,22.76418f,0f), new Vector3(-1.092785E-06f,25f,0f), new Vector3(-1.092785E-06f,25f,0f), new Vector3(-12.51472f,22.76418f,0f), new Vector3(-7.247468f,24.94594f,0f), new Vector3(-17.67767f,17.67767f,0f), new Vector3(-17.67767f,17.67767f,0f), new Vector3(-24.94594f,7.247468f,0f), new Vector3(-22.76418f,12.51471f,0f), new Vector3(-25f,-2.185569E-06f,0f), new Vector3(-25f,-2.185569E-06f,0f), new Vector3(-22.76418f,-12.51472f,0f), new Vector3(-24.94594f,-7.247472f,0f), new Vector3(-17.67767f,-17.67767f,0f), new Vector3(-17.67767f,-17.67767f,0f), new Vector3(-7.247469f,-24.94594f,0f), new Vector3(-12.51471f,-22.76418f,0f), new Vector3(2.98122E-07f,-25f,0f), new Vector3(2.98122E-07f,-25f,0f), new Vector3(12.51472f,-22.76418f,0f), new Vector3(7.24747f,-24.94594f,0f), new Vector3(17.67768f,-17.67766f,0f), new Vector3(17.67768f,-17.67766f,0f), new Vector3(24.94595f,-7.247465f,0f), new Vector3(22.76418f,-12.51472f,0f), new Vector3(25f,4.371139E-06f,0f) };
  15. // Use this for initialization
  16. void Start () {
  17. // Recursion - Set a objects value and have it recursively effect it's children
  18. LeanTween.alpha( avatarRecursive, 0f, 1f).setRecursive(true).setLoopPingPong();
  19. LeanTween.alpha( avatar2dRecursive, 0f, 1f).setRecursive(true).setLoopPingPong();
  20. LeanTween.alpha( wingPersonPanel, 0f, 1f).setRecursive(true).setLoopPingPong();
  21. // Destroy on Complete -
  22. // Chaining tweens together
  23. // setOnCompleteOnRepeat
  24. // Move to path of transforms that are moving themselves
  25. LeanTween.value( avatarMove, 0f, (float)movePts.Length-1, 5f).setOnUpdate((float val)=>{
  26. int first = (int)Mathf.Floor(val);
  27. int next = first < movePts.Length-1 ? first + 1 : first;
  28. float diff = val - (float)first;
  29. // Debug.Log("val:"+val+" first:"+first+" next:"+next);
  30. Vector3 diffPos = (movePts[next].position-movePts[first].position);
  31. avatarMove.transform.position = movePts[first].position + diffPos*diff;
  32. }).setEase(LeanTweenType.easeInOutExpo).setLoopPingPong();
  33. // move the pts
  34. for(int i = 0; i < movePts.Length; i++)
  35. LeanTween.moveY( movePts[i].gameObject, movePts[i].position.y + 1.5f, 1f).setDelay(((float)i)*0.2f).setLoopPingPong();
  36. // move objects at a constant speed
  37. for(int i = 0; i < avatarSpeed.Length; i++)
  38. LeanTween.moveLocalZ( avatarSpeed[i], (i+1)*5f, 1f).setSpeed(6f).setEase(LeanTweenType.easeInOutExpo).setLoopPingPong(); // any time you set the speed it overrides the time value
  39. // move around a circle at a constant speed
  40. for(int i = 0; i < avatarSpeed2.Length; i++){
  41. LeanTween.moveLocal( avatarSpeed2[i], i == 0 ? circleSm : circleLrg, 1f).setSpeed(20f).setRepeat(-1);
  42. }
  43. }
  44. }