Beispiel #1
0
    void Update()
    {
        if (outline != null)
        {
            if (is_hovered != outline.activeSelf)
            {
                outline.SetActive(is_hovered);
            }
        }

        last_pos   = transform.position;
        is_hovered = PlayerControlsMouse.Get().IsInRaycast(gameObject);
    }
    void Update()
    {
        PlayerControlsMouse controls = PlayerControlsMouse.Get();

        float target_alpha = controls.IsJoystickActive() ? 1f : 0f;

        canvas.alpha = Mathf.MoveTowards(canvas.alpha, target_alpha, 4f * Time.deltaTime);

        Vector2 screenPos = controls.GetJoystickPos();

        rect.anchoredPosition = TheUI.Get().ScreenPointToCanvasPos(screenPos);
        pin.anchoredPosition  = controls.GetJoystickDir() * 50f;
    }
Beispiel #3
0
 void Update()
 {
     if (building_mode)
     {
         PlayerControlsMouse mouse = PlayerControlsMouse.Get();
         if (mouse.IsUsingMouse())
         {
             transform.position = mouse.GetPointingPos();
         }
         is_overlap = overlap_list.Count > 0;
         Color color = is_overlap ? Color.red : Color.white;
         SetModelColor(new Color(color.r, color.g, color.b, 0.5f));
         //Debug.Log(is_overlap);
     }
 }
    private void Start()
    {
        PlayerControlsMouse mouse_controls = PlayerControlsMouse.Get();

        mouse_controls.onClickFloor  += OnClickFloor;
        mouse_controls.onClickObject += OnClickObject;
        mouse_controls.onClick       += OnClick;
        mouse_controls.onRightClick  += OnRightClick;

        //Init attributes
        foreach (AttributeData attr in attributes)
        {
            if (!PlayerData.Get().HasAttribute(attr.type))
            {
                PlayerData.Get().SetAttributeValue(attr.type, attr.start_value);
            }
        }
    }
Beispiel #5
0
    void Update()
    {
        transform.position = PlayerControlsMouse.Get().GetPointingPos();
        transform.rotation = Quaternion.LookRotation(TheCamera.Get().transform.forward, Vector3.up);

        ItemSlot   islot   = InventoryBar.Get().GetSelectedSlot();
        ItemSlot   eslot   = EquipBar.Get().GetSelectedSlot();
        ItemSlot   slot    = eslot != null ? eslot : islot;
        Selectable select  = Selectable.GetNearestHover(transform.position);
        MAction    maction = slot != null && slot.GetItem() != null?slot.GetItem().FindMergeAction(select) : null;

        title.enabled = maction != null;
        title.text    = maction != null ? maction.title : "";

        if ((slot != null) != icon_group.activeSelf)
        {
            icon_group.SetActive(slot != null);
        }

        if (slot != null && slot.GetItem())
        {
            icon.sprite = slot.GetItem().icon;
        }
    }
Beispiel #6
0
 private void Start()
 {
     PlayerControlsMouse.Get().onClick      += (Vector3) => { CancelSubSelection(); };
     PlayerControlsMouse.Get().onRightClick += (Vector3) => { CancelSelection(); };
 }
 void Awake()
 {
     _instance = this;
     last_pos  = Input.mousePosition;
 }
 private void Start()
 {
     //PlayerControlsMouse.Get().onClick += OnMouseClick;
     PlayerControlsMouse.Get().onRightClick += OnMouseClick;
 }
    void FixedUpdate()//프레임과 상관없이 일정 시간의 지나면 실행됨 update보다 자주 실행됨, 물리적 구현 사용
    {
        if (TheGame.Get().IsPaused())
        {
            rigid.velocity = Vector3.zero;
            return;
        }

        if (is_dead)
        {
            return;
        }


        //죽지 않으면 실행되는 구현
        PlayerControls      controls  = PlayerControls.Get();
        PlayerControlsMouse mcontrols = PlayerControlsMouse.Get();
        Vector3             tmove     = Vector3.zero;

        //Navmesh
        if (auto_move && use_navmesh && path_found && path_index < nav_paths.Length)
        {
            auto_move_target_next = nav_paths[path_index];
            Vector3 move_dir_total = auto_move_target_next - transform.position;
            move_dir_total.y = 0f;
            if (move_dir_total.magnitude < 0.2f)
            {
                path_index++;
            }
        }

        //Moving
        auto_move_timer += Time.fixedDeltaTime;
        if (auto_move && auto_move_timer > 0.02f)
        {
            if (!use_navmesh || !calculating_path)
            {
                Vector3 move_dir_total = auto_move_target - transform.position;
                Vector3 move_dir_next  = auto_move_target_next - transform.position;
                Vector3 move_dir       = move_dir_next.normalized * Mathf.Min(move_dir_total.magnitude, 1f);
                move_dir.y = 0f;

                float move_dist = Mathf.Min(move_speed * move_speed_mult, move_dir.magnitude * 10f);
                tmove = move_dir.normalized * move_dist;
            }
        }
        else
        {
            Vector3 cam_move = TheCamera.Get().GetRotation() * controls.GetMove();
            if (mcontrols.IsJoystickActive())
            {
                Vector2 joystick = mcontrols.GetJoystickDir();
                cam_move = TheCamera.Get().GetRotation() * new Vector3(joystick.x, 0f, joystick.y);
            }
            tmove = cam_move * move_speed * move_speed_mult;
        }

        if (is_action)
        {
            tmove = Vector3.zero;
        }

        DetectGrounded();

        //Falling
        if (!is_grounded)
        {
            tmove += Vector3.down * fall_speed;
        }

        //Do move
        move           = Vector3.Lerp(move, tmove, move_accel * Time.fixedDeltaTime);
        rigid.velocity = move;

        //Facing
        if (!is_action && IsMoving())
        {
            facing = new Vector3(move.x, 0f, move.z).normalized;
        }

        Quaternion targ_rot = Quaternion.LookRotation(facing, Vector3.up);

        rigid.MoveRotation(Quaternion.RotateTowards(rigid.rotation, targ_rot, rotate_speed * Time.fixedDeltaTime));

        //Fronted
        DetectFronted();

        //Traveled calcul
        Vector3 last_frame_travel = transform.position - prev_pos;

        move_average = Vector3.MoveTowards(move_average, last_frame_travel, 1f * Time.fixedDeltaTime);
        prev_pos     = transform.position;

        //Stop auto move
        bool stuck_somewhere = (move_average.magnitude < 0.02f) && (auto_move_timer > 1f);

        if (stuck_somewhere)
        {
            StopMove();
        }

        if (controls.IsMoving() || mcontrols.IsJoystickActive())
        {
            StopAction();
        }
    }