Ejemplo n.º 1
0
    private void ExecuteAttack()
    {
        mTurnStatus = EnemyTurnStatus.Running;

        Node targetNode = mPath.First.Next.Value;
        // Do not move the enemy in the grid for 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(targetNode.PosX, targetNode.PosY), 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 += () => {
            GameManager.Instance.Player.TakeDamage(typeAlgorithms[(int)UnitType].GetDamagePower());
        };

        DelayAction returnDelay = new DelayAction(0.1f);

        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);

        ActionSequence sequence = new ActionSequence(scaleUp, hitParallel, returnDelay, returnParallel);

        sequence.OnActionFinish = () => { mTurnStatus = EnemyTurnStatus.Processed; };
        ActionHandler.RunAction(sequence);
    }
Ejemplo n.º 2
0
    // Protected Functions
    public override void ExecuteTurn()
    {
        UI_EnemyTurnTitle.Instance.TransitionEnemy(true, m_enumPieceType.ToString());

        // if: RemoteCallAStar() runs the A-Star pathfind once
        if (!RemoteCallAStar())
        {
            return;
        }

        // if: The next node is the player, use a different attacking animation
        if (m_AStar.StartNode.linkTo == m_AStar.TargetNode)
        {
            // Variables Updates

            // Action Handling
            MoveToAction actJump1 = new MoveToAction(transform, Graph.InverseExponential, m_AStar.TargetNode.position + new Vector3(0f, 2f, 0f), 0.5f);
            actJump1.OnActionStart += () =>
            {
                CameraManager.Instance.ZoomInAt(LevelManager.Instance.PlayerInstance.transform.position + new Vector3(0f, 1f), true);
            };
            MoveToAction actSlam        = new MoveToAction(transform, Graph.Exponential, m_AStar.TargetNode.position, 0.1f);
            MoveToAction actJump2       = new MoveToAction(transform, Graph.InverseExponential, m_AStar.StartNode.position, 0.5f);
            MoveToAction actBackToStart = new MoveToAction(transform, Graph.Exponential, m_AStar.StartNode.position, 0.4f);

            ScaleToAction  actSquash        = new ScaleToAction(LevelManager.Instance.PlayerInstance.transform, Graph.Exponential, new Vector3(1f, 0f, 1f), 0.1f);
            ScaleToAction  actInflate       = new ScaleToAction(LevelManager.Instance.PlayerInstance.transform, Graph.InverseExponential, Vector3.one, 0.2f);
            ActionParallel actSlamAndSquash = new ActionParallel(actSlam, actSquash);
            actSlamAndSquash.OnActionStart += () =>
            {
                CameraManager.Instance.Shake();
            };
            actSlamAndSquash.OnActionFinish += () =>
            {
                CameraManager.Instance.LookAt(LevelManager.Instance.PlayerInstance.transform.position, true);
            };
            ActionParallel actJumpAndInflate = new ActionParallel(actJump2, actInflate);

            ActionSequence actionSeq_Hit = new ActionSequence(actJump1, actSlamAndSquash, actJumpAndInflate, actBackToStart);
            actionSeq_Hit.OnActionFinish += LevelManager.Instance.ExecuteNextTurn;

            ActionHandler.RunAction(actionSeq_Hit);
        }
        // else: Use the move animation
        else
        {
            // if: The there is no next path, the piece is basically trapped
            if (m_AStar.StartNode.linkTo == null)
            {
                return;
            }

            // Variables Updates
            int[] arr_nCoords = m_AStar.Position2GridCoords(m_AStar.StartNode.linkTo.position);
            m_nX = arr_nCoords[0];
            m_nY = arr_nCoords[1];

            // Action Handling
            MoveToAction action_MoveTo = new MoveToAction(this.transform, Graph.InverseExponential, m_AStar.StartNode.linkTo.position, 0.5f);
            action_MoveTo.OnActionFinish += LevelManager.Instance.ExecuteNextTurn;

            ActionHandler.RunAction(action_MoveTo);
        }
    }
