public void WeaponModuleShootWeapon()
        {
            if (CurrentWeapon == null)
            {
                return;
            }
            WeaponPistol weaponPistol = CurrentWeapon as WeaponPistol;

            if (weaponPistol == null)
            {
                return;
            }
            weaponPistol.WeaponPistolMono.ShowMuzzle();
            Debug.Log("Actual Fire!");

            Ray ray = new Ray(RightHandTransform.position,
                              _facadeHuman.TransformModule.MainTransform.forward);

            Debug.DrawRay(RightHandTransform.position,
                          _facadeHuman.TransformModule.MainTransform.forward * 100f);

            RaycastHit[] hits = Physics.RaycastAll(ray,
                                                   100.0F, _layerMask, queryTriggerInteraction);

            foreach (var hit in hits)
            {
                ColliderHumanPart chm = hit.collider.gameObject.GetComponent <ColliderHumanPart>();
                if (chm != null)
                {
                    chm.Foo();
                }
            }
        }
Beispiel #2
0
    private void InitWeaponInstances()
    {
        _weaponPlacementDictionary = new Dictionary <WeaponType, WeaponPlacement>();

        WeaponKnife knife = Instantiate(_weaponList.GetWeaponList().Knife);

        knife.transform.parent        = _rightHandSocket;
        knife.transform.localPosition = Vector3.zero;
        WeaponPlacement wk = new WeaponPlacement(_knifeSocket, knife);

        _weaponPlacementDictionary.Add(WeaponType.Knife, wk);

        WeaponPistol pistol = Instantiate(_weaponList.GetWeaponList().Pistol);

        pistol.transform.parent        = _pistolSocket;
        pistol.transform.localPosition = Vector3.zero;
        pistol.transform.rotation      = _pistolSocket.rotation;
        WeaponPlacement wp = new WeaponPlacement(_pistolSocket, pistol);

        _weaponPlacementDictionary.Add(WeaponType.Pistol, wp);

        WeaponRifle rifle = Instantiate(_weaponList.GetWeaponList().Rifle);

        rifle.transform.parent        = _rifleSocket;
        rifle.transform.localPosition = Vector3.zero;
        rifle.transform.localRotation = _pistolSocket.rotation;
        WeaponPlacement wr = new WeaponPlacement(_rifleSocket, rifle);

        _weaponPlacementDictionary.Add(WeaponType.Rifle, wr);
    }
    // Start is called before the first frame update
    void Start()
    {
        _PistolComponent = GetComponent <WeaponPistol>();
        _PistolComponent.WeaponSetup(PistolMaxAmmo, PistolBulletPrefab, PistolSprite, PistolBulletSpeed);
        _ShotgunComponent = GetComponent <WeaponShotgun>();
        _ShotgunComponent.WeaponSetup(ShotgunMaxAmmo, ShotgunBulletPrefab, ShotgunSprite, ShotgunBulletSpeed, SpreadAngle, BulletsPerShot);
        _GrenadeLauncherComponent = GetComponent <WeaponGrenadeLauncher>();
        _GrenadeLauncherComponent.WeaponSetup(GrenadeLauncherMaxAmmo, GrenadeLauncherBulletPrefab, GrenadeLauncherSprite, GrenadeLauncherBulletSpeed);

        CurrentWeapon = GetComponent <WeaponPistol>();
        SwitchWeapon(CurrentWeaponType);
    }
Beispiel #4
0
    void Start()
    {
        pAlive       = true;
        rb           = GetComponent <Rigidbody>();
        playerHealth = 100;

        // Makes a temp game object for setting up pistol
        // Assigns the temp to pistol.
        GameObject temp = GameObject.FindGameObjectWithTag("Pistol");

        pistol        = temp.GetComponent <WeaponPistol>();
        mgun          = GameObject.FindGameObjectWithTag("MG").GetComponent <WeaponMachineGun>();
        flamer        = GameObject.FindGameObjectWithTag("Flamethrower").GetComponent <WeaponFlameThrower>();
        inventory     = new Inventory();
        currentWeapon = null;

        // Disable mounts until weapons are picked up.
        pistol.gameObject.SetActive(false);
        mgun.gameObject.SetActive(false);
        flamer.gameObject.SetActive(false);
    }
Beispiel #5
0
    void Start()
    {
        base.playerNumber = 2;
        //createBullets();

        //base.character = CharacterEnum.Tesla;


        base.speed     = 2f;
        base.direction = base.right;

        SetControlKeys(KeyCode.Keypad8, KeyCode.Keypad4, KeyCode.Keypad5, KeyCode.Keypad6, KeyCode.Keypad7, KeyCode.Keypad9);

        base.rb2d = gameObject.GetComponent <Rigidbody2D>();

        base.pressedKeys = new List <KeyCode>();
        base.inventory   = new List <WeaponBase>();

        WeaponBase pistol = new WeaponPistol();

        base.inventory.Add(pistol);
        base.activeWeapon = base.inventory[0];
    }
Beispiel #6
0
        public void Weapon_Fire_CreatesBullets()
        {
            Weapon w = new WeaponAdvancedAR();

            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponAdvancedShotgun();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponAR();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponKnife();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponPistol();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponPistolShield();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);

            w = new WeaponShotgun();
            Assert.IsTrue(w.Fire(Vector2.One).Count > 0);
        }
Beispiel #7
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];
    }
Beispiel #8
0
 public WeaponListModel(WeaponKnife knife, WeaponPistol pistol, WeaponRifle rifle)
 {
     Knife  = knife;
     Pistol = pistol;
     Rifle  = rifle;
 }
Beispiel #9
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];
    }