Пример #1
0
 void endGamePrompt()
 {
     SfxManager.PlaySound("Click");
     confirmPrompt.SetActive(true);
     exitYes.onClick.AddListener(endGame);
     exitNo.onClick.AddListener(continueGame);
 }
Пример #2
0
    // on collision with other cats
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!isDead && collision.gameObject.tag == "CatBack") // then kill cat
        {
            GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject;
            SfxManager.PlaySound("killCat");
            GameManager.getInstance().onSuccessfulKill(deadCat);
        }

        // if mouse touches front of cat
        else if (collision.gameObject.tag == "Cat") // then game over
        {
            if (!catIsStunned(collision.gameObject))
            {
                anim.SetTrigger("isDead");
                if (!isDead)
                {
                    StartCoroutine(lagGameOver());
                }
            }
            else
            {
                GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject;
                SfxManager.PlaySound("killCat");
                GameManager.getInstance().onSuccessfulKill(deadCat);
            }
        }
    }
Пример #3
0
    IEnumerator NextLevel()
    {
        // TODO async this maybe
        string sceneName = SceneManager.GetActiveScene().name;

        GameManager.Instance.cfp.FadeOut();
        yield return(new WaitForSeconds(1));

        for (int i = 0; i < levels.scenes.Count; i++)
        {
            string s = levels.scenes[i];
            if (s != sceneName)
            {
                continue;
            }

            int levelNumber = i + 1;
            if (PlayerPrefs.GetInt("maxUnlocked", 1) < levelNumber)
            {
                PlayerPrefs.SetInt("maxUnlocked", levelNumber);
                PlayerPrefs.Save();
            }

            SfxManager.PlaySound("win");
            SceneManager.LoadScene(levels.scenes[levelNumber], LoadSceneMode.Single);
            break;
        }
    }
Пример #4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // for jump
        if (isJumping && collision.gameObject.tag == "Ground" && rb.velocity.y <= 0)
        {
            rb.velocity = new Vector3(0, 0, 0);
            isJumping   = false;
            anim.SetBool("isJumping", false);
        }

        // if mouse touches bottom of cat
        if (collision.gameObject.tag == "Cat") // then kill player
        {
            if (!catIsStunned(collision.gameObject))
            {
                // game over code
                anim.SetTrigger("isDead");
                if (!isDead)
                {
                    StartCoroutine(lagGameOver());
                }
            }
            else
            {
                GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject;
                SfxManager.PlaySound("killCat");
                GameManager.getInstance().onSuccessfulKill(deadCat);
            }
        }
    }
Пример #5
0
 void TryPlaySound(List <SfxData> sfxs)
 {
     if (!sfxs.IsEmpty())
     {
         _sfx.PlaySound(sfxs.ToArray());
     }
 }
 private void checkJumpPoint(Collider2D collider)
 {
     switch (collider.gameObject.tag)
     {
     case "JumpPoint":
         if (!isJumping)
         {
             if (mouse != null && mouse.GetComponent <Transform>().position.y > trans.position.y)    //jump
             {
                 rb.AddForce(new Vector2(rb.velocity.x, jumpSpeedY));
                 isJumping = true;
                 SfxManager.PlaySound("jumpingCat");
             }
         }
         break;
         //case "JumpPoint2":
         //    if (!isJumping)
         //    {
         //        if (mouse != null && mouse.GetComponent<Transform>().position.y > trans.position.y) // jump higher
         //        {
         //            rb.AddForce(new Vector2(rb.velocity.x, jumpSpeedY * 1.1f));
         //            Debug.Log("jumppoint2");
         //            isJumping = true;
         //            SfxManager.PlaySound("jumpingCat");
         //        }
         //    }
         //    break;
     }
 }
Пример #7
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.tag == "Monster" || collision.tag == "Boss")
        {
            if (collision.GetComponent <enemyHealth>().currentHealth < 0)
            {
                return;
            }
            this.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0);

            this.GetComponent <Animator>().SetTrigger("Hit");
            SfxManager.PlaySound("FireBallHit");

            float damage = (float)SaveManager.Instance.gestureDMG[4];
            if (!damageShown)
            {
                FloatingTextController.CreateFloatingText(damage.ToString(), transform);
                damageShown = true;
            }
            FightManager.currEnemy.gameObject.GetComponent <enemyHealth>().addDamage(damage);

            //duration of animation
            StartCoroutine(destroyAfterTime(0.77f));
        }
    }
