コード例 #1
0
    public void DoAbsorb()
    {
        if (nearestEnemy != null)
        {
            if (!IWM.usingFlameThrower && !IWM.usingHyperJump && !IWM.usingHyperDash && !IWM.usingMisileLaucher && !IWM.absorbing && nearestEnemy.addStamina > 0) //&& nearestEnemy.addLife > 0)
            {
                if (canAbsorb)
                {
                    IWM.player.CC.canHit = false;

                    if (!playSound)
                    {
                        source.loop = true;
                        source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                        source.PlayOneShot(absorbing);
                        playSound = true;
                    }

                    IWM.player.stop        = true;
                    IWM.absorbing          = true;
                    IWM.stamina            = IWM.stamina - nearestEnemy.addStamina * nearestEnemy.absorbPercentage;
                    IWM.player.life.health = IWM.player.life.health - nearestEnemy.addLife * nearestEnemy.absorbPercentage;
                    IWM.addConstantLife    = false;
                    IWM.addConstantStamina = false;
                    //StartCoroutine(ResetAbsorb());
                }
            }
        }
    }
コード例 #2
0
ファイル: PlayerController.cs プロジェクト: Ozker24/Improved
    public void CheckItems()
    {
        ItemBase itemCollected = itemDetector.closestItem.GetComponent <ItemBase>();

        if (itemCollected.WhichItem == 4)
        {
            items.itemsCount[4]++;
            items.visualItemsCount[4]++;

            items.molotovVisuals[items.visualItemsCount[4] - 1].SetActive(true);
        }
        if (itemCollected.WhichItem == 3)
        {
            items.itemsCount[3]++;
            items.visualItemsCount[3]++;

            items.granadeVisuals[items.visualItemsCount[3] - 1].SetActive(true);
        }
        if (itemCollected.WhichItem == 2)
        {
            items.itemsCount[2]++;
            items.visualItemsCount[2]++;

            items.soundGranadeVisuals[items.visualItemsCount[2] - 1].SetActive(true);
        }
        if (itemCollected.WhichItem == 1)
        {
            items.itemsCount[1]++;
            items.visualItemsCount[1]++;

            items.firstAidVisuals[items.visualItemsCount[1] - 1].SetActive(true);
        }
        if (itemCollected.WhichItem == 0)
        {
            items.itemsCount[0]++;
            items.visualItemsCount[0]++;

            items.EMPVisuals[items.visualItemsCount[0] - 1].SetActive(true);
        }

        if (itemCollected.collectSound != null)
        {
            //AudioSource source = gameObject.AddComponent<AudioSource>();
            //CollectItemSource.clip = itemCollected.collectSound;
            //source.playOnAwake = false;

            baseSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
            baseSource.PlayOneShot(itemCollected.collectSound);
            //Destroy(source, source.clip.length);
        }
    }
コード例 #3
0
    private void OnCollisionEnter(Collision collision)
    {
        if (!playOneTime)
        {
            source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
            source.Play();
            Instantiate(explosionParticle, transform.position, Quaternion.identity);
            playOneTime = true;
        }

        Renderer renderer = GetComponent <Renderer>();

        renderer.enabled = false;
        explosionArea.GetComponent <Renderer>().enabled = false;

        Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius, explosionLayer);

        foreach (Collider objectsToExplode in colliders)
        {
            if (objectsToExplode.tag == "Enemy")
            {
                EnemyTest enemy = objectsToExplode.GetComponent <EnemyTest>();
                enemy.Damage(misileDamage);
            }
        }

        Destroy(gameObject, 5);
    }
