예제 #1
0
    // Update is called once per frame
    void Update()
    {
        ///////////////////////////////////////////////////////////////////////////////////Detect Skill Button

        SkillNUM = SkillScript.DetectSkillKeyDown(); //Detecting Key Down

        if (SkillStage == SkillStageNUM.DetectSkillButton && SkillNUM != 0 && !PlayerMovementScript.bPlayerMove)
        {
            SkillStage++;
        }

        ///////////////////////////////////////////////////////////////////////////////////Start Skill

        if (SkillStage == SkillStageNUM.AfterPressButton)
        {
            //start prompt
            VitaParticleScript.PromptFadeIn();

            //start UI
            FadeInUI();

            //set Current Skill
            CurrentSkillNUM = SkillNUM;

            //Change Light
            SkillScript.MagicLightScript.ChangeLightColor(SkillNUM);
            SkillScript.MagicLightScript.FadeIn();
            SkillScript.MagicLightScript.FadeOutCountDown(fLightUpTime);

            //Player skill animate
            SkillScript.StartSkillAnimate();

            //next stage
            SkillStage++;
        }

        ///////////////////////////////////////////////////////////////////////////////////Gathering, check if user look on vita

        if (SkillStage == SkillStageNUM.Gathering)
        {
            float Distance = Vector3.Distance(VitaPosition, gazeOnScreen);

            VitaSoulgGatheringTimer += Time.deltaTime;

            if (Distance <= 10.05f)
            {
                VitaParticleScript.animator.SetBool("isGazeing", true);
                VitaSoulBG.SetBool("isGazeing", true);

                //fade out prompt
                if (VitaParticleScript.bPromptExist)
                {
                    VitaParticleScript.PromptFadeOut();
                }

                if (VitaSoulgGatheringTimer >= fNeedGatheringTime) //gathering for 2s
                {
                    //vita animate
                    VitaParticleScript.animator.SetBool("isGazeing", false);
                    VitaSoulBG.SetBool("isGazeing", false);

                    //allow user controll vita
                    VitaParticleGazeScript.bVitaSoulCanGaze = true;

                    //reset timer
                    VitaSoulCanGazeTimer    = 0.0f;
                    VitaSoulgGatheringTimer = 0.0f;

                    //player can't move
                    PlayerMovementScript.canMove = false;

                    //next stage
                    SkillStage++;
                }
            }
            else
            {
                //inerrupt gathering, reset timer
                VitaSoulgGatheringTimer = 0.0f;

                VitaSoulCanGazeTimer += Time.deltaTime;


                VitaParticleScript.animator.SetBool("isGazeing", false);
                VitaSoulBG.SetBool("isGazeing", false);


                if (!VitaParticleScript.bPromptExist)
                {
                    VitaParticleScript.PromptFadeIn();
                }
            }
        }

        ///////////////////////////////////////////////////////////////////////////////////if player move before gathering finished Vita or Can Gaze Time up or pressed skill button again
        if ((PlayerMovementScript.bPlayerMove || VitaSoulCanGazeTimer >= fCanGazeTime || (SkillNUM != 0 && VitaSoulCanGazeTimer > 0.5f)) && SkillStage == SkillStageNUM.Gathering)
        {
            //reset vita animate
            VitaParticleScript.PromptFadeOut();
            VitaParticleScript.animator.SetBool("isGazeing", false);
            VitaSoulBG.SetBool("isGazeing", false);

            //reset gaze
            VitaParticleGazeScript.bVitaSoulCanGaze = false;

            //reset UI
            FadeOutUI();

            //reset player animate
            SkillScript.ResetAnimateToIdle();


            //reset timer
            VitaSoulCanGazeTimer    = 0.0f;
            VitaSoulgGatheringTimer = 0.0f;

            //reset magic light and reset can light up vita bool
            SkillScript.MagicLightScript.FadeOut();

            //reset Current skill num
            PlayerSkill.CURRENTSKILL = 0;

            //back stage
            SkillStage = 0;
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////Start Gaze Control Vita

        //start light up vita
        if (magicLightScript.LightUpVita && SkillStage == SkillStageNUM.StartGazeControlVita)
        {
            //set currentSkill
            PlayerSkill.CURRENTSKILL = CurrentSkillNUM;

            //reset timer
            VitaSoulCanGazeTimer = 0.0f;

            VitaParticleScript.LightUpVita(magicLightScript.magicLt.color);
            VitaParticleScript.SkillNUM = PlayerSkill.CURRENTSKILL;

            VitaParticleScript.animator.SetBool("StartSkill", true);

            magicLightScript.LightUpVita = false; // reset bool

            SkillStage++;                         //next stage
        }

        //if never light up count dowm
        else if (SkillStage == SkillStageNUM.StartGazeControlVita)
        {
            VitaSoulCanGazeTimer += Time.deltaTime;
            if (VitaSoulCanGazeTimer > 5.0f || (VitaSoulCanGazeTimer > 0.5f && SkillNUM != 0)) //over 5.0s or after Player raise hand and then press skillbutton
            {
                //reset animate
                if (VitaParticleScript.bPromptExist)
                {
                    VitaParticleScript.PromptFadeOut();
                }

                //player can't move
                PlayerMovementScript.canMove = true;

                VitaParticleGazeScript.bVitaSoulCanGaze = false;
                FadeOutUI();

                //reset player animate
                SkillScript.ResetAnimateToIdle();

                //reset magic light
                SkillScript.MagicLightScript.FadeOut();

                //reset timer
                VitaSoulCanGazeTimer = 0.0f;

                //reset Current skill num
                PlayerSkill.CURRENTSKILL = 0;

                //back stage
                SkillStage = 0;
            }
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////Finish Light Up Vita
        if (SkillStage == SkillStageNUM.FinishLLghtUpVita)
        {
            VitaSoulCanGazeTimer += Time.deltaTime;
            //skill 2
            if (PlayerSkill.CURRENTSKILL == 2)
            {
                //check which rock is trigger
                if (Skill2Stage == Skill2StageNUM.DetectRockTrigger)
                {
                    for (int i = 0; i < RockScript.Length; i++)
                    {
                        if (RockScript[i]._bTrigger)
                        {
                            Skill2Stage++;
                            iCurrentRockNum = i + 1; //start index with 1
                        }
                    }
                }


                //set skill stage initial
                if (Skill2Stage == Skill2StageNUM.Skill2InitialSet)
                {
                    Skill2Board.transform.GetChild(iCurrentGraphic).gameObject.active = true;

                    //change position = camera position X.Y
                    Skill2Board.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, 0.0f);

                    //fade in skill 2
                    FadeInBoard();


                    Skill2Stage++;
                }


                //start check block
                if (Skill2Stage == Skill2StageNUM.CheckBlockColor)
                {
                    Block_Level2[] BlockCheck = Skill2Board.transform.GetChild(iCurrentGraphic).GetComponentsInChildren <Block_Level2>();
                    bAllColorOn = true;
                    foreach (Block_Level2 item in BlockCheck)
                    {
                        if (item._bIsOnColor == false)
                        {
                            bAllColorOn = false;
                            break;
                        }
                    }
                }
            }

            if (bAllColorOn || VitaSoulCanGazeTimer > 7.0f || SkillNUM != 0) //when time up or push the button again or finish skill2
            {
                //player can move
                PlayerMovementScript.canMove = true;

                VitaParticleGazeScript.bVitaSoulCanGaze = false;

                //reset particle
                VitaParticleScript.StopSkillAfterTime(0.0f);

                // reset timer
                VitaSoulCanGazeTimer = 0.0f;

                //reset magic light
                SkillScript.MagicLightScript.FadeOut();

                //reset player animate
                SkillScript.ResetAnimateToIdle();

                FadeOutUI();

                VitaParticleScript.animator.SetBool("StartSkill", false);

                VitaSoulRenderer.color = new Color(VitaSoulRenderer.color.r, VitaSoulRenderer.color.g, VitaSoulRenderer.color.b, 1.0f);

                SkillStage = 0;//reset stage

                //skill 2 Board
                if (PlayerSkill.CURRENTSKILL == 2)
                {
                    //reset Skill2 stage
                    Skill2Stage = Skill2StageNUM.DetectRockTrigger;

                    if (bAllColorOn)
                    {
                        //Destroy Rock
                        RockScript[iCurrentRockNum - 1].DestroyRock();
                    }

                    //reset skill 2
                    ResetSkill2();

                    //reset current rock num
                    iCurrentRockNum = 0;
                }

                //reset Current skill num
                PlayerSkill.CURRENTSKILL = 0;
            }
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////Changeing Player, Vita collider for Skill 1
        //change Fog Detect Collider
        if (PlayerSkill.CURRENTSKILL == 0 && bColliderOnPlayer == false)
        {
            //change CircleCollider2D size
            FogColliderGameObject.GetComponent <CircleCollider2D>().radius = 1.4f;

            //open player collider enbled
            FogColliderGameObjectForPlayer1.GetComponent <CircleCollider2D>().enabled = true;
            FogColliderGameObjectForPlayer2.GetComponent <CircleCollider2D>().enabled = true;

            //set to player position
            FogColliderGameObject.transform.position = GameObject.Find("Player").transform.position;


            //set to child of player
            FogColliderGameObject.transform.parent = GameObject.Find("Player").transform;

            bColliderOnPlayer = true;
        }
        else if (PlayerSkill.CURRENTSKILL == 1 && bColliderOnPlayer == true)
        {
            //change CircleCollider2D size
            FogColliderGameObject.GetComponent <CircleCollider2D>().radius = 1.327327f;

            //revert player collider enbled
            FogColliderGameObjectForPlayer1.GetComponent <CircleCollider2D>().enabled = false;
            FogColliderGameObjectForPlayer2.GetComponent <CircleCollider2D>().enabled = false;

            //set to Vita position
            FogColliderGameObject.transform.position = GameObject.Find("VitaSoul").transform.position;

            //set to child of Vita
            FogColliderGameObject.transform.parent = GameObject.Find("VitaSoul").transform;

            bColliderOnPlayer = false;
        }
    }