Пример #8
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (requiresSpecificCharacter && !other.gameObject.CompareTag(specificCharacterName))
        {
            return;
        }

        if (!isTouching)
        {
            //when switch is triggered, faded.
            //pic.color = new Color(pic.color.r, pic.color.g, pic.color.b, 0.1F);
            GameManager.Instance.cfp.WatchSomething(goTime, stayTime, objectsToTrigger.ToArray());
            SfxManager.PlaySound("switch");
            if (ActivateEffect)
            {
                ActivateEffect.Play();
            }
            StartCoroutine(ActivateRoutine());
            //when switch is triggered, faded.
            //pic.color = new Color(pic.color.r, pic.color.g, pic.color.b, 0.1F);
            isTouching    = true;
            light.enabled = flipLight ? false : true;
            pic.sprite    = activated;
        }
    }
Пример #9
0
    // todo: implement animation
    protected new void Start()
    {
        base.Start();
        speed = startSpeed;
        SfxManager.PlaySound("chargingCat");

        StartCoroutine(walkToWindup());
    }
Пример #10
0
 // Update is called once per frame
 void Update()
 {
     while (totalMoved > distanceBetweenFootsteps)
     {
         totalMoved -= distanceBetweenFootsteps;
         SfxManager.PlaySound("footstep");
     }
 }
Пример #11
0
    IEnumerator lagGameOver()
    {
        isDead = true;
        yield return(new WaitForSeconds(0.4f)); // delay to play explosion anim

        SfxManager.PlaySound("gameOverSound");
        GameManager.getInstance().gameOver();
    }
Пример #12
0
 public void OnTriggerExit2D(Collider2D other)
 {
     if (other.GetComponent <CharacterMovement>() || other.GetComponent <CharacterMovement_simple>())
     {
         anim.SetTrigger("FadeOut");
         SfxManager.PlaySound("tutorialHide");
     }
 }
Пример #13
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag.Contains("Player"))
     {
         gameObject.SetActive(false);
         SfxManager.PlaySound("coin");
         GameMaster.instance.currentCoin++;
     }
 }
Пример #14
0
    void GameOver()
    {
        MusicManager.StopBGM();
        SfxManager.PlaySound("GameOver");
        StartCoroutine(playAfterTime(1f));

        ButtonShop.paused = false;
        ButtonShop.togglePause();
        gameOverScreen.SetActive(true);
    }
Пример #15
0
 void Jump()
 {
     if (!isJumping)
     {
         SfxManager.PlaySound("Jumping");
         playerRB.AddForce(Vector2.up * jumpHeight, ForceMode2D.Impulse);
         playerAnim.SetInteger("State", 2);
         isJumping = true;
     }
 }
Пример #16
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <CharacterMovement_simple>())
     {
         SfxManager.PlaySound("coin");
         Debug.Log(CounterManager.Instance);
         CounterManager.Instance.Increment();
         Destroy(gameObject);
     }
 }
Пример #17
0
    private IEnumerator DiagRoutine(Dialog[] dgs)
    {
        Time.timeScale     = 0;
        dialogCanvas.alpha = 1;
        isRunningDialog    = true;
        foreach (Dialog dg in dgs)
        {
            textContent.text = "";

            actorImage.sprite = dg.actor.sprite;


            for (int i = 0; i < dg.content.Length; i++)
            {
                textContent.text += dg.content[i];
                SfxManager.PlaySound(dg.actor.name.ToLower());

                float _t = 0;
                while (_t < timeBetweenChars)
                {
                    yield return(new WaitForEndOfFrame());

                    _t += Time.unscaledDeltaTime;
                    if (shouldSkip)
                    {
                        break;
                    }
                }

                if (shouldSkip)
                {
                    textContent.text = dg.content;
                    shouldSkip       = false;
                    break;
                }
            }

            float _tl = 0;
            while (_tl < timeBetweenLines)
            {
                yield return(new WaitForEndOfFrame());

                _tl += Time.unscaledDeltaTime;
                if (shouldSkip)
                {
                    shouldSkip = false;
                    break;
                }
            }
        }

        dialogCanvas.alpha = 0;
        isRunningDialog    = false;
        Time.timeScale     = 1;
    }
