示例#1
0
    private void Start()
    {
        if (gameObject.GetComponent <CreateNewAmmo>())
        {
            CreateNewAmmo a = gameObject.GetComponent <CreateNewAmmo>();
            itemAmmo = a.NewAmmo;
            Destroy(a);
        }
        Transform _weight = gameObject.transform.Find("Weight");
        Transform _name   = gameObject.transform.Find("Type");

        switch (itemAmmo.AmmoTypes)
        {
        case BaseAmmo.AmmoType.HandgunAmmo:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.hgAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.hgAmmoWeight * PlayerStats.hgAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.ShotgunShells:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.sgAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.sgAmmoWeight * PlayerStats.sgAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.RifleAmmo:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.rifleAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.rifleAmmoWeight * PlayerStats.rifleAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.AssaultRifleAmmo:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.arAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.arAmmoWeight * PlayerStats.arAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.MachinegunAmmo:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.mgAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.mgAmmoWeight * PlayerStats.mgAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.MagnumAmmo:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.magnumAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.magnumAmmoWeight * PlayerStats.magnumAmmo) * 100) / 100).ToString() + " lbs";
            break;

        case BaseAmmo.AmmoType.ExplosiveRounds:
            _name.GetComponent <Text>().text   = itemAmmo.ItemName + "(" + PlayerStats.explosiveAmmo + ")";
            _weight.GetComponent <Text>().text = (Mathf.Round((PlayerStats.explosiveAmmoWeight * PlayerStats.explosiveAmmo) * 100) / 100).ToString() + " lbs";
            break;
        }
    }
        public MovingTurretShot(Game game, BaseTurret emitter)
            : base(game)
        {
            // TODO: Construct any child components here
            ammo = emitter.CurrentAmmoType;

            maxSpeed = ammo.baseSpeed * emitter.ammoSpeedModifier;
            acceleration = ammo.baseAcceleration * emitter.ammoAccelerationModifier;
            lifetime_ms = ammo.baseLifetime_ms * emitter.ammoLifetimeModifier;
            damage = ammo.baseDamage * emitter.ammoDamageModifier;

            position = emitter.EntrancePoint;
            center = new Vector2(ammo.texture.Width / 2, ammo.texture.Height);

            rotation = emitter.rotation;
            moveDirection = new Vector2((float)-Math.Sin(rotation), (float)-Math.Cos(rotation));
            // ToDo: Mit drehung des turrets syncen

            currentSpeed = 0.0f;
        }
示例#3
0
        public MovingTurretShot(Game game, BaseTurret emitter)
            : base(game)
        {
            // TODO: Construct any child components here
            ammo = emitter.CurrentAmmoType;

            maxSpeed     = ammo.baseSpeed * emitter.ammoSpeedModifier;
            acceleration = ammo.baseAcceleration * emitter.ammoAccelerationModifier;
            lifetime_ms  = ammo.baseLifetime_ms * emitter.ammoLifetimeModifier;
            damage       = ammo.baseDamage * emitter.ammoDamageModifier;

            position = emitter.EntrancePoint;
            center   = new Vector2(ammo.texture.Width / 2, ammo.texture.Height);

            rotation      = emitter.rotation;
            moveDirection = new Vector2((float)-Math.Sin(rotation), (float)-Math.Cos(rotation));
            // ToDo: Mit drehung des turrets syncen

            currentSpeed = 0.0f;
        }
示例#4
0
    }         //end of function

    public void PickedUpAmmo(BaseAmmo myAmmo)
    {
        itemAmmo = myAmmo;
        Transform _weight = gameObject.transform.Find("Weight");
        Transform _name   = gameObject.transform.Find("Type");

        _weight.GetComponent <Text>().text = itemAmmo.Weight.ToString() + " lbs";
        switch (itemAmmo.AmmoTypes)
        {
        case BaseAmmo.AmmoType.HandgunAmmo:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.hgAmmo + ")";
            break;

        case BaseAmmo.AmmoType.ShotgunShells:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.sgAmmo + ")";
            break;

        case BaseAmmo.AmmoType.RifleAmmo:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.rifleAmmo + ")";
            break;

        case BaseAmmo.AmmoType.AssaultRifleAmmo:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.arAmmo + ")";
            break;

        case BaseAmmo.AmmoType.MachinegunAmmo:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.mgAmmo + ")";
            break;

        case BaseAmmo.AmmoType.MagnumAmmo:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.magnumAmmo + ")";
            break;

        case BaseAmmo.AmmoType.ExplosiveRounds:
            _name.GetComponent <Text>().text = itemAmmo.ItemName + "(" + PlayerStats.explosiveAmmo + ")";
            break;
        }
        itemAmmo.Quantity = 0;
    }
