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.

47 lines
1.1 KiB

  1.  using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. public class ShootingCannon : ActiveBlock
  6. {
  7. public bool shootingRight;
  8. public GameObject shootingObject;
  9. public Transform spawnLocation;
  10. public TextMeshPro counter;
  11. public int countdowntimer;
  12. int countdown;
  13. public override int GetInitative()
  14. {
  15. //order
  16. return 4;
  17. }
  18. private void Start()
  19. {
  20. countdown = countdowntimer;
  21. }
  22. private void Update()
  23. {
  24. counter.text = countdown.ToString();
  25. }
  26. public override IEnumerator OnEnvironmentTurn(PlayerData[] allPlayers)
  27. {
  28. countdown--;
  29. if (countdown == 0)
  30. {
  31. GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
  32. if (shootingRight == true){
  33. shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
  34. }else{
  35. shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
  36. }
  37. countdown = countdowntimer;
  38. }
  39. isFinished = true;
  40. yield break;
  41. }
  42. }