private void OnTriggerEnter2D(Collider2D target)
    {
        Destroy(target.gameObject);
        if (target.tag == "leisure block")
        {
            SoundManagerScript.PlaySound("impact");
            Destroy(target.gameObject);
        }

        else if (target.tag == "Player")
        {
            Destroy(target.gameObject);
            Score.won = false;
            SceneManager.LoadScene("gameovermenu");
        }
    }
示例#2
0
 private void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag.Equals("Bullet"))
     {
         ScoreScript.scoreValue += 10;
         SoundManagerScript.PlaySound("enemyDeath");
         Instantiate(blood, transform.position, Quaternion.identity);
         Destroy(col.gameObject);
         Destroy(gameObject);
         int powerUp = (Random.Range(0, 20));
         if (powerUp == 7)
         {
             SpawnPowerUp();
         }
     }
 }
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.gameObject.GetComponent <Rigidbody2D>().velocity.y <= -3 &&  isActive)
     {
         //odraz od příšery a její zabití
         collider.gameObject.GetComponent <Rigidbody2D>().AddForce(Vector3.up * 900f);
         this.GetComponent <SpriteRenderer>().sprite = MonsterDead;
         var defPostion = transform.position.y;
         isActive = false;
     }
     else if (collider.name.StartsWith("player") && isActive)
     {
         SceneManager.LoadScene("GameOver");
         SoundManagerScript.PlaySound("gameOver");
     }
 }
示例#4
0
    private IEnumerator Die()
    {
        anim.Play("Die");
        gameObject.layer = 14; // switch to "ImmuneBoss" layer
        GetComponent <Rigidbody2D>().velocity = Vector3.zero;
        go = false;
        yield return(new WaitForSeconds(1f));

        if (!dead)
        {
            SoundManagerScript.PlaySound("puff");
            dead = true;
        }
        Instantiate(smoke, new Vector3(transform.position.x, transform.position.y + 1, 0), Quaternion.identity);
        Destroy(gameObject);
    }
示例#5
0
    void Update()
    {
        TimeSpan spanTime = TimeSpan.FromSeconds(startingTime);

        if (spanTime.TotalSeconds <= 6)
        {
            SoundManagerScript.PlaySound("Alarm");
            countdownText.color = Color.red;
        }

        if (spanTime.TotalSeconds <= 0)
        {
            currentTime = 0;
            SceneManager.LoadScene(2);
        }
    }
示例#6
0
    void BotArrow()
    {
        SoundManagerScript.PlaySound("click_sound");

        NextGrid.transform.localPosition += new Vector3(0, 0, -4);
        UpdateRayPosition(NextGridLimit);
        if (NextGrid.transform.localPosition.z <= NextGridLimit.BotLimit)
        {
            BotArrowCurrent.SetActive(false);
        }

        if (!TopArrowCurrent.activeSelf)
        {
            TopArrowCurrent.SetActive(true);
        }
    }
示例#7
0
 private void CheckBounds()
 {
     if (transform.position.y < verticalBoundary)
     {
         enemyManager.ReturnEnemy(gameObject);
         if (livesRef.lives > 0)
         {
             livesRef.lives--;
             SoundManagerScript.PlaySound("loseLife");
         }
         else
         {
             SceneManager.LoadScene("End");
         }
     }
 }
示例#8
0
    void Die()
    {
        diePanel.SetActive(true);
        vita.SetActive(false);

        SoundManagerScript.PlaySound("death");
        GlobalVariables.highscoreBool = false;

        //non so perchè ma per far si che venga fuori il DiePanel devo per forza metterci questo IF
        //se non lo metto schifa quel pannello perchè è uno stronzo
        if (diePanel.activeSelf)
        {
            gameObject.SetActive(false);
            dead = true;
        }
    }
 public void ReduceHealth(GameObject enemy)
 {
     if (mirrorDamage)
     {
         enemy.GetComponent <EnemyController>().health -= gameObject.GetComponent <PlayerAttack>().damage;
     }
     else
     {
         if (!dead)
         {
             health -= 1;
             SoundManagerScript.PlaySound("PlayerHurtSound");
             Debug.Log("The character has taken damage! His health is now " + health);
         }
     }
 }
    private void CreateEnemy()
    {
        SoundManagerScript.PlaySound("enemyAppearance");
        endOfGameMenu.SetActive(true);
        Time.timeScale   = 0f;
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        var transformOfCurrentGameObject = controller.transform;
        var enemyRotation   = transformOfCurrentGameObject.rotation.eulerAngles + new Vector3(0, 180, 0);
        var enemyGameObject = Instantiate(enemy,
                                          transform.position + distanceBetweenPlayer * transformOfCurrentGameObject.forward -
                                          new Vector3(0, transformOfCurrentGameObject.localScale.y, 0), Quaternion.Euler(enemyRotation));

        enemyGameObject.transform.localScale = scaleOfEnemy;
    }
 public override void receiveDmg(float dmg)
 {
     hp -= dmg;
     healthBar.SetHealth((int)hp);
     sr.material = matRed;
     SoundManagerScript.PlaySound("playerHurtSound");
     if (hp <= 0)
     {
         gameController.GetComponent <GameController>().GameOver();
         Destroy(gameObject);
     }
     else
     {
         Invoke("ResetMaterial", .1f);
     }
 }
