コード例 #1
0
 public void TakeDamage(int damage, Vector3 recoilOffset)
 {
     if (Time.time > timeDamageTaken + damageCooldownLength)
     {
         timeDamageTaken = Time.time;
         // If the player took more than 10 damage start recoil
         if (damage > 10)
         {
             // Scale recoil based on damage
             float recoilMultiplier = damage / 40f;
             //float timeMult = (float)damage / 100;
             LeanTween.move(playerCam, playerCam.transform.position + recoilOffset * recoilMultiplier, .25f).setEaseOutExpo();
             Stun(.25f);
             //StartCoroutine(recoil(recoilOffset * recoilMultiplier, 0.05f));
         }
         SetHealth(-damage, this);
         if (photonView.isMine)
         {
             var random = Random.Range(0, 4);
             AudioFW.Play("PlayerTakesDamage" + random);
             if (!intense)
             {
                 Intense();
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="d">Damage</param>
 /// <param name="r">Range</param>
 /// <param name="s">Speed</param>
 /// <param name="dir">Direction</param>
 /// <param name="shotByNPC">True if shot by npc</param>
 public void LaunchProjectile(int d, float r, float s, Vector2 dir, bool shotByNPC)
 {
     // Set original position
     origPos = transform.position;
     // Set damage of the projectile
     damage = d;
     // Set range
     range = r;
     // Set speed
     speed = s;
     // Set direction
     direction = dir;
     // Set npc
     npc = shotByNPC;
     // Set Launchtime
     launchTime = Time.time;
     if (impulse)
     {
         rb2D.AddForce(dir * s, ForceMode2D.Impulse);
     }
     if (npc)
     {
         var random = Random.Range(0, 4);
         AudioFW.Play("EnemyShoot" + random);
     }
     else
     {
         var random = Random.Range(0, 4);
         AudioFW.Play("PlayerShoot" + random);
     }
     launched = true;
     //Debug.Log("launched");
 }
コード例 #3
0
    public void Melee()
    {
        int random = Random.Range(0, 4);

        AudioFW.Play("PlrMelee" + random);
        if (!photonView.isMine)
        {
            damage = 0;
        }
        Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, attackRange, layerMaskEnemy);
        foreach (var hit in hits)
        {
            IDamageable <int> iDamageable = hit.gameObject.GetComponent(typeof(IDamageable <int>)) as IDamageable <int>;
            if (iDamageable != null)
            {
                iDamageable.TakeDamage(damage, new Vector3(0, 0, 0));
            }
        }
        if (photonView.isMine)
        {
            Vector2 mouseVector = new Vector2(Input.mousePosition.x - camPos.x, Input.mousePosition.y - camPos.y).normalized;

            if (characterType == EntityType.Hero1)
            {
                animator.SetTrigger("LightOniAttack");
            }
            else if (characterType == EntityType.Hero3)
            {
                animator.SetTrigger("DarkOniAttack");
            }
            animator.SetFloat("Horizontal", mouseVector.x);
            animator.SetFloat("Vertical", mouseVector.y);
        }
    }
コード例 #4
0
    public void Attack()
    {
        //No need to check the closest target, since we should lock our attention to one troop at least as long as it's in the reachRadius

        if (Vector2.Distance(transform.position, currentTarget.position) < reachRad && currentTarget != gameObject.transform)
        {
            //Attack the target
            attackTimer -= Time.deltaTime;
            if (attackTimer <= 0)
            {
                List <Transform> enemyUnits = targetManager.FindAllTargetsWithinRadius(gameObject.transform, thisPlayer, attackRad + 0.1f);

                foreach (Transform unit in enemyUnits)
                {
                    IDamageable healthScript = unit.GetComponent <IDamageable>();
                    if (healthScript != null)
                    {
                        healthScript.ApplyDamage(attackPower);
                    }
                }
                attackTimer += attackPerSecond;
                AudioFW.Play("Unit_DarkK_Attack");
            }
        }
        else if (Vector2.Distance(transform.position, currentTarget.position) < aggroRadius)
        {
            currentState = AIstate.Aggro;
        }
        else
        {
            currentState = AIstate.Navigate;
            //DeListen target death notification
        }
    }
コード例 #5
0
ファイル: Credits.cs プロジェクト: AriPunavuori/Crawler
 public void OnClickGoToLobby()
 {
     AudioFW.StopAllSounds();
     AudioFW.PlayLoop("MenuLoop");
     PhotonNetwork.LeaveRoom();
     PlayerNetwork.Instance.LoadMenu();
 }
コード例 #6
0
    private void FixedUpdate()
    {
        RotateWheels(350);

        if (lives < 15 && !damaged)
        {
            damaged     = true;
            agent.speed = damagedSpeed;
            AudioFW.Play("TruckDamaged");
        }
        if (lives < 1)
        {
            EnemyManager.enemiesLeft--;
            GunShoot gun = GameObject.Find("BulletSpawn").GetComponent <GunShoot>();
            gun.kills++;
            Clipboard.instance.ChangeKills(gun.kills.ToString());
            Destroy(gameObject);
            GameObject deadTruck = Instantiate(truckDeath, transform.position, transform.rotation);
            Destroy(deadTruck, 5f);
            CameraShaker.GetInstance("Main Camera").ShakeOnce(6f, 5f, 0.0f, 2.5f);
            AudioFW.Play("TruckDie");
        }

        if (damaged)
        {
            flames.SetActive(true);
        }
    }
コード例 #7
0
    IEnumerator MeleeAttackRotator(float time, float rotation, int dmg, GameObject rotator, float warningTime)
    {
        rotator.LeanScale(new Vector3(1f, 1f, 1f), warningTime);
        //transform.GetComponent<SpriteRenderer>().color = Color.yellow;
        if (photonView.isMine)
        {
            AudioFW.Play("BossMeleeSwing");
        }
        yield return(new WaitForSeconds(warningTime));

        rotator.gameObject.transform.GetChild(0).GetComponent <PolygonCollider2D>().enabled = true;
        float      rotDelta    = 0;
        float      elapsedTime = 0;
        Quaternion startRot    = new Quaternion();

        startRot.eulerAngles = rotator.transform.rotation.eulerAngles;
        Quaternion rot  = new Quaternion();
        MeleeHand  hand = rotator.transform.GetChild(0).gameObject.GetComponent <MeleeHand>();

        hand.damage = dmg;

        while (elapsedTime < time)
        {
            rotDelta                   = (rotation * (elapsedTime / time));
            rot.eulerAngles            = startRot.eulerAngles + new Vector3(0, 0, rotDelta);
            rotator.transform.rotation = rot;
            elapsedTime               += Time.deltaTime;
            yield return(null);
        }
        Destroy(rotator);
        //transform.GetComponent<SpriteRenderer>().color = Color.white;
        meleeAttackFin = true;
    }
コード例 #8
0
 void LessIntense()
 {
     AudioFW.AdjustLoopVolume("GameLoopNormal", .4f, 2.5f);
     AudioFW.AdjustLoopVolume("GameLoopIntense", .0f, 2.5f);
     intense = false;
     print("Not so intence anymore");
 }
コード例 #9
0
 void RPC_Dash()
 {
     AudioFW.Play("Dash");
     dashing = true;
     print("dash particles on others!");
     dashEffectParticles.GetComponent <ParticleSystem>().Play();
 }
コード例 #10
0
    void InRoom()
    {
        var rb = roomInteractables.GetComponentsInChildren <Button>();

        foreach (var b in rb)
        {
            b.interactable = true;
        }
        var lb = lobbyInteractables.GetComponentsInChildren <Button>();

        foreach (var b in lb)
        {
            b.interactable = false;
        }
        MenuCanvasManager.Instance.currentRoomCanvas.transform.SetAsLastSibling();
        AudioFW.Play("Whip");
        LeanTween.move(roomInteractables, Vector3.zero, .5f).setEaseOutQuart();
        if (PhotonNetwork.isMasterClient)
        {
            startGame.interactable = true;
            startGame.Select();
        }
        else
        {
            startGame.interactable = false;
            leaveGame.Select();
        }
    }
コード例 #11
0
    public void Attack()
    {
        //No need to check the closest target, since we should lock our attention to one troop at least as long as it's in the reachRadius

        if (Vector2.Distance(transform.position, currentTarget.position) < reachRad && currentTarget != gameObject.transform)
        {
            //Attack the target
            attackTimer -= Time.deltaTime;
            if (attackTimer <= 0)
            {
                currentTarget.GetComponent <IDamageable>().ApplyDamage(attackPower);
                AudioFW.Play("Unit_Archer_Attack");
                attackTimer += attackPerSecond;
            }
        }
        else if (Vector2.Distance(transform.position, currentTarget.position) < aggroRadius)
        {
            currentState = AIstate.Aggro;
        }
        else
        {
            currentState = AIstate.Navigate;
            //DeListen target death notification
        }
    }
コード例 #12
0
    public IEnumerator LoseGame()
    {
        print("You Lose!");
        gameLost = true;
        yield return(new WaitForSeconds(2));

        camAnim.SetTrigger("Lose");
        gameAnim.SetTrigger("Lose");
        AudioFW.Play("LoseGame");
        yield return(new WaitForSeconds(1.5f));

        GameObject expl = Instantiate(explosion, transform.GetChild(0).transform.position, explosion.transform.rotation);

        transform.GetChild(0).gameObject.SetActive(false);
        Destroy(expl, 0.25f);
        yield return(new WaitForSeconds(0.07f));

        fader.SetActive(true);
        faderAnim.SetTrigger("Fade");
        AudioFW.StopLoop("Ambience");
        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        foreach (GameObject enemy in enemies)
        {
            Destroy(enemy);
        }
    }
コード例 #13
0
    void ShootMLAW()
    {
        int random = Random.Range(0, 3);

        AudioFW.Play("MLAWFire" + random);
        PoolManager.Instance.mlawPool.SpawnProjectile(projSpawn.transform.position, projSpawn.transform.rotation, 100, 1);
    }
コード例 #14
0
    void ShootWizBall()
    {
        int random = Random.Range(0, 3);

        AudioFW.Play("WizSpawn" + random);
        PoolManager.Instance.wizballPool.SpawnProjectile(projSpawn.transform.position, projSpawn.transform.rotation, 30, 5);
    }
コード例 #15
0
    public void AddKey(int num)
    {
        inputs.Add(num);
        int rng = Random.Range(1, 4);

        AudioFW.Play("button" + rng);
    }
コード例 #16
0
ファイル: InfoManager.cs プロジェクト: AriPunavuori/Crawler
 public void Show(int hero)
 {
     if (!movingOut)
     {
         if (!selected)
         {
             frameImage.color = heroColors[hero];
             heroImage        = heroImages[hero];
             Image SetheroImageCard = heroImageCard.GetComponent(typeof(Image)) as Image;
             SetheroImageCard.sprite = heroImage;
             for (int i = 0; i < textFields.Length; i++)
             {
                 textFields[i].text = character.GetCharacterData(i, hero);
             }
             AudioFW.Play("Whip");
             ShowCard();
             queue = -1;
         }
     }
     else
     {
         queue = hero;
     }
     HideTitle();
 }
コード例 #17
0
 private void OnCollisionEnter(Collision collision)
 {
     if (!hasPlayed)
     {
         int rng = Random.Range(1, 3);
         AudioFW.Play("impact" + rng);
     }
 }
コード例 #18
0
 public void setBossDefeated()
 {
     GameManager.Instance.bossDefeated = true;
     if (photonView.isMine)
     {
         AudioFW.Play("BossDeath");
     }
 }
コード例 #19
0
 void RPC_GameLost()
 {
     print("RPC_GameLost " + name);
     switchingScene = true;
     rb2D.velocity  = Vector2.zero;
     AudioFW.StopAllSounds();
     AudioFW.Play("AllDead");
 }
コード例 #20
0
 private void Start()
 {
     select += Select;
     PlayerNetwork.Instance.numberOfPlayers = PhotonNetwork.playerList.Length;
     AudioFW.StopAllSounds();
     AudioFW.PlayLoop("CharaterSelectionLoop");
     Invoke("PumpText", .5f);
 }
コード例 #21
0
 public void AfterSelection()
 {
     AudioFW.StopAllSounds();
     InfoManager.Instance.HideCard();
     InfoManager.Instance.HideTitle();
     AudioFW.Play("Whip");
     LeanTween.move(controlInfo, Vector2.zero, .5f).setEaseInQuart().setOnComplete(select);
 }
コード例 #22
0
 void Select()
 {
     AudioFW.Play("CharacterSelected");
     LeanTween.cancel(chooseText);
     LeanTween.scale(chooseText, Vector3.one, 0f);
     chooseText.GetComponent <TextMeshProUGUI>().text = "Get Ready!";
     LeanTween.scale(chooseText, Vector3.one * 1.2f, .2f).setLoopPingPong().setEaseInExpo();
 }
コード例 #23
0
 void Dash()
 {
     AudioFW.Play("Dash");
     dashing = true;
     dashEffectParticles.GetComponent <ParticleSystem>().Play();
     dashVector = lastDir;
     photonView.RPC("RPC_Dash", PhotonTargets.Others);
 }
コード例 #24
0
 void Intense()
 {
     intenseTime = Time.time + intenseCooldown;
     AudioFW.AdjustLoopVolume("GameLoopNormal", .0f, .5f);
     AudioFW.AdjustLoopVolume("GameLoopIntense", .4f, .5f);
     intense = true;
     print("Its getting intense!");
 }
コード例 #25
0
    IEnumerator StartShootSounds()
    {
        AudioFW.StopSfx("BurstTail");
        AudioFW.Play("BurstStart");
        yield return(new WaitForSeconds(0.030f));

        AudioFW.PlayLoop("BurstLoop");
    }
コード例 #26
0
 public void OnButtonHoverExit()
 {
     LeanTween.scale(rectTransform, Vector3.one, onHoverExitLength);
     if (shadow != null)
     {
         shadow.effectDistance = shadowDistance;
     }
     AudioFW.Play("ButtonSwitch");
 }
コード例 #27
0
 public void OnButtonHoverEnter()
 {
     LeanTween.scale(rectTransform, Vector3.one * onHoverSizeMultiplier, onHoverEnterLength);
     if (shadow != null)
     {
         shadow.effectDistance = shadowDistance * onHoverSizeMultiplier * 1.5f;
     }
     AudioFW.Play("ButtonSwitch");
 }
コード例 #28
0
ファイル: Spawner.cs プロジェクト: AriPunavuori/Crawler
 void Spit()
 {
     LeanTween.scale(gameObject, Vector3.one, spawnInterval * 0.35f).setEaseOutElastic();
     AudioFW.Play("Spit");
     if (PhotonNetwork.isMasterClient)
     {
         SpawnNow();
     }
 }
コード例 #29
0
    void Update()
    {
        if (!outOfAmmo && !overheating && !GameManager.instance.gameLost && !Menus.paused)
        {
            if (Input.GetKey(KeyCode.Mouse0))
            {
                if (!shooting)
                {
                    shooting = true;
                    StartCoroutine("StartShootSounds");
                }
                if (Time.time > nextFireTime)
                {
                    Shoot();
                    --currentAmmo;
                    flashParticle.SetActive(true);
                    nextFireTime = Time.time + fireRate;

                    //spawn belt links
                    GameObject newLink = Instantiate(link, linkSpawn.transform.position, Quaternion.identity);
                    newLink.GetComponent <Rigidbody>().AddForce(new Vector3(Random.Range(0.5f, 1.5f), 0, 0), ForceMode.Impulse);
                    Destroy(newLink, 0.5f);
                }
            }
            if (Input.GetKeyUp(KeyCode.Mouse0))
            {
                if (shooting)
                {
                    shooting = false;
                    StopShootSounds();
                    flashParticle.SetActive(false);
                }
            }
        }
        else if (outOfAmmo)
        {
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                AudioFW.Play("ClickEmpty");
            }
        }

        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            pistol.GetComponent <Animator>().SetTrigger("Shoot");
        }

        if (Input.GetKeyDown(KeyCode.R) && !overheating && currentAmmo < maxAmmo && !reloading)
        {
            StartCoroutine(Reload());
        }
        if (Input.GetKeyDown(KeyCode.F) && !overheating && !shooting && !reloading)
        {
            overheating = true;
            StartCoroutine(BarrelChange());
        }
    }
コード例 #30
0
    void Shoot()
    {
        CameraShaker.GetInstance("Main Camera").ShakeOnce(1.5f, 2f, 0, 0.5f);

        //Bullet spread calculations
        Vector3    deviation3D = Random.insideUnitCircle * accuracy;
        Quaternion rot         = Quaternion.LookRotation(Vector3.forward + deviation3D);
        Vector3    fwd         = transform.rotation * rot * Vector3.forward;

        bool       enemyHit = false;
        RaycastHit hit;

        if (Physics.Raycast(trans.position, fwd, out hit))
        {
            if (hit.transform.CompareTag("Enemy"))
            {
                Destroy(hit.transform.gameObject, 0.5f);
                hit.transform.GetComponent <Enemy>().dying = true;
                enemyHit = true;
                StartCoroutine(ShowHitMark(false));

                //blood splatter effect
                GameObject impact    = Instantiate(bodyImpact, hit.transform.position, bodyImpact.transform.rotation);
                float      randScale = Random.Range(2f, 3f);
                impact.transform.localScale = (new Vector3(randScale, randScale, randScale));
                Destroy(impact, 1f);
            }
            else if (hit.transform.CompareTag("Truck"))
            {
                hit.transform.GetComponent <Truck>().lives--;
                StartCoroutine(ShowHitMark(true));
                float randHitSound = Random.Range(0f, 1f);
                if (randHitSound > 0.65f)
                {
                    AudioFW.PlayRandomPitch("MetalHit");
                }
            }
        }
        GameObject newShot = Instantiate(mGShot, trans.position, trans.parent.rotation);

        newShot.GetComponent <Rigidbody>().AddForce(fwd * shootForce, ForceMode.Impulse);
        if (enemyHit)
        {
            Destroy(newShot, 0.1f);
            EnemyManager.enemiesLeft--;
            kills++;
            Clipboard.instance.ChangeKills(kills.ToString());
        }
        else
        {
            Destroy(newShot, 1f);
        }

        GameObject flash = Instantiate(mFlash, trans.GetChild(0).position, Quaternion.identity);

        Destroy(flash, 0.02f);
    }