fork download
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CharacterAnimationDelegate : MonoBehaviour
  6. {
  7. public GameObject leftArmAttackPoint;
  8. public GameObject rightArmAttackPoint;
  9. public GameObject leftLegAttackPoint;
  10. public GameObject rightLegAttackPoint;
  11.  
  12. public float standUpTimer = 2f;
  13.  
  14. private CharacterAnimation animationScript;
  15.  
  16. private AudioSource audioSource;
  17.  
  18. [SerializeField]
  19. private AudioClip missSound, fallSound, groundHitSound, deathSound;
  20.  
  21. private EnemyMovement enemyMovement;
  22.  
  23. private ShakeCamera camera;
  24.  
  25. void Awake()
  26. {
  27. animationScript = GetComponent<CharacterAnimation>();
  28.  
  29. audioSource = GetComponent<AudioSource>();
  30.  
  31. if(gameObject.CompareTag(Tags.ENEMY_TAG))
  32. {
  33. enemyMovement = GetComponentInParent<EnemyMovement>();
  34. }
  35.  
  36. camera = GameObject.FindWithTag(Tags.MAIN_CAMERA_TAG).GetComponent<ShakeCamera>();
  37. }
  38.  
  39. //Functions to turn ON collision points on Player limbs
  40. void turnOnLeftArm()
  41. {
  42. leftArmAttackPoint.SetActive(true);
  43. }
  44.  
  45. void turnOnRightArm()
  46. {
  47. rightArmAttackPoint.SetActive(true);
  48. }
  49.  
  50. void turnOnLeftLeg()
  51. {
  52. leftLegAttackPoint.SetActive(true);
  53. }
  54.  
  55. void turnOnRightleg()
  56. {
  57. rightLegAttackPoint.SetActive(true);
  58. }
  59.  
  60. //Functions to turn OFF collision points on Player limbs
  61. void turnOffLeftArm()
  62. {
  63. if(leftArmAttackPoint.activeInHierarchy)
  64. {
  65. leftArmAttackPoint.SetActive(false);
  66. }
  67. }
  68.  
  69. void turnOffRightArm()
  70. {
  71. if (rightArmAttackPoint.activeInHierarchy)
  72. {
  73. rightArmAttackPoint.SetActive(false);
  74. }
  75. }
  76.  
  77. void turnOffLeftLeg()
  78. {
  79. if (leftLegAttackPoint.activeInHierarchy)
  80. {
  81. leftLegAttackPoint.SetActive(false);
  82. }
  83. }
  84.  
  85. void turnOffRightleg()
  86. {
  87. if (rightLegAttackPoint.activeInHierarchy)
  88. {
  89. rightLegAttackPoint.SetActive(false);
  90. }
  91. }
  92.  
  93. /*Tag to left arm on player character;
  94.   Add event to call function at certain
  95.   animation point during the 'Punch 3' animation in Animation tab*/
  96. void TagLeftArm()
  97. {
  98. leftArmAttackPoint.tag = Tags.LEFT_ARM_TAG;
  99. }
  100.  
  101. /*Untag to left arm on player character;
  102.   Add event to call function at certain
  103.   animation point during the 'Punch 3' animation in Animation tab*/
  104. void UnTagLeftArm()
  105. {
  106. leftArmAttackPoint.tag = Tags.UNTAGGED_TAG;
  107. }
  108.  
  109. /*Tag to left leg on player character;
  110.   Add event to call function at certain animation point
  111.   during the 'Kick 2' animation in Animation tab*/
  112. void TagLeftLeg()
  113. {
  114. leftArmAttackPoint.tag = Tags.LEFT_LEG_TAG;
  115. }
  116.  
  117. /*Untag to left leg on player character;
  118.   Add event to call function at certain animation point
  119.   during the 'Kick 2' in Animation tab*/
  120. void UnTagLeftLeg()
  121. {
  122. leftArmAttackPoint.tag = Tags.UNTAGGED_TAG;
  123. }
  124.  
  125. /*Add function at end of 'EnemyKnockDown-End' animation
  126.   in Animation Tab*/
  127. void EnemyStandpUp()
  128. {
  129. StartCoroutine(StandUpAfterTime());
  130. }
  131.  
  132. IEnumerator StandUpAfterTime()
  133. {
  134. yield return new WaitForSeconds(standUpTimer);
  135. animationScript.StandUp();
  136. }
  137.  
  138. /*Add event to call function at certain animation point
  139.   during the 'Punch1', 'Punch2', 'Punch3', 'Kick1', and 'Kick2'
  140.   in Animation tabs*/
  141. public void AttackSoundFx()
  142. {
  143. audioSource.volume = 0.2f;
  144. audioSource.clip = missSound;
  145. audioSource.Play();
  146. }
  147.  
  148. void characterDeathSoundFx()
  149. {
  150. audioSource.volume = 1f;
  151. audioSource.clip = deathSound;
  152. audioSource.Play();
  153. }
  154.  
  155.  
  156. void EnemyKnockDown()
  157. {
  158. audioSource.clip = fallSound;
  159. audioSource.Play();
  160. }
  161.  
  162. void EnemyHitGround()
  163. {
  164. audioSource.clip = groundHitSound;
  165. audioSource.Play();
  166. }
  167.  
  168. void DisableMovement()
  169. {
  170. enemyMovement.enabled = false;
  171.  
  172. /*Set enemy parent game object to Default Layer;
  173.   Rendering enemy invalid while on the ground;
  174.   0 = Default Layer in Layers Tab*/
  175. transform.parent.gameObject.layer = 0;
  176. }
  177.  
  178. void EnableMovement()
  179. {
  180. enemyMovement.enabled = true;
  181.  
  182. /*Set enemy parent game object to Enemy Layer;
  183.   Rendering enemy active again when it gets back up;
  184.   9 = Enemy Layer in Layers Tab*/
  185.  
  186. transform.parent.gameObject.layer = 9;
  187. }
  188.  
  189. //Call Accessor in ShakeCamera script to change boolean variable
  190.  
  191. void ShakeCameraOnFall()
  192. {
  193. camera.shouldShakeAccessor = true;
  194. }
  195.  
  196. void CharacterDied()
  197. {
  198. Invoke("DeactivateEnemy", 2f);
  199. }
  200.  
  201. void DeactivateEnemy()
  202. {
  203. EnemyManager.instance.SpawnEnemy();
  204.  
  205. gameObject.SetActive(false);
  206. }
  207.  
  208. // Start is called before the first frame update
  209. void Start()
  210. {
  211.  
  212. }
  213.  
  214. // Update is called once per frame
  215. void Update()
  216. {
  217.  
  218. }
  219. }
  220.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(5,43): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(7,12): error CS0246: The type or namespace name `GameObject' could not be found. Are you missing an assembly reference?
prog.cs(8,12): error CS0246: The type or namespace name `GameObject' could not be found. Are you missing an assembly reference?
prog.cs(9,12): error CS0246: The type or namespace name `GameObject' could not be found. Are you missing an assembly reference?
prog.cs(10,12): error CS0246: The type or namespace name `GameObject' could not be found. Are you missing an assembly reference?
prog.cs(14,13): error CS0246: The type or namespace name `CharacterAnimation' could not be found. Are you missing an assembly reference?
prog.cs(16,13): error CS0246: The type or namespace name `AudioSource' could not be found. Are you missing an assembly reference?
prog.cs(19,13): error CS0246: The type or namespace name `AudioClip' could not be found. Are you missing an assembly reference?
prog.cs(21,13): error CS0246: The type or namespace name `EnemyMovement' could not be found. Are you missing an assembly reference?
prog.cs(23,13): error CS0246: The type or namespace name `ShakeCamera' could not be found. Are you missing an assembly reference?
Compilation failed: 11 error(s), 0 warnings
stdout
Standard output is empty