public IEnumerator Test_SoundWhenPlayerUsesBoost()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.boost);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);
        Enemy enemy = CreateEnemy(false);

        gameCtr.sfxControl = sfx;

        Item item = ScriptableObject.CreateInstance <Item>();

        item.type = ItemType.AttackBoost;

        yield return(new WaitForEndOfFrame());

        gameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        item.Use(player.stats, gameCtr);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.boost, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 2
0
        private void Start()
        {
            motionAnimControll    = this.GetComponentInChildren <MotionAnimControll>();
            guardControll         = this.GetComponent <GuardControll>();
            playerCancelProcesses = transform.GetComponentsInChildren <IPlayerCancelProcess>();

            rigid = this.GetComponent <Rigidbody>();
            motionAnimControll.ResponseStream.Subscribe(RecieveResponce);
            soundEffectControl = GetComponent <SoundEffectControl>();
        }
Ejemplo n.º 3
0
    public void Use(FighterStatsClass user, IGameController gameCtr = null)
    {
        if (usesLeft == 0)
        {
            Debug.LogWarning("Tried to use item when it had 0 uses left. No effect!");
            return;
        }
        if (user == null)
        {
            Debug.LogWarning("Tried to use item without a user. No effect!");
            return;
        }

        switch (type)
        {
        case ItemType.AttackBoost:
            user.AddLastingDamageBoost("Boost Item", 1.2f);
            if (gameCtr != null)
            {
                SoundEffectControl sfx = gameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.Boost();
                }
            }
            break;

        case ItemType.Healing:
            user.GetHealedBy(80);

            if (gameCtr != null)
            {
                SoundEffectControl sfx = gameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.Heal();
                }
            }
            break;

        case ItemType.DealDamage:
            if (gameCtr != null)
            {
                gameCtr.PlayerThrowBomb();
            }
            break;

        default:
            Debug.LogWarning("There was no behavior specified for item of type " + type.ToString());
            break;
        }
        usesLeft--;
    }
Ejemplo n.º 4
0
        public void NotifyPlayer(string message, SoundEffectControl soundEffect)
        {
            var time = new DateTimeOffset(new DateTime(Math.Max(NextAvailableTime.Ticks, DateTimeOffset.Now.Ticks)));

            NextAvailableTime = time.AddSeconds(_notifyPlayerTime);
            _playerNotifies.Add(new NotifyPlayer
            {
                SecondsRemaining = GetTimeRemaining(time),
                Message          = message,
                SoundEffect      = soundEffect
            });
        }
Ejemplo n.º 5
0
    public override void ShowDodge()
    {
        if (GameCtr != null)
        {
            GameCtr.ReactToDodge(dodged, DodgeDuration);

            SoundEffectControl sfx = GameCtr.GetSFXControl();
            if (sfx != null)
            {
                sfx.EnemyDodged();
            }
        }
    }
Ejemplo n.º 6
0
    // Spiel endet nach Abschluss der Animation -> Blackscreen && Thank you for playing canvas



    void Update()
    {
        if (player != null)
        {
            if (!isOpen)
            {
                float dist = player.GetDistanceToPlayer(this.transform.position);
                if (dist < openDistance)
                {
                    if (animator != null)
                    {
                        animator.SetTrigger("OpenChest");
                    }

                    if (gameCtr != null)
                    {
                        SoundEffectControl sfx = gameCtr.GetSFXControl();
                        if (sfx != null)
                        {
                            sfx.ChestOpen();
                        }
                    }

                    isOpen = true;
                    if (gameCtr != null)
                    {
                        gameCtr.outroPlaying = true;
                    }
                }
            }
            else
            {
                if (flareLight != null)
                {
                    if (flareLight.intensity < maxLightIntensity)
                    {
                        flareLight.intensity += staticService.GetDeltaTime() * lightIncreaseSpeed;
                        flareLight.intensity  = Mathf.Min(maxLightIntensity, flareLight.intensity);
                    }
                    else
                    {
                        if (gameCtr != null &&
                            !gameCtr.gameEnded)
                        {
                            gameCtr.InvokeGameEnd(2, flareLight);
                        }
                    }
                }
            }
        }
    }
    public IEnumerator Test_SoundWhenGameEnds()
    {
        float endDuration          = 0.001f;
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.desaster);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);

        yield return(new WaitForEndOfFrame());

        gameCtr.InvokeGameEnd(endDuration, null);

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.desaster, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 8
0
    public override void ShowDodge()
    {
        IGameController gameCtr = playerAddition.GetGameController();

        if (gameCtr != null)
        {
            gameCtr.ReactToDodge(dodged, DodgeDuration);

            SoundEffectControl sfx = gameCtr.GetSFXControl();
            if (sfx != null)
            {
                sfx.PlayerDodged();
            }
        }
    }
    public IEnumerator Test_SoundWhenTeleporting()
    {
        SoundEffectControl sfx      = CreateSFXControl(EffectToTest.teleport);
        Player             player   = CreatePlayer();
        GameController     gameCtr  = CreateGameController(player);
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        teleport.PlayerTeleport();

        yield return(new WaitForSeconds(teleport.TeleportTime));

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.teleport, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 10
0
    public void PlayerCollectItem()
    {
        if (droppedItem != null)
        {
            if (droppedItem.GetUsesLeft() == 0)
            {
                droppedItem.SetUpItem();
            }
            if (player.inventory != null)
            {
                player.inventory.CollectItem(droppedItem);
            }

            if (player.GameCtr != null)
            {
                SoundEffectControl sfx = player.GameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.ItemPickUp();
                }
            }
        }
        else
        {
            if (door != null)
            {
                // this is a key, react to collecting it
                door.Open();

                if (player.GameCtr != null)
                {
                    SoundEffectControl sfx = player.GameCtr.GetSFXControl();
                    if (sfx != null)
                    {
                        sfx.KeyPickUp();
                    }
                }
            }
        }

        GameObject.Destroy(this.gameObject);
    }
