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

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ShootingCannon : ActiveBlock
{
public bool shootingRight;
public GameObject shootingObject;
public Transform spawnLocation;
public TextMeshPro counter;
public int countdowntimer;
int countdown;
public override int GetInitative()
{
//order
return 4;
}
private void Start()
{
countdown = countdowntimer;
}
private void Update()
{
counter.text = countdown.ToString();
}
public override IEnumerator OnEnvironmentTurn(PlayerData[] allPlayers)
{
countdown--;
if (countdown == 0)
{
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
if (shootingRight == true){
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
}else{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
}
countdown = countdowntimer;
}
isFinished = true;
yield break;
}
}