Example #1
0
        private IEnumerator GetHit(int dmg = 1)
        {
            RpgManager.PlaySFX(sfx_hit);

            pv -= dmg;
            RpgManager.HUD.UpdateHearts(pv, 3);
            animator.SetTrigger("Hit");

            isHitInCooldown = true;

            if (pv <= 0)
            {
                GetComponent <Collider2D>().enabled = false;
                animator.SetBool("GameOver", true);
                enabled = false;
                Stop();
                yield return(new WaitForSeconds(1.0f));

                RpgManager.GameOver();
                yield break;
            }

            yield return(new WaitForSeconds(hitDelay));

            isHitInCooldown = false;
        }
Example #2
0
        private void Update()
        {
            if (Input.GetButtonDown(INPUT_FIRE))
            {
                if (isCanvasOpen && !sameframe)
                {
                    RpgManager.PlaySFX(sfx_talk);

                    if (dialogText && dialogText.isWriting)
                    {
                        dialogText.EndSetTextCoroutine();
                    }
                    else if (talkText.isWriting)
                    {
                        talkText.EndSetTextCoroutine();
                    }
                    else if (onEndTalk != null)
                    {
                        onEndTalk();
                    }
                }
                else if (attackEnabled && !overrideMovement)
                {
                    Fire();
                }
            }

            sameframe = false;
        }
Example #3
0
 public static void RefillHP(bool mute = false)
 {
     Player.pv = 3;
     RpgManager.HUD.UpdateHearts(Player.pv, 3);
     if (!mute)
     {
         RpgManager.PlaySFX(RpgManager.Instance.sfx_refillHP);
     }
 }
Example #4
0
        private IEnumerator OnIntroAnimEndCoroutine()
        {
            int       index = RpgManager.Instance.GetGameOverCommentId(true, firstComment.Count);
            AudioClip clip  = firstComment[index];

            RpgManager.PlaySFX(clip);
            yield return(new WaitForSeconds(clip.length));

            menuController.gameObject.SetActive(true);
        }
Example #5
0
 public void PlaySFX(AudioClip clip)
 {
     if (audioSource)
     {
         audioSource.PlayOneShot(clip);
     }
     else
     {
         RpgManager.PlaySFX(clip);
     }
 }
Example #6
0
        private IEnumerator Teleport(GameObject go)
        {
            if (sfx)
            {
                RpgManager.PlaySFX(sfx);
            }

            RpgManager.Player.movementEnabled = false;
            yield return(StartCoroutine(RpgManager.CameraManager.FadeInCoroutine()));

            go.transform.position = target.position;
            yield return(StartCoroutine(RpgManager.CameraManager.FadeOutCoroutine()));

            RpgManager.Player.movementEnabled = true;
        }
Example #7
0
        private void Awake()
        {
            renderer = GetComponent <SpriteRenderer>();

            int rdm = Random.Range(0, sprites.Count);

            renderer.sprite = sprites[rdm];
            renderer.color  = colors[rdm];

            if (rdm == 2 && RpgManager.CurrentStory is CaveStory)
            {
                rdm++;
            }
            RpgManager.PlaySFX(clips[rdm], 0.5f);

            baseScale = transform.localScale.x;
        }
Example #8
0
        private IEnumerator EndInteraction()
        {
            player.movementEnabled = false;

            MovableEntity movable = GetComponentInChildren <MovableEntity>();
            var           rb      = movable.GetComponent <Rigidbody2D>();

            rb.bodyType = RigidbodyType2D.Dynamic;
            movable.MoveTo(RpgManager.Player.transform.position);

            yield return(new WaitWhile(() => movable.isMoving));

            character.SetActive(false);

            if (isAltea)
            {
                RpgManager.SetKey(SaveKey.metAltea, 1);
            }
            else
            {
                RpgManager.SetKey(SaveKey.metOrion, 1);
                player.attackEnabled = true;
            }

            RpgManager.SaveGame(isAltea ? "SPA" : "Orion");

            float oldvolume = RpgManager.CurrentStory.GetMusicVolume();

            RpgManager.CurrentStory.SetMusicVolume(0);
            RpgManager.PlaySFX(sfx_jingle);
            bool wait = true;

            player.Talk((isAltea ? "Altea" : "Orion") + " rejoint l'equipe !", () => wait = false);
            yield return(new WaitForSeconds(sfx_jingle.length - 1));

            yield return(new WaitWhile(() => wait));

            gameObject.SetActive(false);

            player.EndTalk();
            RpgManager.CurrentStory.SetMusicVolume(oldvolume);
        }
Example #9
0
        private void FixedUpdate()
        {
            if (creatureController.isSpeeping || creatureController.isJustHit)
            {
                rigidbody.velocity = Vector2.zero;
                return;
            }

            Vector3 playerPos  = RpgManager.Player.transform.position;
            bool    wasChasing = isChasing;

            isChasing = isPlayerInRoamZone(playerPos);

            if (isChasing && !justHitPlayer)
            {
                if (!wasChasing)
                {
                    RpgManager.PlaySFX(sfx_seePlayer);
                }

                speed      = Mathf.Clamp(speed + speedChaseIncrement, speedRoam, maxSpeedChase);
                target     = playerPos;
                isStopping = false;
            }
            else if (isStopping)
            {
                speed = speedRoam;
                rigidbody.velocity = Vector2.zero;
                return;
            }

            if (Vector3.Distance(transform.position, target) < stoppingDistance)
            {
                rigidbody.velocity = Vector2.zero;
                StartCoroutine(waitCoroutine());
            }
            else
            {
                rigidbody.velocity = (target - transform.position).normalized * speed;
                //Debug.Log(rigidbody.velocity);
            }
        }