Ejemplo n.º 11
0
    public IEnumerator Test_SoundWhenCollectingKey()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.keyPickUp);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);

        gameCtr.sfxControl = sfx;
        ItemDrop drop = CreateItemDrop(true);

        drop.player = player;

        yield return(new WaitForEndOfFrame());

        drop.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.keyPickUp, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 12
0
    public void ShowMessage(string message, SoundEffectControl SoundEffect)
    {
        if (_isGameOver)
        {
            return;
        }
        SoundEffect.Play();
        Player winner;

        if (Enum.TryParse(message, out winner))
        {
            _isGameOver = true;
            GameResult.Resolve(winner);
        }
        else
        {
            Text.text      = message;
            _timeRemaining = 0.5f;
        }
    }
Ejemplo n.º 13
0
    public IEnumerator Test_SoundWhenChestOpens()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.chestOpen);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);

        gameCtr.sfxControl = sfx;
        TreasureChest chest = CreateChest();

        chest.player             = player;
        chest.transform.position = new Vector3(chest.openDistance + 1, 0, 0);

        yield return(new WaitForEndOfFrame());

        player.transform.position = new Vector3(chest.openDistance, 0, 0);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.chestOpen, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 14
0
    public IEnumerator Test_SoundWhenFleeing()
    {
        SoundEffectControl sfx    = CreateSFXControl(EffectToTest.flee);
        Player             player = CreatePlayer();
        Enemy enemy = CreateEnemy(false);

        enemy.playerCanFlee         = true;
        enemy.playerFleeProbability = 1;
        GameController GameCtr = CreateGameController(player);

        yield return(new WaitForEndOfFrame());

        GameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        GameCtr.PlayerTryFleeBattle();

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.flee, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 15
0
    public override void HandleDeath()
    {
        base.HandleDeath();
        if (GameCtr != null)
        {
            PlayerStatsClass player = GameCtr.GetPlayerStats();
            if (player != null)
            {
                player.ModifyPoints(PointsToGain);
            }
            if (GameCtr.GetCurrentEnemies() != null)
            {
                Enemy enemy = GameCtr.GetCurrentEnemies()[0];
                GameCtr.HandleDeath(enemy.transform, enemy.DeathParticle, enemy.DeathParticleLength, new Vector3(0, 0, 0));
                SoundEffectControl sfx = GameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.EnemyDeath();
                }

                if (lockedDoor != null)
                {
                    ItemDrop key = lockedDoor.OnEnemyDied();
                    if (key != null)
                    {
                        ItemDrop droppedKey = GameObject.Instantiate(key, enemy.transform.position, enemy.transform.rotation);
                        droppedKey.door = lockedDoor;
                    }
                    else
                    {
                        enemy.DropRandomItem();
                    }
                }
                else
                {
                    enemy.DropRandomItem();
                }
            }
        }
    }
Ejemplo n.º 16
0
    public IEnumerator Test_SoundWhenPlayerCharges()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.playerCharge);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);
        Enemy enemy = CreateEnemy(false);

        gameCtr.sfxControl = sfx;

        yield return(new WaitForEndOfFrame());

        gameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        gameCtr.PlayerChargeForBoost();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.playerCharge, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 17
0
    public IEnumerator Test_SoundWhenGameOver()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.gameOver);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);
        Enemy enemy = CreateEnemy(false);

        gameCtr.sfxControl = sfx;

        yield return(new WaitForEndOfFrame());

        gameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        player.stats.ReceiveDamage(player.stats.MaxHealth);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.gameOver, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Ejemplo n.º 18
0
    public IEnumerator Test_SoundWhenEnemyDodges()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.dodged);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);
        Enemy enemy = CreateEnemy(false);

        enemy.stats.DodgePropability = 1;

        yield return(new WaitForEndOfFrame());

        gameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        player.stats.AttackOpponent(enemy.stats, true, true);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.enemySource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.dodged, sfx.enemySource.clip, "Enemy audio source did not play the right track!");
    }
