public async Task HandleAsync(ChangeAvatarCommand command) { var user = await _userRepository.GetAsync(new UserId(command.UserId)) ?? throw new UserNotFoundException(); var avatar = await AvatarFactory.CreateFrom(command.Image); user.Change(avatar); }
public IActionResult GetBase(int skinId = 2000) => File(AvatarFactory.Render(new Character() { ItemEntries = new int[] { skinId, skinId + 10000 }.Select(c => new AvatarItemEntry() { ItemId = c, Region = Region, Version = Version }).ToArray() }).ImageToByte(Request, true, null, true), "image/png");
public EnemyPlayer(string playerId, string name, string avatarType) : this(playerId) { this.Name = name; if (Enum.TryParse(avatarType, out AvatarType type)) { Avatar = AvatarFactory.CreateTypeOf(type); } }
public IActionResult GetFrame(int npcId) { NPC npcData = NPCFactory.GetNPC(npcId); if (npcData.IsComponentNPC ?? false) { return(File(AvatarFactory.Render(new Character() { AnimationName = "stand1", ItemEntries = npcData.ComponentIds .Concat(new int[] { npcData.ComponentSkin ?? 2000, (npcData.ComponentSkin ?? 2000) + 10000 }) .Select(c => new AvatarItemEntry() { ItemId = c, Region = Region, Version = Version }) .ToArray() }).ImageToByte(Request), "image/png")); } if (!npcData.Framebooks.ContainsKey("stand")) { return(NotFound()); } FrameBook standing = npcData.GetFrameBook("stand").First(); if (standing == null) { return(NotFound()); } Frame firstFrame = standing.frames.First(); if (firstFrame == null || firstFrame.Image == null) { return(NotFound()); } return(File(firstFrame.Image.ImageToByte(Request), "image/png")); }
public void ChangeAvatar(AvatarType aType) { ClearModels(); GameObject avatarObj = AvatarFactory.GetInstance().CreateAvatar(aType); //! 改变人物 avatarObj.transform.rotation = Quaternion.Euler(0f, 200f, 0f); ResourceConfigScript rConf = GameApp.GetInstance().GetResourceConfig(); Weapon w = GameApp.GetInstance().GetGameState().GetBattleWeapons()[0]; string firstWeaponName = w.Name; string wNameEnd = Weapon.GetWeaponNameEnd(w.GetWeaponType()); GameObject weapon = WeaponFactory.GetInstance().CreateWeaponModel(firstWeaponName, avatarObj.transform.position, avatarObj.transform.rotation); //! 创建武器 Transform weaponBoneTrans = avatarObj.transform.Find(BoneName.WEAPON_PATH); //! 获取人物上挂载武器的节点 weapon.transform.parent = weaponBoneTrans; //! 设置武器的父节点 avatarObj.transform.localScale = scale; avatarObj.GetComponent <UnityEngine.Animation>()[AnimationName.PLAYER_IDLE + wNameEnd].wrapMode = WrapMode.Loop; avatarObj.GetComponent <UnityEngine.Animation>().Play(AnimationName.PLAYER_IDLE + wNameEnd); SetModel(avatarObj); lastMotionTime = Time.time; }
public IActionResult Render(int npcId, string framebook, int frame = 0) { NPC npcData = NPCFactory.GetNPC(npcId); if (npcData.IsComponentNPC ?? false) { return(File(AvatarFactory.Render(new Character() { AnimationName = framebook, FrameNumber = frame, ItemEntries = npcData.ComponentIds .Concat(new int[] { npcData.ComponentSkin ?? 2000, (npcData.ComponentSkin ?? 2000) + 10000 }) .Select(c => new AvatarItemEntry() { ItemId = c, Region = Region, Version = Version }) .ToArray() }).ImageToByte(Request), "image/png")); } FrameBook standing = npcData.GetFrameBook(framebook).First(); if (standing == null) { return(NotFound()); } Frame firstFrame = standing.frames.ElementAt(frame % standing.frames.Count()); if (firstFrame == null || firstFrame.Image == null) { return(NotFound()); } return(File(firstFrame.Image.ImageToByte(Request), "image/png")); }
void Awake() { studentTime = AvatarFactory.CreateTypeOf(AvatarType.Student).MinutesToPlay; businessTime = AvatarFactory.CreateTypeOf(AvatarType.Businessman).MinutesToPlay; }