Пример #1
0
 // Start is called before the first frame update
 public override void Initialization(CoreBase target, int damage, AgentTeam team, Vector2 scale)
 {
     base.Initialization(target, damage, team, scale);
     _speed                   = Mathf.Abs(_speed) * (TargetTeam == AgentTeam.Ally ? -1 : 1);
     AnimatorManager          = GetComponent <Animator>();
     AnimatorManager.AnimClip = (int)AbilityAnimClip.Move;
 }
Пример #2
0
 public void DoAction(CoreBase trainBy)
 {
     if (trainBy.Details.Level < 10)
     {
         trainBy.GetDetails <BuildingDetails>().Upgrade();
     }
 }
Пример #3
0
        public static async Task <List <Status> > SearchTweet(Tokens token, string searchWord, int _count)
        {
            bool flg = false;

            if (flg)
            {
                var param = new Dictionary <string, object>()
                {
                    { "q", searchWord }, { "count", _count * 2 }, { "result_type", "recent" }, { "modules", "status" }
                };
                var res = await token.SendRequestAsync(MethodType.Get, "https://api.twitter.com/1.1/search/universal.json", param);

                string json = await res.Source.Content.ReadAsStringAsync();

                var jsonObject = Newtonsoft.Json.Linq.JObject.Parse(json);
                var modules    = jsonObject["modules"].Children <Newtonsoft.Json.Linq.JObject>();
                var tweets     = new List <Status>();
                foreach (var status in modules)
                {
                    foreach (Newtonsoft.Json.Linq.JProperty prop in status.Properties())
                    {
                        if (prop.Name == "status")
                        {
                            tweets.Add(CoreBase.Convert <Status>(Newtonsoft.Json.JsonConvert.SerializeObject(status["status"]["data"])));
                        }
                    }
                }
                return(tweets);
            }
            else
            {
                return((await token.Search.TweetsAsync(count => _count * 2, q => searchWord)).ToList());
            }
        }
Пример #4
0
        private MediaUploadResult UploadChunkedImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <KeyValuePair <string, object> > parameters)
        {
            string mediaId;

            using (var res = AccessUploadApi(new Dictionary <string, object>()
            {
                { "command", "INIT" },
                { "total_bytes", totalBytes },
                { "media_type", GetMediaTypeString(mediaType) }
            }.Concat(parameters)))
                using (var sr = new StreamReader(res.GetResponseStream()))
                    mediaId = (string)JObject.Parse(sr.ReadToEnd())["media_id_string"];

            const int maxChunkSize = 5 * 1000 * 1000;

            byte[] chunk          = null;
            var    remainingBytes = totalBytes;

            for (var segmentIndex = 0; remainingBytes > 0; segmentIndex++)
            {
                var chunkSize = remainingBytes < maxChunkSize ? remainingBytes : maxChunkSize;
                if (chunk == null || chunk.Length != chunkSize)
                {
                    chunk = new byte[chunkSize];
                }
                var readCount = media.Read(chunk, 0, chunkSize);
                if (readCount == 0)
                {
                    break;
                }
                if (chunkSize != readCount)
                {
                    var newChunk = new byte[readCount];
                    Buffer.BlockCopy(chunk, 0, newChunk, 0, readCount);
                    chunk = newChunk;
                }
                this.AccessUploadApi(new Dictionary <string, object>()
                {
                    { "command", "APPEND" },
                    { "media_id", mediaId },
                    { "segment_index", segmentIndex },
                    { "media", chunk }
                }).Close();
                remainingBytes -= readCount;
            }

            using (var res = AccessUploadApi(new Dictionary <string, object>()
            {
                { "command", "FINALIZE" },
                { "media_id", mediaId }
            }))
                using (var sr = new StreamReader(res.GetResponseStream()))
                {
                    var json   = sr.ReadToEnd();
                    var result = CoreBase.Convert <MediaUploadResult>(json);
                    result.Json = json;
                    return(result);
                }
        }
