public void CanAddEvents()
        {
            var tracker = new StatsTracker();

            Assert.AreEqual(tracker.count(), 0);

            tracker.addEvent("testEvent");
            Assert.AreEqual(tracker.count(), 1);

            tracker.addEvent("testEventWithData", "[test data]");
            Assert.AreEqual(tracker.count(), 2);

            for (int i = 0; i < 20; i++)
            {
                if (i % 2 == 0)
                {
                    tracker.addEvent("testEventWithData", String.Format("test{0}", i));
                }
                else
                {
                    tracker.addEvent("testEvent");
                }
            }

            Assert.AreEqual(tracker.count(), 22);
            Assert.AreEqual(tracker.count("testEvent"), 11);
            Assert.AreEqual(tracker.count("testEventWithData"), 11);

            var result = tracker.latest("testEventWithData");

            Assert.IsNotNull(result);
            Assert.AreEqual(result.data, "test18");
        }
    void IncreaseRage()
    {
        if (m_deltaX > 0.0001f)
        {
            return;
        }

        if (m_hasLost)
        {
            return;
        }

        m_rageValue -= m_rageIncreasePerSec * Time.deltaTime;
        if (m_rageValue <= 0.0f)
        {
            m_rageValue = 0.0f;
            m_hasLost   = true;
            StatsTracker.OnLevelFailed();
        }

        if (m_hasLost)
        {
            TurnAround();
            m_speed *= 2.0f;

            FollowPlayerCamera cameraScript   = Camera.main.GetComponent <FollowPlayerCamera>();
            Transform          childCamTarget = transform.FindChild(StringManager.Names.cameraTargetRedRidingHood);
            cameraScript.SetTarget(childCamTarget);
            childCamTarget.SetParent(null);
            cameraScript.SetZoomEnabled(false);
        }
    }
Example #3
0
    private void Awake()
    {
        controller = GetComponent <MovementController>();
        sTracker   = new StatsTracker(baseStats);

        attackTimer = attackCooldown;
    }
Example #4
0
 // Use this for initialization
 void Start()
 {
     statsTracker = StatsTracker.Instance();
     statsTracker.Basenumber++;
     gameObject.name = "EnemyBase_" + statsTracker.Basenumber;
     statsTracker.RegBase(gameObject);
 }
Example #5
0
 void Awake()
 {
     if (GameObject.FindGameObjectWithTag("StatsTracker")) {
         stats = GameObject.FindGameObjectWithTag("StatsTracker").GetComponent<StatsTracker>();
     } else {
         Debug.Log("Stats Tracker not set, timer will not function.");
     }
 }
Example #6
0
    // Use this for initialization
    void Start()
    {
        if (Application.isWebPlayer) {
            Screen.SetResolution (960, 600, false, 60);
        }

        stats = GameObject.FindGameObjectWithTag("StatsTracker").GetComponent<StatsTracker>();
    }
Example #7
0
 internal void StopCharacterInteraction(StatsTracker statsTracker)
 {
     m_ActiveInteractors.Remove(statsTracker);
     if (m_DestroyOnUse)
     {
         Destroy(gameObject, 0.05f);
     }
 }
Example #8
0
        public override void Init(Coord startingCoord)
        {
            base.Init(startingCoord);
            moveFromCoord = startingCoord;

            StatsTracker.AddEntity(id);

            ChooseNextAction();
        }
Example #9
0
        /// <summary>
        /// Reserve this interactable for a given actor. This actor should
        /// be on their way to the interactable. Only a limited number of actors can reserve
        /// this interactable. Once a reservation is no longer needed then call to ClearReservation(brain).
        /// </summary>
        /// <param name="statsTracker">The actor who reseved this interactable.</param>
        /// <returns>True if the the reservation was succesful.</returns>
        internal bool ReserveFor(StatsTracker statsTracker)
        {
            if (m_Reservations.Count + m_ActiveInteractors.Count >= m_MaxInteractors)
            {
                return(false);
            }

            m_Reservations.Add(statsTracker);
            return(true);
        }
 void Start()
 {
     StatsTracker.OnLevelLoaded();
     // Disable UI in Tutorial Level until RRH_Trigger activates it
     if (Application.loadedLevel == 2)
     {
         Debug.Log("TUTORIAL LEVEL -> UserInterface disabled!");
         disableAll();
     }
 }
