示例#1
0
        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]));
            }
        }
示例#2
0
    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;
    }
示例#3
0
    //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>();
        }
    }
示例#4
0
    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;
    }
示例#5
0
    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;
    }
示例#6
0
        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;
 }
示例#8
0
 public TankShootCommand(TankGun gun, KeyCode keyCode) : base(keyCode, CommandType.Single)
 {
     Gun = gun;
 }
 public void SetTargetTank(Tank tank)
 {
     targetTank = tank;
     tankGun    = targetTank.GetComponent <TankGun>();
 }