Пример #1
0
    void StartSpell(GameObject spell, bool isFacingLeft)
    {
        GameObject tempSpell = InstantiateGameObject(spell);

        if (tempSpell.GetComponent <PlayerWeapon>() != null)
        {
            if (isFacingLeft)
            {
                tempSpell.GetComponent <PlayerWeapon>().Setup(leftDir);
            }
            else
            {
                tempSpell.GetComponent <PlayerWeapon>().Setup(rightDir);
            }
        }
        else if (tempSpell.GetComponent <PlayerBuff>() != null)
        {
            PlayerBuff tempBuff = tempSpell.GetComponent <PlayerBuff>();

            tempBuff.Setup();

            if (tempBuff.invulDuration > 0)
            {
                isInvul      = true;
                invulEndTime = Time.timeSinceLevelLoad + tempBuff.invulDuration;

                // Update HUD
                gameManager.StartInvulDurationAnim(tempBuff.invulDuration);
            }

            if (tempBuff.fasterSpeedDuration > 0)
            {
                isFaster      = true;
                fasterEndTime = Time.timeSinceLevelLoad + tempBuff.fasterSpeedDuration;
                playerController.ApplySpeedBuff(tempBuff.speedMultiplier);

                // When the player animator animates slide, it will call the SetToSlideOffset() in PlayerBuffs cript
                playerAnimator.AddPlayerBuff(tempBuff);
            }
        }
    }