예제 #1
0
 //GetCurrentUI
 public void getCurrentUI()
 {
     currentUI[0] = catResolver.GetLabel();
     currentUI[1] = eyebrowResolver.GetLabel();
     if (whichplayer == 1)
     {
         currentUI[2] = eyeResolver.GetLabel();
         //currentUI[8] = wheelchairResolver.GetLabel();
     }
     else if (whichplayer == 0)
     {
         currentUI[3] = sunglassesResolver.GetLabel();
     }
     currentUI[4] = mouthResolver.GetLabel();
     currentUI[5] = hairaResolver.GetLabel();
     currentUI[6] = hairbResolver.GetLabel();
     currentUI[7] = haircResolver.GetLabel();
 }
예제 #2
0
    public void InjectCustom(Sprite customSprite)
    {
        // Duplicate bones and poses
        string referenceLabel = targetResolver.GetLabel();
        Sprite referenceHead  =
            spriteLibrary.GetSprite(targetCategory, referenceLabel);

        SpriteBone[]            bones = referenceHead.GetBones();
        NativeArray <Matrix4x4> poses = referenceHead.GetBindPoses();

        customSprite.SetBones(bones);
        customSprite.SetBindPoses(poses);

        // Inject new sprite
        const string customLabel = "customHead";

        spriteLibrary.AddOverride(customSprite, targetCategory, customLabel);
        targetResolver.SetCategoryAndLabel(targetCategory, customLabel);
    }
예제 #3
0
 public static int get_label_as_number(
     this SpriteResolver in_resolver
     )
 {
     return(Int32.Parse(in_resolver.GetLabel()));
 }
예제 #4
0
 public void InitView(string spriteName)
 {
     spriteResolver.SetCategoryAndLabel(spriteName, spriteResolver.GetLabel());
 }
    /**
     * @Description: The function of changing equipment,
     *              other script can using PlayerController.Instance.ChangeEquipments to call this function.
     *              for the first param, developer could using PlayerController.EquopmentType to choose which equipmentType they want to change,
     *              for the second param, developer could using PlayerController.EQUIPMENT_LEVEL_XXX to choose which level of equipment they want to change.
     * @version: 1.0.0
     * @Author: Zilin Zhang
     * @Date: 2020-11-27 03:30:14
     * @LastEditors: Zilin Zhang
     * @LastEditTime: 2020-11-27 03:29:45
     */
    public void ChangeEquipments(EquipmentType equipmentType, string equipmentLevel)
    {
        switch (equipmentType)
        {
        case EquipmentType.armour:
            foreach (var resolver in spriteResolvers)
            {
                if (!(resolver.GetCategory().Equals("LeftItem") || resolver.GetCategory().Equals("RightItem")))
                {
                    resolver.SetCategoryAndLabel(resolver.GetCategory(), equipmentLevel);
                }
            }
            if (equipmentLevel.Equals(EQUIPMENT_LEVEL_NORMAL))
            {
                itemEquipment.SetActive(true);
            }
            else
            {
                itemEquipment.SetActive(false);
            }
            break;

        case EquipmentType.leftHand:
            if (rightHandResolve.GetLabel().Equals(EQUIPMENT_RIGHT_ITEM_WOOD_BOW))
            {
                rightHandResolve.SetCategoryAndLabel(rightHandResolve.GetCategory(), EQUIPMENT_LEFT_OR_RIGHT_ITEM_NONE);
                arrowBag.SetActive(false);
                isEquippedRemoteWeapon = false;
            }
            leftHandResolve.SetCategoryAndLabel(leftHandResolve.GetCategory(), equipmentLevel);
            break;

        case EquipmentType.rightHand:
            // handle some special type
            // can not use other things in left hand when using bow
            if (equipmentLevel.Equals(EQUIPMENT_RIGHT_ITEM_WOOD_BOW) ||
                equipmentLevel.Equals(EQUIPMENT_RIGHT_ITEM_IRON_BOW) ||
                equipmentLevel.Equals(EQUIPMENT_RIGHT_ITEM_GOLD_BOW))
            {
                leftHandResolve.SetCategoryAndLabel(leftHandResolve.GetCategory(), EQUIPMENT_LEFT_ITEM_WOOD_ARROW);
                rightHandResolve.SetCategoryAndLabel(rightHandResolve.GetCategory(), EQUIPMENT_RIGHT_ITEM_WOOD_BOW);
                arrowBag.SetActive(true);
                isEquippedRemoteWeapon = true;
            }
            else
            {
                if (rightHandResolve.GetLabel().Equals(EQUIPMENT_RIGHT_ITEM_WOOD_BOW) ||
                    rightHandResolve.GetLabel().Equals(EQUIPMENT_RIGHT_ITEM_IRON_BOW) ||
                    rightHandResolve.GetLabel().Equals(EQUIPMENT_RIGHT_ITEM_GOLD_BOW))
                {
                    leftHandResolve.SetCategoryAndLabel(leftHandResolve.GetCategory(), EQUIPMENT_LEFT_OR_RIGHT_ITEM_NONE);
                    arrowBag.SetActive(false);
                    isEquippedRemoteWeapon = false;
                }
                rightHandResolve.SetCategoryAndLabel(rightHandResolve.GetCategory(), equipmentLevel);
            }
            break;

        default:
            break;
        }
    }
