Example #1
0
        private IEnumerator LoadUnloadFacebookSceneCoroutine(bool load)
        {
            if (load)
            {
                player.movementEnabled = false;
            }

            yield return(StartCoroutine(cameraManager.FadeInCoroutine()));

            if (load)
            {
                SceneManager.LoadScene("FacebookConversation", LoadSceneMode.Additive);
                RpgManager.CameraManager.ChangeCameraOutputSize(0.5f);
                yield return(StartCoroutine(cameraManager.FadeOutCoroutine()));
            }
            else
            {
                AsyncOperation ao = Instance.unloadingFacebook = SceneManager.UnloadSceneAsync("FacebookConversation");
                yield return(new WaitUntil(() => ao.isDone));

                CameraManager.ChangeCameraOutputSize(1.0f);
                yield return(StartCoroutine(cameraManager.FadeOutCoroutine()));

                RpgManager.OnEndUnloadingFacebook();
            }
        }
Example #2
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 #3
0
 public void EndTalk()
 {
     dialogText = RpgManager.DialogueTalk(null);
     talkCanvas.SetActive(false);
     isCanvasOpen    = false;
     movementEnabled = true;
 }
Example #4
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Morgane")
     {
         RpgManager.ZoneDisplayName(zoneName);
     }
 }
Example #5
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 #6
0
        private void Interaction_1()
        {
            RpgManager.CurrentStory.StopMusic();
            RpgManager.PlayEndMusic();
            RpgManager.Instance.gameState = RpgManager.GameState.End;

            player.Talk(speech1, Interaction_2);
        }
Example #7
0
        public void OnEndPokemonBattle()
        {
            RpgManager.Instance.gameState = RpgManager.Instance.gameState ^ RpgManager.GameState.Minigame;

            RpgManager.SetKey(SaveKey.defeatedCerberus, -2);
            cerberusMovable.transform.position = luckyMovable.transform.position;
            StartCoroutine(EndPokemonCoroutine());
        }
Example #8
0
        private void LaunchFacebookConversation()
        {
            RpgManager.Instance.gameState = RpgManager.Instance.gameState ^ RpgManager.GameState.Minigame;

            player.EndTalk();

            RpgManager.LoadFacebookScene();
        }
Example #9
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 #10
0
        public void OnIntroanimationEnded()
        {
            mainmenuController.enabled = true;

            if (RpgManager.GetKey(SaveKey.defeatedCerberus) == 1)
            {
                cheatPanel.SetActive(true);
            }
        }
Example #11
0
        private void ItsTooDark_3()
        {
            player.EndTalk();

            float      dist1   = Vector3.Distance(entrance1.transform.position, player.transform.position);
            float      dist2   = Vector3.Distance(entrance2.transform.position, player.transform.position);
            Teleporter nearest = dist2 < dist1 ? entrance2 : entrance1;

            RpgManager.LoadScene(nearest.targetScene, nearest.targetSpawnPoint);
        }
Example #12
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 #13
0
        public void Dialog(bool?left, string message, Action OnEndTalk = null)
        {
            sameframe = true;

            isCanvasOpen    = true;
            movementEnabled = false;

            this.onEndTalk = OnEndTalk;

            dialogText = RpgManager.DialogueTalk(left, message);
        }
Example #14
0
 public void PlaySFX(AudioClip clip)
 {
     if (audioSource)
     {
         audioSource.PlayOneShot(clip);
     }
     else
     {
         RpgManager.PlaySFX(clip);
     }
 }
Example #15
0
        private void Interaction()
        {
            counter++;
            if (counter >= audioClips.Count)
            {
                counter = 0;
            }

            RpgManager.CurrentStory.SetMusic(audioClips[counter]);

            //player.Talk(audioNames[counter], () => player.EndTalk());
            RpgManager.ZoneDisplayName(audioNames[counter]);
        }
Example #16
0
 private void ToggleKey(SaveKey key, bool defaultIsZero = false)
 {
     if (defaultIsZero)
     {
         SetKey(key, GetKey(key) == 1 ? 0 : 1);
     }
     else
     {
         SetKey(key, GetKey(key) == 0 ? 1 : 0);
     }
     RpgManager.ZoneDisplayName("Cheat\n" + key.ToString() + " set to " + GetKey(key));
     dataDebug.SetData(RpgManager.Data);
 }
Example #17
0
        protected override void Interact()
        {
            player = RpgManager.Player;

            //animator.SetTrigger("Exit");
            state = State.Idle;

            RpgManager.SaveGame(placeID);

            RpgManager.RefillHP();

            bubbleLabel.text = endLabel;
            icon.gameObject.SetActive(false);
        }