Пример #5
0
        private Task <UploadFinalizeCommandResult> UploadStatusCommandAsyncImpl(IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken)
        {
            var options = Tokens.ConnectionOptions ?? ConnectionOptions.Default;

            return(this.Tokens.SendRequestAsyncImpl(MethodType.Get, InternalUtils.GetUrl(options, options.UploadUrl, true, "media/upload.json"),
                                                    parameters.EndWith(new KeyValuePair <string, object>("command", "STATUS")), cancellationToken)
                   .ReadResponse(s => CoreBase.Convert <UploadFinalizeCommandResult>(s), cancellationToken));
        }
Пример #6
0
 public override void Initialization(CoreBase target, int damage, AgentTeam team, Vector2 scale)
 {
     base.Initialization(target, damage, team, scale);
     _rigid = GetComponent <Rigidbody2D>();
     _rigid.AddForce(new Vector2(0, Mathf.Abs(Naukri.NMath.Gap(transform.position.x, Target.transform.position.x)) * InitForce));
     AnimatorManager = GetComponent <Animator>();
     targetPos       = _rigid.transform.position;
 }
Пример #7
0
        //POST methods

        private Task <MediaUploadResult> UploadAsyncImpl(IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken)
        {
            return(this.Tokens.SendRequestAsyncImpl(MethodType.Post, string.Format("https://upload.twitter.com/{0}/media/upload.json", Property.ApiVersion), parameters, cancellationToken)
                   .ContinueWith(
                       t => InternalUtils.ReadResponse(t, s => CoreBase.Convert <MediaUploadResult>(s), cancellationToken),
                       cancellationToken
                       )
                   .Unwrap());
        }
Пример #8
0
 /// <summary>
 /// Настроить сервисы.
 /// </summary>
 /// <param name="services">Сервисы.</param>
 public virtual void ConfigureServices(IServiceCollection services)
 {
     CoreBase?.ConfigureServices(services);
     DataBase?.ConfigureServices(services);
     CoreDataSqlServer?.ConfigureServices(services);
     DataEntity?.ConfigureServices(services);
     DataEntitySqlServer?.ConfigureServices(services);
     HostBase?.ConfigureServices(services);
 }
Пример #9
0
 private Task <MediaUploadResult> UploadAsyncImpl(IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken)
 {
     return(this.AccessUploadApiAsync(parameters, cancellationToken)
            .ContinueWith(
                t => InternalUtils.ReadResponse(t, s => CoreBase.Convert <MediaUploadResult>(s), cancellationToken),
                cancellationToken
                )
            .Unwrap());
 }
Пример #10
0
 private MediaUploadResult UploadImpl(IEnumerable <KeyValuePair <string, object> > parameters)
 {
     using (var sr = new StreamReader(this.AccessUploadApi(parameters).GetResponseStream()))
     {
         var json   = sr.ReadToEnd();
         var result = CoreBase.Convert <MediaUploadResult>(json);
         result.Json = json;
         return(result);
     }
 }
Пример #11
0
    void dropOff()
    {
        //Drops are made at the Core Base
        CoreBase cBase = GameObject.Find("coreBase").GetComponent <CoreBase>();

        foreach (KeyValuePair <ResourceType, float> ent in ResourcesPerDrop)
        {
            cBase.addResource(ent.Key, ent.Value);
        }
    }
Пример #12
0
    public override bool Triggers()
    {
        RaycastHit2D hit = Physics2D.Raycast(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange, _agent.EnemyLayerMask);

        if (hit)
        {
            LockedAgent = hit.collider.GetComponent <CoreBase>();
            return(true);
        }
        return(false);
    }
Пример #13
0
        public void SampleProgram()
        {
            CoreBase cB     = new CoreBase(2, 3);
            var      ouptut = cB.LoginSamplePage();

            Console.WriteLine(ouptut);

            TwoOrMultiDimensionArray twoDimenstion = new TwoOrMultiDimensionArray();

            twoDimenstion.TwoDimenstional();
        }
Пример #14
0
        //POST methods

        private MediaUploadResult UploadImpl(IEnumerable <KeyValuePair <string, object> > parameters)
        {
            using (var sr = new StreamReader(this.Tokens.SendRequestImpl(
                                                 MethodType.Post, string.Format("https://upload.twitter.com/{0}/media/upload.json", Property.ApiVersion), parameters)
                                             .GetResponseStream()))
            {
                var json   = sr.ReadToEnd();
                var result = CoreBase.Convert <MediaUploadResult>(json);
                result.Json = json;
                return(result);
            }
        }
