private GameOperationResponse HandleRetrieveCharacters(int sessionId, RetrieveCharacters operation) { try { var characters = this.application.CharacterDatabase.Query <PlayerData>("PlayerData/ByUsername") //.Customize(x => x.WaitForNonStaleResultsAsOfNow()) .Where(chr => chr.Username.Equals(operation.Username, StringComparison.CurrentCultureIgnoreCase)) .Select(chr => new { chr.Name, chr.Race, chr.Origin, chr.Level }) .ToArray(); if (characters.Length > 0) { var characterCollection = new CharacterStructure[characters.Length]; for (var i = 0; i < characters.Length; i++) { var chr = characters[i]; characterCollection[i] = new CharacterStructure(chr.Race, chr.Origin, chr.Level, chr.Name); } return(new RetrieveCharactersResponse(operation.OperationCode) { ReturnCode = (short)ResultCode.Ok, Characters = characterCollection }); } return(operation.GetErrorResponse((short)ResultCode.Ok)); } catch (Exception e) { _logger.Error(e); return(operation.GetErrorResponse((short)ResultCode.Fail)); } }
/// <summary> /// Creates a new character /// </summary> public static void CreateCharacter(PhotonPeer peer, CharacterStructure characterInfo) { var parameters = new Dictionary <byte, object>() { { (byte)1, (byte)GameOperationCode.CreateCharacter }, { (byte)ParameterCode.Data, characterInfo }, }; peer.OpCustom((byte)ClientOperationCode.Character, parameters, true); }
public void Init(CharacterStructure characterStructure) { cs = characterStructure; emotionDict.Add("neutral", cs.faceSprites.neutral); emotionDict.Add("happy", cs.faceSprites.happy); emotionDict.Add("angry", cs.faceSprites.angry); emotionDict.Add("sad", cs.faceSprites.sad); emotionDict.Add("shocked", cs.faceSprites.shocked); emotionDict.Add("horny", cs.faceSprites.horny); emotionDict.Add("suspicious", cs.faceSprites.suspicious); }
private void SetCharacter() { if (currentCharacter != null) { Destroy(currentCharacter.gameObject); } var newCharGO = Instantiate(StoryLogic.characterDict[currentNode.character], transform); currentCharacter = GetComponentInChildren <CharacterStructure>(); var currentCharacterLogic = currentCharacter.gameObject.AddComponent <CharacterLogic>(); currentCharacterLogic.Init(currentCharacter); currentCharacterLogic.SetEmotion(currentNode.emotion); }
public static bool IsValidCharacterInfo(CharacterStructure characterInfo, out ResultCode resultCode) { resultCode = ResultCode.Ok; if (!Enum.IsDefined(typeof(Race), characterInfo.Race)) { resultCode = ResultCode.InvalidRace; return(false); } if (!Enum.IsDefined(typeof(Origin), characterInfo.Origin)) { resultCode = ResultCode.InvalidOrigin; return(false); } return(true); }
public static bool IsValidCharacterInfo(CharacterStructure characterInfo) { ResultCode resultCode; return(IsValidCharacterInfo(characterInfo, out resultCode)); }