CraftModel.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CraftModel : MonoBehaviour {
  5. public Animator topAnim;
  6. public Animator bottomAnim;
  7. public ShotManager shotManager;
  8. public SkinnedMeshRenderer[] skinArr;
  9. public bool moving
  10. {
  11. set{
  12. Debuger.Log ("Set Run "+value);
  13. if(bottomAnim != null)
  14. bottomAnim.SetBool ("Run", value);
  15. if(topAnim != null)
  16. topAnim.SetBool ("Run", value);
  17. }
  18. }
  19. public void Attack()
  20. {
  21. if(topAnim != null)
  22. topAnim.SetTrigger ("Attack");
  23. }
  24. public void LookTo(Vector3 pos)
  25. {
  26. if (topAnim != null) {
  27. Vector3 forward = pos - topAnim.transform.position;
  28. Quaternion lookQuaternion = Quaternion.LookRotation (forward);
  29. shotManager.transform.rotation = topAnim.transform.rotation = Quaternion.Slerp (topAnim.transform.rotation, lookQuaternion, GameTime.deltaTime * 3f);
  30. }
  31. }
  32. public void LookToForward()
  33. {
  34. if (topAnim != null) {
  35. Quaternion lookQuaternion = Quaternion.Euler (Vector3.zero);
  36. shotManager.transform.localRotation = topAnim.transform.localRotation = Quaternion.Slerp (topAnim.transform.localRotation, lookQuaternion, GameTime.deltaTime * 3f);
  37. }
  38. }
  39. public void LookAt(Vector3 pos)
  40. {
  41. if (topAnim != null) {
  42. Vector3 forward = pos - topAnim.transform.position;
  43. Quaternion lookQuaternion = Quaternion.LookRotation (forward);
  44. shotManager.transform.rotation = topAnim.transform.rotation = lookQuaternion;
  45. }
  46. }
  47. public void SetSkin(Texture texture)
  48. {
  49. for(int i=0; i<skinArr.Length; i++)
  50. {
  51. skinArr [i].material.mainTexture = texture;
  52. }
  53. }
  54. }