Пример #18
0
    private void FixedUpdate()
    {
        rbody.velocity = new Vector2(horizontalVelocity, rbody.velocity.y);

        /*
         * if (Mathf.Abs(rbody.velocity.y) > 15)
         * {
         *  //Debug.Log(Mathf.Abs(rbody.velocity.y));
         *  onGround = false;
         * }
         */
        bool grounded = IsGrounded();

        timeSinceGrounded += Time.deltaTime;


        if (actionBufferTime > 0)
        {
            actionBufferTime -= Time.deltaTime;
        }
        else
        {
            if (IsGrounded() && !onGround)
            {
                actionBufferTime = 0.2f;
                onGround         = true;
                if (rbody.velocity.y < -6)
                {
                    SfxManager.PlaySound("land", transform.position);
                    LandEffect.Play();
                }
            }
        }
        if (grounded && !wasGroundedLastFrame)
        {
            timeSinceGrounded = 0;
            jumpLeft          = maxJumps;

            Transform platform = GetPlatform();
            if (!platform.GetComponent <HingeJoint2D>() && (!platform.GetComponent <Rigidbody2D>() || platform.GetComponent <Rigidbody2D>().bodyType == RigidbodyType2D.Static) && !platform.GetComponent <Collectible>())
            {
                StartCoroutine(SetGroundedPosInTime(0.2f));
                transform.SetParent(GetPlatform());
            }
        }
        else if (!grounded && wasGroundedLastFrame)
        {
            transform.SetParent(null);
        }



        wasGroundedLastFrame = grounded;
    }
Пример #19
0
 void Right()
 {
     SfxManager.PlaySound("Walking");
     if (!facingRight)
     {
         Flip();
     }
     if (!isJumping)
     {
         playerAnim.SetInteger("State", 1);
     }
     playerRB.velocity = new Vector2(moveSpeed, playerRB.velocity.y);
     //playerObject.transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
 }
Пример #20
0
    public void onSuccessfulKill(GameObject cat)
    {
        int catIndex = -1;

        if (cat.GetComponent <ChargeCatMovement>() != null)
        {
            catIndex = CHARGING_CAT_INDEX;
            cat.GetComponent <ChargeCatMovement>().onCatDeath();
        }
        else if (cat.GetComponent <JumpCatMovement>() != null)
        {
            catIndex = JUMPING_CAT_INDEX;
            cat.GetComponent <JumpCatMovement>().onCatDeath();
        }
        else if (cat.GetComponent <CatMovement>() != null)
        {
            catIndex = BASIC_CAT_INDEX;
            cat.GetComponent <CatMovement>().onCatDeath();
        }
        catsKilled[catIndex]++;

        if ((catsKilled[BASIC_CAT_INDEX] == NumBasicCatKills) || (catsKilled[JUMPING_CAT_INDEX] == NumJumpCatKills) || (catsKilled[CHARGING_CAT_INDEX] == NumChargeCatKills))
        {
            difficultyMod++;
            resetCounters();
        }

        //if (killCounter == NumCatKills)
        //{
        //    //difficultyMod++;
        //    killCounter = 0;
        //}
        //else
        //{
        //    killCounter++;
        //}

        if (difficultyMod < LevelDampener)
        {
            numCatsEscaped = 0;
        }

        difficultyMod = (difficultyMod > LevelCap) ? LevelCap : Mathf.Max(difficultyModMin, difficultyMod);


        SfxManager.PlaySound("catDeathCry");
        destroyCat(cat);
        stunAllCats(cat);
    }
Пример #21
0
    public void jump(bool isRecoil)
    {
        isJumping = true;
        SfxManager.PlaySound("jump");
        anim.SetBool("isJumping", true);

        if (isRecoil)
        {
            rb.velocity = new Vector3(rb.velocity.x, jumpSpeedY * 0.8f, 0);
        }
        else
        {
            rb.velocity = new Vector3(rb.velocity.x, jumpSpeedY, 0);
        }
    }
Пример #22
0
 public void stopTimer(bool hasCompletedLevel)
 {
     if (!hasCompletedLevel)
     {
         SfxManager.PlaySound("stop");
         SfxManager.PlaySound("clockDeath");
         timerText.text = "";
         startCd = false;
     } else
     {
         SfxManager.PlaySound("levelComplete");
         timerText.text = "";
         startCd = false;
     }
 }
