private void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            defaultWeapon.Fire();
        }

        if (Input.GetButtonUp("Fire1"))
        {
            defaultWeapon.FireUp();
        }

        if (Input.GetButtonDown("Fire1"))
        {
            defaultWeapon.FireDown();
        }

        if (Input.GetKeyUp(KeyCode.R))
        {
            defaultWeapon.Reload();

            Weapon_Gun weapongun = defaultWeapon as Weapon_Gun;
            if (weapongun != null)
            {
                weapongun.MagazineCurrent = weapongun.MagazineCapacity;
            }
        }
    }
Пример #2
0
 void ComponentAssignment()
 {
     count = 0;
     Transform[] allChildren = transform.GetComponentsInChildren <Transform>();
     foreach (Transform child in allChildren)
     {
         if (child.gameObject.name == "Turret_Main")
         {
             child.gameObject.name = "Turret_Main_0" + (count + 1);
             turretControls[count] = child.GetComponent <TurretControls>();
             count++;
         }
         if (child.gameObject.tag == "Weapon_Gun")
         {
             gun        = child;
             weapon_Gun = gun.GetComponent <Weapon_Gun>();
             if (gun != null)
             {
                 Debug.Log(gun.name);
                 gunIndex.Add(new GunIndex(gun, weapon_Gun));
             }
             else
             {
                 Debug.Log("INDEXING ERROR! TankControls>ComponentAssignment gunIndex failed!");
             }
         }
     }
 }
Пример #3
0
    override protected void Awake()
    {
        base.Awake();

        _swordGun = GetComponent <Weapon_Gun>();

        CollisionIsAllowedWhenRetracted = _collisionIsAllowedWhenRetracted;
    }
Пример #4
0
 public void FireWeapon(Weapon_Gun gun)
 {
     gun.Fire(shootPoint.position, anim.direction);
     AMMO -= gun.ammoCost;
     if (AMMO < 0)
     {
         AMMO = 0;
     }
 }
Пример #5
0
    void Attack()
    {
        float degreesDelta = Random.Range(1, 30);
        float radiansDelta = degreesDelta * Mathf.PI / 180;

        Weapon_Gun gun = _enemy.weapon as Weapon_Gun;

        Vector3 dir  = (Player.Position - gun.MuzzlePosition).normalized;
        Vector3 dirL = Vector3.RotateTowards(dir, -dir, -radiansDelta, 999);
        Vector3 dirR = Vector3.RotateTowards(dir, -dir, radiansDelta, 999);

        _enemy.Attack(dir);
        _enemy.Attack(dirL);
        _enemy.Attack(dirR);
    }
Пример #6
0
    void ComponentAssignment()      //assignment is fixed, but the ready variables aren't switching to "ready".
    {
        Transform[] allChildren = GetComponentsInChildren <Transform>();
        foreach (Transform child in allChildren)
        {
            if (child.gameObject.name == "Turret")
            {
                turret = child;
            }
            if (child.gameObject.name == "RotationKey")
            {
                rotKey = child;
            }
            if (child.gameObject.name == "RotationTarget")
            {
                rotTarget = child;
            }
            if (child.gameObject.name == "ElevationTarget")
            {
                elevTarget = child;
            }

            if (child.gameObject.tag == "Weapon_Gun")
            {
                gun        = child;
                weapon_Gun = gun.GetComponent <Weapon_Gun>();
                foreach (Transform childTransform in gun)
                {
                    if (childTransform.gameObject.name == "Muzzle")
                    {
                        muzzle = childTransform;
                    }
                }
                if (gun != null && muzzle != null)
                {
                    gunIndex.Add(new GunIndex(gun, weapon_Gun));
                }
                else
                {
                    Debug.Log("INDEXING ERROR! GUN OR MUZZLE INDEXING FAILED!");
                }
            }
        }
        gunsTotal = gunIndex.Count;
        count     = 0;
    }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     weapon_Gun = gun.GetComponent <Weapon_Gun>();
 }
Пример #8
0
 public void AssignGun(Weapon_Gun gun)
 {
     this.gun = gun;
 }
Пример #9
0
 public GunIndex(Transform gunBarrel, Weapon_Gun gunScript)
 {
     gun        = gunBarrel;
     weapon_Gun = gunScript;
 }
Пример #10
0
 void SelectWeapon()
 {
     weapon_Gun        = gunIndex[gunCount].weapon_Gun;
     currentWeaponName = weapon_Gun.name;
     shellForce        = weapon_Gun.shellForce;
 }