コード例 #4
0
    public void LauchMisile()
    {
        if (!underRoof)
        {
            if (IWM.stamina > 0 && !IWM.usingFlameThrower && !IWM.usingHyperJump && !IWM.usingHyperDash && !IWM.usingLaserGun && !IWM.usingMisileLaucher && canLaunch && !IWM.absorbing)
            {
                Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
                RaycastHit hit = new RaycastHit();// que hemos golpeado primero

                if (Physics.Raycast(ray, out hit, misileDist))
                {
                    IWM.usingMisileLaucher = true;
                    IWM.stamina           -= restStamina;
                    canLaunch = false;
                    IWM.usingMisileLaucher = false;
                    StartCoroutine(ResetCanLaunch());

                    source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                    source.Play();

                    nextMisilePos = hit.point;

                    Instantiate(misile, transform.position, Quaternion.identity);
                }
            }
        }
    }
コード例 #5
0
    public void MyUpdate()
    {
        HUD.UpdateCurrentAmmo(weapons[WeaponSelected].currentAmmo);

        if (selectingGun)
        {
            if (timeCounter > timeToSelect)
            {
                if (weaponPreSelected != WeaponSelected && selectingGun)
                {
                    WeaponSelected = weaponPreSelected;

                    WVisuals.StartChangingGunVisuals();

                    ableGun = false;
                    UiSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                    UiSource.PlayOneShot(changeGunClips.clips[WeaponSelected]);
                    StartCoroutine(AbleGun(timeAbleGun[WeaponSelected]));
                }

                timeCounter  = 0;
                selectingGun = false;
                //si hay audio que suena al salir la ui aqui.
            }
            else
            {
                timeCounter += Time.deltaTime;
            }
        }
    }
コード例 #6
0
    public void Explode()
    {
        finalPos = transform.position;

        //Get Objects
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layer);

        source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
        source.PlayOneShot(explosionClip);

        foreach (Collider nearbyObject in colliders)
        {
            if (nearbyObject.tag == "Enemy")
            {
                EnemyTest enemy = nearbyObject.GetComponent <EnemyTest>();

                enemy.positionWhereSound = finalPos;

                /*if (enemy.wantToHear)
                 * {
                 *  enemy.SetLook(enemy.positionWhereSound);
                 * }*/

                Debug.Log("Vector Set");
            }
        }

        //Remove Granade
        coll.enabled        = false;
        rb.detectCollisions = false;
        mesh.enabled        = false;

        //Destroy(gameObject, 5);
    }
コード例 #7
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            Debug.Log("Enemy");
            EnemyTest enemy = other.GetComponent <EnemyTest>();

            if (!enemy.dead)
            {
                enemy.anim.SetAnimHit();
            }

            enemy.StunnedSet(StunedTime);

            if (!player.GM.improved)
            {
                enemy.Damage(player.normalModeFistDamage);
            }
            else
            {
                enemy.Damage(player.improvedModeFistDamage);
            }

            enemy.Detected = true;
            if (!enemy.dead)
            {
                basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                basicSource.PlayOneShot(HitSound);
            }
        }
    }
コード例 #8
0
    public void Molotov()
    {
        if (itemSelected == 4 && pressed && itemsCount [4] > 0)
        {
            if (!firstTime)
            {
                Debug.Log("M");

                if (ClipsSelected.clips[itemSelected] != null)
                {
                    baseSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                    baseSource.PlayOneShot(ClipsSelected.clips[itemSelected]);
                }

                //audio de apuntando

                molotovVisuals[visualItemsCount[itemSelected] - 1].SetActive(false);

                visualItemsCount[4]--;

                firstTime = true;
            }

            Debug.Log("Apunting with Molotov");
        }

        if (itemSelected == 4 && realised == 1 && itemsCount[4] > 0)
        {
            Debug.Log("Launched molotov");

            player.anims.SetAnimLaunch();

            if (ClipsLaunched.clips[itemSelected] != null)
            {
                baseSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                baseSource.PlayOneShot(ClipsLaunched.clips[itemSelected]);
            }

            //audPlay.Play(5, 1, Random.Range(0.95f, 1.05f)); // esta antes por temas de velocidad del audio
            InstantiateThings(MolotovPrefab);

            itemsCount[4]--;

            CantGunCantItem(false, false, false);
        }
    }