Ejemplo n.º 3
0
    void Start()
    {
        // Draw 3 cards.
        ActionParallel drawParallel = new ActionParallel();

        if (PlayerPrefs.HasKey(Constants.kStrNumCardsInHand))
        {
            int numCards = PlayerPrefs.GetInt(Constants.kStrNumCardsInHand);
            for (int i = 0; i < numCards; i++)
            {
                DelayAction draw = new DelayAction(i * 0.3f);

                CardType type = (CardType)PlayerPrefs.GetInt(Constants.kStrCardType[i]);
                if (type == CardType.Movement)
                {
                    GridType moveType = (GridType)PlayerPrefs.GetInt(Constants.kStrCardMoveType[i]);
                    draw.OnActionFinish += () => {
                        DeckManager.Instance.DrawCard(moveType);
                    };
                }
                else
                {
                    CardTier tier = (CardTier)PlayerPrefs.GetInt(Constants.kStrCardTier[i]);
                    draw.OnActionFinish += () => {
                        DeckManager.Instance.DrawSpecificCard(type, tier);
                    };
                }

                drawParallel.Add(draw);
            }
        }
        else
        {
            DelayAction firstDraw = new DelayAction(0.1f);
            firstDraw.OnActionFinish += () => { DeckManager.Instance.DrawCard(); };
            DelayAction secondDraw = new DelayAction(0.1f + 0.3f);
            secondDraw.OnActionFinish += () => { DeckManager.Instance.DrawCard(); };
            DelayAction thirdDraw = new DelayAction(0.1f + 0.3f + 0.3f);
            secondDraw.OnActionFinish += () => { DeckManager.Instance.DrawCard(); };
            drawParallel = new ActionParallel(firstDraw, secondDraw, thirdDraw);
        }

        Vector3     vec3PlayerPos = DungeonManager.Instance.GridPosToWorldPos(Player.PosX, Player.PosY);
        Vector3     vec3ExitPos   = DungeonManager.Instance.GridPosToWorldPos(DungeonManager.Instance.ExitPosX, DungeonManager.Instance.ExitPosY);
        DelayAction pan           = new DelayAction(2.0f);

        pan.OnActionStart += () => {
            BoardScroller.Instance.FocusCameraToPos(vec3ExitPos, 1.5f, Graph.SmoothStep);
        };
        pan.OnActionFinish += () => {
            BoardScroller.Instance.FocusCameraToPos(vec3PlayerPos, 0.5f, Graph.SmoothStep);
        };

        DelayAction phaseAnimDelay = new DelayAction(0.6f);

        phaseAnimDelay.OnActionFinish += () => {
            EventAnimationController.Instance.ExecutePhaseAnimation(GamePhase.PlayerPhase);
            mbGameStarted = true;
        };

        ActionSequence startSeq = new ActionSequence(drawParallel, pan, phaseAnimDelay);

        ActionHandler.RunAction(startSeq);
    }