Example #11
0
        private void Server_DataReceived(object sender, SimpleTCP.Message e)
        {
            string properJson = Util.RemoveEndSpecialCharacter(e.MessageString);

            StatsTracker.IncreaseBytesReceived(e.Data.Length);

            Util.CyanWriteLine($"Received message from {e.TcpClient.Client.RemoteEndPoint}: {properJson}");

            JObject json = JObject.Parse(properJson);

            string command = json["command"].ToString();

            Parser.ParseCommand(command, e, json);
        }
 // Use this for initialization
 void Start()
 {
     if (useTag == true && myTag != "")        //this should place a building in a place with the indicated tag
     {
         buildingSpace = GameObject.FindGameObjectsWithTag(myTag);
         foreach (GameObject myBuilding in buildingSpace)
         {
             Instantiate(buildingPrefab, myBuilding.transform.position, myBuilding.transform.rotation);
         }
     }
     else
     {
         statsTracker = StatsTracker.Instance();
     }
 }
Example #13
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == StringManager.Tags.redRidingHood)
        {
            Camera.main.GetComponent <FollowPlayerCamera>().m_ignoreRRH = true;
            m_redRidingHoodHasEntered = true;
            Destroy(other.gameObject);
        }

        if (m_redRidingHoodHasEntered && other.tag == StringManager.Tags.player)
        {
            StatsTracker.OnLevelSuccess();
            Destroy(other.gameObject);
        }
    }