コード例 #9
0
    public void ShotLaserGun()
    {
        if (!inFireRate)
        {
            inFireRate = true;

            IWM.stamina -= restStamina;

            laserShotPartcile.Play();

            if (damage == semiAutoDamage)
            {
                baseSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                baseSource.PlayOneShot(shotSingleShot);
            }
            else if (damage == sniperDamage)
            {
                baseSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                baseSource.PlayOneShot(shotSniperShot);
            }

            Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
            RaycastHit hit = new RaycastHit();// que hemos golpeado primero

            if (Physics.Raycast(ray, out hit, distance))
            {
                if (hit.transform.tag == "Enemy")
                {
                    Debug.Log("Hit");
                    GameObject particle = Instantiate(laserHitPartcile, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));

                    Destroy(particle, 10);
                    hit.transform.SendMessage("Damage", damage, SendMessageOptions.RequireReceiver);
                }
            }

            Debug.Log(restStamina);

            StartCoroutine(FinisedFireRate());
        }
    }
コード例 #10
0
 public void DoDash()
 {
     if (IWM.stamina > 0 && !IWM.usingFlameThrower && !IWM.usingHyperJump && !IWM.usingHyperDash && !IWM.usingLaserGun && !IWM.usingMisileLaucher && !IWM.absorbing)
     {
         source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
         //source.Play();
         Debug.LogWarning("HyperDash sound is desactive");
         IWM.usingHyperDash = true;
         IWM.stamina       -= restStamina;
         IWM.player.Dodge();
     }
 }
コード例 #11
0
    public void Damage(float life)
    {
        currentLife -= life;

        if (currentLife <= 0)
        {
            currentLife = 0;
            if (!dead)
            {
                basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                basicSource.PlayOneShot(clips.clips[2]);
            }
            DieSet();
        }
    }
コード例 #12
0
ファイル: FlameThrower.cs プロジェクト: Ozker24/Improved
 public void Fire()
 {
     if (IWM.stamina > 0 && !IWM.usingLaserGun && !IWM.usingHyperJump && !IWM.usingHyperDash && !IWM.usingMisileLaucher && !IWM.absorbing)
     {
         if (!playSound)
         {
             playSound = true;
             flameParticle.Play();
             source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
             source.Play();
         }
         IWM.player.CC.canHit = false;
         fireing = true;
         IWM.usingFlameThrower = true;
     }
 }
コード例 #13
0
    public void Explode()
    {
        Debug.Log("Booom");

        // Show Effects
        //Instantiate(explosionEffect, transform.position, transform.rotation);

        GameObject EMPExplosion = Instantiate(explosionEffect, transform.position, transform.rotation);

        //Debug.Log(source + "AAAAAAAAAAAAAAAAAAAAA");

        //Common.common.ChangePitchAndVolume(source);
        source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
        source.PlayOneShot(explosionClip);

        Destroy(EMPExplosion, 10);

        //Get Objects
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layer);

        foreach (Collider nearbyObject in colliders)
        {
            if (nearbyObject.tag == "Enemy")
            {
                nearbyObject.transform.SendMessage("StunnedSet", empTime, SendMessageOptions.RequireReceiver);
                Debug.Log("Enemy");
            }

            else if (nearbyObject.tag == "Interruptor")
            {
                Interruptor interruptor = nearbyObject.GetComponentInParent <Interruptor>();

                if (interruptor != null)
                {
                    interruptor.DoInteraction();
                }
            }
        }
        //Damage enemies

        //Remove Granade
        coll.enabled        = false;
        rb.detectCollisions = false;
        mesh.enabled        = false;

        Destroy(gameObject, 5);
    }
