微信登录

Player - Arrow.cs - 玩家_射箭

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Common;
  5. public class Arrow : MonoBehaviour {
  6. public RoleType roleType;
  7. public int speed = 5;
  8. public GameObject explosionEffect;
  9. public bool isLocal = false;
  10. private Rigidbody rgd;
  11. // Use this for initialization
  12. void Start () {
  13. rgd = GetComponent<Rigidbody>();
  14. }
  15. // Update is called once per frame
  16. void Update () {
  17. rgd.MovePosition( transform.position+ transform.forward * speed * Time.deltaTime);
  18. }
  19. private void OnTriggerEnter(Collider other)
  20. {
  21. if (other.tag == "Player")
  22. {
  23. GameFacade.Instance.PlayNormalSound(AudioManager.Sound_ShootPerson);
  24. if (isLocal)
  25. {
  26. bool playerIsLocal = other.GetComponent<PlayerInfo>().isLocal;
  27. if (isLocal != playerIsLocal)
  28. {
  29. GameFacade.Instance.SendAttack( Random.Range(10,20) );
  30. }
  31. }
  32. }
  33. else
  34. {
  35. GameFacade.Instance.PlayNormalSound(AudioManager.Sound_Miss);
  36. }
  37. GameObject.Instantiate(explosionEffect, transform.position, transform.rotation);
  38. GameObject.Destroy(this.gameObject);
  39. }
  40. }