Beispiel #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;
        }
    }
Beispiel #2
0
    private void ExecuteMove(int _newX, int _newY)
    {
        AudioManager.PlayMoveSound();

        SetPosition(_newX, _newY);
        MoveToAction moveToPos = new MoveToAction(this.transform, Graph.InverseExponential,
                                                  DungeonManager.Instance.GridPosToWorldPos(_newX, _newY), 0.5f);

        moveToPos.OnActionFinish = () => {
            mTurnStatus = PlayerTurnStatus.Waiting; mSpriteRen.sortingOrder = mnDefaultSpriteOrderInLayer;

            // Check if reached the dungeonExit.
            if (DungeonManager.Instance.IsExitCell(PosX, PosY))
            {
                RepeatPanelControls.ClearRepeats();
                DeckManager.Instance.ReorganiseCards();
                GameManager.Instance.ReachedFloorExit();
            }

            // Repeat if needed.
            if (RepeatPanelControls.NumRepeatsLeft > 0)
            {
                if (RepeatPanelControls.NumRepeatsLeft > 0)
                {
                    ControlAreaManager.ExecutedCard.Execute();
                }
            }
        };
        ActionHandler.RunAction(moveToPos);
    }
Beispiel #3
0
    public void ExecuteTurn(int _newX, int _newY)
    {
        mTurnStatus             = PlayerTurnStatus.Running;
        mSpriteRen.sortingOrder = 1000;

        if (DungeonManager.Instance.IsEnemyPos(_newX, _newY))
        {
            ExecuteAttack(_newX, _newY);
        }
        else
        {
            ExecuteMove(_newX, _newY);
        }

        BoardScroller.Instance.FocusCameraToPos(
            DungeonManager.Instance.GridPosToWorldPos(PosX, PosY),
            0.2f,
            Graph.InverseExponential);
    }
Beispiel #4
0
    void Awake()
    {
        mTurnStatus = PlayerTurnStatus.Waiting;

        mSpriteRen                  = GetComponent <SpriteRenderer>();
        mSpriteRen.sprite           = PlayerSprites[0];
        mnDefaultSpriteOrderInLayer = mSpriteRen.sortingOrder;

        mShieldBubbleTransform         = transform.GetChild(0);
        mShieldBubbleSpriteRen         = mShieldBubbleTransform.GetComponent <SpriteRenderer>();
        mShieldBubbleSpriteRen.sprite  = ShieldBubble;
        mShieldBubbleSpriteRen.enabled = false;

        mCoinTransform         = transform.GetChild(1);
        mCoinSpriteRen         = mCoinTransform.GetComponent <SpriteRenderer>();
        mCoinSpriteRen.sprite  = Coin;
        mCoinSpriteRen.enabled = false;

        transform.localScale *= DungeonManager.Instance.ScaleMultiplier;
    }
 public void SetStatus(PlayerTurnStatus newStatus)
 {
     this.playerStatus = newStatus;
 }
Beispiel #6
0
    private void ExecuteAttack(int _targetX, int _targetY)
    {
        ActionSequence sequence = new ActionSequence();

        // Player's logical position values set below, after attack.
        ScaleToAction scaleUp = new ScaleToAction(this.transform, Graph.SmoothStep, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.75f, 0.5f);

        scaleUp.OnActionStart += () => { AudioManager.PlayPreAtkSound(); };

        MoveToAction moveToPos = new MoveToAction(this.transform, Graph.Dipper,
                                                  DungeonManager.Instance.GridPosToWorldPos(_targetX, _targetY), 0.25f);
        ScaleToAction  scaleDownHit = new ScaleToAction(this.transform, Graph.Dipper, Vector3.one * DungeonManager.Instance.ScaleMultiplier * 1.1f, 0.25f);
        ActionParallel hitParallel  = new ActionParallel(moveToPos, scaleDownHit);

        hitParallel.OnActionFinish += () => {
            EnemyPiece target = DungeonManager.Instance.DungeonBlocks[_targetX, _targetY].Enemy;
            target.TakeDamage(1);

            AudioManager.PlayPlayerAtkImpactSound();

            if (target.Health <= 0)
            {
                ScaleToAction scaleDown = new ScaleToAction(this.transform, Graph.SmoothStep, Vector3.one * DungeonManager.Instance.ScaleMultiplier, 0.5f);
                scaleDown.OnActionStart += () => {
                    BoardScroller.Instance.FocusCameraToPos(this.transform.position, 0.5f, Graph.InverseExponential);
                };
                scaleDown.OnActionFinish += () => {
                    // Repeat if needed.
                    if (RepeatPanelControls.NumRepeatsLeft > 0)
                    {
                        if (RepeatPanelControls.NumRepeatsLeft > 0)
                        {
                            ControlAreaManager.ExecutedCard.Execute();
                        }
                    }
                };
                sequence.Add(scaleDown);

                SetPosition(_targetX, _targetY);
            }
            else
            {
                MoveToAction moveBack = new MoveToAction(this.transform, Graph.SmoothStep,
                                                         DungeonManager.Instance.GridPosToWorldPos(PosX, PosY), 0.5f);
                ScaleToAction  scaleDownReturn = new ScaleToAction(this.transform, Graph.SmoothStep, Vector3.one * DungeonManager.Instance.ScaleMultiplier, 0.5f);
                ActionParallel returnParallel  = new ActionParallel(moveBack, scaleDownReturn);
                returnParallel.OnActionFinish += () => {
                    // Repeat if needed.
                    if (RepeatPanelControls.NumRepeatsLeft > 0)
                    {
                        if (RepeatPanelControls.NumRepeatsLeft > 0)
                        {
                            ControlAreaManager.ExecutedCard.Execute();
                        }
                    }
                };
                sequence.Add(returnParallel);
            }
        };

        DelayAction returnDelay = new DelayAction(0.1f);

        sequence.Add(scaleUp, hitParallel, returnDelay);
        sequence.OnActionFinish = () => { mTurnStatus = PlayerTurnStatus.Waiting; mSpriteRen.sortingOrder = mnDefaultSpriteOrderInLayer; };
        ActionHandler.RunAction(sequence);
    }
Beispiel #7
0
 public void SetPlayerStatus(int key, PlayerTurnStatus status)
 {
     this.playerDictionary[key].SetStatus(status);
 }