コード例 #1
0
    public void DeductShieldPoints(int _shieldPoints)
    {
        // If shield is already broken or not active, just ignore.
        if (Shield <= 0)
        {
            mTurnStatus = PlayerTurnStatus.Waiting;
            return;
        }

        mPlayerData.Shield -= _shieldPoints;
        PlayerInfoManager.Instance.UpdateShield(mPlayerData.Shield);

        // Check if shield got broken.
        if (mPlayerData.Shield <= 0)
        {
            AudioManager.PlayShieldDownSound();

            mTurnStatus = PlayerTurnStatus.Running;

            // Broken sheild animation.
            ShakeAction2D shieldFailureShake = new ShakeAction2D(mShieldBubbleTransform, 100, 0.05f, Graph.InverseLinear);
            shieldFailureShake.SetShakeByDuration(0.8f, 100);
            ScaleToAction shieldScaleDown = new ScaleToAction(mShieldBubbleTransform, Graph.Exponential, Vector3.zero, 1.0f);
            shieldScaleDown.OnActionFinish += () => {
                mShieldBubbleSpriteRen.enabled = false;
                mTurnStatus = PlayerTurnStatus.Waiting;
            };
            ActionHandler.RunAction(shieldFailureShake, shieldScaleDown);
        }
        else
        {
            mTurnStatus = PlayerTurnStatus.Waiting;
        }
    }
コード例 #2
0
    public void Use()
    {
        AudioManager.PlayButtonClickSound();

        PlayerPiece player = GameManager.Instance.Player;

        // Focus onto player and animate player.
        BoardScroller.Instance.FocusCameraToPos(
            DungeonManager.Instance.GridPosToWorldPos(player.PosX, player.PosY),
            0.2f,
            Graph.InverseExponential);
        ScaleToAction  scaleUp      = new ScaleToAction(player.transform, Graph.SmoothStep, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.75f, 0.5f);
        ScaleToAction  scaleDownHit = new ScaleToAction(player.transform, Graph.Dipper, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.1f, 0.25f);
        ActionSequence smashSeq     = new ActionSequence(scaleUp, scaleDownHit);

        smashSeq.OnActionFinish += () => {
            // Dramatic shake.
            ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 10, 1.85f, Graph.InverseLinear);
            camShake.SetShakeByDuration(0.6f, 35);
            ActionHandler.RunAction(camShake);

            // Make all things take damage.
            for (int i = 0; i < mArrAffectedPositions.Length; i++)
            {
                DungeonBlock block = DungeonManager.Instance.DungeonBlocks[(int)mArrAffectedPositions[i].x, (int)mArrAffectedPositions[i].y];
                switch (block.State)
                {
                case BlockState.EnemyPiece:
                    if (RepeatPanelControls.NumRepeatsLeft > 0)
                    {
                        block.Enemy.TakeDamage(1 * RepeatPanelControls.NumRepeatsLeft);
                    }
                    else
                    {
                        block.Enemy.TakeDamage(1);
                    }
                    break;

                case BlockState.Obstacle:
                    DungeonManager.Instance.DestroyBlock(block.PosX, block.PosY);
                    break;
                }
            }

            RepeatPanelControls.ClearRepeats();
        };
        ActionHandler.RunAction(smashSeq);

        // Dismiss panel.
        ControlAreaManager.SetCardPanelVisibility(CardType.Smash, false);

        // Organise the cards.
        DeckManager.Instance.ReorganiseCards();
    }
コード例 #3
0
ファイル: ShakeTest_2D.cs プロジェクト: Daburu/Daburu-Tools
 void Start()
 {
     Graph attenGraph = new Graph((float _x) =>
         {
             if (_x < 0.5f)
                 return _x * 2.0f;
             else
                 return _x * -2.0f + 2.0f;
         });
     ShakeAction2D shake = new ShakeAction2D(transform, 20, 1.0f, attenGraph);
     //		shake.SetShakeFrequency(50.0f);
     shake.SetShakeByDuration(10.0f, 1000);
     shake.SetShakeIntensity(1.5f);
     ActionHandler.RunAction(shake);
 }
コード例 #4
0
    public void TakeDamage(int _damage)
    {
        EventAnimationController.Instance.SpawnDamageParticles(transform.position);
        ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 5, 0.5f, Graph.InverseLinear);

        camShake.SetShakeByDuration(0.2f, 15);
        ActionHandler.RunAction(camShake);

        mnHealth -= _damage;

        // Special Take Damage events.
        typeAlgorithms[(int)UnitType].SpecialTakeDamageEvents();

        // Check if piece died. Handling for dying.
        if (mnHealth <= 0)
        {
            Die();
        }
    }
コード例 #5
0
    public void TakeDamage(int _damage)
    {
        // Let Shield Take Damage.
        if (Shield > 0)
        {
            AudioManager.PlayEnemyAtkImpactWithShieldSound();

            DeductShieldPoints(_damage);

            ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 10, 1.25f, Graph.InverseLinear);
            camShake.SetShakeByDuration(0.2f, 15);
            ActionHandler.RunAction(camShake);
            return;
        }

        AudioManager.PlayEnemyAtkImpactSound();

        mPlayerData.Health -= _damage;
        PlayerInfoManager.Instance.UpdateHealth(mPlayerData.Health);

        // Damage indicators.
        EventAnimationController.Instance.FlashRedDamageIndicator();

        // Check if player died. Handling for dying.
        if (mPlayerData.Health > 0)
        {
            // Player hasn't died.
            ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 10, 1.25f, Graph.InverseLinear);
            camShake.SetShakeByDuration(0.2f, 15);
            ActionHandler.RunAction(camShake);
        }
        else
        {
            // End the game here.
            GameManager.Instance.PlayerDied();

            // More dramatic shake.
            ShakeAction2D camShake = new ShakeAction2D(Camera.main.transform, 10, 1.75f, Graph.InverseLinear);
            camShake.SetShakeByDuration(0.4f, 25);
            ActionHandler.RunAction(camShake);
        }
    }
コード例 #6
0
    void Start()
    {
        Graph attenGraph = new Graph((float _x) =>
        {
            if (_x < 0.5f)
            {
                return(_x * 2.0f);
            }
            else
            {
                return(_x * -2.0f + 2.0f);
            }
        });
        ShakeAction2D shake = new ShakeAction2D(transform, 20, 1.0f, attenGraph);

        //		shake.SetShakeFrequency(50.0f);
        shake.SetShakeByDuration(10.0f, 1000);
        shake.SetShakeIntensity(1.5f);
        ActionHandler.RunAction(shake);
    }