예제 #6
0
        //Randomize character
        public void onClick_randomize()
        {
            string tpname;

            tpname = randBody("mouth", 35);
            mouthResolver.SetCategoryAndLabel("mouth", tpname);
            unselectbody("mouth");
            selectbody(tpname);

            tpname = randBody("hairb", 33);
            hairbResolver.SetCategoryAndLabel("hairb", tpname);
            unselectbody("hairb");
            selectbody(tpname);


            if (hairbResolver.GetLabel() == "hairb1")
            {
                int which = UnityEngine.Random.Range(0, 2);
                //which haira with hairb1
                if (which == 0)
                {
                    hairaResolver.SetCategoryAndLabel("haira", "haira20");
                    unselectbody("haira");
                    selectbody("haira20");
                }
                else
                {
                    hairaResolver.SetCategoryAndLabel("haira", "haira10");
                    unselectbody("haira");
                    selectbody("haira10");
                }

                haircResolver.SetCategoryAndLabel("hairc", "hairc1");
                unselectbody("hairc");
                selectbody("hairc1");

                catResolver.SetCategoryAndLabel("cat", "cat1");
                unselectbody("cat");
                selectbody("cat1");
            }
            else
            {
                tpname = randBody("haira", 20);
                hairaResolver.SetCategoryAndLabel("haira", tpname);
                unselectbody("haira");
                selectbody(tpname);

                tpname = randBody("hairc", 16);
                haircResolver.SetCategoryAndLabel("hairc", tpname);
                unselectbody("hairc");
                selectbody(tpname);


                tpname = randBody("cat", 30);
                catResolver.SetCategoryAndLabel("cat", tpname);
                unselectbody("cat");
                selectbody(tpname);
            }
            if (PlayerNetwork.Instance.myCharacter == 0)
            {
                tpname = randBody("sunglasses", 20);
                sunglassesResolver.SetCategoryAndLabel("sunglasses", tpname);
                unselectbody("sunglasses");
                selectbody(tpname);
            }
            else
            {
                tpname = randBody("eye", 20);
                eyeResolver.SetCategoryAndLabel("eye", tpname);
                unselectbody("eye");
                selectbody(tpname);

                //tpname = randBody("wheelchair", 20);
                //wheelchairResolver.SetCategoryAndLabel("wheelchair", tpname);
                //unselectbody("wheelchair");
                //selectbody(tpname);
            }
            tpname = randBody("eyebrow", 17);
            eyebrowResolver.SetCategoryAndLabel("eyebrow", tpname);
            unselectbody("eyebrow");
            selectbody(tpname);
        }
