public void UpdateActivityExpirationTimer(GenericActivity activity, int minutes)
    {
        if (m_activityUni.UpdateTimer(minutes))
        {
            m_activityUni.ResolveActivity();
            SwapActivity(m_universityActivity);
        }

        if (m_activityCrime.UpdateTimer(minutes))
        {
            m_activityCrime.ResolveActivity();
            SwapActivity(m_crimeActivity);
        }

        if (m_activityWork.UpdateTimer(minutes))
        {
            m_activityWork.ResolveActivity();
            SwapActivity(m_workActivity);
        }

        if (m_activityRelax.UpdateTimer(minutes))
        {
            m_activityRelax.ResolveActivity();
            SwapActivity(m_relaxActivity);
        }

        if (m_activitySleep.UpdateTimer(minutes))
        {
            m_activitySleep.ResolveActivity();
            SwapActivity(m_sleepActivity);
        }
    }
Exemplo n.º 2
0
        public void SetValue_GenericType()
        {
            // Arrange
            var activityHelper = TypeHelper.Get <GenericActivity <string> >();
            var activity       = new GenericActivity <string>();
            var created        = DateTime.Now;

            // Act
            activityHelper.SetValue(activity, "Id", 100);
            activityHelper.SetValue(activity, "Name", "Read");
            activityHelper.SetValue(activity, "Level", 7.7);
            activityHelper.SetValue(activity, "IsActive", true);
            activityHelper.SetValue(activity, "Created", created);
            activityHelper.SetValue(activity, "ActivityType", ActivityTypeEnum.Public);
            activityHelper.SetValue(activity, "GenericProperty", "Hello World");

            // Assert
            Assert.AreEqual(activity.Id, 100);
            Assert.AreEqual(activity.Name, "Read");
            Assert.AreEqual(activity.Level, 7.7);
            Assert.AreEqual(activity.IsActive, true);
            Assert.AreEqual(activity.Created, created);
            Assert.AreEqual(activity.Updated, null);
            Assert.AreEqual(activity.ActivityType, ActivityTypeEnum.Public);
            Assert.AreEqual(activity.GenericProperty, "Hello World");
        }
Exemplo n.º 3
0
        public void GetValue_GenericType()
        {
            // Arrange
            var activityHelper = TypeHelper.Get <GenericActivity <string> >();
            var activity       = new GenericActivity <string>()
            {
                Id              = 100,
                Name            = "Read",
                Level           = 7.7,
                IsActive        = true,
                Created         = DateTime.Now,
                ActivityType    = ActivityTypeEnum.Public,
                GenericProperty = "Hello World"
            };

            // Act
            var id              = activityHelper.GetValue(activity, "Id");
            var name            = activityHelper.GetValue(activity, "Name");
            var level           = activityHelper.GetValue(activity, "Level");
            var isActive        = activityHelper.GetValue(activity, "IsActive");
            var created         = activityHelper.GetValue(activity, "Created");
            var updated         = activityHelper.GetValue(activity, "Updated");
            var activityType    = activityHelper.GetValue(activity, "ActivityType");
            var genericProperty = activityHelper.GetValue(activity, "GenericProperty");

            // Assert
            Assert.AreEqual(activity.Id, id);
            Assert.AreEqual(activity.Name, name);
            Assert.AreEqual(activity.Level, level);
            Assert.AreEqual(activity.IsActive, isActive);
            Assert.AreEqual(activity.Created, created);
            Assert.AreEqual(activity.Updated, updated);
            Assert.AreEqual(activity.ActivityType, activityType);
            Assert.AreEqual(activity.GenericProperty, genericProperty);
        }
