Example #1
0
 // Update is called once per frame
 void Update()
 {
     currentCountdownTime -= Time.deltaTime;
     if (currentCountdownTime <= 0)
     {
         WeaponMine newMine = Instantiate(minePrefab, transform.position, transform.rotation);
         newMine.damageAmount = damage;
         currentCountdownTime = dropTimeFrequency;
     }
 }
Example #2
0
    public void setUpWeapons(PlayerInfo pi)
    {
        weaponHandling.player        = GetComponent <PlayerBase>();
        weaponHandling.specialWeapon = GetComponent <WeaponSpecial>();

        WeaponBase pistol     = new WeaponPistol(pi.charEnum);
        WeaponBase sniper     = new WeaponSniper();
        WeaponBase biogun     = new WeaponBiogun();
        WeaponBase MP40       = new WeaponMP40();
        WeaponBase mine       = new WeaponMine();
        WeaponBase flame      = new WeaponFlamethrower();
        Transform  childFlame = transform.Find("Flame");

        weaponHandling.flamethrower = childFlame.GetComponent <WeaponFlamethrowerLogic>();

        //WeaponBase specialCurie = new WeaponSpecialCurieLogic();
        // Tu sa vytvoria vsetky zbrane ktore sa priradia do weapon handling aby sa nemusel volat zbytocne load na sprajtoch
        //weaponHandling.weapons.Add(WeaponEnum.specialCurie, special);
        WeaponBase special = null;

        switch (pi.charEnum)
        {
        case CharacterEnum.Tesla:
            special = new WeaponTeslaSpecial();
            weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent <BulletManager>(), this, special);
            weaponHandling.weapons.Add(WeaponEnum.specialTesla, special);
            break;

        case CharacterEnum.Curie:
            special = new WeaponCurieSpecial();
            weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent <BulletManager>(), this, special);
            weaponHandling.weapons.Add(WeaponEnum.specialCurie, special);
            break;

        case CharacterEnum.DaVinci:
            special = new WeaponDaVinciSpecial();
            //special = new WeaponTeslaSpecial();
            weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent <BulletManager>(), this, special);
            weaponHandling.weapons.Add(WeaponEnum.specialDaVinci, special);
            //weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
            //weaponHandling.weapons.Add(WeaponEnum.specialTesla, special);
            break;

        case CharacterEnum.Einstein:
            special = new WeaponEinsteinSpecial();
            weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent <BulletManager>(), this, special);
            weaponHandling.weapons.Add(WeaponEnum.specialEinstein, special);
            break;

        case CharacterEnum.Nobel:
            special = new WeaponNobelSpecial();
            weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent <BulletManager>(), this, special);
            weaponHandling.weapons.Add(WeaponEnum.specialNobel, special);
            break;
        }

        weaponHandling.weapons.Add(WeaponEnum.sniper, sniper);
        weaponHandling.weapons.Add(WeaponEnum.pistol, pistol);
        weaponHandling.weapons.Add(WeaponEnum.biogun, biogun);
        weaponHandling.weapons.Add(WeaponEnum.MP40, MP40);
        weaponHandling.weapons.Add(WeaponEnum.mine, mine);
        weaponHandling.weapons.Add(WeaponEnum.flamethrower, flame);


        // Inicializacia prvej zbrane
        weaponHandling.inventory.Add(pistol);
        weaponHandling.inventory.Add(special);
        //weaponHandling.inventory.Add(flame);
        //weaponHandling.inventory.Add(sniper);
        //weaponHandling.inventory.Add(biogun);
        //weaponHandling.inventory.Add(MP40);
        //weaponHandling.inventory.Add(mine);

        weaponHandling.activeWeapon = weaponHandling.inventory[0];
    }