예제 #7
0
        void Update()
        {
            UpdateCamera();

            blinkCountdown -= Time.deltaTime;
            if (blinkCountdown < 0.0f)
            {
                leftEye.SetCategoryAndLabel("EyesClosed", leftEye.GetLabel());
                rightEye.SetCategoryAndLabel("EyesClosed", rightEye.GetLabel());
                eyesOpenCountdown = 0.1f;
                blinkCountdown    = Random.Range(2.0f, 4.0f);
            }
            if (eyesOpenCountdown > 0.0f)
            {
                eyesOpenCountdown -= Time.deltaTime;
                if (eyesOpenCountdown < 0.0f)
                {
                    leftEye.SetCategoryAndLabel("EyesOpen", leftEye.GetLabel());
                    rightEye.SetCategoryAndLabel("EyesOpen", rightEye.GetLabel());
                }
            }

            if (speaking)
            {
                mouthCountdown -= Time.deltaTime;
                if (mouthCountdown < 0.0f)
                {
                    // randomly alternate between our open-mouth sprites
                    mouth.SetCategoryAndLabel("Mouth", (Random.Range(0.0f, 1.0f) > 0.5f ? "open-d" : "open-o"));
                    mouthCountdown = 0.05f;
                }
            }


            // Handle any jumps
            if (UnityEngine.Input.GetKeyDown(KeyCode.Space))
            {
                animator.SetTrigger("jump");
            }

            // Handle any horizontal input
            float horizontalMovement = UnityEngine.Input.GetAxis("Horizontal");

            rigidbody2d.velocity = new Vector2(horizontalMovement * moveVelocity, rigidbody2d.velocity.y);

            // Quick and dirty flip in X axis, but long term should do better (i.e. character's hair flick should not change direction!)
            if (Mathf.Abs(horizontalMovement) > float.Epsilon)
            {
                animatorObject.transform.localScale = new Vector3((horizontalMovement > 0.0f ? -1.0f : 1.0f), 1.0f, 1.0f);
            }

            animator.SetFloat("speed", Mathf.Abs(horizontalMovement));
            if (horizontalMovement != 0)
            {
                //Speech.Instance.Disable();
            }

            // Handle our search mode (set the cursor to a crosshair)
            if (UnityEngine.Input.GetKeyDown(KeyCode.Q))
            {
                Cursor.SetCursor(crosshairCursorTexture, new Vector2(32.0f, 32.0f), CursorMode.Auto);
                Searching = true;
            }
            else if (UnityEngine.Input.GetKeyUp(KeyCode.Q))
            {
                Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
                Searching = false;
            }

            // Handle arm movement
            if (UnityEngine.Input.GetKey(KeyCode.E))
            {
                Reaching = true;
                animator.SetBool("reaching", Reaching);
                Vector3 p   = UnityEngine.Input.mousePosition;
                Vector3 pos = UnityEngine.Camera.main.ScreenToWorldPoint(p);
                pos.z = shoulder.position.z;
                Vector3 shoulders = shoulder.position;// + new Vector3(0.0f, 3.36f, 0.0f);
                Vector3 mouseDir  = shoulders - pos;


                float x = Mathf.InverseLerp(minArmReach, maxArmReach, Mathf.Abs(mouseDir.x));
                //x = mouseDir.x > 0.0f ? x : -x;
                x = Mathf.Abs(mouseDir.x) < minArmReach ? 0.001f : x;
                animator.SetFloat("arm-x", -x);


                float y = Mathf.InverseLerp(0.0f, maxArmReach, Mathf.Abs(mouseDir.y));
                y = mouseDir.y > 0.0f ? -y : y;
                animator.SetFloat("arm-y", y);
                //Debug.Log("X: " + x + " Y: " + y);
            }
            else
            {
                Reaching = false;
                animator.SetBool("reaching", Reaching);
            }

            if ((Reaching || Searching) && UnityEngine.Input.GetMouseButtonDown(0))
            {
                RaycastHit2D hit = Physics2D.Raycast(UnityEngine.Camera.main.ScreenToWorldPoint(UnityEngine.Input.mousePosition), Vector2.zero, Mathf.Infinity, LayerMask.GetMask("interactables"));
                if (hit.collider != null && hit.collider.gameObject != null)
                {
                    Interactable interactable = hit.collider.gameObject.GetComponent <Interactable>();
                    if (Searching)
                    {
                        //interactable.LookAt();
                        speechBubble.Display(interactable.Description());
                    }
                    else if (interactable.Touching())
                    {
                        switch (interactable.GetInteractableType())
                        {
                        case InteractableType.PickUp:
                        {
                            //((Item)interactable).PickUp();
                            break;
                        }

                        case InteractableType.Door:
                        {
                            doorOffset = transform.position - interactable.transform.position;
                            ((Door)interactable).Open();
                            break;
                        }
                        }
                    }
                }
            }
        }