示例#1
0
        private void AdaptOrderInLayer()
        {
            auto_sort.RefreshSort();

            if (bearer)
            {
                if (!rotate_item)
                {
                    CharacterHoldItem char_bearer = bearer.GetComponent <CharacterHoldItem>();
                    int offset = char_bearer.GetCharacter().GetSide() == 0 ? 5 : -5;
                    sprite_render.sortingOrder = char_bearer.GetCharacter().GetSortOrder() + offset;
                }
            }
        }
示例#2
0
        private void UpdatePosition()
        {
            target_pos = transform.position;
            float target_angle = 0f;

            target_rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, target_angle);

            if (bearer)
            {
                Vector3 motion = bearer.GetMove();
                if (bearer)
                {
                    if (motion.magnitude > 0.1f)
                    {
                        last_motion = motion;
                    }
                }

                //Update position of the item
                flipX = bearer.GetCharacter().GetSide();
                GameObject hand = bearer.hand.gameObject;
                target_pos = hand.transform.position + hand.transform.up * carry_offset.y + hand.transform.right * carry_offset.x * flipX;
                Vector3 rot_vector_forw = Quaternion.Euler(0f, 0f, carry_angle_deg * flipX) * hand.transform.forward;
                Vector3 rot_vector_up   = Quaternion.Euler(0f, 0f, carry_angle_deg * flipX) * hand.transform.up;
                target_rotation = Quaternion.LookRotation(rot_vector_forw, rot_vector_up);
            }

            //Move the object
            transform.position = target_pos;
            transform.rotation = target_rotation;

            //Flip
            transform.localScale = bearer || throwing ? start_size * carry_size : start_size;
            transform.localScale = new Vector3(Mathf.Abs(transform.localScale.x) * flipX, transform.localScale.y, transform.localScale.z);
        }