private void UpdateSlotView(AvatarState avatarState) { var game = Game.Game.instance; // var playerModel = game.Stage.GetPlayer().Model; var playerModel = _player.Model; nicknameText.text = string.Format( NicknameTextFormat, avatarState.level, avatarState.NameWithHash); var title = avatarState.inventory.Costumes.FirstOrDefault(costume => costume.ItemSubType == ItemSubType.Title && costume.equipped); titleText.text = title is null ? "" : title.GetLocalizedName(); costumeSlots.SetPlayerCostumes(playerModel, ShowTooltip, Unequip); equipmentSlots.SetPlayerEquipments(playerModel, ShowTooltip, Unequip); var currentAvatarState = game.States.CurrentAvatarState; if (avatarState.Equals(currentAvatarState)) { // 인벤토리 아이템의 장착 여부를 `equipmentSlots`의 상태를 바탕으로 설정하기 때문에 `equipmentSlots.SetPlayer()`를 호출한 이후에 인벤토리 아이템의 장착 상태를 재설정한다. // 또한 인벤토리는 기본적으로 `OnEnable()` 단계에서 `OnResetItems` 이벤트를 일으키기 때문에 `equipmentSlots.SetPlayer()`와 호출 순서 커플링이 생기게 된다. // 따라서 강제로 상태를 설정한다. inventory.gameObject.SetActive(true); SubscribeInventoryResetItems(inventory); var currentPlayer = game.Stage.selectedPlayer; cpText.text = CPHelper.GetCP(currentPlayer.Model, game.TableSheets.CostumeStatSheet) .ToString(); } else { inventory.gameObject.SetActive(false); cpText.text = CPHelper.GetCPV2(avatarState, game.TableSheets.CharacterSheet, game.TableSheets.CostumeStatSheet) .ToString(); } UpdateUIPlayer(); }
public void Test_AvatarState_Equals() { #region Create AvatarStates var avatarState = new AvatarState(); var avatarStateB = new AvatarState(); var avatarState1 = new AvatarState(); avatarState1.HeadPosition = new Vector3(1, 2, 3); avatarState1.HeadRotation = new Quaternion(0, 0, 0, 0); avatarState1.LHandPosition = new Vector3(0, 0, 0); avatarState1.LHandRotation = new Quaternion(0, 0, 0, 0); avatarState1.RHandPosition = new Vector3(0, 0, 0); avatarState1.RHandRotation = new Quaternion(0, 0, 0, 0); var avatarState2 = new AvatarState(); avatarState2.PlayerID = Guid.NewGuid(); avatarState2.HeadPosition = new Vector3(0, 0, 0); avatarState2.HeadRotation = new Quaternion(1, 2, 3, 4); avatarState2.LHandPosition = new Vector3(0, 0, 0); avatarState2.LHandRotation = new Quaternion(0, 0, 0, 0); avatarState2.RHandPosition = new Vector3(0, 0, 0); avatarState2.RHandRotation = new Quaternion(0, 0, 0, 0); var avatarState3 = new AvatarState(); avatarState3.PlayerID = Guid.NewGuid(); avatarState3.HeadPosition = new Vector3(0, 0, 0); avatarState3.HeadRotation = new Quaternion(0, 0, 0, 0); avatarState3.LHandPosition = new Vector3(1, 2, 3); avatarState3.LHandRotation = new Quaternion(0, 0, 0, 0); avatarState3.RHandPosition = new Vector3(0, 0, 0); avatarState3.RHandRotation = new Quaternion(0, 0, 0, 0); var avatarState4 = new AvatarState(); avatarState4.PlayerID = Guid.NewGuid(); avatarState4.HeadPosition = new Vector3(0, 0, 0); avatarState4.HeadRotation = new Quaternion(0, 0, 0, 0); avatarState4.LHandPosition = new Vector3(0, 0, 0); avatarState4.LHandRotation = new Quaternion(1, 2, 3, 4); avatarState4.RHandPosition = new Vector3(0, 0, 0); avatarState4.RHandRotation = new Quaternion(0, 0, 0, 0); var avatarState5 = new AvatarState(); avatarState5.PlayerID = Guid.NewGuid(); avatarState5.HeadPosition = new Vector3(0, 0, 0); avatarState5.HeadRotation = new Quaternion(0, 0, 0, 0); avatarState5.LHandPosition = new Vector3(0, 0, 0); avatarState5.LHandRotation = new Quaternion(0, 0, 0, 0); avatarState5.RHandPosition = new Vector3(1, 2, 3); avatarState5.RHandRotation = new Quaternion(0, 0, 0, 0); var avatarState6 = new AvatarState(); avatarState6.PlayerID = Guid.NewGuid(); avatarState6.HeadPosition = new Vector3(0, 0, 0); avatarState6.HeadRotation = new Quaternion(0, 0, 0, 0); avatarState6.LHandPosition = new Vector3(0, 0, 0); avatarState6.LHandRotation = new Quaternion(0, 0, 0, 0); avatarState6.RHandPosition = new Vector3(0, 0, 0); avatarState6.RHandRotation = new Quaternion(1, 2, 3, 4); #endregion Create all-unique AvatarStates // Test that each avatar state equals itself. Assert.IsTrue(avatarState.Equals(avatarState)); Assert.IsTrue(avatarState.Equals(avatarStateB)); Assert.IsTrue(avatarState1.Equals(avatarState1)); Assert.IsTrue(avatarState2.Equals(avatarState2)); Assert.IsTrue(avatarState3.Equals(avatarState3)); Assert.IsTrue(avatarState4.Equals(avatarState4)); Assert.IsTrue(avatarState5.Equals(avatarState5)); Assert.IsTrue(avatarState6.Equals(avatarState6)); // Test that the 1st avatar does not equal any other avatar state. Assert.IsFalse(avatarState.Equals(avatarState1)); Assert.IsFalse(avatarState.Equals(avatarState2)); Assert.IsFalse(avatarState.Equals(avatarState3)); Assert.IsFalse(avatarState.Equals(avatarState4)); Assert.IsFalse(avatarState.Equals(avatarState5)); Assert.IsFalse(avatarState.Equals(avatarState6)); }