CraftModel.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 Texture[] textureArr;
  10. public bool moving
  11. {
  12. set{
  13. Debuger.Log ("Set Run "+value);
  14. if(bottomAnim != null)
  15. bottomAnim.SetBool ("Run", value);
  16. if(topAnim != null)
  17. topAnim.SetBool ("Run", value);
  18. }
  19. }
  20. public void Attack()
  21. {
  22. if(topAnim != null)
  23. topAnim.SetTrigger ("Attack");
  24. }
  25. public void LookTo(Vector3 pos)
  26. {
  27. if (topAnim != null) {
  28. Vector3 forward = pos - topAnim.transform.position;
  29. Quaternion lookQuaternion = Quaternion.LookRotation (forward);
  30. shotManager.transform.rotation = topAnim.transform.rotation = Quaternion.Slerp (topAnim.transform.rotation, lookQuaternion, GameTime.deltaTime * 3f);
  31. }
  32. }
  33. public void LookToForward()
  34. {
  35. if (topAnim != null) {
  36. Quaternion lookQuaternion = Quaternion.Euler (Vector3.zero);
  37. shotManager.transform.localRotation = topAnim.transform.localRotation = Quaternion.Slerp (topAnim.transform.localRotation, lookQuaternion, GameTime.deltaTime * 3f);
  38. }
  39. }
  40. public void LookAt(Vector3 pos)
  41. {
  42. if (topAnim != null) {
  43. Vector3 forward = pos - topAnim.transform.position;
  44. Quaternion lookQuaternion = Quaternion.LookRotation (forward);
  45. shotManager.transform.rotation = topAnim.transform.rotation = lookQuaternion;
  46. }
  47. }
  48. public void SetSkin(Texture texture)
  49. {
  50. for(int i=0; i<skinArr.Length; i++)
  51. {
  52. skinArr [i].material.mainTexture = texture;
  53. }
  54. }
  55. }