//--------------------------------------------------------------------------------------
    // initialization.
    //--------------------------------------------------------------------------------------
    void Awake()
    {
        m_aAnimator     = GetComponent <Animator>();
        m_asAudioSource = GetComponent <AudioSource>();
        // initilising animation booleans to false
        m_bFireAni   = false;
        m_bDamageAni = false;

        // set boolean for moving to false
        m_bMovingAni = false;

        // get the soldiers rigidbody
        m_rbRigidBody = GetComponent <Rigidbody>();
        // get the rocketlaunchers script
        m_gLauncherScript = m_gRocketLauncher.GetComponent <RocketLauncher>();
        // get the grenadeLaunchers script
        m_gGrenadeScript = m_gGrenadeLauncher.GetComponent <GrenadeLauncher>();
        // Soldiers Current health should always start at MaxHealth
        m_fCurrentHealth = m_fMaxHealth;
        // so the soldiers cannot move upwards
        m_rbRigidBody.constraints = RigidbodyConstraints.FreezePositionY;
        // so the soldier doesn't rotate unless it is to FaceMouse()
        m_rbRigidBody.freezeRotation = true;

        // Instantiate and setActive of MovementCircle to false.
        m_gMovementCircle = Instantiate(m_gMovementCirlceBluePrint);
        m_gMovementCircle.SetActive(false);

        // Set the Current position to the soldiers postion.
        m_v3CurrentPostion = transform.position;

        // Make the size of the MovementCircle the same as the MovementRadius.
        m_gMovementCircle.transform.localScale *= m_fMovementRadius;
    }
예제 #2
0
    protected void Start()
    {
        grenade     = GetComponent <GrenadeLauncher>();
        audioSource = GetComponent <AudioSource>();

        ChangeState(SkeletonStates.Patrol);
    }
예제 #3
0
 public void NewGame()
 {
     _index                 = 0;
     health                 = 6;
     HealthText.text        = health.ToString();
     currentGrenadeLauncher = GrenadeLaunchers[_index];
     CameraController.SwitchCameraTo((int)_index);
     StartCoroutine(StartStage());
 }
예제 #4
0
 private void Awake()
 {
     rb              = GetComponent <Rigidbody2D>();
     boxCollider2D   = GetComponent <BoxCollider2D>();
     sword           = GetComponent <Sword>();
     grenadeLauncher = GetComponent <GrenadeLauncher>();
     audioSource     = GetComponent <AudioSource>();
     spriteRenderer  = GetComponentInChildren <SpriteRenderer>();
 }
예제 #5
0
        static void Main(string[] args)
        {
            IWeapon gun = new Gun("M4A1");

            var scopedGun = new GrenadeLauncher(new ButtStock(new ExtendedMag(new Scope(gun))));


            scopedGun.Fire();
        }
예제 #6
0
 private void SwitchStage()
 {
     _index++;
     currentGrenadeLauncher = GrenadeLaunchers[_index];
     CameraController.SwitchCameraTo((int)_index);
     if (_index < 4)
     {
         StartCoroutine(StartStage());
     }
 }
예제 #7
0
    void fireWeapon(float fireTime)
    {
        fireEnabled = false;

        GrenadeLauncher grenadeLauncher = GetComponent <GrenadeLauncher>();
        Vector3         grenadePosition = transform.position + Vector3.Scale(Vector3.one, transform.forward) + new Vector3(0, 1f, 0);
        GameObject      grenade         = Instantiate(grenadePrefab, grenadePosition, Quaternion.identity) as GameObject;

        grenadeLauncher.fire(grenade, grenadePosition, transform.forward, fireTime);

        StartCoroutine(EnableFire());
    }
예제 #8
0
        //Evénement détache la grenade de la main du joeur et la lancer
        public void DettachGrenade()
        {
            PLayer_Stats.ThrowedGrened.transform.parent = null;

            GrenadeLauncher Gl = PLayer_Stats.ThrowedGrened.GetComponent <GrenadeLauncher>();
            Exploid         Ep = PLayer_Stats.ThrowedGrened.GetComponent <Exploid>();

            Ep.Lunched = true;



            // Gl.target = PLayer_Stats.Grenade_Zone;
            Gl.Launch();
            PLayer_Stats.ThrowedGrened.AddComponent <CapsuleCollider>();
        }