Example #3
0
    public static WeaponBase GetWeapon(WeaponType type)
    {
        // To find a muzzle point:
        //  Add this in fire: Debug.DrawLine(worldMuzzle, worldMuzzle + direction * 5.0f, Color.red, 0.1f);
        //  Adjust for scale and maybe pivot?
        //  Select weapon, ctrl+shift+p to pause
        switch (type)
        {
        case WeaponType.None:
            return(None);

        case WeaponType.Shotgun:
            if (Shotgun == null)
            {
                Shotgun                   = new WeaponShutgun();
                Shotgun.Type              = WeaponType.Shotgun;
                Shotgun.Cd                = 0.5f;
                Shotgun.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                Shotgun.Sprite            = SpriteData.Instance.Shotgun;
                Shotgun.BulletSprite      = SpriteData.Instance.RoundBullet;
                Shotgun.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                Shotgun.FireAudio         = AudioManager.Instance.AudioData.PlayerShotgunFire;
                Shotgun.MoveSpeedModifier = 0.25f;
            }
            return(Shotgun);

        case WeaponType.SuperShotgun:
            if (SuperShotgun == null)
            {
                SuperShotgun                   = new WeaponSuperShutgun();
                SuperShotgun.Type              = WeaponType.SuperShotgun;
                SuperShotgun.Cd                = 0.4f;
                SuperShotgun.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                SuperShotgun.Sprite            = SpriteData.Instance.Shotgun;
                SuperShotgun.BulletSprite      = SpriteData.Instance.RoundBullet;
                SuperShotgun.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                SuperShotgun.FireAudio         = AudioManager.Instance.AudioData.PlayerShotgunFire;
                SuperShotgun.MoveSpeedModifier = 0.25f;
            }
            return(SuperShotgun);

        case WeaponType.SawedShotgun:
            if (SawedShotgun == null)
            {
                SawedShotgun                   = new WeaponSawedShutgun();
                SawedShotgun.Type              = WeaponType.SawedShotgun;
                SawedShotgun.Cd                = 0.4f;
                SawedShotgun.Scale             = new Vector3(1.0f, 4.0f, 1.0f);
                SawedShotgun.Sprite            = SpriteData.Instance.Shotgun;
                SawedShotgun.BulletSprite      = SpriteData.Instance.RoundBullet;
                SawedShotgun.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                SawedShotgun.FireAudio         = AudioManager.Instance.AudioData.PlayerShotgunFire;
                SawedShotgun.MoveSpeedModifier = 0.25f;
            }
            return(SawedShotgun);

        case WeaponType.ShotgunSlug:
            if (ShotgunSlug == null)
            {
                ShotgunSlug                   = new WeaponShutgunSlug();
                ShotgunSlug.Type              = WeaponType.ShotgunSlug;
                ShotgunSlug.Cd                = 0.3f;
                ShotgunSlug.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                ShotgunSlug.Sprite            = SpriteData.Instance.Shotgun;
                ShotgunSlug.BulletSprite      = SpriteData.Instance.RoundBullet;
                ShotgunSlug.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                ShotgunSlug.FireAudio         = AudioManager.Instance.AudioData.PlayerShotgunFire;
                ShotgunSlug.MoveSpeedModifier = 0.5f;
            }
            return(ShotgunSlug);

        case WeaponType.Staff:
            if (Staff == null)
            {
                Staff                   = new WeaponStaff();
                Staff.Type              = WeaponType.Staff;
                Staff.Cd                = 0.3f;
                Staff.Scale             = new Vector3(0.5f, 0.8f, 1.0f);
                Staff.Sprite            = SpriteData.Instance.Staff;
                Staff.BulletSprite      = SpriteData.Instance.Bullet;
                Staff.Muzzle            = new Vector3(1.5f, 0.013f, 0.0f);
                Staff.FireAudio         = AudioManager.Instance.AudioData.PlayerStaffFire;
                Staff.MoveSpeedModifier = 0.8f;
            }
            return(Staff);

        case WeaponType.Staff2:
            if (Staff2 == null)
            {
                Staff2                   = new WeaponStaff2();
                Staff2.Type              = WeaponType.Staff2;
                Staff2.Cd                = 0.5f;
                Staff2.Scale             = new Vector3(0.5f, 0.8f, 1.0f);
                Staff2.Sprite            = SpriteData.Instance.Staff;
                Staff2.BulletSprite      = SpriteData.Instance.Orc;
                Staff2.Muzzle            = new Vector3(1.5f, 0.013f, 0.0f);
                Staff2.FireAudio         = AudioManager.Instance.AudioData.PlayerStaffFire;
                Staff2.MoveSpeedModifier = 0.8f;
            }
            return(Staff2);

        case WeaponType.Sniper:
            if (Sniper == null)
            {
                Sniper                   = new WeaponSniper();
                Sniper.Type              = WeaponType.Sniper;
                Sniper.Cd                = 0.4f;
                Sniper.Scale             = new Vector3(1.5f, 2.0f, 1.0f);
                Sniper.Sprite            = SpriteData.Instance.Sniper;
                Sniper.BulletSprite      = SpriteData.Instance.Bullet;
                Sniper.Muzzle            = new Vector3(0.6f, 0.02f, 0.0f);
                Sniper.FireAudio         = AudioManager.Instance.AudioData.PlayerSniperFire;
                Sniper.MoveSpeedModifier = 0.25f;
            }
            return(Sniper);

        case WeaponType.Machinegun:
            if (Machinegun == null)
            {
                Machinegun                   = new WeaponMachinegun();
                Machinegun.Type              = WeaponType.Machinegun;
                Machinegun.Cd                = 0.08f;
                Machinegun.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                Machinegun.Sprite            = SpriteData.Instance.MachineGun;
                Machinegun.BulletSprite      = SpriteData.Instance.RoundBullet;
                Machinegun.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                Machinegun.FireAudio         = AudioManager.Instance.AudioData.PlayerMachinegunFire;
                Machinegun.MoveSpeedModifier = 0.5f;
            }
            return(Machinegun);

        case WeaponType.Paintball:
            if (Paintball == null)
            {
                Paintball                   = new WeaponPaintball();
                Paintball.Type              = WeaponType.Paintball;
                Paintball.Cd                = 0.2f;
                Paintball.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                Paintball.Sprite            = SpriteData.Instance.MachineGun;
                Paintball.BulletSprite      = SpriteData.Instance.RoundBullet;
                Paintball.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                Paintball.FireAudio         = AudioManager.Instance.AudioData.PlayerPaintballFire;
                Paintball.MoveSpeedModifier = 1.0f;
            }
            return(Paintball);

        case WeaponType.Rambo:
            if (Rambo == null)
            {
                Rambo                   = new WeaponRambo();
                Rambo.Type              = WeaponType.Rambo;
                Rambo.Cd                = 0.07f;
                Rambo.Scale             = new Vector3(1.5f, 4.0f, 1.0f);
                Rambo.Sprite            = SpriteData.Instance.MachineGun;
                Rambo.BulletSprite      = SpriteData.Instance.RoundBullet;
                Rambo.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                Rambo.FireAudio         = AudioManager.Instance.AudioData.PlayerMachinegunFire;
                Rambo.MoveSpeedModifier = 0.0f;
            }
            return(Rambo);

        case WeaponType.Grenade:
            if (Grenade == null)
            {
                Grenade           = new WeaponGrenade();
                Grenade.Type      = WeaponType.Grenade;
                Grenade.Cd        = GrenadeScript.Cd;
                Grenade.FireAudio = AudioManager.Instance.AudioData.PlayerThrowBomb;
            }
            return(Grenade);

        case WeaponType.Mine:
            if (Mine == null)
            {
                Mine           = new WeaponMine();
                Mine.Type      = WeaponType.Mine;
                Mine.Cd        = 0.3f;
                Mine.FireAudio = AudioManager.Instance.AudioData.PlayerThrowBomb;
            }
            return(Mine);

        case WeaponType.Unarmed:
            if (Unarmed == null)
            {
                Unarmed = new WeaponUnarmed();
                Unarmed.MoveSpeedModifier = 1.0f;
                Unarmed.Type      = WeaponType.Unarmed;
                Unarmed.FireAudio = AudioManager.Instance.AudioData.UnarmedBlast;
                Unarmed.Cd        = 0.5f;
            }
            return(Unarmed);

        case WeaponType.Horn:
            if (Horn == null)
            {
                Horn           = new WeaponHorn();
                Horn.Type      = WeaponType.Horn;
                Horn.Cd        = 2.0f;
                Horn.FireAudio = AudioManager.Instance.AudioData.OrcHorn;
            }
            return(Horn);

        case WeaponType.Sword1:
            if (Sword == null)
            {
                Sword                   = new WeaponSword();
                Sword.Type              = WeaponType.Sword1;
                Sword.Cd                = 0.3f;
                Sword.FireAudio         = AudioManager.Instance.AudioData.SaberSwing;
                Sword.MoveSpeedModifier = 0.0f;
            }
            return(Sword);

        case WeaponType.Yoda:
            if (Yoda == null)
            {
                Yoda      = new WeaponYoda();
                Yoda.Type = WeaponType.Yoda;
            }
            return(Yoda);

        case WeaponType.Sawblade:
            if (Sawblade == null)
            {
                Sawblade                   = new WeaponSawblade();
                Sawblade.Type              = WeaponType.Sawblade;
                Sawblade.Cd                = 1.0f;
                Sawblade.BulletSprite      = SpriteData.Instance.Sawblade;
                Sawblade.Muzzle            = new Vector3(0.5f, 0.013f, 0.0f);
                Sawblade.FireAudio         = AudioManager.Instance.AudioData.PlayerThrowBomb;
                Sawblade.MoveSpeedModifier = 0.2f;
            }
            return(Sawblade);

        //case WeaponType.Flamethrower:
        //    if (Flamethrower == null)
        //    {
        //        Flamethrower = new WeaponFlamethrower();
        //        Flamethrower.Type = WeaponType.Flamethrower;
        //        Flamethrower.Cd = 0.05f;
        //        Flamethrower.Scale = new Vector3(1.5f, 2.0f, 1.0f);
        //        Flamethrower.Sprite = SpriteData.Instance.Flamethrower;
        //        Flamethrower.BulletSprite = SpriteData.Instance.RoundBullet;
        //        Flamethrower.Muzzle = new Vector3(0.6f, 0.02f, 0.0f);
        //        Flamethrower.FireAudio = AudioManager.Instance.AudioData.PlayerFlamethrowerFire;
        //        Flamethrower.MoveSpeedModifier = 0.5f;
        //    }
        //return Flamethrower;

        default:
            Debug.LogError("Unknown weapon type: " + type.ToString());
            return(Shotgun);
        }
    }
