static void Main(string[] args) { Revolver revolver = new Revolver(); Rifle rifle = new Rifle(); Shotgun shotgun = new Shotgun(); Gatling gatling = new Gatling(); IWeapon[] soldierWeapons = { revolver, rifle, shotgun, gatling }; Soldier soldier = new Soldier(soldierWeapons); Console.WriteLine("The soldier is trying his weapons: "); for (int i = 0; i < soldierWeapons.Length; i++) { Console.WriteLine(soldier.Shoot(soldierWeapons[i])); } Console.WriteLine(); Console.WriteLine("The tank operators are doing some weapon tests: "); TankGun tankGun = new TankGun(); MachineGun machineGun = new MachineGun(); Missile missile = new Missile(); IWeapon[] tankWeapons = { tankGun, machineGun, missile }; Tank tank = new Tank(tankWeapons); for (int i = 0; i < tankWeapons.Length; i++) { Console.WriteLine(tank.Shoot(tankWeapons[i])); } }
void Start() { // //Get Scripts // if (data == null) { data = GetComponent <TankData>(); } if (motor == null) { motor = GetComponent <TankMotor>(); } if (gun == null) { gun = GetComponent <TankGun>(); } //Add in spawn points waypoints = GameObject.FindGameObjectsWithTag("Spawn"); //Get Transform Component tf = this.gameObject.GetComponent <Transform> (); //Get the currentWaypoint (Closest Waypoint); currentWaypoint = GetClosestWayPoint(tf); looseCannonStartWayPoint = currentWaypoint; avoidanceStage = 0; sc = GetComponent <SphereCollider> (); sc.radius = hearDistance; playerTf = GetComponent <Transform> (); playerTf = GameObject.FindGameObjectWithTag("Player").transform; }
//Initialize Variables void Start() { //if scripts are null set them if (data == null) { data = GetComponent <TankData>(); } if (motor == null) { motor = GetComponent <TankMotor>(); } if (gun == null) { gun = GetComponent <TankGun>(); } }
void Awake() { iCont = GetComponent<InputController>(); pCont = GetComponent<PlayerController>(); tGun = GetComponentInChildren<TankGun>(); batShield = gameObject.AddComponent<CircleCollider2D>(); batShield.isTrigger = true; batShield.radius = 1.0f; batShield.enabled = false; GameObject shield = Instantiate(shieldPrefab); shield.transform.SetParent(transform); shield.transform.localPosition = Vector3.zero + Vector3.forward * -0.1f; shieldPrefab = shield; shieldPrefab.SetActive(false); if (Manager.instance.gameMode == Manager.GameModes.BLITZKRIEG) fireDelay *= 0.5f; }
private void Awake() { _gunStatus = GetComponent <TextMeshProUGUI>(); _tankGun = FindObjectOfType <TankGun>(); if (!_gunStatus) { Debug.LogError("Failed to get TextMeshProTextUI element on " + gameObject.name.ToString() + ", creating one now..."); _gunStatus = gameObject.AddComponent <TextMeshProUGUI>(); } if (!_tankGun) { Debug.LogError("No TankGun found in the current scene!"); Debug.LogError("You may have forgotten to place a TankActor instance!"); } TankGun.OnGunStatusUpdate += UpdateGunStatusText; }
public static MilitaryCar CreateOplot() { var gun = new TankGun(); return(new MilitaryCar(gun)); }
void Start() { tGun = GetComponentInChildren<TankGun>(); if (Manager.instance.gameMode == Manager.GameModes.BLITZKRIEG) fireDelay *= 0.5f; }
public TankShootCommand(TankGun gun, KeyCode keyCode) : base(keyCode, CommandType.Single) { Gun = gun; }
public void SetTargetTank(Tank tank) { targetTank = tank; tankGun = targetTank.GetComponent <TankGun>(); }