Ejemplo n.º 4
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);
    }
    public void ExecutePhaseAnimation(GamePhase _phase)
    {
        mbIsAnimating = true;
        mCtrlArea.SetControlBlockerEnabled(true);

        Color overlayCol = mBGOverlayImage.color;

        overlayCol.a            = 0.0f;
        mBGOverlayImage.color   = overlayCol;
        mBGOverlayImage.enabled = true;
        switch (_phase)
        {
        case GamePhase.PlayerPhase:
            mPhaseTop.sprite    = PlayerPhaseTopSprite;
            mPhaseBottom.sprite = PlayerPhaseBottomSprite;
            break;

        case GamePhase.EnemyPhase:
            mPhaseTop.sprite    = EnemyPhaseTopSprite;
            mPhaseBottom.sprite = EnemyPhaseBottomSprite;
            break;
        }

        mPhaseTop.rectTransform.localEulerAngles    = Vector3.forward * 90.0f;
        mPhaseBottom.rectTransform.localEulerAngles = Vector3.forward * 90.0f;

        RotateByAction2D topRotIn    = new RotateByAction2D(mPhaseTop.transform, Graph.InverseExponential, -86.0f, 0.6f);
        RotateByAction2D bottomRotIn = new RotateByAction2D(mPhaseBottom.transform, Graph.InverseExponential, -86.0f, 0.6f);
        ActionParallel   rotateIn    = new ActionParallel(topRotIn, bottomRotIn);

        rotateIn.OnActionStart += () => { AudioManager.PlayPhaseInSound(); };

        DelayAction rotInOutDelay = new DelayAction(0.6f);

        RotateByAction2D topRotOut    = new RotateByAction2D(mPhaseTop.transform, Graph.Exponential, -86.0f, 0.6f);
        RotateByAction2D bottomRotOut = new RotateByAction2D(mPhaseBottom.transform, Graph.Exponential, -86.0f, 0.6f);
        ActionParallel   rotateOut    = new ActionParallel(topRotOut, bottomRotOut);

        rotateOut.OnActionStart += () => { AudioManager.PlayPhaseOutSound(); };

        ActionSequence rotInOutSeq = new ActionSequence(rotateIn, rotInOutDelay, rotateOut);

        rotInOutSeq.OnActionFinish += () => {
            mBGOverlayImage.enabled = false;
            mCtrlArea.SetControlBlockerEnabled(false);
            mbIsAnimating = false;
        };



        DelayAction stallFrontDelay = new DelayAction(0.5f);
        DelayAction stallEndDelay   = new DelayAction(0.5f);

        RotateByAction2D topRotStall    = new RotateByAction2D(mPhaseTop.transform, InverseSmoothStep, -8.0f, 0.8f);
        RotateByAction2D bottomRotStall = new RotateByAction2D(mPhaseBottom.transform, InverseSmoothStep, -8.0f, 0.8f);
        ActionParallel   rotateStall    = new ActionParallel(topRotStall, bottomRotStall);

        ActionSequence rotStallSeq = new ActionSequence(stallFrontDelay, rotateStall, stallEndDelay);


        DelayAction            alphaDelay   = new DelayAction(0.8f);
        ImageAlphaFadeToAction alphaIn      = new ImageAlphaFadeToAction(mBGOverlayImage, Graph.Linear, 0.5f, 0.5f);
        ImageAlphaFadeToAction alphaOut     = new ImageAlphaFadeToAction(mBGOverlayImage, Graph.Linear, 0.0f, 0.5f);
        ActionSequence         alphaFadeSeq = new ActionSequence(alphaIn, alphaDelay, alphaOut);

        ActionHandler.RunAction(rotInOutSeq, rotStallSeq, alphaFadeSeq);
    }
    private void SetupTitleWithLogo()
    {
        sbLoadedGame         = true;
        mSplashPanelCG.alpha = 1.0f;

        // Logo Animation
        DelayAction prePulseDelay = new DelayAction(1.5f);
        PulseAction clickPulse    = new PulseAction(
            mLogoTransform,
            1,
            Graph.Exponential,
            0.25f,
            Vector3.one,
            Vector3.one * 0.8f);

        clickPulse.OnActionStart += () => { AudioManager.PlayPenClickSound(); };
        DelayAction postPulseDelay = new DelayAction(0.25f);

        MoveByAction   anticipateLeft      = new MoveByAction(mLogoTransform, Graph.InverseExponential, Vector3.left * (100) * (Screen.height / 1920.0f), 0.5f);
        ScaleToAction  anticipateSquash    = new ScaleToAction(mLogoTransform, Graph.InverseExponential, new Vector3(0.75f, 1.25f, 1.25f), 0.5f);
        ActionParallel anticipateParallel  = new ActionParallel(anticipateLeft, anticipateSquash);
        DelayAction    postAnticipateDelay = new DelayAction(0.1f);
        MoveByAction   zoomRight           = new MoveByAction(mLogoTransform, Graph.InverseExponential, Vector3.right * (1024 + 400) * (Screen.height / 1920.0f), 0.3f);
        ScaleToAction  scaleDown           = new ScaleToAction(mLogoTransform, Graph.InverseExponential, new Vector3(1.5f, 0.5f, 0.5f), 0.5f);
        ActionParallel zoomRightParallel   = new ActionParallel(zoomRight, scaleDown);

        DelayAction preFadeDelay = new DelayAction(0.2f);
        CanvasGroupAlphaFadeToAction fadeCGAway = new CanvasGroupAlphaFadeToAction(mSplashPanelCG, 0.0f, 1.5f);

        fadeCGAway.OnActionFinish += () => {
            mSplashPanelCG.blocksRaycasts = false;
        };

        // Tap to Start text.
        DelayAction TurnOn = new DelayAction(0.5f);

        TurnOn.OnActionFinish += () => {
            mTapToStartText.enabled = true;
            if (mStartButton.interactable == false)
            {
                mStartButton.interactable = true;
            }
        };
        DelayAction TurnOff = new DelayAction(1.0f);

        TurnOff.OnActionFinish += () => { mTapToStartText.enabled = false; };
        ActionSequence      tapTextFlashSeq = new ActionSequence(TurnOn, TurnOff);
        ActionRepeatForever repeatFlash     = new ActionRepeatForever(tapTextFlashSeq);

        ActionSequence splashSeq = new ActionSequence(
            prePulseDelay, clickPulse, postPulseDelay,
            anticipateParallel, postAnticipateDelay, zoomRightParallel,
            preFadeDelay, fadeCGAway,
            repeatFlash
            );

        ActionHandler.RunAction(splashSeq);



        // Card Animations.
        // Card is already spinning in the background.
        // 0 to 90, snap -90, -90 to 0
        mSpiningCard.localEulerAngles = Vector3.zero;
        // Timing here doesn't matter. Is used to sync. 0.5f just nice to have card back show when canvas fades.
        RotateByAction initSpin = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 90.0f, 0.5f);

        initSpin.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale -= Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mCardSprites[Random.Range(0, mCardSprites.Length)];
        };
        RotateByAction spinA = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 180.0f, 3.0f);

        spinA.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale += Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mSpriteCardBack;
        };
        RotateByAction spinB = new RotateByAction(mSpiningCard, Graph.Linear, Vector3.up * 180.0f, 3.0f);

        spinB.OnActionFinish += () => {
            mCardSpriteRen.transform.localScale -= Vector3.right * 2.0f;
            mCardSpriteRen.sprite = mCardSprites[Random.Range(0, mCardSprites.Length)];
        };

        ActionSequence cardSpinSeq = new ActionSequence(spinA, spinB);

        ActionHandler.RunAction(new ActionSequence(initSpin, new ActionRepeatForever(cardSpinSeq)));
    }
