//check and create if weapon is available
    public void Attack(bool isEnemy)
    {
        if (CanAttack)
        {
            shootCD = shootingRate;

            //create shot
            var shotTransform = Instantiate(shotPrefab) as Transform;

            //positioning
            shotTransform.position = transform.position;

            //check if enemy
            AmmoScript shot = shotTransform.gameObject.GetComponent <AmmoScript>();
            if (shot != null)
            {
                shot.isShot = isEnemy;
            }

            //shoot at enemy
            movementScript move = shotTransform.gameObject.GetComponent <movementScript>();
            if (move != null)
            {
                move.spDirection = this.transform.right;
            }
        }
    }
Пример #2
0
    void RpcGiveAmmoTo(NetworkInstanceId applyAmmoTo, float amountToGive, NetworkInstanceId ammoToDestroy)
    {
        GameObject       ObjToApplyAmmoTo     = ClientScene.FindLocalObject(applyAmmoTo).gameObject;
        PlayerController objsPlayerController = ObjToApplyAmmoTo.GetComponent <PlayerController>();

        GameObject ammoGiver   = ClientScene.FindLocalObject(ammoToDestroy);
        AmmoScript ammosScript = ammoGiver.GetComponent <AmmoScript>();

        //Get Player Controller and apply apply to it's weapon script
        if (ammosScript.ammoType == GunScript.GunTypes.AK)
        {
            objsPlayerController.akAmmoCarrying += amountToGive;
        }
        else if (ammosScript.ammoType == GunScript.GunTypes.M4)
        {
            objsPlayerController.m4AmmoCarrying += amountToGive;
        }
        else if (ammosScript.ammoType == GunScript.GunTypes.Micro)
        {
            objsPlayerController.microAmmoCarrying += amountToGive;
        }
        else if (ammosScript.ammoType == GunScript.GunTypes.Snipper)
        {
            objsPlayerController.snipperAmmoCarrying += amountToGive;
        }

        Destroy(ammoGiver);
    }
Пример #3
0
 void Start()
 {
     letterDisplay = transform.Find("letter").GetComponent <InputDisplayScript>();
     numberDisplay = transform.Find("number").GetComponent <InputDisplayScript>();
     spawner       = GetComponentInChildren <MonsterSpawner>();
     ammo          = GetComponentInChildren <AmmoScript>();
     shot          = GetComponentInChildren <ShotScript>();
     reload        = transform.Find("reload").GetComponent <SpriteRenderer>();
 }
Пример #4
0
 public void Start()
 {
     shootingScript = gameObject.GetComponent <ShootingScript>();
     ammoScript     = gameObject.GetComponent <AmmoScript>();
     bulletPool     = GameObject.Find("BulletPool").GetComponent <BulletPool>();
     character      = transform.Find("Character");
     GameManager.instance.playerStats  = transform.Find("StatsandSkills/PlayerStats").GetComponent <PlayerStats>();
     GameManager.instance.playerSkills = transform.Find("StatsandSkills/PlayerSkills").GetComponent <PlayerSkills>();
     speed = GameManager.instance.playerStats.movement.speed;
 }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     PCS = GetComponent <PlayerControlScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(3);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 50;
     CanShoot          = true;
     projectile        = Resources.Load("ChaffPrefab") as GameObject;
 }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS = GetComponent <PlayerControlScript> ();
     SPS = GameObject.Find("Main Camera").GetComponent <SoundPlayerScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 50;
     CanShoot          = true;
     projectile        = Resources.Load("KnifeProjectilePrefab") as GameObject;
 }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     PCS = GetComponent <PlayerControlScript> ();
     SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OP  = GameObject.Find("ObjectPoolerIntercept").GetComponent <ObjectPoolScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 50;
     CanShoot          = true;
     projectile        = Resources.Load("InterCeptorPrefab") as GameObject;
 }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerTripMine").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 25;
     CanShoot          = true;
 }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerFireArrow").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(3);
     AS.SetReloadTime(1.5f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 15;
     CanShoot          = true;
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     PCS = GetComponent <PlayerControlScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(1);
     AS.SetReloadTime(.5f);
     PCS.SetPrimaryWeapon(Charge);
     ShotTimer         = 0;
     ShootFireCooldown = 15;
     CanShoot          = true;
     projectile        = Resources.Load("SwordPrefab") as GameObject;
 }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS = GameObject.Find("Main Camera").GetComponent <SoundPlayerScript> ();
     PCS = GetComponent <PlayerControlScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(3);
     AS.SetReloadTime(2f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 15;
     CanShoot          = true;
     projectile        = Resources.Load("SplitProjectilePrefab") as GameObject;
     Trail             = Resources.Load("ShortTrail") as GameObject;
 }
