private void InitSpriteResolve() { string[] toDefault = { "arm.l", "arm.r", "leg.l", "leg.r", "torso", "head", "head.face", }; foreach (Transform child in transform) { Debug.Log(child.name); SpriteResolver spriteResolver = child.GetComponent <SpriteResolver>(); if (spriteResolver) { if (Array.IndexOf(toDefault, child.name) >= 0) { spriteResolver.SetCategoryAndLabel(child.name, "default"); } else { spriteResolver.SetCategoryAndLabel(child.name, "empty"); } } } }
public void SelectRandom() { string[] labels = LibraryAsset.GetCategoryLabelNames(targetCategory).ToArray(); int index = Random.Range(0, labels.Length); string label = labels[index]; targetResolver.SetCategoryAndLabel(targetCategory, label); }
//Initialize default body part squares with pressed sprite and animation private void defaultbody_pressed_selected() { string tpname; tpname = "eyebrow" + deyebrow; unselectbody("eyebrow"); selectbody(tpname); eyebrowResolver.SetCategoryAndLabel("eyebrow", tpname); tpname = "haira" + dhaira; unselectbody("haira"); selectbody(tpname); hairaResolver.SetCategoryAndLabel("haira", tpname); tpname = "hairb" + dhairb; unselectbody("hairb"); selectbody(tpname); hairbResolver.SetCategoryAndLabel("hairb", tpname); tpname = "hairc" + dhairc; unselectbody("hairc"); selectbody(tpname); haircResolver.SetCategoryAndLabel("hairc", tpname); tpname = "cat" + dcat; unselectbody("cat"); selectbody(tpname); catResolver.SetCategoryAndLabel("cat", tpname); tpname = "mouth" + dmouth; unselectbody("mouth"); selectbody(tpname); mouthResolver.SetCategoryAndLabel("mouth", tpname); if (PlayerNetwork.Instance.myCharacter == 0) { tpname = "sunglasses" + dsunglasses; unselectbody("sunglasses"); selectbody(tpname); sunglassesResolver.SetCategoryAndLabel("sunglasses", tpname); } if (PlayerNetwork.Instance.myCharacter == 1) { tpname = "eye" + deye; unselectbody("eye"); selectbody(tpname); eyeResolver.SetCategoryAndLabel("eye", tpname); //tpname = "wheelchair" + dwheelchair; //unselectbody("wheelchair"); //selectbody(tpname); //wheelchairResolver.SetCategoryAndLabel("wheelchair", tpname); } }
// Update is called once per frame void Update() { if ((!flip && bone.transform.position.x - relative.position.x > threshold) || (flip && bone.transform.position.x - relative.position.x < -1 * threshold)) { sr.SetCategoryAndLabel(sr.GetCategory(), "Side"); } else { sr.SetCategoryAndLabel(sr.GetCategory(), "Front"); } }
private void SetLabel(SpriteResolver spriteResolver, string label) { var category = spriteResolver.GetCategory(); label = DoesLabelExistInCategory(label, category) ? label : NoneLabel; spriteResolver.SetCategoryAndLabel(category, label); }
public void Show() { FeedBtn.interactable = false; Skin.SetCategoryAndLabel("Skin", GameManager.Inst().Player.Types[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()]); PlayerAnim.SetInteger("Color", GameManager.Inst().ShtManager.BaseColor[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()] + 1); for (int i = 0; i < Constants.MAXREINFORCETYPE; i++) { Player.EqData eq = GameManager.Inst().Player.GetReinforce(i); LeftCount[i].text = "0"; CurCount[i].text = "0"; GaugeBars[i].fillAmount = GetFillAmount(i); AddBars[i].fillAmount = 0.0f; CurValues[i].text = GetCurrentValue(i); AddValues[i].text = "+0"; if (eq != null) { LeftCount[i].text = eq.Quantity.ToString(); GameManager.Inst().UiManager.MainUI.Center.Weapon.SetCurEquip(eq); PlusBtn[i].interactable = true; MinBtn[i].interactable = false; FeedBtn.interactable = true; switch (eq.Type) { case 0: if (GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetAtk() >= GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetMaxAtk()) { FeedBtn.interactable = false; } break; case 1: if (GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetHp() >= GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetMaxHp()) { FeedBtn.interactable = false; } break; case 2: if (GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetSpd() >= GameManager.Inst().UpgManager.BData[GameManager.Inst().UiManager.MainUI.Center.Weapon.GetCurBulletType()].GetMaxSpd()) { FeedBtn.interactable = false; } break; } } else { PlusBtn[i].interactable = false; MinBtn[i].interactable = false; } } }
public void ChangeToolMode(ToolCode toolCode, bool toolMode) { if (toolCode == ToolCode.Default) { toolCode = defaultTool; } ToolEquipData toolData = toolsEquipData.Find(toolEquipData => toolEquipData.toolCode == toolCode); if (toolData != null) { // Смену каждого инструмента можно реализовать двумя способами. Через смену всего спрайта или через инициализацию // дополнительного gameObject с инструментом. Изначально я делал отдельные спрайты персонажа для каждого инструмента. Для // моих спрайтов автоматических риггинг работает некорректно, а вручную это занимает время. Т.е. введение новых инструментов // становится довольно муторно. Но с таким способом можно лучше регулировать "глубину" инструмента - например, чтобы он был за головой, но перед телом. // Метод с геймобъектом быстрее, но там не получится сделать разное отношение глубин для разных частей тела - только для всего тела целиком. // Поэтому я оставил оба способа, потому что где-то без замены спрайта не обойтись (как, например, с лопатой), а где-то хватит и геймобъекта (мешок) if (toolData.isToUseSpriteSwitch) { spriteResolver.SetCategoryAndLabel(spriteResolver.GetCategory(), toolMode ? toolData.spriteResolveLabel : "Main"); } else { toolData.ChangeMode(toolMode); } } }
// Start is called before the first frame update void Start() { habilidadeOleo = 5; checkpointOleo = GetComponent <CheckPoint_Oleo>(); animator = GetComponent <Animator>(); oleoSprite.SetCategoryAndLabel("Oleo", "h_5"); UpdateOleo(); }
public void ShowEquipInfo(int Type) { CurType = Type; Skin.SetCategoryAndLabel("Skin", GameManager.Inst().Player.Types[Type]); PlayerAnim.SetInteger("Color", GameManager.Inst().ShtManager.BaseColor[Type] + 1); //for (int i = 0; i < 3; i++) // PaintGauge(i, Type, 0); GameManager.Inst().UiManager.MainUI.Center.Weapon.SetWeaponUI(Type); }
void Update() // Update is called once per frame { loaded = arrowObj.activeSelf ? false : true; category = GetCategory(); if (movementVector.magnitude > 0) { orientation = new Vector3(arrowOffset * movementVector.x, arrowOffset * movementVector.y, -1); label = LabelGenerator.GetLabel(orientation); } spriteResolver.SetCategoryAndLabel(category, label); }
public void Show(int stage) { WeaponSkin.SetCategoryAndLabel("Skin", GameManager.Inst().Player.Types[stage + 5]); WeaponName.text = GameManager.Inst().TxtManager.BulletTypeNames[stage + 5]; int color = GameManager.Inst().ShtManager.BaseColor[stage + 5]; Player.SetInteger("Color", ++color); Planet.sprite = PlanetImgs[stage]; PlanetName.text = GameManager.Inst().TxtManager.PlanetNames[stage]; Anim.Play(); }
// Start is called before the first frame update void Start() { eyes.SetCategoryAndLabel(eyes.GetCategory(), "" + Random.Range(1, 10)); mouth.SetCategoryAndLabel(mouth.GetCategory(), "" + Random.Range(1, 10)); hair.SetCategoryAndLabel(hair.GetCategory(), "" + Random.Range(1, 10)); List <string> s = library.GetCategoryLabelNames(weapons.GetCategory()).ToList(); weapons.SetCategoryAndLabel(weapons.GetCategory(), s[Random.Range(0, 5)]); Pawn pawn = GetComponentInParent <Pawn>(); if (pawn.color) { string label = "Thief"; List <string> s1 = library.GetCategoryLabelNames(label).ToList(); body.SetCategoryAndLabel(label, s1[Random.Range(0, 3)]); } else { string label = "Raider"; List <string> s1 = library.GetCategoryLabelNames(label).ToList(); body.SetCategoryAndLabel(label, s1[Random.Range(0, 3)]); } }
public IEnumerator play_animation() { while (is_emotion_playing) { emotion_resolver.SetCategoryAndLabel(emotion_name, emotion_sprite_index.ToString()); yield return(new WaitForSeconds(0.2f)); emotion_sprite_index = (emotion_sprite_index + 1) % 2; timer -= 0.2f; if (timer < 0.0f) { emotion_name = "Empty"; } } }
//UpdateUI with given bodyparts public void UpdateUI(string[] bodyUI, int whichPlayer) { catResolver.SetCategoryAndLabel(getType(bodyUI[0]), bodyUI[0]); eyebrowResolver.SetCategoryAndLabel(getType(bodyUI[1]), bodyUI[1]); if (whichPlayer == 1) { eyeResolver.SetCategoryAndLabel(getType(bodyUI[2]), bodyUI[2]); //wheelchairResolver.SetCategoryAndLabel(getType(bodyUI[8]), bodyUI[8]); } else if (whichPlayer == 0) { sunglassesResolver.SetCategoryAndLabel(getType(bodyUI[3]), bodyUI[3]); } mouthResolver.SetCategoryAndLabel(getType(bodyUI[4]), bodyUI[4]); hairaResolver.SetCategoryAndLabel(getType(bodyUI[5]), bodyUI[5]); hairbResolver.SetCategoryAndLabel(getType(bodyUI[6]), bodyUI[6]); haircResolver.SetCategoryAndLabel(getType(bodyUI[7]), bodyUI[7]); }
// Start is called before the first frame update void Start() { anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); plattforms = GameObject.FindGameObjectsWithTag("Platt"); leftFront.SetCategoryAndLabel("Front", type.ToString()); rightFront.SetCategoryAndLabel("Front", type.ToString()); leftBack.SetCategoryAndLabel("Back", type.ToString()); rightBack.SetCategoryAndLabel("Back", type.ToString()); head.SetCategoryAndLabel("Head", type.ToString()); body.SetCategoryAndLabel("Body", type.ToString()); doingAction = true; StartCoroutine(MoveToRandom()); StartCoroutine(AutoDestroy()); }
public void Update() { spriteResolver.SetCategoryAndLabel("goon", label); }
public void SetSkin() { Skin.SetCategoryAndLabel("Skin", Types[BulletType]); }
public void SetSkin() { Skin.SetCategoryAndLabel("Skin", GameManager.Inst().Player.Types[BulletType]); }
public void InitView(string spriteName) { spriteResolver.SetCategoryAndLabel(spriteName, spriteResolver.GetLabel()); }
public void SetMovement(Vector2 newMovement) // set the arrow's movement { movement = newMovement; spriteResolver.SetCategoryAndLabel("arrow", LabelGenerator.GetLabel(movement)); }
/** * @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; } }
public void onClick_wheelchair() { wheelchairResolver.SetCategoryAndLabel("wheelchair", getNamefromBtn()); }
private void UpdateModSprites() { //Swap Arm Sprites if (armTwoMod == bm_StrongArm || armOneMod == bm_StrongArm) { lArmSR.SetCategoryAndLabel("L_arm", "StrongArm L"); rArmSR.SetCategoryAndLabel("R_arm", "StrongArm R"); //position hands Vector2 LsaPos = GameObject.Find("LSAPos").transform.position; Vector2 RsaPos = GameObject.Find("RSAPos").transform.position; LdrillVisual.transform.position = LsaPos; RdrillVisual.transform.position = RsaPos; LgunVisual.transform.position = LsaPos; RgunVisual.transform.position = RsaPos; LhookVisual.transform.position = LsaPos; RhookVisual.transform.position = RsaPos; } else { lArmSR.SetCategoryAndLabel("L_arm", "Arm L"); rArmSR.SetCategoryAndLabel("R_arm", "Arm R"); //position hands Vector2 LdefPos = GameObject.Find("LOrigPos").transform.position; Vector2 RdefPos = GameObject.Find("ROrigPos").transform.position; LdrillVisual.transform.position = LdefPos; RdrillVisual.transform.position = RdefPos; LgunVisual.transform.position = LdefPos; RgunVisual.transform.position = RdefPos; LhookVisual.transform.position = LdefPos; RhookVisual.transform.position = RdefPos; } //Swap Leg Sprites if (legsMod == bm_Legs) { lLegSR.SetCategoryAndLabel("L_leg", "Leg L"); rLegSR.SetCategoryAndLabel("R_leg", "Leg R"); lFootSR.SetCategoryAndLabel("L_foot", "Foot L"); rFootSR.SetCategoryAndLabel("R_foot", "Foot R"); } else if (legsMod == bm_SuperLegs) { lLegSR.SetCategoryAndLabel("L_leg", "SuperLeg L"); rLegSR.SetCategoryAndLabel("R_leg", "SuperLeg R"); lFootSR.SetCategoryAndLabel("L_foot", "Foot L"); rFootSR.SetCategoryAndLabel("R_foot", "Foot R"); } else if (legsMod == bm_RocketLegs) { lLegSR.SetCategoryAndLabel("L_leg", "HoverLeg L"); rLegSR.SetCategoryAndLabel("R_leg", "HoverLeg R"); lFootSR.SetCategoryAndLabel("L_foot", "HoverFoot L"); rFootSR.SetCategoryAndLabel("R_foot", "HoverFoot R"); } //Hands LdrillVisual.SetActive(false); RdrillVisual.SetActive(false); LgunVisual.SetActive(false); RgunVisual.SetActive(false); LhookVisual.SetActive(false); RhookVisual.SetActive(false); if (armOneMod == bm_Drill) { RdrillVisual.SetActive(true); } else if (armOneMod == bm_Gun) { RgunVisual.SetActive(true); } else if (armOneMod == bm_Grapple) { RhookVisual.SetActive(true); } if (armTwoMod == bm_Drill) { LdrillVisual.SetActive(true); } else if (armTwoMod == bm_Gun) { LgunVisual.SetActive(true); } else if (armTwoMod == bm_Grapple) { LhookVisual.SetActive(true); } }
public void SetModel(string model) { _resolver.SetCategoryAndLabel(_category, model); }
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; } } } } } }