Example #1
0
    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);
        }
    }
Example #2
0
        /// <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}");
            }
        }
Example #3
0
        /// <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);
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        mouseWeapon = FindObjectOfType <MouseWeapon>();
        puppet      = FindObjectOfType <Puppet>();

        slapSpawnTimer = new Timer(0.23f);
    }
Example #5
0
        /// <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}");
                }
            }));
        }
Example #6
0
    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);
    }
Example #7
0
 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>());
            }
        }
Example #9
0
 /// <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);
 }
Example #10
0
        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);
            }
        }
Example #11
0
        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);
        }
Example #12
0
    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;
        }
    }
Example #13
0
        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);
        }
Example #14
0
        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);
        }
Example #15
0
    // 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]));
    }
Example #16
0
 public PlayInstructs(Actions newAct, ConstFile.Notes newNote, float yPos, Puppet u)
 {
     action = newAct;
     note   = newNote;
     y      = yPos;
     unit   = u;
 }
Example #17
0
        public async Task <bool> Has(Contact contact)
        {
            var memberIdList = await Puppet.RoomMemberList(Id);

            return((memberIdList?.Any(id => contact.Id == id))
                   .GetValueOrDefault(false));
        }
Example #18
0
        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>());
            }
        }
Example #19
0
        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)));
            }
        }
Example #20
0
 /// <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));
 }
Example #21
0
 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;
 }
Example #22
0
 public Task Delete(Contact contact)
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"del({contact})");
     }
     return(Puppet.RoomDel(Id, contact.Id));
 }
Example #23
0
 public async Task <string> QrCode()
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"qrCode()");
     }
     return((await Puppet.RoomQRCode(Id)).GuardQrCodeValue());
 }
Example #24
0
 public Task SetAnnounce(string text)
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"announce({text})");
     }
     return(Puppet.RoomAnnounce(Id, text));
 }
Example #25
0
 public Task <string> GetAnnounce()
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"announce()");
     }
     return(Puppet.RoomAnnounce(Id));
 }
Example #26
0
 public Task Quit()
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"quit() {this}");
     }
     return(Puppet.RoomQuit(Id));
 }
Example #27
0
    // Use this for initialization
    void Start()
    {
        audioManager      = FindObjectOfType <AudioManager>();
        gameActionManager = FindObjectOfType <GameActionManager>();
        puppet            = FindObjectOfType <Puppet>();

        SetListeners();
    }
Example #28
0
 public Task Add(Contact contact)
 {
     if (Logger.IsEnabled(LogLevel.Trace))
     {
         Logger.LogTrace($"add({contact})");
     }
     return(Puppet.RoomAdd(Id, contact.Id));
 }
Example #29
0
 /// <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));
 }
Example #30
0
        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));
 }
Example #32
0
 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"];
 }
Example #34
0
 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);
 }
Example #36
0
 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();
 }