コード例 #14
0
ファイル: Granade.cs プロジェクト: Ozker24/Improved
    public void Explode()
    {
        Debug.Log("Booom");

        // Show Effects
        GameObject GranadeExplosion = Instantiate(explosionEffect, transform.position, transform.rotation);

        Destroy(GranadeExplosion, 10);

        source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
        source.PlayOneShot(explosionClip);

        //Get Objects
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layer);

        foreach (Collider nearbyObject in colliders)
        {
            //Add Force to objects
            Rigidbody rb = nearbyObject.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.AddExplosionForce(force, transform.position, radius);
            }

            if (nearbyObject.tag == "Enemy")
            {
                EnemyTest enemy = nearbyObject.GetComponent <EnemyTest>();

                //rb.AddExplosionForce(force, transform.position, radius);

                enemy.Damage(enemy.maxLife);
            }
        }
        //Damage enemies

        //Remove Granade
        coll.enabled        = false;
        rb.detectCollisions = false;
        mesh.enabled        = false;

        Destroy(gameObject, 5);
    }
コード例 #15
0
    public void Explode()
    {
        Debug.Log("Booom");

        // Show Effects
        //Instantiate(explosionEffect, transform.position, transform.rotation);

        source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
        source.PlayOneShot(explosionClip);

        //Get Objects
        Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layer);

        foreach (Collider nearbyObject in colliders)
        {
            //animacion y particula de quemar

            if (nearbyObject.tag == "Enemy")
            {
                EnemyTest enemy = nearbyObject.GetComponent <EnemyTest>();
                enemy.Damage(enemy.currentLife);
                enemy.dead = true;
                //Debug.Log("Killed By Molotov");
            }
            else if (nearbyObject.tag == "Fireable")
            {
                Destroy(nearbyObject.gameObject, 2f);
            }
        }

        GameObject fireZone = Instantiate(fireZonePrefab, new Vector3(transform.position.x, 0, transform.position.z), Quaternion.Euler(0, 0, 0));

        //Damage enemies

        //Remove Molotov
        coll.enabled        = false;
        rb.detectCollisions = false;
        mesh.enabled        = false;

        Destroy(gameObject, 5);
    }
コード例 #16
0
ファイル: FireZone.cs プロジェクト: Ozker24/Improved
 public void Start()
 {
     source.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
     source.Play();
 }