Пример #23
0
    void makeDead()
    {
        //make sound
        isDead = true;
        if (gameObject.scene.name == "Fight scene")
        {
            SfxManager.PlaySound("EnemyDie2");
        }
        else if (gameObject.scene.name == "Fight scene 1")
        {
            SfxManager.PlaySound("EnemyDie");
        }
        else if (gameObject.scene.name == "Fight scene 2")
        {
            SfxManager.PlaySound("EnemyDie3");
        }

        Destroy(this.GetComponent <AutoMove>());
        this.GetComponent <enemyDamage>().isDead = true;
        this.GetComponent <Animator>().SetBool("isDead", true); //death animation
        this.GetComponent <Rigidbody2D>().AddForceAtPosition(new Vector2(5f, 3.75f), this.GetComponent <Transform>().position, ForceMode2D.Impulse);

        FightManager.monsterDeathCounter++;
        AutoMove.playerContact = false;
        SaveManager.Instance.addGold();

        if (gameObject.tag == "Boss")
        {
            SaveManager.Instance.monsterToClear--;
            SaveManager.Instance.wonLevel();
            MusicManager.StopBGM();
            SfxManager.PlaySound("PlayerWin");
            StartCoroutine(playAfterTime(1f));
            FightManager.winMap = true;
        }
        //Length of animation
        StartCoroutine(destroyAfterTime(0.9f, gameObject));

        /* AudioSource.PlayClipAtPoint(deathKnell, transform.position);
         * Instantiate(enemyDeathFX, transform.position, transform.rotation);
         * if (drops)
         * {
         *  Instantiate(theDrop,transform.position,transform.rotation);
         * }
         */
    }
Пример #24
0
    IEnumerator spawnCat(int index, int spawnIndex)
    {
        SfxManager.PlaySound("catSpawn");
        Vector3 newLocalScale;

        yield return(new WaitForSeconds(0.1f));

        GameObject createdCat = Instantiate(cats[index], spawnPoints[spawnIndex].position, spawnPoints[0].rotation);

        newLocalScale = createdCat.transform.localScale;
        Vector3 pos = createdCat.transform.position;

        if (spawnIndex >= 3) //should face the left
        {
            newLocalScale.x = -newLocalScale.x;
        }
        createdCat.transform.localScale = newLocalScale;
    }
Пример #25
0
    public void SignIn()
    {
        SfxManager.PlaySound("Click");
        if (!PlayGamesPlatform.Instance.localUser.authenticated)
        {
            // Sign in with Play Game Services, showing the consent dialog
            // by setting the second parameter to isSilent=false.
            PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
        }
        else
        {
            // Sign out of play games
            PlayGamesPlatform.Instance.SignOut();

            // Reset UI
            signInButtonText.text = "SIGN IN";
            //authStatus.text = "";
        }
    }
Пример #26
0
    void OnJump(InputValue value)
    {
        bool spacePressed = value.isPressed;

        if (spacePressed && jumpLeft > 0)
        {
            if (Time.time - lastJumpTime < 0.1f)
            {
                return;
            }
            lastJumpTime     = Time.time;
            rbody.velocity   = new Vector2(rbody.velocity.x, jumpSpeed);
            actionBufferTime = 0.2f;
            jumpLeft--;
            onGround = false;
            SfxManager.PlaySound("jump", transform.position);
            JumpEffect.Play();
        }
    }
Пример #27
0
    public void ManipulateLimb(string aDirection, string aType)
    {
        int   layer = LimbManager.GetLimbNumber(aDirection);
        float speed;

        if (aType == "extend")
        {
            speed = ExtendSpeed;
        }
        else if (aType == "retract")
        {
            speed = -RetractSpeed;
        }
        else
        {
            speed = 0;
        }

        float animationTime = LimbAnimator.GetCurrentAnimatorStateInfo(layer - 1).normalizedTime;

        LimbAnimator.SetFloat("Limb" + layer.ToString() + "Speed", speed);

        if (animationTime >= 1.0f && aType == "extend")
        {
            LimbAnimator.Play(LimbAnimator.GetCurrentAnimatorStateInfo(layer - 1).fullPathHash, layer - 1, 1.0f);
            LimbAnimator.SetFloat("Limb" + layer.ToString() + "Speed", 0);
            speed = 0;
        }
        if (animationTime <= 0 && aType == "retract")
        {
            LimbAnimator.Play(LimbAnimator.GetCurrentAnimatorStateInfo(layer - 1).fullPathHash, layer - 1, 0.0f);
            LimbAnimator.SetFloat("Limb" + layer.ToString() + "Speed", 0);
            speed = 0;
        }

        //Debug.Log(speed);
        if (speed != 0f)
        {
            this.gameObject.GetComponent <PhysicsManagement>().ManualCenterOfGravity();
            SoundPlayer.PlaySound(layer - 1, aType);
        }
    }
Пример #28
0

        
Пример #29
0
 public void startTimer()
 {
     startTime = Time.time;
     startCd = true;
     SfxManager.PlaySound("ticking");
 }
Пример #30
0
 public void Reset()
 {
     transform.position = lastGroundedPosition;
     SfxManager.PlaySound("lose");
 }