Exemplo n.º 4
0
        private static Task SetActivitySchedulerAction()
        {
            DateTimeOffset utcnow   = DateTimeOffset.UtcNow;
            IActivity      activity = new GenericActivity($"{utcnow.Year}-{utcnow.Month.ToString().PadLeft(2, '0')}-{utcnow.Day.ToString().PadLeft(2, '0')} {utcnow.Hour.ToString().PadLeft(2, '0')}:{utcnow.Minute.ToString().PadLeft(2, '0')} UTC", ActivityType.Watching);

            utcnow.AddSeconds(utcnow.Second * -1);
            utcnow.AddMinutes(1);
            ActionScheduler.AddSchedulerEntry(utcnow, SetActivitySchedulerAction);
            return(Client.SetActivityAsync(activity));
        }
    public void WriteInActivityFile(GenericActivity activity, List <GenericActivity> list, int index)
    {
        activity.Category       = list[index].Category;
        activity.Title          = list[index].Title;
        activity.Timer          = list[index].Timer;
        activity.Text           = list[index].Text;
        activity.Option1        = list[index].Option1;
        activity.Option1Success = list[index].Option1Success;
        activity.Option1Fail    = list[index].Option1Fail;
        activity.Option2        = list[index].Option2;
        activity.Option2Success = list[index].Option2Success;
        activity.Option2Fail    = list[index].Option2Fail;

        activity.O1SuccessStaminaChange = list[index].O1SuccessStaminaChange;
        activity.O1SuccessStressChange  = list[index].O1SuccessStressChange;
        activity.O1SuccessCashChange    = list[index].O1SuccessCashChange;
        activity.O1SuccessGradesChange  = list[index].O1SuccessGradesChange;
        activity.O1SuccessCrimesChange  = list[index].O1SuccessCrimesChange;
        activity.O1SuccessTimeCost      = list[index].O1SuccessTimeCost;
        activity.O1FailStaminaChange    = list[index].O1FailStaminaChange;
        activity.O1FailStressChange     = list[index].O1FailStressChange;
        activity.O1FailCashChange       = list[index].O1FailCashChange;
        activity.O1FailGradesChange     = list[index].O1FailGradesChange;
        activity.O1FailCrimesChange     = list[index].O1FailCrimesChange;
        activity.O1FailTimeCost         = list[index].O1FailTimeCost;
        activity.O2SuccessStaminaChange = list[index].O2SuccessStaminaChange;
        activity.O2SuccessStressChange  = list[index].O2SuccessStressChange;
        activity.O2SuccessCashChange    = list[index].O2SuccessCashChange;
        activity.O2SuccessGradesChange  = list[index].O2SuccessGradesChange;
        activity.O2SuccessCrimesChange  = list[index].O2SuccessCrimesChange;
        activity.O2SuccessTimeCost      = list[index].O2SuccessTimeCost;
        activity.O2FailStaminaChange    = list[index].O2FailStaminaChange;
        activity.O2FailStressChange     = list[index].O2FailStressChange;
        activity.O2FailCashChange       = list[index].O2FailCashChange;
        activity.O2FailGradesChange     = list[index].O2FailGradesChange;
        activity.O2FailCrimesChange     = list[index].O2FailCrimesChange;
        activity.O2FailTimeCost         = list[index].O2FailTimeCost;
        activity.SkipStaminaChange      = list[index].SkipStaminaChange;
        activity.SkipStressChange       = list[index].SkipStressChange;
        activity.SkipCashChange         = list[index].SkipCashChange;
        activity.SkipGradesChange       = list[index].SkipGradesChange;
        activity.SkipCrimesChange       = list[index].SkipCrimesChange;
        activity.SkipTimeCost           = list[index].SkipTimeCost;

        if (activity.Category != "Sleep")
        {
            //when done remove from list
            list.Remove(list[index]);
        }
    }
    public void WriteInActivityFile(GenericActivity activity)
    {
        if (activity.Category != "Sleep")
        {
            //activity.Category = null;
            activity.Title          = "Nothing to do";
            activity.Timer          = "0:00:00";
            activity.Text           = null;
            activity.Option1        = null;
            activity.Option1Success = null;
            activity.Option1Fail    = null;
            activity.Option2        = null;
            activity.Option2Success = null;
            activity.Option2Fail    = null;

            activity.O1SuccessStaminaChange = 0;
            activity.O1SuccessStressChange  = 0;
            activity.O1SuccessCashChange    = 0;
            activity.O1SuccessGradesChange  = 0;
            activity.O1SuccessCrimesChange  = 0;
            activity.O1SuccessTimeCost      = 0;
            activity.O1FailStaminaChange    = 0;
            activity.O1FailStressChange     = 0;
            activity.O1FailCashChange       = 0;
            activity.O1FailGradesChange     = 0;
            activity.O1FailCrimesChange     = 0;
            activity.O1FailTimeCost         = 0;
            activity.O2SuccessStaminaChange = 0;
            activity.O2SuccessStressChange  = 0;
            activity.O2SuccessCashChange    = 0;
            activity.O2SuccessGradesChange  = 0;
            activity.O2SuccessCrimesChange  = 0;
            activity.O2SuccessTimeCost      = 0;
            activity.O2FailStaminaChange    = 0;
            activity.O2FailStressChange     = 0;
            activity.O2FailCashChange       = 0;
            activity.O2FailGradesChange     = 0;
            activity.O2FailCrimesChange     = 0;
            activity.O2FailTimeCost         = 0;
            activity.SkipStaminaChange      = 0;
            activity.SkipStressChange       = 0;
            activity.SkipCashChange         = 0;
            activity.SkipGradesChange       = 0;
            activity.SkipCrimesChange       = 0;
            activity.SkipTimeCost           = 0;
        }
    }
    //takes the data and stores it in separate lists
    public void Load(TextAsset csv)
    {
        m_activityList.Clear();
        string[][] dataGrid = CsvParser.Parse(csv.text); //parse the file and store in a matrix of strings
        for (int i = 0; i < dataGrid.Length; i++)
        {
            // Debug.Log(dataGrid.Length);
            // Debug.Log("ID = " + i.ToString());

            if (dataGrid[i][0] != "")
            {
                GenericActivity activity = ScriptableObject.CreateInstance <GenericActivity>();
                //Activity activity = new Activity();
                //Instantiate<GameObject>(m_activityGO);

                activity.ID = i;

                activity.Category       = dataGrid[i][0];
                activity.Title          = dataGrid[i][1];
                activity.Timer          = dataGrid[i][2];
                activity.Text           = dataGrid[i][3];
                activity.Option1        = dataGrid[i][4];
                activity.Option1Success = dataGrid[i][5];
                activity.Option1Fail    = dataGrid[i][6];
                activity.Option2        = dataGrid[i][7];
                activity.Option2Success = dataGrid[i][8];
                activity.Option2Fail    = dataGrid[i][9];

                int.TryParse(dataGrid[i][10], out activity.O1SuccessStaminaChange);
                int.TryParse(dataGrid[i][11], out activity.O1SuccessStressChange);
                int.TryParse(dataGrid[i][12], out activity.O1SuccessCashChange);
                int.TryParse(dataGrid[i][13], out activity.O1SuccessGradesChange);
                int.TryParse(dataGrid[i][14], out activity.O1SuccessCrimesChange);
                int.TryParse(dataGrid[i][15], out activity.O1SuccessTimeCost);
                int.TryParse(dataGrid[i][16], out activity.O1FailStaminaChange);
                int.TryParse(dataGrid[i][17], out activity.O1FailStressChange);
                int.TryParse(dataGrid[i][18], out activity.O1FailCashChange);
                int.TryParse(dataGrid[i][19], out activity.O1FailGradesChange);
                int.TryParse(dataGrid[i][20], out activity.O1FailCrimesChange);
                int.TryParse(dataGrid[i][21], out activity.O1FailTimeCost);
                int.TryParse(dataGrid[i][22], out activity.O2SuccessStaminaChange);
                int.TryParse(dataGrid[i][23], out activity.O2SuccessStressChange);
                int.TryParse(dataGrid[i][24], out activity.O2SuccessCashChange);
                int.TryParse(dataGrid[i][25], out activity.O2SuccessGradesChange);
                int.TryParse(dataGrid[i][26], out activity.O2SuccessCrimesChange);
                int.TryParse(dataGrid[i][27], out activity.O2SuccessTimeCost);
                int.TryParse(dataGrid[i][28], out activity.O2FailStaminaChange);
                int.TryParse(dataGrid[i][29], out activity.O2FailStressChange);
                int.TryParse(dataGrid[i][30], out activity.O2FailCashChange);
                int.TryParse(dataGrid[i][31], out activity.O2FailGradesChange);
                int.TryParse(dataGrid[i][32], out activity.O2FailCrimesChange);
                int.TryParse(dataGrid[i][33], out activity.O2FailTimeCost);
                int.TryParse(dataGrid[i][34], out activity.SkipStaminaChange);
                int.TryParse(dataGrid[i][35], out activity.SkipStressChange);
                int.TryParse(dataGrid[i][36], out activity.SkipCashChange);
                int.TryParse(dataGrid[i][37], out activity.SkipGradesChange);
                int.TryParse(dataGrid[i][38], out activity.SkipCrimesChange);
                int.TryParse(dataGrid[i][39], out activity.SkipTimeCost);

                m_activityList.Add(activity);
            }
        }

        m_universityList.Clear();
        m_heroicList.Clear();
        m_workList.Clear();
        m_relaxList.Clear();
        m_sleepList.Clear();

        m_universityList = FindAll_Category("Uni");
        m_heroicList     = FindAll_Category("Crime");
        m_workList       = FindAll_Category("Work");
        m_relaxList      = FindAll_Category("Relax");
        m_sleepList      = FindAll_Category("Sleep");

        isLoaded = true;
    }
    public void SwapActivity(GenericActivity dataToUpdate)//add category as a parameter to implement search algorithm
    {
        switch (dataToUpdate.Category)
        {
        case "Uni":
            if (m_universityList.Count >= 1)
            {
                WriteInActivityFile(dataToUpdate, m_universityList, 0);
            }
            else
            {
                WriteInActivityFile(dataToUpdate);
                Debug.Log("Uni list is empty");
            }
            break;

        case "Crime":
            if (m_heroicList.Count >= 1)
            {
                WriteInActivityFile(dataToUpdate, m_heroicList, 0);
            }
            else
            {
                WriteInActivityFile(dataToUpdate);
                Debug.Log("Crime list is empty");
            }
            break;

        case "Work":
            if (m_workList.Count >= 1)
            {
                WriteInActivityFile(dataToUpdate, m_workList, 0);
            }
            else
            {
                WriteInActivityFile(dataToUpdate);
                Debug.Log("Work list is empty");
            }
            break;

        case "Relax":
            if (m_relaxList.Count >= 1)
            {
                WriteInActivityFile(dataToUpdate, m_relaxList, 0);
            }
            else
            {
                WriteInActivityFile(dataToUpdate);
                Debug.Log("Relax list is empty");
            }
            break;

        case "Sleep":
            if (m_sleepList.Count >= 1)
            {
                WriteInActivityFile(dataToUpdate, m_sleepList, 0);
            }
            else
            {
                WriteInActivityFile(dataToUpdate);
                Debug.Log("Sleep list is empty");
            }
            break;
        }
        //WriteInActivityFile(dataToUpdate, fromThisList, 2);//substitute 2 with search algorithm output
    }