예제 #9
0
    public ItemLibrary()
    {
        this.items = new Hashtable();

        GrenadeLauncher gl = new GrenadeLauncher();

        gl.Buy();

        this.items.Add("LazerCannon", new LazerCannon());
        this.items.Add("GrenadeLauncher", gl);
        this.items.Add("ResistanceEnhancement", new ResistanceEnhancement());
        this.items.Add("MedicalKit", new MedicalKit());
        this.items.Add("JumpPack", new JumpPack());
        this.items.Add("RushBoots", new RushBoots());
        this.items.Add("SpeedBoots", new SpeedBoots());
    }
예제 #10
0
 public Demoman()
 {
     _weapon1    = new GrenadeLauncher();
     _weapon2    = new PipebombLauncher();
     _weapon3    = new Shotgun();
     _weapon4    = new Axe();
     _gren1      = Ammunition.FragGrenade;
     _gren2      = Ammunition.MIRVGrenade;
     _health     = 90;
     _armour     = 120;
     _maxShells  = 50;
     _maxNails   = 50;
     _maxRockets = 50;
     _maxCells   = 50;
     _maxGren1   = 4;
     _maxGren2   = 4;
 }
예제 #11
0
    public void ReceiveInventory(int index, int weaponID)
    {
        switch ((WeaponList)weaponID)
        {
        case WeaponList.Pistol:
            inventory[index] = new Pistol(this, Map);
            break;

        case WeaponList.Rifle:
            inventory[index] = new Rifle(this, Map);
            break;

        case WeaponList.GrenadeLauncher:
            inventory[index] = new GrenadeLauncher(this, Map);
            break;

        case WeaponList.Bow:
            inventory[index] = new Bow(this, Map);
            break;
        }
    }
예제 #12
0
 void Start()
 {
     grScript = grenade.GetComponent <GrenadeLauncher>();
 }
예제 #13
0
    // Start is called before the first frame update
    void Start()
    {
        this.Choices = GameObject.Find("ChoosenWeapons");
        this.Weapons = GameObject.Find("Weapons");
        this.snipper = Weapons.transform.Find("SnipperRiffel").gameObject;
        this.assault = Weapons.transform.Find("AssultRiffel").gameObject;
        this.gun     = Weapons.transform.Find("ShotGun").gameObject;
        this.rocket  = Weapons.transform.Find("RPG7").gameObject;
        this.grenade = Weapons.transform.Find("TGL").gameObject;

        this.isSnipper = Choices.GetComponent <WeaponChoose>().getData()[0];
        this.isAssault = Choices.GetComponent <WeaponChoose>().getData()[1];
        this.isGun     = Choices.GetComponent <WeaponChoose>().getData()[2];
        this.isRocket  = Choices.GetComponent <WeaponChoose>().getData()[3];
        this.isGrenade = Choices.GetComponent <WeaponChoose>().getData()[4];

        //Snipper riffel
        if (isSnipper)
        {
            sr = this.snipper.GetComponent <sniperRifle>();
        }
        else
        {
            Destroy(this.snipper);
            this.assault.SetActive(true);
        }
        //assult riffel
        if (isAssault)
        {
            ar = this.assault.GetComponent <assaultRifle>();
        }
        else
        {
            Destroy(this.assault);
            this.gun.SetActive(true);
        }
        //shot gun
        if (isGun)
        {
            sg = this.gun.GetComponent <shotgun>();
        }
        else
        {
            Debug.Log("Destroying the shootgun");
            Destroy(this.gun);
        }
        //RocketLauncher
        if (isRocket)
        {
            rl = this.rocket.GetComponent <RocketLauncher>();
        }
        else
        {
            Destroy(this.rocket);
        }
        //GrenadeLauncher
        if (isGrenade)
        {
            gl = this.grenade.GetComponent <GrenadeLauncher>();
        }
        else
        {
            Destroy(this.grenade);
        }

        /*if (isSnipper)
         * {
         *  Debug.Log("Setting snipper");
         *  sr = Weapons.GetComponent<sniperRifle>();
         *  GameObject test = Weapons.transform.Find("SnipperRiffel").gameObject;
         *  sr = (sniperRifle)test;
         *
         * }
         * else
         * {
         *  // DestroyImmediate(Weapons.GetComponent<sniperRifle>().gameObject);
         *  Destroy(Weapons.transform.Find("SnipperRiffel").gameObject);
         * }
         * //assult riffel
         * if (isAssault)
         * {
         *  //ar = Weapons.GetComponent<assaultRifle>();
         *  ar = (assaultRifle)Weapons.transform.Find("AssultRiffel").gameObject;
         *
         * }
         * else
         * {
         *  //DestroyImmediate(Weapons.GetComponent<assaultRifle>().gameObject);
         *  Destroy(Weapons.transform.Find("AssultRiffel").gameObject);
         * }
         * //shot gun
         * if (isGun)
         * {
         *
         *  //sg = Weapons.GetComponent<shotgun>();
         *  sg = (shotgun)Weapons.transform.Find("ShotGun").gameObject;
         * }
         * else
         * {
         *  Debug.Log("Destroying the shootgun");
         *  //DestroyImmediate(Weapons.GetComponent<shotgun>().gameObject);
         *  Destroy(Weapons.transform.Find("ShotGun").gameObject);
         * }
         * //RocketLauncher
         * if (isRocket)
         * {
         *  //rl = Weapons.GetComponent<RocketLauncher>();
         *  rl = (RocketLauncher)Weapons.transform.Find("RPG7").gameObject;
         * }
         * else
         * {
         *  //DestroyImmediate(Weapons.GetComponent<RocketLauncher>().gameObject);
         *  Destroy(Weapons.transform.Find("RPG7").gameObject);
         * }*/
    }