Пример #15
0
        public CoreComponent GetCoreComponent(CoreBase coreElement)
        {
            foreach (var child in ContentView.GetComponentsInChildren <CoreComponent>())
            {
                if (child.CoreElement.Name == coreElement.Name && child.CoreElement.ContainingFolder == coreElement.ContainingFolder)
                {
                    return(child);
                }
            }

            return(null);
        }
Пример #16
0
 /// <summary>
 /// <para>Curate a Collection by adding or removing Tweets in bulk.</para>
 /// <para>Available parameters:</para>
 /// <para>- <c>string</c> id (required)</para>
 /// <para>- <c>IEnumerable&lt;CollectionEntryChange&gt;</c> changes (required)</para>
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The errors.</returns>
 public Task <ListedResponse <CollectionEntryOperationError> > EntriesCurateAsync(object parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.Tokens.PostContentAsync(
                InternalUtils.GetUrl(this.Tokens.ConnectionOptions, "collections/entries/curate"),
                "application/json; charset=UTF-8",
                InternalUtils.ParametersToJson(parameters),
                cancellationToken
                ).ReadResponse(
                s => new ListedResponse <CollectionEntryOperationError>(CoreBase.ConvertArray <CollectionEntryOperationError>(s, "response.errors")),
                cancellationToken
                ));
 }
Пример #17
0
        public LoginForm()
        {
            InitializeComponent();

            comboBoxRole.Items.Add(new ComboBoxItem(Convert.ToInt64(EAcountType.Admin), AcountTypesCore.Types[EAcountType.Admin]));
            comboBoxRole.Items.Add(new ComboBoxItem(Convert.ToInt64(EAcountType.Operator), AcountTypesCore.Types[EAcountType.Operator]));
            //comboBoxRole.Items.Add(new ComboBoxItem(Convert.ToInt64(EAcountType.Cook), AcountTypesCore.Types[EAcountType.Cook]));
            comboBoxRole.SelectedIndex = 0;
            this.KeyPreview            = true;
            this.KeyDown += LoginForm_KeyDown;
            CoreBase.Init();
        }
Пример #18
0
 /// <summary>
 /// <para>Curate a Collection by adding or removing Tweets in bulk.</para>
 /// <para>Available parameters:</para>
 /// <para>- <c>string</c> id (required)</para>
 /// <para>- <c>IEnumerable&lt;CollectionEntryChange&gt;</c> changes (required)</para>
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <returns>The errors.</returns>
 public ListedResponse <CollectionEntryOperationError> EntriesCurate(object parameters)
 {
     using (var res = this.Tokens.PostContent(
                InternalUtils.GetUrl(this.Tokens.ConnectionOptions, "collections/entries/curate"),
                "application/json; charset=UTF-8",
                InternalUtils.ParametersToJson(parameters)))
         using (var sr = new StreamReader(res.GetResponseStream()))
         {
             var json = sr.ReadToEnd();
             var list = CoreBase.ConvertArray <CollectionEntryOperationError>(json, "response.errors");
             return(new ListedResponse <CollectionEntryOperationError>(list, InternalUtils.ReadRateLimit(res), json));
         }
 }
Пример #19
0
 public Log                  StartLog(CoreBase core)
 {
     try
     {
         string logLevel    = SettingRead(Settings.logLevel);
         int    logLevelInt = int.Parse(logLevel);
         log = new Log(core, this, logLevelInt);
         return(log);
     }
     catch (Exception ex)
     {
         throw new Exception(t.GetMethodName() + " failed", ex);
     }
 }
