Example #1
0
    public override bool Handle()
    {
        if (info.BlockControl)
        {
            return(false);
        }

        bool forwardTouch = Utils.IsTouchRoom(forwardCollider);
        bool downTouch    = Utils.IsTouchRoom(forwardDownCollider);

        if (forwardTouch || !downTouch || distance <= 0)
        {
            return(false);
        }

        EntityMovableInfo.RunEvent result = info.GetEventSystem <EntityMovableInfo.RunEvent>().CallListners(new EntityMovableInfo.RunEvent(gameObject, gameObject.transform.localScale.x > 0 ? 1 : -1, info.RunSpeed));
        if (result.IsCancel)
        {
            return(false);
        }

        info.IsRunForward = true;
        info.IsRunBack    = false;
        return(true);
    }
Example #2
0
    private void Move(int direction, float speed)
    {
        int scale = (int)transform.localScale.x;

        if (scale != direction)
        {
            transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
        }

        EntityMovableInfo.RunEvent result = info.GetEventSystem <EntityMovableInfo.RunEvent>().CallListners(new EntityMovableInfo.RunEvent(gameObject, direction, speed));
        if (!result.IsCancel)
        {
            rigidbody2D.velocity = new Vector2(result.Direction * result.Speed, rigidbody2D.velocity.y);
        }
    }
Example #3
0
    public override bool Handle()
    {
        if (info.BlockControl)
        {
            return(false);
        }

        bool rotated      = Utils.IsRotatedToPlayer(player, gameObject.transform);
        bool willRotate   = rotated ? !toPlayer : toPlayer;
        bool forwardTouch = Utils.IsTouchRoom(forwardCollider);
        bool backTouch    = Utils.IsTouchRoom(backCollider);
        bool downTouch    = Utils.IsTouchRoom(willRotate ? backDownCollider : forwardDownCollider);

        if (!downTouch || distance <= 0)
        {
            return(false);
        }

        if (willRotate)
        {
            if (backTouch)
            {
                return(false);
            }

            gameObject.transform.localScale = new Vector3(-gameObject.transform.localScale.x,
                                                          gameObject.transform.localScale.y, gameObject.transform.localScale.z);
        }
        else if (forwardTouch)
        {
            return(false);
        }

        EntityMovableInfo.RunEvent result = info.GetEventSystem <EntityMovableInfo.RunEvent>().CallListners(new EntityMovableInfo.RunEvent(gameObject, gameObject.transform.localScale.x > 0 ? 1 : -1, info.RunSpeed));
        if (result.IsCancel)
        {
            return(false);
        }

        info.IsRunForward = true;
        info.IsRunBack    = false;
        return(true);
    }