示例#12
0
    IEnumerator PortalTransitionRoutine(GameObject character)
    {
        SoundManagerScript.PlaySound(SoundManagerScript.Sound.portal);
        yield return(new WaitForSeconds(0.75f));

        character.SetActive(false);
        character.transform.position = ObjectHandler.Instance.tiles[45].transform.position;
        character.GetComponent <Character>().SetCurrentTile(45);
        yield return(new WaitForSeconds(1.0f));

        character.SetActive(true);
        yield return(new WaitForSeconds(0.75f));

        character.GetComponent <Character>().StackCharacterOnTileAndAttack();
        GameManager.Instance.EndTurn(1.0f);
    }
示例#13
0
 public void TakeDamage(float damage)
 {
     if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Crouch") == false)
     {
         health -= damage;
         if (null != anim)
         {
             SoundManagerScript.PlaySound("playerHit");
             anim.Play("Mushmom_Hit");
         }
     }
     if (health <= 0)
     {
         Die();
     }
 }
示例#14
0
    public void Move(float move, bool jump)
    {
        //only control the player if grounded or airControl is turned on
        if ((m_Grounded || m_AirControl) && knockBackCount <= 0)
        {
            // Move the character by finding the target velocity
            Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);
            // And then smoothing it out and applying it to the character
            m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing);

            // If the input is moving the player right and the player is facing left...
            if (move > 0 && !m_FacingRight)
            {
                // ... flip the player.
                Flip();
            }
            // Otherwise if the input is moving the player left and the player is facing right...
            else if (move < 0 && m_FacingRight)
            {
                // ... flip the player.
                Flip();
            }
        }
        else
        {
            // If player was knocked back
            if (knockBackFromRight)
            {
                m_Rigidbody2D.velocity = new Vector2(-knockBack, knockBack);
            }
            else
            {
                m_Rigidbody2D.velocity = new Vector2(knockBack, knockBack);
            }
            knockBackCount -= Time.deltaTime;
        }
        // If the player should jump...
        if (m_Grounded && jump)
        {
            // Play jump sound
            SoundManagerScript.PlaySound("Jump");

            // Add a vertical force to the player.
            m_Grounded = false;
            m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));
        }
    }
示例#15
0
    private void DoubleJump(Vector3 wishDir)
    {
        if (canDJump)
        {
            SoundManagerScript.PlaySound("djump");
            float tempJumpForce = jumpForce;
            //Calculate upwards
            float upSpeed = rb.velocity.y;
            if (upSpeed < 0)
            {
                upSpeed = 0;
            }
            else if (upSpeed < dJumpBaseSpd)
            {
                upSpeed       = dJumpBaseSpd;
                tempJumpForce = 0;
            }

            //Calculate sideways
            Vector3 jumpVector = Vector3.zero;
            Vector2 force      = Vector2.zero;
            wishDir = wishDir.normalized;
            Vector3 spid = new Vector3(rb.velocity.x, 0, rb.velocity.z);
            if (spid.magnitude < airTargetSpeed)
            {
                jumpVector  = wishDir * dashForce;
                jumpVector -= spid;
            }
            else if (Vector3.Dot(spid.normalized, wishDir) > -0.4f)
            {
                jumpVector   = wishDir * dashForce;
                force        = ClampedAdditionVector(new Vector2(rb.velocity.x, rb.velocity.z), new Vector2(jumpVector.x, jumpVector.z));
                jumpVector.x = force.x;
                jumpVector.z = force.y;
            }
            else
            {
                jumpVector = wishDir * spid.magnitude;
            }

            //Apply Jump
            jumpVector.y = tempJumpForce;
            rb.velocity  = new Vector3(rb.velocity.x, upSpeed, rb.velocity.z);
            rb.AddForce(jumpVector, ForceMode.Impulse);
            canDJump = false;
        }
    }