示例#5
0
    public void SetWeapon(int s)
    {
        foreach (BaseWeapon bw in allWeapons)
        {
            if (s == bw.weaponID)
            {
                currWeapon = allWeapons[s];
                sr.sprite  = currWeapon.sprite;

                foreach (BaseAmmo ba in allAmmos)
                {
                    if (ba.ammoType == currWeapon.bulletType)
                    {
                        currAmmo         = ba;
                        ammoImage.sprite = currAmmo.sprite;
                        break;
                    }
                }

                shootSpeedReal = 0f;
                break;
            }
        }
    }
示例#6
0
文件: Gun.cs 项目: vrtex/Astro-Monkey
 public bool RestoreAmmo(BaseAmmo ammoPack)
 {
     return(RestoreAmmo(ammoPack.ProjectileType, ammoPack.Count));
 }
示例#7
0
 public void DropAmmo(BaseAmmo myAmmo)
 {
     dropAmmo = myAmmo;
     gameObject.GetComponent <AmmoDisplay>().myText.text = dropAmmo.AmmoTypes.ToString();
 }
示例#8
0
 public abstract Vector AmmoRespawnSpot(BaseAmmo pAmmo);
示例#9
0
 public abstract float AmmoRespawnTime(BaseAmmo pAmmo);
示例#10
0
 public abstract AmmoRespawn AmmoShouldRespawn(BaseAmmo pAmmo);
示例#11
0
 public void TransferData(BaseAmmo ammo)
 {
     shopAmmo = ammo;
 }
示例#12
0
    public void CreateAmmo()
    {
        newAmmo        = new BaseAmmo();
        newAmmo.ItemID = Random.Range(0, 10000);
        int temp = Random.Range(0, 7);

        newAmmo.MapIcon = Resources.Load <Sprite>("Icons/MapIcons/Ammo");
        switch (temp)
        {
        default:
            newAmmo.SellValue = 2;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.HandgunAmmo;
            //assigning the name
            newAmmo.ItemName = "Handgun Bullets";
            newAmmo.ItemDesc = "9mm handgun bullets.";
            newAmmo.Quantity = Random.Range(5, 10);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.hgAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Handgun");
            break;

        case 1:
            newAmmo.SellValue = 5;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.ShotgunShells;
            //assigning the name
            newAmmo.ItemName = "Shotgun Shells";
            newAmmo.ItemDesc = "12 gauge shells.";
            newAmmo.Quantity = Random.Range(1, 3);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.sgAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Shotgun");
            break;

        case 2:
            newAmmo.SellValue = 4;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.RifleAmmo;
            //assigning the name
            newAmmo.ItemName = "Rifle Rounds";
            newAmmo.ItemDesc = "30 caliber rounds.";
            newAmmo.Quantity = Random.Range(1, 3);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.rifleAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Rifle");
            break;

        case 3:
            newAmmo.SellValue = 1;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.MachinegunAmmo;
            //assigning the name
            newAmmo.ItemName = "Machinegun Bullets";
            newAmmo.ItemDesc = ".40 carbine bullets.";
            newAmmo.Quantity = Random.Range(10, 20);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.mgAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Machinegun");
            break;

        case 4:
            newAmmo.SellValue = 2;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.AssaultRifleAmmo;
            //assigning the name
            newAmmo.ItemName = "Assault Rifle Bullets";
            newAmmo.ItemDesc = "5.56 NATO rounds.";
            newAmmo.Quantity = Random.Range(5, 15);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.arAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/AssaultRifle");
            break;

        case 5:
            newAmmo.SellValue = 8;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.MagnumAmmo;
            //assigning the name
            newAmmo.ItemName = "Magnum Rounds";
            newAmmo.ItemDesc = ".357 magnum rounds.";
            newAmmo.Quantity = Random.Range(1, 2);
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.magnumAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Magnum");
            break;

        case 6:
            newAmmo.SellValue = 12;
            newAmmo.AmmoTypes = BaseAmmo.AmmoType.ExplosiveRounds;
            //assigning the name
            newAmmo.ItemName = "Explosive Rounds";
            newAmmo.ItemDesc = "These can be used with the heavier artilery.";
            newAmmo.Quantity = 1;
            newAmmo.Weight   = newAmmo.Quantity * PlayerStats.explosiveAmmoWeight;
            newAmmo.Icon     = Resources.Load <Sprite>("Icons/Ammo/Explosive");
            break;
        }
    }
示例#13
0
 public override Vector AmmoRespawnSpot(BaseAmmo pAmmo)
 {
     return(pAmmo.Origin);
 }
示例#14
0
 public override float AmmoRespawnTime(BaseAmmo pAmmo)
 {
     return(-1);
 }
示例#15
0
 public override AmmoRespawn AmmoShouldRespawn(BaseAmmo pAmmo)
 {
     return(AmmoRespawn.No);
 }