예제 #14
0
 private void Awake()
 {
     launcher = FindObjectOfType <GrenadeLauncher>();
 }
예제 #15
0
파일: Player.cs 프로젝트: lordee/godotfps
    private Weapon SetupWeapon(WEAPONTYPE weapon)
    {
        Weapon weap = null;

        switch (weapon)
        {
        case WEAPONTYPE.SYRINGE:
            weap = new Syringe();
            break;

        case WEAPONTYPE.AXE:
            weap = new Axe();
            break;

        case WEAPONTYPE.SHOTGUN:
            weap = new Shotgun();
            break;

        case WEAPONTYPE.SUPERSHOTGUN:
            weap = new SuperShotgun();
            break;

        case WEAPONTYPE.NAILGUN:
            weap = new NailGun();
            break;

        case WEAPONTYPE.SUPERNAILGUN:
            weap = new SuperNailGun();
            break;

        case WEAPONTYPE.GRENADELAUNCHER:
            weap = new GrenadeLauncher();
            break;

        case WEAPONTYPE.PIPEBOMBLAUNCHER:
            weap = new PipebombLauncher();
            break;

        case WEAPONTYPE.ROCKETLAUNCHER:
            weap = new RocketLauncher();
            break;

        case WEAPONTYPE.MINIGUN:
            weap = new Minigun();
            break;

        case WEAPONTYPE.INCENDIARYCANNON:
            weap = new IncendiaryCannon();
            break;

        case WEAPONTYPE.FLAMETHROWER:
            weap = new Flamethrower();
            break;

        case WEAPONTYPE.NONE:
        default:

            break;
        }

        if (weap != null)
        {
            weap.Init(_game);
            weap.Spawn(this, nameof(weap));
        }

        return(weap);
    }