示例#16
0
    private void Spit()
    {
        Vector2 direction;

        spitTimer += Time.deltaTime;

        if (spitTimer >= spitInterval)
        {
            direction = player.transform.position - transform.position;
            direction.Normalize();

            SoundManagerScript.PlaySound("ThrowWBC");
            Instantiate(spit, spitPoint.transform.position, spitPoint.transform.rotation);

            spitTimer = 0;
        }
    }
示例#17
0
    IEnumerator Pickup(Collider player)
    {
        stats = player.GetComponent <PlayerMovement>();
        if (isBoosted == false)
        {
            isBoosted = true;
            SoundManagerScript.PlaySound("PowerUp");
            stats.speed *= multiplier;
            StartCoroutine(FromTo(60f, 75f, 0.2f, false));
            yield return(new WaitForSeconds(duration));

            isBoosted = false;
            SoundManagerScript.PlaySound("PowerDown");
            StartCoroutine(FromTo(stats.speed, stats.speed / multiplier, 0.7f, true));
            StartCoroutine(FromTo(75f, 60f, 0.7f, false));
        }
    }
示例#18
0
    /**
     * Checks for each objective in the objectives array to see if the player has come within 1 unit of that object,
     * signifying that the player has collected or completed that object. The objective's hasCompleted boolean will
     * be set to true.
     */
    void CheckObjectives()
    {
        Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

        foreach (Objective o in objectives)
        {
            if (Vector2.Distance(o.objective.transform.position, player.position) < 1)
            {
                o.hasCompleted = true;
                if (o.objective.activeSelf)
                {
                    SoundManagerScript.PlaySound("money");
                }
                o.objective.SetActive(false);
            }
        }
    }
示例#19
0
 public void ability() // cd: 10f
 {
     if (!cooldowns[1])
     {
         SoundManagerScript.PlaySound("Skill");
         RaycastHit2D[] ultHits = Physics2D.CircleCastAll(wielder.position, 4.0f, Vector2.zero);
         foreach (RaycastHit2D hit in ultHits)
         {
             if (hit.transform.CompareTag("Enemy"))
             {
                 hit.transform.GetComponent <Enemy>().takeDamage(damage + 2);
             }
         }
         SpawnAndDestroy(hitbox, 0.25f);
         StartCoroutine(FadeTo(1, 10, 1, cooldownImageAbility));
     }
 }
示例#20
0
    private void Update()
    {
        //  Debug.Log(Health);
        HealthBar.SetHealth(Health);
        if (Health <= 0)
        {
            LostLevel.SetActive(true);
            Time.timeScale = 0f;
            Health         = 100;
            SoundManagerScript.PlaySound("stinger_lose");
            //animator.SetTrigger("Death");
            //DestroyGameObject();
            return;
        }

        //white dizzzy logic
    }
示例#21
0
    IEnumerator coroutineA()
    {
        int i = 3;

        while (i >= 1)
        {
            cont.text = i.ToString();
            i--;
            yield return(new WaitForSeconds(1.0f));
        }
        cont.fontSize = 900;
        cont.text     = "GOO!!";
        SoundManagerScript.PlaySound("go");
        yield return(new WaitForSeconds(1.0f));

        cont.enabled = false;
    }
示例#22
0
    /// <summary>
    /// Méthode permettant de diminuer ou d'augmenter les points de vie du Personnage
    /// </summary>
    /// <param name="dmg">nb de points de vie a ajouter (valeur négative pour enlever)</param>
    /// /// <returns> true si tué sinon false</returns>
    public bool takeDamageHeal(int dmg)
    {
        health += dmg;
        if (health <= 0)
        {
            health    = 0;
            healthMax = 0;
            for (int k = 0; k < hand.Count; k++)
            {
                GameObject.Find("GameManager").GetComponent <GameManager>().Disc(hand[k]);
            }
            hand.Clear();

            List <GameObject> Personnages = GameObject.Find("GameManager").GetComponent <GameManager>().Personnages;

            for (int i = 0; i < Personnages.Count; i++)
            {
                if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetHealth() == 0)
                {
                    if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetRole() == "Sheriff")
                    {
                        GameObject.Find("GameManager").GetComponent <GameManager>().nbSheriff--;
                        Debug.Log(GameObject.Find("GameManager").GetComponent <GameManager>().nbSheriff);
                    }
                    else if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetRole() == "Hors La Loi")
                    {
                        GameObject.Find("GameManager").GetComponent <GameManager>().nbHorsLaLoi--;
                        Debug.Log(GameObject.Find("GameManager").GetComponent <GameManager>().nbHorsLaLoi);
                    }

                    Personnages.RemoveAt(i);
                }
            }
        }
        if (health > healthMax)
        {
            health = healthMax;
        }
        if (health == 0 && !isDead)
        {
            isDead = true;
            SoundManagerScript.PlaySound("Oof");
        }

        return(isDead);
    }