Пример #12
0
    void Shot()
    {
        if (ammo.Length == 0)
        {
            return;
        }
        var        shot = Instantiate(ammo[lvl]) as GameObject; // stop death before adding target
        AmmoScript AS   = shot.GetComponent <AmmoScript>();

        shot.GetComponent <Transform>().position = gameObject.GetComponent <Transform>().position;
        AS.Damage         = damage[lvl];
        AS.Speed          = velocity[lvl];
        AS.Target         = target;
        AS.TargetAssigned = true;
    }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerAssault").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(15);
     AS.SetReloadTime(2f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 4;
     CanShoot          = true;
     //projectile = Resources.Load ("AssultProjectilePrefab") as GameObject;
     //Trail = Resources.Load ("ShortTrail") as GameObject;
 }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
        SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
        PCS = GetComponent <PlayerControlScript> ();
        AS  = GetComponent <AmmoScript>();
        AS.SetSecondaryMagazineSize(2);
        PCS.SetSecondaryWeapon(ShootOutline);
        PCS.SetSecondaryWeaponRelease(Shoot);
        CanShoot   = true;
        projectile = Resources.Load("ShieldPrefab") as GameObject;
        POutline   = Instantiate(projectile, Vector3.zero, Quaternion.identity) as GameObject;
        Color CtoChange = ES.GetColor(PCS.GetPlayerNum());

        CtoChange.a = .75f;
        POutline.GetComponent <SpriteRenderer> ().color = CtoChange;
        POutline.SetActive(false);
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerRng").GetComponent <ObjectPoolScript> ();
     OPGrenade    = GameObject.Find("ObjectPoolerGrenadeRng").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(5);
     AS.SetReloadTime(2f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 20;
     CanShoot          = true;
     projectile        = Resources.Load("RngGunProjectile") as GameObject;
     projectileG       = Resources.Load("GrenadeRngPrefab") as GameObject;
     Trail             = Resources.Load("ShortTrail") as GameObject;
 }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerGrenade").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Cook);
     PCS.SetSecondaryWeaponRelease(Shoot);
     ShotTimer           = 0;
     CookTime            = 0;
     ShootFireCooldown   = 50;
     CanShoot            = true;
     projectile          = Resources.Load("GrenadePrefab") as GameObject;
     Trail               = Resources.Load("ShortTrail") as GameObject;
     GrenadeDetonateTime = projectile.GetComponent <ProjectileScript> ().SelfDestruct;
 }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS = GetComponent <PlayerControlScript> ();
     SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 10;
     CanShoot          = true;
     ProjectileWrapper = Resources.Load("WallProjectileWrapper") as GameObject;
     ProjectileWrapper = Instantiate(ProjectileWrapper, Vector3.zero, Quaternion.identity) as GameObject;
     PrimaryBullet     = ProjectileWrapper.transform.GetChild(0).gameObject;
     SecondaryBullet   = ProjectileWrapper.transform.GetChild(1).gameObject;
     WPS = PrimaryBullet.GetComponent <WallProjectileScript> ();
     PrimaryBullet.SetActive(false);
     SecondaryBullet.SetActive(false);
 }
Пример #18
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerLazer").GetComponent <ObjectPoolScript> ();
     particlesOBJ = Resources.Load("ChargeParticleHolder") as GameObject;
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(6);
     AS.SetReloadTime(3f);
     PCS.SetPrimaryWeapon(Charge);
     PCS.SetPrimaryWeaponRelease(Shoot);
     ShotTimer                  = 0;
     chargeLevel                = 1;
     ShootFireCooldown          = 7;
     CanShoot                   = true;
     particlesOBJ               = Instantiate(particlesOBJ, transform.position, transform.rotation) as GameObject;
     particlesSystem            = particlesOBJ.GetComponentInChildren <ParticleSystem> ();
     particlesSystem.startColor = ES.GetColor(PCS.GetPlayerNum());
     particlesOBJ.SetActive(false);
 }
Пример #19
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        //call AmmoScript.cs
        AmmoScript shot = collider.gameObject.GetComponent <AmmoScript>();

        //check if shot
        if (shot != null)
        {     //check if enemy
            if (shot.isShot != isEnemy)
            { //reduce hp
                hp -= shot.dmg;
                //destroy ammo after use
                Destroy(shot.gameObject);
                //If hp is less than or equal to 0 destroy self gameObject and create sound.
                if (hp <= 0)
                {
                    SoundEffectsScript.Instance.MakeExplosionSound();
                    Destroy(gameObject);
                }
            }
        }
    }
    public virtual void FireShots(GameObject _towerTarget, GameObject _ammoToFire, Transform _ammoSpawnPt, TowerType _type)
    {
        if (isBuilding == false)
        {
            transform.LookAt(_towerTarget.transform.position);

            GameObject ammoSpawn = (GameObject)Instantiate(_ammoToFire,
                                                           _ammoSpawnPt.position, _ammoSpawnPt.rotation);

            AmmoScript ammo = ammoSpawn.GetComponent <AmmoScript> ();
            ammo.AmmoTarget(_towerTarget.transform);
            Destroy(ammoSpawn, 5.0f);

            Debug.Log(_type + " tower is firing...");

            if (!isShooting)
            {
                isShooting = true;
                Invoke("StopFiring", fireRate);
            }
        }
    }