Пример #20
0
 public override bool Triggers()
 {
     //RaycastHit2D hit = Physics2D.Raycast(_rayOrigin, _agent.Direction, _agent.GetDetails<TroopDetails>().HitRange * 1.5f, _agent.EnemyLayerMask);
     //if (!hit) return false;
     RaycastHit2D[] hits;
     if (_agent.Team == AgentTeam.Ally)
     {
         hits = (
             from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
             where a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().HitPoint < a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().MaxHitPoint
             orderby a.transform.position.x descending
             select a).ToArray();
     }
     else
     {
         hits = (
             from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
             where a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().HitPoint < a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().MaxHitPoint
             orderby a.transform.position.x
             select a).ToArray();
     }
     if (hits.Length == 0)
     {
         hits = (from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
                 orderby a.transform.position.x
                 select a).ToArray();
     }
     foreach (RaycastHit2D h in hits)
     {
         if (h.transform.gameObject == gameObject)
         {
             continue;
         }
         CoreBase agent = h.transform.transform.GetComponent <CoreBase>();
         if (agent.GetDetails <DetailsBase>().Type == AgentType.Building)
         {
             continue;
         }
         if (Naukri.NMath.Gap(_agent.transform.position.x, agent.transform.position.x) > _agent.GetDetails <TroopDetails>().HitRange)
         {
             return(false);
         }
         else
         {
             LockedAgent = agent;
             return(true);
         }
     }
     return(false);
 }
