예제 #1
0
    void GetTouch( )
    {
        bool bTouchPlayer           = false;
        List <Collider2D> colliders = new List <Collider2D> ( );

        col.OverlapCollider(new ContactFilter2D( ), colliders);
        foreach (Collider2D collider in colliders)
        {
            //if the collider is ground enter this state
            if (collider.gameObject.layer == LayerMask.NameToLayer("Ground"))
            {
                //if now use pingPongMove will change its direction due to direction of collider
                if (currentMove == pingPongMove)
                {
                    if (GalaxySeeker.Physics2D.IsRight(Parent.tf.position, collider.transform.position))
                    {
                        pingPongMove.IsFacingRight = false;
                    }
                    else if (GalaxySeeker.Physics2D.IsRight(Parent.tf.position, collider.transform.position))
                    {
                        pingPongMove.IsFacingRight = true;
                    }
                }
                //if now use rangeMove will try to find another target position
                else if (currentMove == rangeMove)
                {
                    rangeMove.FindNewTargetPos( );
                }
            }
            //if collider with player and player stand on it change moveMode to rangeMove
            if (collider.gameObject.tag == "Player")
            {
                if (GalaxySeeker.Physics2D.IsAbove(Parent.tf.position, collider.transform.position))
                {
                    targetTransform = collider.transform;
                    targetTransform.SetParent(Parent.tf);
                    bTouchPlayer = true;
                    currentMove  = rangeMove;
                    if (!rasg.Anim.IsPlaying(rageAnim.name))
                    {
                        rasg.Anim.Play(rageAnim.name);
                    }
                }
            }
        }

        // if player out of it set parent to null
        if (!bTouchPlayer && targetTransform)
        {
            targetTransform.SetParent(null);
            targetTransform = null;
            pingPongMove.SetVerticalPos(Parent.tf.position.y);
            currentMove = pingPongMove;
            rasg.Anim.Play(rasg.Anim.clip.name);
        }
    }
예제 #2
0
        void CheckTouch( )
        {
            bool tmp = Parent.GetTouchPlayer( );

            if (tmp)
            {
                Parent.Player.tf.SetParent(Parent.tf);
            }
            else
            {
                Parent.Player.tf.SetParent(null);
            }
            Parent.IsTouchedByPlayer = tmp;
            ETouchType type = Parent.GetTouchGround( );

            if (type != ETouchType.NONE)
            {
                randMove.FindNewTargetPos( );
            }
        }