Example #14
0
        /// <summary>
        /// If all the conditions of this state are satisfied then this will return true.
        /// </summary>
        public bool IsSatisfiedFor(StatsTracker statsTracker)
        {
            if (statTemplate != null)
            {
                StatSO stat = statsTracker.GetOrCreateStat(statTemplate);

                switch (objective)
                {
                case Objective.LessThan:
                    if (stat.NormalizedValue >= normalizedTargetValue)
                    {
                        return(false);
                    }
                    break;

                case Objective.Approximately:
                    return(Mathf.Approximately(stat.NormalizedValue, normalizedTargetValue));

                case Objective.GreaterThan:
                    if (stat.NormalizedValue <= normalizedTargetValue)
                    {
                        return(false);
                    }
                    break;
                }
            }

            // Check substates
            for (int i = 0; i < m_SubStates.Count; i++)
            {
                if (!m_SubStates[i].IsSatisfiedFor(statsTracker))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #15
0
        private async Task ExecuteTrafficCollector(ExecutionContext executionContext, ILogger logger)
        {
            DateTime functionStartDate = DateTime.UtcNow;
            string   sessionId         = Guid.NewGuid().ToString();
            string   identifier        = "TrafficTimer";

            CloudQueue trafficCloudQueue = await AzureHelpers.GetStorageQueueAsync("traffic").ConfigureAwait(false);

            IQueue trafficQueue = new CloudQueueWrapper(trafficCloudQueue);

            FunctionContext context = new FunctionContext()
            {
                CollectorType     = CollectorType.TrafficTimer.ToString(),
                FunctionStartDate = functionStartDate,
                SessionId         = sessionId,
                InvocationId      = executionContext.InvocationId.ToString(),
            };

            StatsTracker     statsTracker    = null;
            bool             success         = false;
            ITelemetryClient telemetryClient = new GitHubApplicationInsightsTelemetryClient(this.telemetryClient, context, logger);

            try
            {
                telemetryClient.TrackEvent("SessionStart", GetCollectorCommonSessionStartEventProperties(context, identifier));

                ICache <RateLimitTableEntity> rateLimiterCache = new AzureTableCache <RateLimitTableEntity>(telemetryClient, "ratelimiter");
                await rateLimiterCache.InitializeAsync().ConfigureAwait(false);

                ICache <ConditionalRequestTableEntity> requestsCache = new AzureTableCache <ConditionalRequestTableEntity>(telemetryClient, "requests");
                await requestsCache.InitializeAsync().ConfigureAwait(false);

                string organizations = await AzureHelpers.GetBlobContentAsync("github-settings", "organizations.json").ConfigureAwait(false);

                JArray organizationsArray = JArray.Parse(organizations);
                foreach (JToken organizationToken in organizationsArray)
                {
                    JObject organization      = (JObject)organizationToken;
                    string  organizationLogin = organization.SelectToken("$.OrganizationLogin").Value <string>();
                    long    organizationId    = organization.SelectToken("$.OrganizationId").Value <long>();

                    IRateLimiter     rateLimiter = new GitHubRateLimiter(this.configManager.UsesGitHubAuth(context.CollectorType) ? organizationLogin : "******", rateLimiterCache, this.httpClient, telemetryClient, maxUsageBeforeDelayStarts: 80.0, this.apiDomain);
                    GitHubHttpClient httpClient  = new GitHubHttpClient(this.httpClient, rateLimiter, requestsCache, telemetryClient);

                    statsTracker = new StatsTracker(telemetryClient, httpClient, StatsTrackerRefreshFrequency);

                    IAuthentication authentication = this.configManager.GetAuthentication(CollectorType.TrafficTimer, httpClient, organizationLogin, this.apiDomain);
                    CollectorBase <GitHubCollectionNode> collector = new GitHubCollector(httpClient, authentication, telemetryClient, new List <IRecordWriter>());

                    GitHubCollectionNode repositoriesNode = new GitHubCollectionNode()
                    {
                        RecordType         = DataContract.RepositoryInstanceRecordType,
                        ApiName            = DataContract.RepositoriesApiName,
                        GetInitialUrl      = additionalMetadata => OnboardingProcessor.InitialRepositoriesUrl(organizationLogin, this.apiDomain),
                        ProcessRecordAsync = async record =>
                        {
                            string repositoryName = record.SelectToken("$.name").Value <string>();
                            long   repositoryId   = record.SelectToken("$.id").Value <long>();

                            Repository repository = new Repository(organizationId, repositoryId, organizationLogin, repositoryName);
                            await trafficQueue.PutObjectAsJsonStringAsync(repository, TimeSpan.MaxValue).ConfigureAwait(false);

                            return(new List <RecordWithContext>());
                        },
                    };

                    await collector.ProcessAsync(repositoriesNode).ConfigureAwait(false);
                }

                success = true;
            }
            catch (Exception exception) when(!(exception is FatalException))
            {
                telemetryClient.TrackException(exception, "TrafficTimer failed.");
                throw exception;
            }
            finally
            {
                SendSessionEndEvent(telemetryClient, context.FunctionStartDate, outputPaths: string.Empty, GetCollectorCommonSessionStartEventProperties(context, identifier), success);
                statsTracker?.Stop();
            }
        }
Example #16
0
        public async Task Traffic([QueueTrigger("traffic")] string queueItem, ExecutionContext executionContext, ILogger logger)
        {
            DateTime functionStartDate = DateTime.UtcNow;
            string   sessionId         = Guid.NewGuid().ToString();

            JsonSerializerSettings serializerSettings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.None
            };
            Repository repositoryDetails = JsonConvert.DeserializeObject <Repository>(queueItem, serializerSettings);
            FunctionContextWriter <FunctionContext> contextWriter = new FunctionContextWriter <FunctionContext>();
            string identifier = $"Traffic";

            FunctionContext context = new FunctionContext()
            {
                CollectorType     = CollectorType.Traffic.ToString(),
                FunctionStartDate = functionStartDate,
                SessionId         = sessionId,
                InvocationId      = executionContext.InvocationId.ToString(),
            };

            StatsTracker     statsTracker    = null;
            string           outputPaths     = string.Empty;
            bool             success         = false;
            ITelemetryClient telemetryClient = new GitHubApplicationInsightsTelemetryClient(this.telemetryClient, context, logger);

            try
            {
                telemetryClient.TrackEvent("SessionStart", GetRepositoryCollectorSessionStartEventProperties(context, identifier, repositoryDetails));

                ICache <RateLimitTableEntity> rateLimiterCache = new AzureTableCache <RateLimitTableEntity>(telemetryClient, "ratelimiter");
                await rateLimiterCache.InitializeAsync().ConfigureAwait(false);

                IRateLimiter rateLimiter = new GitHubRateLimiter(this.configManager.UsesGitHubAuth(context.CollectorType) ? repositoryDetails.OrganizationLogin : "******", rateLimiterCache, this.httpClient, telemetryClient, maxUsageBeforeDelayStarts: 50.0, this.apiDomain);
                ICache <ConditionalRequestTableEntity> requestsCache = new AzureTableCache <ConditionalRequestTableEntity>(telemetryClient, "requests");
                await requestsCache.InitializeAsync().ConfigureAwait(false);

                GitHubHttpClient httpClient = new GitHubHttpClient(this.httpClient, rateLimiter, requestsCache, telemetryClient);

                IAuthentication authentication = this.configManager.GetAuthentication(CollectorType.Traffic, httpClient, repositoryDetails.OrganizationLogin, this.apiDomain);

                StorageManager       storageManager;
                List <IRecordWriter> recordWriters;
                using (storageManager = this.configManager.GetStorageManager(context.CollectorType, telemetryClient))
                {
                    recordWriters = storageManager.InitializeRecordWriters(identifier, context, contextWriter, this.adlsClient.AdlsClient);
                    IRecordStatsTracker recordStatsTracker = null;

                    foreach (IRecordWriter recordWriter in recordWriters)
                    {
                        recordWriter.SetOutputPathPrefix($"{repositoryDetails.OrganizationId}/{repositoryDetails.RepositoryId}");
                        if (recordStatsTracker == null)
                        {
                            recordStatsTracker = recordWriter;
                        }
                    }

                    statsTracker = new StatsTracker(telemetryClient, httpClient, recordStatsTracker, StatsTrackerRefreshFrequency);

                    TrafficProcessor processor = new TrafficProcessor(authentication, recordWriters, httpClient, telemetryClient, this.apiDomain);
                    await processor.ProcessAsync(repositoryDetails).ConfigureAwait(false);
                }

                await storageManager.FinalizeRecordWritersAsync().ConfigureAwait(false);

                outputPaths = RecordWriterExtensions.GetOutputPaths(recordWriters);
                success     = true;
            }
            catch (Exception exception) when(!(exception is FatalException))
            {
                telemetryClient.TrackException(exception, "Traffic failed.");
                throw exception;
            }
            finally
            {
                SendSessionEndEvent(telemetryClient, context.FunctionStartDate, outputPaths, GetRepositoryCollectorSessionStartEventProperties(context, identifier, repositoryDetails), success);
                statsTracker?.Stop();
            }
        }
Example #17
0
 private void Start()
 {
     statsTracker     = StatsTracker.Instance();
     baseSpawnControl = BaseSpawnControl.Instance();
     statsTracker.RegBase(gameObject);
 }
Example #18
0
    // Use this for initialization
    void Start()
    {
        firstEnabled = false;
        secondEnabled = false;
        thirdEnabled = false;

        letterSound = GameObject.FindWithTag("LetterSound").GetComponent<AudioSource>();

        stats = GameObject.FindGameObjectWithTag("StatsTracker").GetComponent<StatsTracker>();

        sourceLines[0] = getTimeText();
        sourceLines[1] = getMoodText();
        sourceLines[2] = getSobrietyText();

        lines[0] = "";
        lines[1] = "";
        lines[2] = "";

        timeStart = Time.time;

        StartCoroutine("triggerAnimation");
    }
Example #19
0
 private static StatsTracker statsTracker; // creates a var of class
 public static StatsTracker Instance()     //function that returns a reference to this
 {
     statsTracker = FindObjectOfType(typeof(StatsTracker)) as StatsTracker;
     return(statsTracker);
 }
 public override void OnDeath()
 {
     base.OnDeath();
     StatsTracker.OnLevelFailed();
     Destroy(this.gameObject);
 }
Example #21
0
 public virtual void Die(string reason = "Natural Causes")
 {
     dead = true;
     onDeath?.Invoke(reason);
     StatsTracker.RemoveEntity(id);
 }
Example #22
0
 void Awake()
 {
     m_StatsTracker = GetComponentInParent <StatsTracker>();
     InteractableManager.Instance.Register(this);
 }
Example #23
0
    // Use this for initialization
    void Start()
    {
        startTime = Time.time;

        if (fadeIn) {
            AudioListener.volume = 0;
        } else {
            AudioListener.volume = 1;
        }

        if ( GameObject.FindGameObjectWithTag("StatsTracker")) {
            stats = GameObject.FindGameObjectWithTag("StatsTracker").GetComponent<StatsTracker>();
        } else {
            Debug.Log("Stats Tracker not set, stats will not be saved.");
        }
    }
Example #24
0
 public static void Init(StatsTracker _statTracker)
 {
     statTracker = _statTracker;
 }
Example #25
0
 private void Start()
 {
     statsTracker = StatsTracker.Instance();
 }