Exemplo n.º 1
0
    private void move( )
    {
        bool wall = false;

        if (decisionTurn(_center.transform, DETECT_TYPE.DETECT_TYPE_WALL))
        {
            wall = true;
        }

        if (wall || (_move_x <= -_move_range_left || _move_range_right <= _move_x))
        {
            refrectDir( );
        }

        MOVE_ANIM dir = getMoveDir( );

        if (dir == MOVE_ANIM.MoveRight)
        {
            _move_x++;
        }
        else
        {
            _move_x--;
        }

        runMoveAnim( );
    }
Exemplo n.º 2
0
 // function //
 protected void initialize( )
 {
     _anim                    = GetComponent <Animator>( );
     _move_anim               = MOVE_ANIM.MoveLeft;
     _data                    = _map.GetComponent <MapData>( );
     _frozen_collider         = GetComponent <BoxCollider2D>( );
     _frozen_collider.enabled = false;
     _rb = GetComponent <Rigidbody2D>( );
 }
Exemplo n.º 3
0
    private void move( )
    {
        if (!_move)
        {
            return;
        }

        bool fall = false;

        if (decisionTurn(_under1.transform, DETECT_TYPE.DETECT_TYPE_FALL))
        {
            if (decisionTurn(_under2.transform, DETECT_TYPE.DETECT_TYPE_FALL))
            {
                fall = true;
            }
        }
        bool wall = false;

        if (decisionTurn(_center.transform, DETECT_TYPE.DETECT_TYPE_WALL))
        {
            wall = true;
        }

        if (fall || wall || (_move_x <= -_move_range_left || _move_range_right <= _move_x))
        {
            refrectDir( );
        }

        MOVE_ANIM dir = getMoveDir( );

        if (dir == MOVE_ANIM.MoveLeft)
        {
            _move_x--;
        }
        else
        {
            _move_x++;
        }

        runMoveAnim( );
        Debug.Log("move");
    }
Exemplo n.º 4
0
    protected void refrectDir( )
    {
        MOVE_ANIM before = this.getMoveDir( );
        MOVE_ANIM result = before;

        switch (before)
        {
        case MOVE_ANIM.MoveLeft:
            result = MOVE_ANIM.MoveRight;
            break;

        case MOVE_ANIM.MoveRight:
            result = MOVE_ANIM.MoveLeft;
            break;
        }
        SpriteRenderer renderer = GetComponent <SpriteRenderer>( );

        renderer.flipX = !renderer.flipX;
        setMoveDir(result);
    }
Exemplo n.º 5
0
    private void attack( )
    {
        Vector2 dir = (_player.transform.position - this.transform.position).normalized;

        bool right = true;

        if (dir.x < 0)
        {
            right = false;
        }

        SpriteRenderer render  = GetComponent <SpriteRenderer>( );
        MOVE_ANIM      now_dir = getMoveDir( );

        if (right && now_dir == MOVE_ANIM.MoveLeft)
        {
            render.flipX = !render.flipX;
            _turn        = true;
        }
        if (!right && now_dir == MOVE_ANIM.MoveRight)
        {
            render.flipX = !render.flipX;
            _turn        = true;
        }

        MageAttack fire_magic = GetComponent <MageAttack>( );

        if (!fire_magic.isReload( ))
        {
            return;
        }

        runAttackAnim( );

        fire_magic.setDir(dir);
    }
Exemplo n.º 6
0
 protected void setMoveDir(MOVE_ANIM dir)
 {
     _move_anim = dir;
 }