public void SetPuppet(Puppet puppet) { gameObject.SetActive(puppet != null); if (puppet != null) { Textbox.text = $"HP: {puppet.CurrentHP}/{puppet.MaxHP}\n Atk: {puppet.Attack} Def: {puppet.Defense} Spe: {puppet.Speed}"; switch (puppet.Element) { case PuppetElement.None: ElementImage.enabled = false; break; case PuppetElement.Light: ElementImage.sprite = ElementLight; ElementImage.enabled = true; break; case PuppetElement.Dark: ElementImage.sprite = ElementDark; ElementImage.enabled = true; break; case PuppetElement.Earth: ElementImage.sprite = ElementEarth; ElementImage.enabled = true; break; } DeathOverlay.SetActive(puppet.State == PuppetState.Dead); } }
/// <summary> /// Accept Room Invitation /// </summary> /// <returns></returns> public async Task Accept() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"accept()"); } await Puppet.RoomInvitationAccept(Id); var inviter = await Inviter(); var topic = await Topic(); try { await inviter.Ready(); if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"accept() with room({topic}) & inviter({inviter}) ready()"); } } catch (Exception exception) { Logger.LogWarning(exception, $"accept() inviter({inviter}) is not ready because of {exception.Message}"); } }
/// <summary> /// send <paramref name="text"/> to <see cref="Room"/> or <see cref="From"/> /// and @<paramref name="replyTo"/> /// </summary> /// <param name="text"></param> /// <param name="replyTo">@someone</param> /// <returns></returns> public async Task <Message?> Say(string text, params Contact[]?replyTo) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"say({text})"); } var room = Room; var from = From; var conversationId = string.Empty; if (room != null && room.Id != string.Empty) { conversationId = room.Id; } else if (from != null && from.Id != string.Empty) { conversationId = from.Id; } if (conversationId == string.Empty) { throw new InvalidOperationException("neither room nor from?"); } var msgId = await Puppet.MessageSendText(conversationId, text, replyTo?.Select(c => c.Id)); if (msgId != null) { var result = WechatyInstance.Message.Load(msgId); await result.Ready; return(result); } return(null); }
// Use this for initialization void Start() { mouseWeapon = FindObjectOfType <MouseWeapon>(); puppet = FindObjectOfType <Puppet>(); slapSpawnTimer = new Timer(0.23f); }
/// <summary> /// `ready()` is For FrameWork ONLY! /// /// Please not to use `ready()` at the user land. /// If you want to sync data, use `sync()` instead. /// </summary> /// <param name="forceSync"></param> /// <returns></returns> public async Task Ready(bool forceSync = false) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"ready()"); } if (!forceSync && IsReady) { return; } if (forceSync) { await Puppet.RoomPayloadDirty(Id); await Puppet.RoomMemberPayloadDirty(Id); } Payload = await Puppet.RoomPayload(Id); var memberIdList = await Puppet.RoomMemberList(Id); await Task.WhenAll(memberIdList.Select(async id => { var contact = WechatyInstance.Contact.Load(id); try { await contact.Ready(); } catch (Exception exception) { Logger.LogError($"ready() member.ready() rejection: {exception.Message}"); } })); }
public static void CreateGhosts() { if (!fa.useGhosts) { return; } //Now create ghostPuppets int num = loadedGhosts.Count; for (int i = 0; i < num; i++) { Puppet p = new Puppet(); p.go = Instantiate(xa.de.ghostPuppet); p.aniScript = p.go.GetComponent <GhostAniController>(); p.aniScript.name.text = downloadedGhostUsername; createdPuppets.Add(p); } if (num <= 0) { playingBack = false; } //No ghosts were loaded, don't do playback Debug.Log("LoadedGhosts: " + loadedGhosts.Count + ", CreatedPuppets: " + createdPuppets.Count + ", Num: " + num); }
public FollowState(AIContoller controller) : base(controller) { // Retrieve references dadTransform = GameManager.instance.GetPlayerPuppet().transform; aiTransform = GetAIController().transform; daughterPuppet = GameManager.instance.GetDaughterPuppet(); }
/// <summary> /// find all <see cref="Message"/> by <paramref name="query"/> if <paramref name="query"/> is not null, otherwise find all <see cref="Message"/> /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <IReadOnlyList <Message> > FindAll([AllowNull] MessageQueryFilter?query = default) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"findAll({JsonConvert.SerializeObject(query)})"); } var invalid = new Dictionary <string, bool>(); try { var messageIdList = await Puppet.MessageSearch(query); var messageList = messageIdList.Select(id => Load(id)); await Task.WhenAll(messageList.Select(async m => { try { await m.Ready; } catch (Exception exception) { Logger.LogWarning(exception, "findAll() message.ready() rejection"); invalid[m.Id] = true; } })); return(messageList.Where(m => !invalid.ContainsKey(m.Id)) .ToImmutableList()); } catch (Exception exception) { Logger.LogWarning(exception, $"findAll() rejected: {exception.Message}"); return(Array.Empty <Message>()); } }
/// <summary> /// init <see cref="Message"/> /// </summary> /// <param name="id"></param> /// <param name="wechaty"></param> /// <param name="logger"></param> /// <param name="name"></param> public Message([DisallowNull] string id, [DisallowNull] Wechaty wechaty, [DisallowNull] ILogger <Message> logger, [AllowNull] string?name = null) : base(wechaty, logger, name) { Id = id; if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"constructor({id}) for class {GetType().Name ?? nameof(Message)}"); } _loadAll = new AsyncLazy <object>(async() => { Payload = await Puppet.MessagePayload(Id); if (Payload == null) { throw new InvalidOperationException("no payload"); } var roomId = Payload.RoomId; var fromId = Payload.FromId; var toId = Payload.ToId; if (!string.IsNullOrWhiteSpace(roomId)) { await WechatyInstance.Room.Load(id).Ready(); } if (!string.IsNullOrWhiteSpace(fromId)) { await WechatyInstance.Contact.Load(fromId).Ready(); } if (!string.IsNullOrWhiteSpace(toId)) { await WechatyInstance.Contact.Load(toId).Ready(); } return(typeof(object)); }, AsyncLazyFlags.ExecuteOnCallingThread | AsyncLazyFlags.RetryOnFailure); }
void Update() { foreach (KeyValuePair <byte, PlayerState> kvp in gameState.players) { PlayerState playerState = kvp.Value; if (!playersReconciliation.ContainsKey(kvp.Key)) { GameObject prefab = playerState.id == currentPlayerId ? playerPrefab : puppetPrefab; PlayerState.TransformState interpolated = playerState.GetLastTransformState(); GameObject go = Instantiate(prefab, interpolated.position, interpolated.rotation, playersContainer); Puppet puppet = go.GetComponent <Puppet>(); if (puppet) { puppet.SubscribeToPlayerId(playerState.id); } playersReconciliation.Add(kvp.Key, go); } } List <byte> playersIdsToRemove = new List <byte>(); foreach (KeyValuePair <byte, GameObject> kvp in playersReconciliation) { if (!gameState.players.ContainsKey(kvp.Key)) { playersIdsToRemove.Add(kvp.Key); } } foreach (byte playerId in playersIdsToRemove) { playersReconciliation.Remove(playerId); } }
public virtual StringBuilder ReadXmlFile(string fullFileName = "") { #region ---Load Default?? Console.WriteLine("HACK-TEST -Convert"); if (string.IsNullOrEmpty(fullFileName)) { fullFileName = DefaultSourceFolder + "test.xml"; } #endregion //////////////END TEST string xml = File.ReadAllText(fullFileName); var catalog1 = xml.ParseXML <TestCase>(); string myScript = string.Empty; //get first var sel = catalog1;//.FirstOrDefault(); foreach (var t in sel.selenese) { Console.WriteLine(string.Format("{0} {1} {2}", t.command, t.target, t.value)); myScript += Puppet.Script(t, this); } //LogApplication.Agent.LogInfo(myScript); Console.WriteLine(Environment.NewLine + myScript); StringBuilder result = new StringBuilder(myScript); return(result); }
public void ConfigureAnimationSettings(Puppet puppet) { int selectedOption = animationSelection.value; if (animationRandomizeToggle.isOn) { selectedOption = UnityEngine.Random.Range(0, animationSelection.options.Count); } switch (animationSelection.options[selectedOption].text) { case "Position": puppet.style = Puppet.MotionStyle.Position; break; case "Rotation": puppet.style = Puppet.MotionStyle.Rotation; break; case "Scale": puppet.style = Puppet.MotionStyle.Scale; break; default: Debug.Log("ERROR: Unknown animation selected"); break; } foreach (Animation animation in puppet.GetComponentsInChildren <Animation>()) { animation.speed = animationSlider.value; } }
public async Task <Room?> Find([DisallowNull] RoomQueryFilter query) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"find({JsonConvert.SerializeObject(query)})"); } var roomList = await FindAll(query); if (roomList.Count > 1) { Logger.LogWarning($"find() got more than one({roomList.Count}) result"); } for (var i = 0; i < roomList.Count; i++) { var room = roomList[i]; if (await Puppet.RoomValidate(room.Id)) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"find() confirm room[#{i}] with id={room.Id} is valid result, return it."); } return(room); } else { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"find() confirm room[#{i}] with id={room.Id} is INVALID result, try next"); } } } Logger.LogWarning($"find() got {roomList.Count} rooms but no one is valid."); return(null); }
public virtual StringBuilder Convert(string fullFileName = "") { //_HACK safe to delete #region ---TEST ONLY: Compiler will automatically erase this in RELEASE mode and it will not run if Global.GlobalTestMode is not set to TestMode.Simulation #if OVERRIDE || DEBUG System.Diagnostics.Debug.WriteLine("HACK-TEST -Convert"); if (string.IsNullOrEmpty(fullFileName)) { fullFileName = DefaultSourceFolder + "test.xml"; } #endif #endregion //////////////END TEST string xml = File.ReadAllText(fullFileName); var catalog1 = xml.ParseXML <TestCase>(); string myScript = string.Empty; //get first var sel = catalog1;//.FirstOrDefault(); foreach (var t in sel.selenese) { Console.WriteLine(string.Format("{0} {1} {2}", t.command, t.target, t.value)); myScript += Puppet.Script(t, this); } //LogApplication.Agent.LogInfo(myScript); System.Diagnostics.Debug.WriteLine(Environment.NewLine + myScript); StringBuilder result = new StringBuilder(); return(result); }
// Could also make it where if they sent in one number, it's just an offset // If it's two numbers, it's a coordinate // PathToPuppet WorldXCoordinate public void MovePuppet(string PuppetPathAndLocation) { string[] args = PuppetPathAndLocation.Split(' '); Puppet puppet = GameObject.Find(args[0]).GetComponent <Puppet>(); puppet.MoveToLocation(float.Parse(args[1])); }
public PlayInstructs(Actions newAct, ConstFile.Notes newNote, float yPos, Puppet u) { action = newAct; note = newNote; y = yPos; unit = u; }
public async Task <bool> Has(Contact contact) { var memberIdList = await Puppet.RoomMemberList(Id); return((memberIdList?.Any(id => contact.Id == id)) .GetValueOrDefault(false)); }
public async Task <IReadOnlyList <Room> > FindAll([AllowNull] RoomQueryFilter?query = default) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"findAll({JsonConvert.SerializeObject(query)})"); } try { var invalid = new ConcurrentDictionary <string, bool>(); var roomIdList = await Puppet.RoomSearch(query); var roomList = roomIdList.Select(Load).ToList(); await Task.WhenAll(roomList.Select(async r => { try { await r.Ready(); } catch (Exception exception) { Logger.LogError(exception, $"findAll() room.ready() rejection: {exception.Message}"); invalid.TryAdd(r.Id, true); } })); return(roomList.Where(r => !invalid.ContainsKey(r.Id)).ToImmutableList()); } catch (Exception exception) { Logger.LogError(exception, $"findAll rejected: {exception.Message}"); return(Array.Empty <Room>()); } }
public async Task <string> GetTopic() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"get topic()"); } if (!IsReady) { Logger.LogWarning("topic() room not ready"); throw new InvalidOperationException("not ready"); } if (Payload != null && !string.IsNullOrEmpty(Payload.Topic)) { return(Payload.Topic); } else { var memberIdList = await Puppet.RoomMemberList(Id); var memberList = memberIdList .Where(id => id != Puppet.SelfId) .Select(id => WechatyInstance.Contact.Load(id)); return(string.Concat(",", memberList.Take(3).Select(m => m.Name))); } }
/// <summary> /// artwork /// </summary> /// <returns></returns> public async Task <FileBox> Artwork() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"artwork() for id: \"{Id}\""); } return(await Puppet.MessageImage(Id, ImageType.Artwork)); }
public static PokerPotItem Create(Puppet.Poker.Datagram.ResponseUpdatePot.DataPot pot) { GameObject gobj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PotItem")); gobj.name = "" + pot.id; PokerPotItem item = gobj.GetComponent<PokerPotItem>(); item.SetValue(pot); return item; }
public Task Delete(Contact contact) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"del({contact})"); } return(Puppet.RoomDel(Id, contact.Id)); }
public async Task <string> QrCode() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"qrCode()"); } return((await Puppet.RoomQRCode(Id)).GuardQrCodeValue()); }
public Task SetAnnounce(string text) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"announce({text})"); } return(Puppet.RoomAnnounce(Id, text)); }
public Task <string> GetAnnounce() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"announce()"); } return(Puppet.RoomAnnounce(Id)); }
public Task Quit() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"quit() {this}"); } return(Puppet.RoomQuit(Id)); }
// Use this for initialization void Start() { audioManager = FindObjectOfType <AudioManager>(); gameActionManager = FindObjectOfType <GameActionManager>(); puppet = FindObjectOfType <Puppet>(); SetListeners(); }
public Task Add(Contact contact) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"add({contact})"); } return(Puppet.RoomAdd(Id, contact.Id)); }
/// <summary> /// thumbnail /// </summary> /// <returns></returns> public async Task <FileBox> Thumbnail() { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"thumbnail() for id: \"{Id}\""); } return(await Puppet.MessageImage(Id, ImageType.Thumbnail)); }
static void Main(string[] args) { var puppet = new Puppet(); puppet.Start("0.0.0.0", 8888, "1212"); Console.ReadKey(); puppet.Stop(); }
/// <summary> /// Send a Friend Request to a `contact` with message `hello`. /// /// The best practice is to send friend request once per minute. /// Remeber not to do this too frequently, or your account may be blocked. /// </summary> /// <param name="contact">Send friend request to contact</param> /// <param name="hello">The friend request content</param> /// <returns></returns> public Task Add([DisallowNull] Contact contact, [DisallowNull] string hello) { if (Logger.IsEnabled(LogLevel.Trace)) { Logger.LogTrace($"static add({contact.Id}, {hello})"); } return(Puppet.FriendshipAdd(contact.Id, hello)); }
public void SetValue(Puppet.Poker.Datagram.ResponseUpdatePot.DataPot pot) { this._pot = pot; SetBet(pot.value); }
public void DoTask(Puppet puppet) { puppet.TotalFrames = 16; TextureLoader t = TextureLoader.GetInstance(puppet.Game); puppet.Texture = t.GameObjectTextures["lemming_block_r"]; }
public void LoadLobbiesByChannel(Puppet.Core.Model.DataChannel channel) { selectedChannel = channel; if (lobbies != null) lobbies = null; IsFiltered = false; APILobby.SetSelectChannel(channel, OnGetAllLobbyInChannel); }
public void LoadLobbiesByChannel(Puppet.Core.Model.DataChannel channel) { view.ShowLoading(); selectedChannel = channel; lobbies = new List<DataLobby>(); IsFiltered = false; view.DrawLobbies(lobbies); APILobby.SetSelectChannel(channel, OnCallbackAllLobbyInSelectedChannel); }
static Guider() { _puppet = new Puppet(_prefiex, PuppetProcessor); }
public void JoinToGame(Puppet.Core.Model.DataLobby lobby) { view.ShowLoading(); APILobby.JoinLobby(lobby, (bool status, string message) => { view.HideLoading(); if (!status) view.ShowError(message); }); }
public void DoTask(Puppet puppet) { throw new NotImplementedException(); }