Example #18
0
 protected override void CollisionEnter(Collision2D collision)
 {
     if (collision.collider.name == "Morgane")
     {
         if (target != null)
         {
             StartCoroutine(Teleport(collision.gameObject));
         }
         else
         {
             RpgManager.LoadScene(targetScene, targetSpawnPoint);
         }
     }
 }
Example #19
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 #20
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;
        }
        public void OnEndFacebook()
        {
            RpgManager.Instance.gameState = RpgManager.Instance.gameState ^ RpgManager.GameState.Minigame;

            AudioSource audioSource = GetComponent <AudioSource>();

            audioSource.clip   = musicAfterFb;
            audioSource.volume = 1.0f;
            audioSource.time   = musicStartAt;
            audioSource.Play();

            RpgManager.SetKey(SaveKey.facebookDone, 1);

            RpgManager.SaveGame("Bed");

            computer.active = false;
            player.Talk(tb_afterFB_1, OnEndFacebook2);
        }
Example #22
0
        protected override IEnumerator Start()
        {
            yield return(StartCoroutine(base.Start()));

            orion.gameObject.SetActive(RpgManager.GetKey(SaveKey.metOrion) != 1);

            player.attackEnabled = RpgManager.GetKey(SaveKey.metOrion) == 1;

            if (RpgManager.GetKey(SaveKey.metAltea) == 1)
            {
                blackVeil.SetActive(false);
            }
            else
            {
                snakeToHide.SetActive(false);
                player.movementEnabled = false;
                ItsTooDark_1();
            }
        }
Example #23
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);
            }
        }
Example #24
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);
        }
        private IEnumerator Beginning()
        {
            player.movementEnabled = false;

            yield return(new WaitForSeconds(1));

            bool wait = true;

            player.Talk(tb_beginning_1, () => wait = false);
            yield return(new WaitWhile(() => wait == true));

            wait = true;
            player.Talk(tb_beginning_2, () => wait = false);
            yield return(new WaitWhile(() => wait == true));

            player.EndTalk();
            RpgManager.SetKey(SaveKey.facebookDone, -1);

            RpgManager.SaveGame("Entrance");
        }
Example #26
0
        private void Awake()
        {
            if (Instance == null)
            {
                RpgManager.Instance = this;

                RpgManager.CameraManager = cameraManager;
                RpgManager.Ennemies      = ennemies;
                RpgManager.Player        = player;
                RpgManager.Projectiles   = projectiles;
                RpgManager.Interaction   = interaction;
                RpgManager.HUD           = hud;

                DontDestroyOnLoad(gameObject);
            }
            else
            {
                //RpgManager.SceneJustLoaded = true;
                RpgManager.Instance.StartCoroutine(RpgManager.Instance.FinishLoadSceneCoroutine(RpgManager.Spawn));
                Destroy(gameObject);
            }
        }
        protected override IEnumerator InitializeScene(bool waitFrame)
        {
            if (waitFrame)
            {
                yield return(new WaitForEndOfFrame());
            }

            player.attackEnabled = false;

            computer.active = (RpgManager.GetKey(SaveKey.facebookDone) != 1);
            entrance.active = (RpgManager.GetKey(SaveKey.facebookDone) == 1);

            if (RpgManager.GetKey(SaveKey.facebookDone) == 0)
            {
                yield return(StartCoroutine(Beginning()));
            }
            else if (RpgManager.GetKey(SaveKey.facebookDone) == 1)
            {
                AudioSource audioSource = GetComponent <AudioSource>();
                audioSource.clip   = musicAfterFb;
                audioSource.volume = 1.0f;
                audioSource.Play();
            }
        }
Example #28
0
        protected override IEnumerator InitializeScene(bool waitFrame)
        {
            if (waitFrame)
            {
                yield return(new WaitForEndOfFrame());
            }

            player.attackEnabled = RpgManager.GetKey(SaveKey.metOrion) == 1;

            papaBullEvent.isDialogue = (RpgManager.GetKey(SaveKey.metOrion) != 1);
            snakeBefore.gameObject.SetActive(RpgManager.GetKey(SaveKey.metAltea) != 1 &&
                                             RpgManager.GetKey(SaveKey.seenBull) == 0 && RpgManager.GetKey(SaveKey.seenSnake) == 0);
            snakeAfter.gameObject.SetActive(RpgManager.GetKey(SaveKey.metAltea) != 1 &&
                                            RpgManager.GetKey(SaveKey.seenBull) == 1 && RpgManager.GetKey(SaveKey.seenSnake) != 1);

            altea.gameObject.SetActive(RpgManager.GetKey(SaveKey.metAltea) != 1);

            entreeMontgeron.gameObject.SetActive(RpgManager.GetKey(SaveKey.seenMontgeron) != 1);

            maisonMontgeron.gameObject.SetActive(RpgManager.GetKey(SaveKey.seenMontgeron) != 1);
            teleporterMontgeron.gameObject.SetActive(RpgManager.GetKey(SaveKey.seenMontgeron) == 1);

            papaBullCreature.gameObject.SetActive(RpgManager.GetKey(SaveKey.seenMontgeron) != 1);
        }