コード例 #17
0
ファイル: Weapon.cs プロジェクト: Ozker24/Improved
    public void Shot()
    {
        if (isReloading || isShoting)
        {
            return;
        }
        if (currentAmmo <= 0)
        {
            Reload();
            return;
        }

        isShoting = true;
        currentAmmo--;

        //audPlay.Play(0, 1, Random.Range(0.95f, 1.05f));
        //ammoReloaded--;
        basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
        basicSource.PlayOneShot(ShotClips.clips[weapon.WeaponSelected]);

        muzzleParticle.Play();

        if (weapon.WeaponSelected != 1)
        {
            Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
            RaycastHit hit = new RaycastHit();// que hemos golpeado primero

            if (Physics.Raycast(ray, out hit, fireDist, weaponLayer))
            {
                //Debug.Log(hit.collider.tag);
                Debug.Log(hit.collider.name);

                if (hit.collider.tag == "Flesh")
                {
                    GameObject particle = (GameObject)Instantiate(bloodParticle, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));

                    Destroy(particle, 10);
                    hit.transform.SendMessage("StunnedSet", stunedTime, SendMessageOptions.RequireReceiver);
                    hit.transform.SendMessage("Damage", bulletDamage, SendMessageOptions.RequireReceiver);

                    EnemyTest enemy = hit.transform.GetComponent <EnemyTest>();
                    if (enemy != null)
                    {
                        enemy.Detected = true;
                        enemy.anim.SetAnimHit();
                    }
                }

                else if (hit.collider.tag == "Metal")
                {
                    GameObject particle = (GameObject)Instantiate(sparklePartcile, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
                    hit.transform.SendMessage("Damage", bulletMetalDamage, SendMessageOptions.RequireReceiver);

                    EnemyTest enemy = hit.transform.GetComponent <EnemyTest>();
                    if (enemy != null)
                    {
                        enemy.Detected = true;
                        enemy.anim.SetAnimHit();
                    }

                    basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                    basicSource.PlayOneShot(MetalClip);
                    Destroy(particle, 10);
                }
            }
        }

        else
        {
            for (int i = 0; i < shotGunSpreads; i++)
            {
                Ray        ray = Camera.main.ViewportPointToRay(new Vector3(Random.Range(0.3f, 0.7f), Random.Range(0.3f, 0.7f), 0));
                RaycastHit hit = new RaycastHit();// que hemos golpeado primero
                Debug.DrawRay(ray.origin, ray.direction * fireDist, Color.red, 0.5f);

                if (Physics.Raycast(ray, out hit, fireDist))
                {
                    Debug.Log(hit.collider.name);

                    if (hit.collider.tag == "Flesh")
                    {
                        GameObject particle = (GameObject)Instantiate(bloodParticle, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));

                        Destroy(particle, 10);

                        hit.transform.SendMessage("StunnedSet", stunedTime, SendMessageOptions.RequireReceiver);
                        hit.transform.SendMessage("Damage", bulletDamage, SendMessageOptions.RequireReceiver);

                        EnemyTest enemy = hit.transform.GetComponent <EnemyTest>();
                        if (enemy != null)
                        {
                            enemy.anim.SetAnimHit();
                            enemy.Detected = true;
                        }
                    }

                    else if (hit.collider.tag == "Metal")
                    {
                        GameObject particle = (GameObject)Instantiate(sparklePartcile, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
                        hit.transform.SendMessage("Damage", bulletMetalDamage, SendMessageOptions.RequireReceiver);
                        basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                        basicSource.PlayOneShot(MetalClip);
                        Destroy(particle, 10);
                    }
                }

                Debug.Log(hit.point);


                /*Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
                 * RaycastHit hit = new RaycastHit();// que hemos golpeado primero
                 *
                 * whereToShot.transform.position = ray.origin;
                 * whereToShot.transform.rotation = Quaternion.Euler(Random.Range(-7, 7), Random.Range(-7, 7), whereToShot.localEulerAngles.z);
                 *
                 * if (Physics.Raycast(whereToShot.position, whereToShot.forward, out hit, fireDist))
                 * {
                 *  Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
                 * }*/
            }
        }

        if (isAutomatic)
        {
            StartCoroutine(ResetShot());
        }
    }
コード例 #18
0
ファイル: CloseCombat.cs プロジェクト: Ozker24/Improved
    public void DoHit()
    {
        if (canHit)
        {
            player.anims.SetAnimFist();
        }

        if (canHit && !player.canExecute)
        {
            player.crouching = false;

            player.GM.ableToInput = false;
            player.axis           = Vector2.zero;

            point = true;
            StartCoroutine(TurnOffPoint());

            TimeCounter = 0;
            Hited       = true;
            triggerAnim = true;

            canHit = false;

            //ejecutar animcion
            player.anims.HitAnimations();

            if (!player.GM.improved)
            {
                normalModeHit.AppearHit();
            }
            else
            {
                improvedModeHit.AppearHit();
            }

            basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
            basicSource.PlayOneShot(hitClips);
            ActualHit++;

            if (ActualHit < maximumHits)
            {
                secondsAbleToImput = initialSecondsAbleToInput;
            }
            else if (ActualHit >= maximumHits)
            {
                secondsAbleToImput = finalSecondsAbleToInput;
            }

            if (ActualHit > maximumHits)
            {
                ActualHit = 1;
            }
            if (ActualHit == 1)
            {
                Hited = false;
            }

            Debug.Log(ActualHit);
            //canHit = true; // se ha de hacer al acabar la animacion.

            StartCoroutine(SetAbleToImput());
        }

        if (player.canExecute)
        {
            if (enemyToExecute != null)
            {
                enemyToExecute.Damage(enemyToExecute.currentLife);
                basicSource.ChangePitchAndVolume(0.7f, 1, 0.95f, 1.05f);
                basicSource.PlayOneShot(executionClip);
                enemyToExecute.executionCollider.enabled = false;
                enemyToExecute    = null;
                player.canExecute = false;
            }
        }
    }