Example #1
0
    // Update is called once per frame
    protected override void FixedUpdate()
    {
        if (joystick.is_Player_Control)
        {
            joystick.Move();
            //움직임을 주는 형태
            if (movetype == MoveType.Transform)
            {
                transform.position += ((Vector3)joystick.input * original_speed);
            }
            else if (movetype == MoveType.Rigidbody)
            {
                GetComponent <Rigidbody2D>().velocity = joystick.input;
            }

            if (transform.position.y != last_y)
            {
                //보이는 순서를 정해줍니다.
                Move_Help.sortingSet(GetComponent <SpriteRenderer>(), transform, transform.position.y);
            }

            last_y = transform.position.y;
        }
        else
        {
            base.FixedUpdate();
        }
    }
Example #2
0
    public void Move()
    {
        if (is_Panel_Control || !IngameManager.instance.playerUI.activeSelf)
        {
            return;
        }

        Move_Help.Set_Flip(player.GetComponent <SpriteRenderer>(), input.normalized);

        Vector2 radius = background.sizeDelta / 2;

        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical   = Input.GetAxisRaw("Vertical");

        input = new Vector2(horizontal, vertical);

        handle.anchoredPosition = input * radius;
    }
Example #3
0
    public void OnDrag(PointerEventData eventData)
    {
        Vector2 position = RectTransformUtility.WorldToScreenPoint(null, background.position);
        Vector2 radius   = background.sizeDelta / 2;

        input = (eventData.position - position) / radius;

        if (input.magnitude > 1)
        {
            input = input.normalized;
        }

        Move_Help.Set_Flip(player.GetComponent <SpriteRenderer>(), input.normalized);


        handle.anchoredPosition = input * radius;

        is_Panel_Control = true;
    }
Example #4
0
File: AI.cs Project: sunkess/test1
    protected virtual void AIMove()
    {
        Vector2 dir      = target_Position[targetNum].position - transform.position;
        float   distance = dir.magnitude;

        if (distance > 0.1f)
        {
            GetComponent <Rigidbody2D>().velocity = dir.normalized * 2;
        }
        else
        {
            GetComponent <Rigidbody2D>().velocity = Vector2.zero;
        }


        if (transform.position.y != last_y)
        {
            Move_Help.sortingSet(GetComponent <SpriteRenderer>(), transform, (int)transform.position.y);
        }


        last_y = transform.position.y;
    }
Example #5
0
 // Start is called before the first frame update
 void Start()
 {
     Move_Help.sortingSet(GetComponent <SpriteRenderer>(), transform, transform.position.y);
 }