Example #29
0
        private void Awake()
        {
            papaBullEvent.onEndInteraction += () => {
                if (RpgManager.GetKey(SaveKey.seenBull) != 1)
                {
                    RpgManager.SetKey(SaveKey.seenBull, 1);
                    snakeBefore.gameObject.SetActive(false);
                    bool b = RpgManager.GetKey(SaveKey.seenSnake) != 1 && RpgManager.GetKey(SaveKey.metAltea) == 0;
                    snakeAfter.gameObject.SetActive(b);
                }
            };

            snakeBefore.onEndInteraction += () => {
                RpgManager.SetKey(SaveKey.seenSnake, -1);
                snakeBefore.gameObject.SetActive(false);
                snakeAfter.gameObject.SetActive(false);
            };
            snakeAfter.onEndInteraction += () => {
                RpgManager.SetKey(SaveKey.seenSnake, 1);
                snakeBefore.gameObject.SetActive(false);
                snakeAfter.gameObject.SetActive(false);
            };

            entreeMontgeron.onEndInteraction += () => {
                RpgManager.SetKey(SaveKey.seenMontgeron, 1);
                entreeMontgeron.gameObject.SetActive(false);
                papaBullCreature.gameObject.SetActive(false);
                RpgManager.SaveGame("Montgeron");
            };

            maisonMontgeron.onEndInteraction += () => {
                RpgManager.SetKey(SaveKey.seenHouse, 1);
                maisonMontgeron.gameObject.SetActive(false);
                teleporterMontgeron.gameObject.SetActive(true);
            };
        }
Example #30
0
        private void Update()
        {
            // F1 : Unset all keys
            // F2 : Toggle facebookDone
            // F3 : Toggle SeenBull & SeenSnake
            // F4 : Toggle MetAltea
            // F5 : Toggle MetOrion
            // F6 : Toggle SeenMontgeron
            // F7 : Toggle SeenHouse
            // F8 : Toggle DefeatedCerberus
            // F11 : Force save
            // F12 : Toggle collisions

            if (Input.GetButtonDown("Back") && gameState != GameState.MainMenu)
            {
                ToggleMenu();
            }
            else if (Input.GetKeyDown(KeyCode.F1))
            {
                /*RpgManager.Data = new GameData();
                 * dataDebug.SetData(RpgManager.Data);
                 * RpgManager.ZoneDisplayName("Cheat \n Unset all save keys");*/
                RefillHP();
                RpgManager.ZoneDisplayName("Cheat\nHeal");
            }
            else if (Input.GetKeyDown(KeyCode.F2))
            {
                ToggleKey(SaveKey.facebookDone, true);
            }
            else if (Input.GetKeyDown(KeyCode.F3))
            {
                int value = (GetKey(SaveKey.seenBull) == 1 && GetKey(SaveKey.seenSnake) == 1) ? 0 : 1;
                SetKey(SaveKey.seenBull, value);
                SetKey(SaveKey.seenSnake, value);
                RpgManager.ZoneDisplayName("Cheat\n" + "seenBull and seenSnake\n" + " set to " + value);
                dataDebug.SetData(RpgManager.Data);
            }
            else if (Input.GetKeyDown(KeyCode.F4))
            {
                ToggleKey(SaveKey.metAltea);
            }
            else if (Input.GetKeyDown(KeyCode.F5))
            {
                ToggleKey(SaveKey.metOrion);
            }
            else if (Input.GetKeyDown(KeyCode.F6))
            {
                ToggleKey(SaveKey.seenMontgeron);
            }
            else if (Input.GetKeyDown(KeyCode.F7))
            {
                ToggleKey(SaveKey.seenHouse);
            }
            else if (Input.GetKeyDown(KeyCode.F8))
            {
                ToggleKey(SaveKey.defeatedCerberus, true);
            }
            else if (Input.GetKeyDown(KeyCode.F11))
            {
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    RpgManager.Data = GameData.LoadFromFile();
                    RpgManager.ZoneDisplayName("Cheat\nForce load");
                    dataDebug.SetData(RpgManager.Data);
                    LoadScene(dataDebug.scene, dataDebug.place);
                }
                else
                {
                    GameData.SaveToFile(RpgManager.Data);
                    RpgManager.ZoneDisplayName("Cheat\nForce save");
                }
            }
            else if (Input.GetKeyDown(KeyCode.F12))
            {
                Collider2D c = player.GetComponent <Collider2D>();
                c.enabled = !c.enabled;
                RpgManager.ZoneDisplayName("Cheat\nCollisions " + (c.enabled ? "Activées" : "Désactivées"));
            }
        }