Пример #21
0
    private void OnTriggerEnter2D(Collider2D _col)
    {
        if (currentAmount > 0)
        {
            AmmoScript _ammo = _col.GetComponent <AmmoScript> ();
            //Destroy (_ammo.gameObject);

            if (_ammo.PlayerID == playerID + 1)
            {
                Debug.Log("'ello");
            }
            else
            {
                currentAmount--;                 //-= _ammo.Damage;
                UpdateShieldAlpha();

                Destroy(_ammo.gameObject);

                /* 220418
                 * int _ID = _ammo.PlayerID;
                 *
                 * Destroy (_ammo.gameObject);
                 * currentHP--;
                 *
                 * AdjustAlpha ();
                 * ////
                 *
                 * /*
                 * Color _colour = sprRenderer.color;
                 * float _tmp1 = alphaUnit * shieldHP;
                 * float _tmp2 = _tmp1 / 255;
                 * _colour.a = _tmp2;
                 * sprRenderer.color = _colour;
                 * ////
                 * }
                 * }
                 *
                 * /*
                 * //if (_ID == playerID) {
                 * //print ("hows it hangin?");
                 * //} else {
                 * Destroy (_ammo.gameObject);
                 *
                 * shieldHP--;
                 *
                 * Debug.Log (shieldHP + ", " + alphaUnit);
                 *
                 * Color _colour = sprRenderer.material.color;
                 * //Color _colour = sprRenderer.color;
                 *
                 *
                 *
                 * //_colour.a = alphaUnit * shieldHP;
                 * float _a = (alphaUnit * shieldHP) / 255;
                 *
                 * float _tmp1 = alphaUnit * shieldHP;
                 * float _tmp2 = _tmp1 / 255;
                 *
                 * Debug.Log (alphaUnit + " * " + shieldHP + " = " + alphaUnit * shieldHP);
                 * Debug.Log (alphaUnit * shieldHP + " / " + 255 + " = " + alphaUnit * shieldHP / 255);
                 * Debug.Log (_tmp2);
                 *
                 * _colour.a = _tmp2;
                 *
                 * Debug.Log (_a);
                 *
                 * //sprRenderer.color = new Color (1, 1, 1, _a);
                 * sprRenderer.material.color = _colour;
                 * //}
                 */
            }
        }
    }
Пример #22
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Ammo")
        {
            switch (ID)
            {
            case 0:
            {
                destroy();
                break;
            }

            case 1:
            {
                if (collision.GetComponent <AmmoScript>().canTakeExtraLife == true)
                {
                    collision.GetComponent <AmmoScript>().takeExtraLife();
                    _activated = true;
                }
                break;
            }

            case 2:
            {
                MakeDamageRight();
                GetComponent <Animation>().Play();
                _activated = true;
                break;
            }

            case 3:
            {
                MakeDamageUp();
                GetComponent <Animation>().Play();
                _activated = true;
                break;
            }

            case 4:
            {
                MakeDamageUp();
                MakeDamageRight();
                GetComponent <Animation>().Play();
                _activated = true;
                break;
            }

            case 5:
            {
                destroy();
                break;
            }

            case 6:
            {
                Physics2D.IgnoreLayerCollision(8, 11);
                Physics2D.IgnoreLayerCollision(11, 12);
                Physics2D.IgnoreLayerCollision(11, 11);
                AmmoScript ammo  = collision.GetComponent <AmmoScript>();
                Vector2    dir   = ammo.getDirect();
                float      speed = ammo.getSpeed();
                ammo.ChangeDirect();
                Vector2    position     = ammo.gameObject.transform.position;
                GameObject additiveammo = Instantiate(additiveAmmo, position, Quaternion.identity, canvas.transform);
                additiveammo.GetComponent <AmmoScript>().setParram(dir, speed, _ammoId);
                additiveammo.GetComponent <AmmoScript>().gameManager = _gameManager;
                _ammoId++;
                _gameManager.AddAmmo(additiveammo);
                _activated = true;
                break;
            }

            case 7:
            {
                Vector2 dir;
                int     a;
                a = Random.Range(0, 11);
                int b;
                b = Random.Range(1, 5);
                if (a >= 6)
                {
                    dir = Vector2.up + Vector2.right * b;
                }
                else
                {
                    dir = Vector2.up + Vector2.left * b;
                }
                collision.GetComponent <AmmoScript>().ChangeDirect(dir.normalized);
                _activated = true;
                break;
            }
            }
        }
    }
Пример #23
0
 // Use this for initialization
 void Start()
 {
     ammoScript = ammo.GetComponent <AmmoScript>();
 }
 // Start is called before the first frame update
 void Start()
 {
     ammo           = gameObject.GetComponent <AmmoScript>();
     Cursor.visible = false;
 }