Example #4
0
    public void setUpWeapons(PlayerInfo pi)
    {
        weaponHandling.player = GetComponent<PlayerBase>();
        weaponHandling.specialWeapon = GetComponent<WeaponSpecial>();

        WeaponBase pistol = new WeaponPistol(pi.charEnum);
        WeaponBase sniper = new WeaponSniper();
        WeaponBase biogun = new WeaponBiogun();
        WeaponBase MP40 = new WeaponMP40();
        WeaponBase mine = new WeaponMine();
        WeaponBase flame = new WeaponFlamethrower();
        Transform childFlame = transform.Find("Flame");
        weaponHandling.flamethrower = childFlame.GetComponent<WeaponFlamethrowerLogic>();

        //WeaponBase specialCurie = new WeaponSpecialCurieLogic();
        // Tu sa vytvoria vsetky zbrane ktore sa priradia do weapon handling aby sa nemusel volat zbytocne load na sprajtoch
        //weaponHandling.weapons.Add(WeaponEnum.specialCurie, special);
        WeaponBase special = null;

        switch (pi.charEnum)
        {
            case CharacterEnum.Tesla:
                special = new WeaponTeslaSpecial();
                weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                weaponHandling.weapons.Add(WeaponEnum.specialTesla, special);
                break;
            case CharacterEnum.Curie:
                special = new WeaponCurieSpecial();
                weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                weaponHandling.weapons.Add(WeaponEnum.specialCurie, special);
                break;
            case CharacterEnum.DaVinci:
                special = new WeaponDaVinciSpecial();
                //special = new WeaponTeslaSpecial();
                weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                weaponHandling.weapons.Add(WeaponEnum.specialDaVinci, special);
                //weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                //weaponHandling.weapons.Add(WeaponEnum.specialTesla, special);
                break;
            case CharacterEnum.Einstein:
                special = new WeaponEinsteinSpecial();
                weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                weaponHandling.weapons.Add(WeaponEnum.specialEinstein, special);
                break;
            case CharacterEnum.Nobel:
                special = new WeaponNobelSpecial();
                weaponHandling.specialWeapon.SetUp(pi, transform.parent.GetComponent<BulletManager>(), this, special);
                weaponHandling.weapons.Add(WeaponEnum.specialNobel, special);
                break;
        }

        weaponHandling.weapons.Add(WeaponEnum.sniper, sniper);
        weaponHandling.weapons.Add(WeaponEnum.pistol, pistol);
        weaponHandling.weapons.Add(WeaponEnum.biogun, biogun);
        weaponHandling.weapons.Add(WeaponEnum.MP40, MP40);
        weaponHandling.weapons.Add(WeaponEnum.mine, mine);
        weaponHandling.weapons.Add(WeaponEnum.flamethrower, flame);

        // Inicializacia prvej zbrane
        weaponHandling.inventory.Add(pistol);
        weaponHandling.inventory.Add(special);
        //weaponHandling.inventory.Add(flame);
        //weaponHandling.inventory.Add(sniper);
        //weaponHandling.inventory.Add(biogun);
        //weaponHandling.inventory.Add(MP40);
        //weaponHandling.inventory.Add(mine);

        weaponHandling.activeWeapon = weaponHandling.inventory[0];
    }