Ejemplo n.º 1
0
        public void StunUpdate(ref AbsorbMechanic absMec)
        {
            //Debug.Log("updating stun");
            stateInfo = animator.GetCurrentAnimatorStateInfo(0);

            //Debug.Log("Normalized state time: " + stateInfo.normalizedTime);
            if (stageOneEntered)
            {
                if (!clipSet)
                {
                    Debug.Log("Setting the clip: " + grabanimationHash);

                    //AnimatorClipInfo[] clips = animator.GetNextAnimatorClipInfo(0);
                    stateInfo = animator.GetCurrentAnimatorStateInfo(0);
                    if (stateInfo.IsName("Grab"))
                    {
                        clipSet = true;
                        time    = stateInfo.length;
                        Debug.Log("Time is: " + time);
                    }
                    else
                    {
                        Debug.Log("Animation playing: " + stateInfo.ToString());
                        return;
                    }
                }

                //Debug.Log("Normalized state time: " + stateInfo.normalizedTime);
                elapsedTime += GameManager.Instance.DeltaTime;

                //Set the target character's parent as the current character's hand
                if (!parentSet)
                {
                    //After ta certain amount of time, set the enemy as child to the player's hand
                    if (elapsedTime > time * 0.4f)
                    {
                        //Halt character movement of both the player and the enemy
                        c.GetComponent <Enemy>().GettingAbsorbed(player, time);

                        c.GetComponent <Collider2D>().enabled = false;
                        Debug.Log("Parent set");
                        c.transform.parent        = player.Hand.transform;
                        c.transform.localPosition = new Vector3(0, -1.0f, 0);
                        c.transform.localRotation = Quaternion.Euler(0, 0, 0);
                        //c.playerSprite.GetComponent<SpriteRenderer>().sortingOrder = player.playerSprite.GetComponent<SpriteRenderer>().sortingOrder - 1;

                        parentSet = true;
                    }
                    return;
                }

                if (elapsedTime > time)
                {
                    animator.SetBool("Absorb", false);

                    if (!stateInfo.IsName("Grab") && !animator.IsInTransition(0))
                    {
                        //TODO: Start a different animation here
                        //For now, just disable the character
                        stageOneEntered = false;
                        stageTwoEntered = true;
                    }
                }

                c.transform.localPosition = new Vector3(0, -1.0f, 0);
                c.transform.localRotation = Quaternion.Euler(0, 0, 0);
            }

            if (stageTwoEntered)
            {
                //Here, the PH transformation must start and respective animation must play
                //Keep the player's movements blocked till then
                StartReaction(c);

                //Deactivate the enemy for now
                c.GetComponent <Enemy>().Die();

                absMec = null;
            }
        }
Ejemplo n.º 2
0
 void InitiateAbsorb(Character c, float duration)
 {
     Debug.Log("initiated the absorb mechanic");
     absMec = new AbsorbMechanic();
     absMec.Setup(this, c, grabAnimationInfo);
 }