Пример #21
0
 public bool IsCollisionWithEnemy()
 {
     foreach (Collider2D b in GetComponent <BoxCollider2D>().OverlapAll())
     {
         if (b.tag == GameArgs.Building || b.tag == GameArgs.Troop)
         {
             CoreBase agent = b.GetComponent <CoreBase>();
             if (agent.Team == TargetTeam)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #22
0
        /// <summary>
        /// Converts the JSON to a <see cref="StreamingMessage"/> object.
        /// </summary>
        /// <param name="x">The JSON value.</param>
        /// <returns>The <see cref="StreamingMessage"/> object.</returns>
        public static StreamingMessage Parse(string x)
        {
            try
            {
                var j = JObject.Parse(x);
                StreamingMessage m;

                if (j["text"] != null)
                {
                    m = StatusMessage.Parse(j);
                }
                else if (j["direct_message"] != null)
                {
                    m = CoreBase.Convert <DirectMessageMessage>(x);
                }
                else if (j["friends"] != null)
                {
                    m = CoreBase.Convert <FriendsMessage>(x);
                }
                else if (j["event"] != null)
                {
                    m = EventMessage.Parse(j);
                }
                else if (j["for_user"] != null)
                {
                    m = EnvelopesMessage.Parse(j);
                }
                else if (j["control"] != null)
                {
                    m = CoreBase.Convert <ControlMessage>(x);
                }
                else
                {
                    m = ExtractRoot(j);
                }

                m.Json = x;
                return(m);
            }
            catch (ParsingException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ParsingException("on streaming, cannot parse the json", x, e);
            }
        }
Пример #23
0
 public IEnumerable <T> StreamAsEnumerable()
 {
     using (var response = _tokens.SendStreamingRequest(_methodType, _url, _parameters))
         using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8, true, 16384))
         {
             while (!reader.EndOfStream)
             {
                 var line = reader.ReadLine();
                 if (string.IsNullOrEmpty(line))
                 {
                     continue;
                 }
                 yield return(CoreBase.Convert <T>(line));
             }
         }
 }
Пример #24
0
 public async Task DoActionAsync(CoreBase trainBy)
 {
     for (int i = 0; i < Amount; i++)
     {
         CoreBase g = Prefabs.Instantiate(Identify).GetComponent <CoreBase>();
         g.transform.SetOnHorizon(trainBy.transform.position.x);
         //
         TroopDetails det = g.GetComponent <CoreBase>().GetDetails <TroopDetails>();
         det.DeBuff.AddFlag(AgentDeBuff.Freeze);
         det.SetLevel(trainBy.Details.Level);
         //
         g.transform.parent = trainBy.transform.parent;
         g.SetTeam(trainBy.Team);
         await Awaiters.Seconds(0.1f);
     }
 }
Пример #25
0
    protected bool IsVisblityCore(CoreBase core)
    {
        int     layerMask = 1 << LayerMask.NameToLayer("ArtMapModel");
        Vector3 unitPos   = transform.position;
        Vector3 corePos   = core.transform.position;

        unitPos.y = unitPos.y + (transform.GetComponent <Collider>().bounds.extents.y / 2);
        corePos.y = corePos.y + (core.GetComponent <Collider>().bounds.extents.y / 2);
        //Debug.DrawLine(unitPos, corePos);

        if (Physics.Linecast(unitPos, corePos, layerMask))
        {
            return(false);
        }

        return(true);
    }
Пример #26
0
        private CoreComponent InstantiateGameElement(CoreBase coreElement, string tabs, string extension = null)
        {
            var text = Instantiate(RootPrefab, Vector3.zero, Quaternion.identity, ContentView.transform).GetComponent <TextMeshProUGUI>();

            if (extension != null)
            {
                text.text = tabs + coreElement.Name + "." + extension;
            }
            else
            {
                text.text = tabs + coreElement.Name;
            }

            text.GetComponent <CoreComponent>().CoreElement = coreElement;

            return(text.GetComponent <CoreComponent>());
        }
Пример #27
0
 public void Heal()
 {
     foreach (Collider2D b in GetComponent <BoxCollider2D>().OverlapAll())
     {
         if (b.tag == GameArgs.Building || b.tag == GameArgs.Troop)
         {
             CoreBase agent = b.GetComponent <CoreBase>();
             if (agent.Team == TargetTeam)
             {
                 agent.GetDetails <DetailsBase>().HitPoint += Damage;
                 if (agent.GetDetails <DetailsBase>().HitPoint > agent.GetDetails <DetailsBase>().MaxHitPoint)
                 {
                     agent.GetDetails <DetailsBase>().HitPoint = agent.GetDetails <DetailsBase>().MaxHitPoint;
                 }
             }
         }
     }
 }
Пример #28
0
 public void Attack()
 {
     foreach (Collider2D b in GetComponent <BoxCollider2D>().OverlapAll())
     {
         if (b.tag == GameArgs.Building || b.tag == GameArgs.Troop || b.tag == GameArgs.Shield)
         {
             CoreBase agent = b.GetComponent <CoreBase>();
             if (agent.Team == TargetTeam)
             {
                 agent.GetDetails <DetailsBase>().HitPoint -= Damage;
                 if (agent.GetDetails <DetailsBase>().Type == AgentType.Troop && Damage >= agent.GetDetails <TroopDetails>().KnockBack)
                 {
                     agent.GetComponent <AlertAbility>().KnockBack = true;
                 }
             }
         }
     }
 }
Пример #29
0
            public Subscription(IObserver <T> observer, LineDelimitedJsonStreamResponseStreamer <T> streamer)
            {
                var cancellationToken = _source.Token;

                Task.Run(async() =>
                {
                    try
                    {
                        using (var response = await streamer.SendRequestAsync(cancellationToken).ConfigureAwait(false))
                            using (var reader = new StreamReader(await response.GetResponseStreamAsync().ConfigureAwait(false), Encoding.UTF8, true, 16384))
                            {
                                while (!reader.EndOfStream)
                                {
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }

                                    var line = await reader.ReadLineAsync().ConfigureAwait(false);
                                    if (string.IsNullOrEmpty(line))
                                    {
                                        continue;
                                    }
                                    var converted = CoreBase.Convert <T>(line);
                                    if (cancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    observer.OnNext(converted);
                                }
                            }

                        observer.OnCompleted();
                    }
                    catch (Exception ex)
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        observer.OnError(ex);
                    }
                });
            }
Пример #30
0
 public virtual void Initialization(CoreBase target, int damage, AgentTeam team, Vector2 scale)
 {
     if (team == AgentTeam.Ally)
     {
         gameObject.GetComponent <SpriteRenderer>().material = GameArgs.World.GetComponent <World>().MaterialDefault;
     }
     else
     {
         FixPosition.x        = -FixPosition.x;
         transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
         gameObject.GetComponent <SpriteRenderer>().material = GameArgs.World.GetComponent <World>().MateriaGrayScale;
     }
     Team                 = team;
     Target               = target;
     TargetTeam           = target.Team;
     Damage               = damage;
     Scale                = new Vector2(Mathf.Abs(scale.x), Mathf.Abs(scale.y));
     transform.localScale = new Vector3(transform.localScale.x * Scale.x, transform.localScale.y * Scale.y, 1);
     FixPosition         *= Scale;
     transform.Translate(FixPosition);
 }