示例#23
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         if (LivesUI.lives >= 10)
         {
             ;
         }
         else
         {
             LivesUI.lives += 5;
             SoundManagerScript.PlaySound("HealthUp");
             //SpawnPowerup();
             Destroy(this.gameObject);
         }
     }
 }
示例#24
0
 private void Atack()
 {
     if (atackCD > 0)
     {
         return;
     }
     atackCD = 1.2f;
     PerformAction("Atack");
     foreach (var enemy in FindObjectsOfType <Enemigo>())
     {
         if (Vector3.Distance(transform.position, enemy.transform.position) <= 2)
         {
             enemy.getHit(stats.GetAtack());
             SoundManagerScript.PlaySound("SwordAttack");
         }
     }
 }
示例#25
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         SoundManagerScript.PlaySound("SFX/GetHit");
         HealthScript.health -= 10f;
         //isDead = true;
     }
     if (collision.gameObject.tag == "Bullet")
     {
         bossHealth -= 10;
         // if (bossHealth <= 0)
         //{
         //   boss1IsDead = true;
         //}
     }
 }
示例#26
0
    private void Reset()
    {
        Vector3 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position;

        transform.position = playerPosition + new Vector3(0, 0.5f, 0);

        float dirX = Random.Range(-5.0f, 5.0f);
        float dirY = Random.Range(2.0f, 5.0f);

        direcao = new Vector3(dirX, dirY).normalized;
        gm.vidas--;
        SoundManagerScript.PlaySound("death");
        if (gm.vidas < 0)
        {
            gm.ChangeState(GameManager.GameState.ENDGAME);
        }
    }
示例#27
0
    //Unity calls this function when our pickup touches any other object
    //If the player touches the pickup object, it will disappear and the player's score will go up

    private void OnCollisionEnter2D(Collision2D collision)
    {
        //Check if the thing we touched was the Player
        Player playerScript = collision.collider.GetComponent <Player>();

        //If the thing we touched has the player script, that means it IS the player, so....
        if (playerScript)
        {
            //We hit the player!
            SoundManagerScript.PlaySound("coinSound");
            //Add to the score based on our value
            scoreObject.AddScore(timepieceValue);

            //Destroy the gameObject that this script is attached to (the coin)
            Destroy(gameObject);
        }
    }
示例#28
0
    private void ActivateAssistant()
    {
        AssistantHelp ah = GameObject.Find("MainGameLogic").GetComponent <AssistantHelp>();

        if (!ah.activated)
        {
            DisplayMessageOnScreen("Assistente Monetario Ativado");
            ah.activated = true;
            SoundManagerScript.PlaySound("happy");
        }
        else
        {
            DisplayMessageOnScreen("Assistente Monetario Desactivado");
            ah.activated = false;
            SoundManagerScript.PlaySound("sad");
        }
    }
示例#29
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.CompareTag("Enemy"))
        {
            SoundManagerScript.PlaySound("ShotFired1");
            Enemy target = hitInfo.GetComponent <Enemy>();
            target.TakeDamage(damage);

            Instantiate(impactEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (!hitInfo.CompareTag("Range"))
        {
            Instantiate(impactEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
示例#30
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "FallDetector")
     {
         gameLevelManager.Respawn();
     }
     if (other.tag == "Checkpoint")
     {
         respawnPoint = other.transform.position;
     }
     if (other.tag == "ArenaTriggers")
     {
         if (movingToRight)
         {
             fixMove            = true;
             rigidBody.velocity = new Vector2((movement * speed) / -1, rigidBody.velocity.y);
         }
         else if (movingToLeft)
         {
             fixMove            = true;
             rigidBody.velocity = new Vector2((movement * speed) / -1, rigidBody.velocity.y);
         }
     }
     if (other.gameObject.tag == "Coin")
     {
         money++;
         SoundManagerScript.PlaySound("coin");
     }
     if (other.gameObject.tag == "Characters")
     {
         isNearCharacter = true;
     }
     if (other.gameObject.name == "Goofy")
     {
         isNearGoofy = true;
     }
     if (other.gameObject.name == "Motor_oil")
     {
         SoundManagerScript.PlaySound("questitem");
         hasMotorOil = true;
     }
     if (other.gameObject.name == "Bus_Stop")
     {
         nearBusStop = true;
     }
 }