Ejemplo n.º 7
0
    /// <summary>
    /// End the sequence.
    /// </summary>
    public void EndSequence()
    {
        // Ending Variables
        m_OPSelection.PoolAllObjects();
        TransitionExit(true, true);
        for (int i = 0; i < marr_nCardOrder.Length; i++)
        {
            if (marr_nCardOrder[i] != -1)
            {
                LevelManager.Instance.PlayerInstance.CardDeck[i] = EnumPieceType.Null;
            }
        }

        // Player Action Handling
        bool[,] arr2_bEnemyConstrain = LevelManager.Instance.GetCharacterConstrain(EnumCharacterType.Enemy);

        ActionSequence actSequence = new ActionSequence();

        for (int i = 1; i <= m_nCurrentStep; i++)
        {
            // Converts to grid space
            int[] arr_nCoords = new int[2];
            arr_nCoords[0] = Mathf.RoundToInt(marr_vec3StepPosition[i].x);
            arr_nCoords[1] = Mathf.RoundToInt(marr_vec3StepPosition[i].z);

            // if: There is no enemy constrain in the current co-ordinates
            if (arr2_bEnemyConstrain[arr_nCoords[0], arr_nCoords[1]])
            {
                MoveToAction actMoveToNext = new MoveToAction(LevelManager.Instance.PlayerInstance.transform, Graph.InverseExponential, marr_vec3StepPosition[i], 0.25f);
                actSequence.Add(actMoveToNext);
            }
            // else: Kill the enemy
            else
            {
                Character    characterTarget = LevelManager.Instance.GetCharacter(arr_nCoords[0], arr_nCoords[1]);
                MoveToAction actJump         = new MoveToAction(LevelManager.Instance.PlayerInstance.transform, Graph.InverseExponential, marr_vec3StepPosition[i] + new Vector3(0f, 2f, 0f), 0.5f);
                actJump.OnActionStart += () =>
                {
                    CameraManager.Instance.ZoomInAt(characterTarget.transform, true);
                };
                MoveToAction actSlam  = new MoveToAction(LevelManager.Instance.PlayerInstance.transform, Graph.Exponential, marr_vec3StepPosition[i], 0.1f);
                DelayAction  actDelay = new DelayAction(0.5f);

                ScaleToAction  actSquash        = new ScaleToAction(characterTarget.transform, Graph.Exponential, new Vector3(1f, 0f, 1f), 0.1f);
                ActionParallel actSlamAndSquash = new ActionParallel(actSlam, actSquash);
                actSlamAndSquash.OnActionStart  += CameraManager.Instance.Shake;
                actSlamAndSquash.OnActionFinish += () =>
                {
                    characterTarget.Kill();
                    CameraManager.Instance.LookAt(LevelManager.Instance.PlayerInstance.transform.position, true);
                };
                actSequence.Add(actJump, actSlamAndSquash, actDelay);
                //CameraManager.Instance.ZoomInAt(marr_vec3StepPosition[i], true);
            }
        }
        actSequence.OnActionFinish += () =>
        {
            // After-animations Variables Handling
            LevelManager.Instance.PlayerInstance.X = Mathf.RoundToInt(marr_vec3StepPosition[m_nCurrentStep].x);
            LevelManager.Instance.PlayerInstance.Y = Mathf.RoundToInt(marr_vec3StepPosition[m_nCurrentStep].z);
            CameraManager.Instance.LookAt(marr_vec3StepPosition[m_nCurrentStep], true);
            m_OPStep.PoolAllObjects();
            m_OPStepArrow.PoolAllObjects();

            UI_EnemyTurnTitle.Instance.TransitionEnter(true);
            LevelManager.Instance.ExecuteNextTurn();
        };

        ActionHandler.RunAction(actSequence);
    }