예제 #16
0
    // Start is called before the first frame update
    void Start()
    {
        ChoosenWeapons = GameObject.Find("ChoosenWeapons").GetComponent <WeaponChoose>().getData();
        //SnipperRiffel
        if (ChoosenWeapons[0])
        {
            sr = transform.GetChild(0).GetComponent <sniperRifle>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(0).gameObject);
            this.GetComponent <Transform>().GetChild(1).gameObject.SetActive(true);
        }

        //AssultRiffel
        if (ChoosenWeapons[1])
        {
            ar = transform.GetChild(1).GetComponent <assaultRifle>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(1).gameObject);
            GetComponent <Transform>().GetChild(2).gameObject.SetActive(true);
        }

        //Shotgun
        if (ChoosenWeapons[2])
        {
            sg = transform.GetChild(2).GetComponent <shotgun>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(2).gameObject);
        }

        //RocketLauncher
        if (ChoosenWeapons[3])
        {
            rl = GetComponent <Transform>().GetChild(3).GetComponent <RocketLauncher>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(3).gameObject);
        }

        //GrenadeLauncher
        if (ChoosenWeapons[4])
        {
            gl = GetComponent <Transform>().GetChild(4).GetComponent <GrenadeLauncher>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(4).gameObject);
        }

        //weapon Titan Legon
        if (ChoosenWeapons[5])
        {
            lw = GetComponent <Transform>().GetChild(5).GetComponent <LegionWeapon>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(5).gameObject);
        }

        //weapon Titan Ion
        if (ChoosenWeapons[6])
        {
            ion = GetComponent <Transform>().GetChild(6).GetComponent <IonScript>();
        }
        else
        {
            Destroy(GetComponent <Transform>().GetChild(6).gameObject);
        }
    }
예제 #17
0
    public void TriggerScript()
    {
        Ray posit = cam.ScreenPointToRay(Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(posit, out hit, 5f))
        {
            // get object that player is currenlty aiming at
            if (hit.collider.GetComponent <Rigidbody>() != null)
            {
                // and apply its script
                Rigidbody col = hit.collider.GetComponent <Rigidbody>();
                if (col.GetComponent <PickUp>() != null && !pickedUpItem)
                {
                    puItem = col.GetComponent <PickUp>();
                    puItem.PickUpItem();
                    pickedUpItem = true;
                }
                else if (col.GetComponent <AmmoBox>() != null && reloadReady)
                {
                    AmmoBox oc = col.GetComponent <AmmoBox>();
                    oc.Reload();
                    reloadReady = false;
                }
                else if (col.GetComponent <Bell>() != null && !rangBell)
                {
                    Bell bell = col.GetComponent <Bell>();
                    bell.RingBell();
                    rangBell = true;
                }
                else if (col.GetComponent <BridgeCranck>() != null && !bridgeUp)
                {
                    BridgeCranck bc = col.GetComponent <BridgeCranck>();
                    bc.CranckIt();
                    bridgeUp = true;
                }
                else if (col.GetComponent <BazookaMechanics>() != null)
                //else if (hand.transform.childCount == 0 && col.GetComponent<BazookaMechanics>() != null)
                {
                    BazookaMechanics  bm = col.GetComponent <BazookaMechanics>();
                    DynamiteMechanics dm = player.GetComponent <DynamiteMechanics>();
                    dm.DisableRestrictions();
                    player.GetComponent <DynamiteMechanics>().enabled = false;
                    bm.PickUp();
                }
                else if (col.name.Contains("Dynamite"))
                {
                    if (hand.transform.childCount > 0)
                    {
                        hand.transform.DetachChildren();
                    }
                    //restrict gravity and position object into players hands
                    col.transform.GetComponent <CapsuleCollider>().enabled = false;
                    col.transform.SetParent(GameObject.Find("RightHand").transform);
                    col.GetComponent <Rigidbody>().constraints          = RigidbodyConstraints.FreezeAll;
                    col.transform.GetComponent <Rigidbody>().useGravity = false;
                    col.transform.position         = hand.transform.position;
                    col.transform.localEulerAngles = new Vector3(-90, 0, 0);
                    player.GetComponent <DynamiteMechanics>().enabled = true;

                    Destroy(GameObject.Find("DynamiteObject"));
                }
                else if (col.GetComponent <GrenadeLauncher>() != null)
                {
                    GrenadeLauncher   gl = col.GetComponent <GrenadeLauncher>();
                    DynamiteMechanics dm = player.GetComponent <DynamiteMechanics>();
                    dm.DisableRestrictions();
                    player.GetComponent <DynamiteMechanics>().enabled = false;
                    gl.PickUp();
                }
            }
        }
    }