Ejemplo n.º 19
0
    public IEnumerator Test_SoundWhenEnemyCharges()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.enemyCharge);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);
        Enemy enemy = CreateEnemy(false);

        enemy.AttackProbability = 0;
        gameCtr.sfxControl      = sfx;

        yield return(new WaitForEndOfFrame());

        gameCtr.StartBattle(enemy);

        yield return(new WaitForEndOfFrame());

        enemy.ChooseRandomBattleActionAndAct(false, true);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.enemySource.isPlaying, "Enemy audio source did not play anything!");
        Assert.AreEqual(sfx.enemyCharge, sfx.enemySource.clip, "Enemy audio source did not play the right track!");
    }
Ejemplo n.º 20
0
    /// <summary>
    /// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
    /// </summary>
    protected override void Start()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);

            StartCoroutine (PlayMusic ());
            CreateDictionary();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 21
0
    void Start()
    {
        player      = FindObjectOfType <Player>();
        playerStats = player.stats;

        musicControl = FindObjectOfType <MusicControl>();
        sfxControl   = FindObjectOfType <SoundEffectControl>();

        battleUI      = GameObject.Find("BattleUI");
        attackBtn     = GameObject.Find("AttackBtn");
        chargeBtn     = GameObject.Find("ChargeBtn");
        fleeBtn       = GameObject.Find("FleeBtn");
        redX          = GameObject.Find("X");
        gameUI        = GameObject.Find("GameUI");
        gameOverUI    = GameObject.Find("GameOverUI");
        introUI       = GameObject.Find("IntroUI");
        blackScreenUI = GameObject.Find("BlackScreenUI");
        gameEndUI     = GameObject.Find("GameEndUI");
        inventoryUI   = GameObject.Find("InventoryUI");

        if (battleUI != null)
        {
            battleUI.SetActive(false);
        }
        if (attackBtn != null)
        {
            attackBtnScript = attackBtn.GetComponent <Button>();
            if (attackBtnScript != null)
            {
                attackBtnScript.interactable = false;
                if (attackBtnScript.transform.childCount > 0)
                {
                    Transform textObject = attackBtnScript.transform.GetChild(0);
                    if (textObject != null)
                    {
                        attackBtnText = textObject.GetComponent <TextMeshProUGUI>();
                    }
                }
            }
        }
        if (chargeBtn != null)
        {
            chargeBtnScript = chargeBtn.GetComponent <Button>();
            if (chargeBtnScript != null)
            {
                chargeBtnScript.interactable = false;
                if (chargeBtnScript.transform.childCount > 0)
                {
                    Transform textObject = chargeBtnScript.transform.GetChild(0);
                    if (textObject != null)
                    {
                        chargeBtnText = textObject.GetComponent <TextMeshProUGUI>();
                    }
                }
            }
        }
        if (fleeBtn != null)
        {
            fleeBtnScript = fleeBtn.GetComponent <Button>();
            if (fleeBtnScript != null)
            {
                fleeBtnScript.interactable = false;
            }
        }

        if (gameUI != null)
        {
            Transform textObj = gameUI.transform.Find("PointsText");
            if (textObj != null)
            {
                pointsText = textObj.gameObject.GetComponent <TextMeshProUGUI>();
                if (pointsText != null)
                {
                    pointsText.text = "0";
                }
            }
        }
        if (gameOverUI != null)
        {
            gameOverUI.SetActive(false);
        }
        if (blackScreenUI != null)
        {
            Transform blackImg = blackScreenUI.transform.GetChild(0);
            if (blackImg != null)
            {
                black = blackImg.GetComponent <Image>();
                if (black != null)
                {
                    black.gameObject.SetActive(true);
                    //black.CrossFadeAlpha(0, introFadeDuration, true);
                }
            }
        }
        if (introUI != null)
        {
            Transform bg = introUI.transform.GetChild(0);
            if (bg != null)
            {
                introBg = bg.GetComponent <Image>();
                if (introBg != null)
                {
                    introBg.gameObject.SetActive(true);
                    introBg.CrossFadeAlpha(1, introFadeDuration, true);

                    introText = introBg.GetComponentInChildren <TextMeshProUGUI>();
                    if (introText != null)
                    {
                        introText.gameObject.SetActive(true);
                        introText.CrossFadeAlpha(1, introFadeDuration, true);
                    }
                }
            }
        }
        if (gameEndUI != null)
        {
            Transform whiteImg = gameEndUI.transform.GetChild(0);
            if (whiteImg != null)
            {
                white = whiteImg.GetComponent <Image>();
                if (white != null)
                {
                    white.gameObject.SetActive(true);
                    white.CrossFadeAlpha(0, 0, true);
                    endText = white.GetComponentInChildren <TextMeshProUGUI>();
                    if (endText != null)
                    {
                        endText.gameObject.SetActive(true);
                        endText.CrossFadeAlpha(0, 0, true);
                    }
                }
            }
        }
        if (inventoryUI != null)
        {
            inventoryUI.SetActive(false);
        }

        if (gameCam == null)
        {
            gameCam = FindObjectOfType <CameraFollow>();
        }

        if (NormalRoom != null)
        {
            NormalRoom.SetActive(true);
        }
        if (BrokenRoom != null)
        {
            BrokenRoom.SetActive(false);
        }
    }