Example #1
0
    public static DateObject GetDate(string id, float modifier)
    {
        DateObject d = dateDictionary[id];

        d.difficulty = modifier;
        return(d);
    }
Example #2
0
        public void AllowsOmitedPrefix()
        {
            // Arrange
            var expected   = new DateTimeOffset(new DateTime(2017, 08, 16, 15, 14, 13));
            var dateString = "20170816151413";

            // Act
            var dateObj = new DateObject(dateString);

            // Assert
            Assert.Equal(expected, dateObj.Value);
        }
Example #3
0
        public void ParsesDateTimeWithOffset()
        {
            // Arrange
            var expected   = new DateTimeOffset(new DateTime(2017, 08, 16, 15, 14, 13), TimeSpan.FromHours(-2));
            var dateString = "D:20170816151413-02'00'";

            // Act
            var dateObj = new DateObject(dateString);

            // Assert
            Assert.Equal(expected, dateObj.Value);
        }
Example #4
0
        public void ParsesDateOnly()
        {
            // Arrange
            var expected   = new DateTimeOffset(new DateTime(2017, 08, 16));
            var dateString = "D:20170816";

            // Act
            var dateObj = new DateObject(dateString);

            // Assert
            Assert.Equal(expected, dateObj.Value);
        }
Example #5
0
    public static void Main()
    {
        // *** String Value
        object Result = EvalJScript(@"('hello world: ' + new Date())");

        Console.WriteLine(Result.ToString() + " - Type: " + Result.GetType().Name);

        // *** Return an integer or numeric - no conversion required
        Result = EvalJScript(@"( 11 * 12)");
        Console.WriteLine(Result.ToString() + " - Type: " + Result.GetType().Name);

        // *** Date value - must be converted!
        Result = EvalJScript(@"(new Date())");
        Console.WriteLine(Result + " - Type: " + Result.GetType().Name);

        // *** Must convert from DateObject to DateTime by coercing
        DateObject dateObject = Result as DateObject;

        Result = Microsoft.JScript.Convert.Coerce(Result, typeof(DateTime));
        Console.WriteLine("Converted to DateTime: " + Result);

        // *** Block of code (last assignment is the return value)
        Result = EvalJScript(@"var out = 'hello';   for ( var x = 1; x < 10; x++) { out = out + 'Line ' + x + '\n'; }");
        Console.WriteLine(Result + " - Type: " + Result.GetType().Name);

        /// *** Closure - calling a JavaScript Function with return value
        Result = EvalJScript(@"( function Test(inputParm) {  return 'hello world ' + inputParm; } )");

        /// *** Invoke the function and retrieve the result
        Closure close = Result as Closure;

        // *** This requires full trust
        Result = close.Invoke(close, new object[1] {
            "Start with this bub..."
        });
        Console.WriteLine(Result);
        Console.WriteLine(" - Type: " + Result.GetType().Name);

        // *** JSON style object
        Result = EvalJScript(@"( {""timeString"":'Time is: ' + new Date(),""dateValue"":new Date()} )");
        JSObject obj = Result as JSObject;

        Console.WriteLine(Result);

        // *** JavaScript style property array access can be used
        object val = obj["dateValue"];

        Console.WriteLine(Microsoft.JScript.Convert.Coerce(val, typeof(DateTime)));

        val = obj["timeString"];
        Console.WriteLine(val);
    }
Example #6
0
        public void FormatsDateTimeOffset()
        {
            // Arrange
            var date     = new DateTimeOffset(new DateTime(2017, 08, 16, 15, 14, 13), TimeSpan.FromHours(-2));
            var expected = "D:20170816151413-02'00'";

            // Act
            var dateObj     = new DateObject(date);
            var stringValue = ((StringObject)dateObj).Value;

            // Assert
            Assert.Equal(expected, stringValue);
        }
Example #7
0
    private void GenerateDateSequence(int length)
    {
        Game.dateSequence.Clear();
        Game.gameLength = length;

        Game.dateSequence.Push(Game.dateDictionary["Boss"]);
        for (int i = 1; i < length; i++)
        {
            string spriteName = Utils.GetRandomDateSpriteName();
            Debug.Log(spriteName);
            DateObject d = Game.GetDate("Date_" + i, length - i);
            Game.dateSequence.Push(d);
        }
    }
Example #8
0
    private void Start()
    {
        battleSquare.SetActive(false);
        mainDialog.gameObject.SetActive(true);

        sr  = GetComponent <SpriteRenderer>();
        src = GetComponent <AudioSource>();

        firingPoints = new Transform[firingPointsParent.childCount];
        for (int i = 0; i < firingPointsParent.childCount; i++)
        {
            firingPoints[i] = firingPointsParent.GetChild(i);
        }

        date = Game.currentDate;

        if (date != null)   //We have a date to do
        {
            if (Game.IsLastScene("Battle"))
            {
                feedbackTextAnim.Play("FeedbackText-Action");
                PlaySound(2);
            }

            if (date.difficulty >= 10)
            {
                GameObject.FindGameObjectWithTag("Music Player").GetComponent <MusicPlayer>().PlayBossIntro();
                boss = true;
                Debug.LogWarning("YOU CAN'T WIN");
            }

            sr.sprite                  = date.sprite;
            dateSuccess                = 100 * date.difficulty;
            playerAttackBar.goal       = Mathf.Clamp(50 + (25 * (date.difficulty / Game.gameLength)), 0, 75);
            playerAttackBar.goal_flirt = 10 * date.hatesFlirting;
            playerAttackBar.goal_joke  = 10 * date.hatesJokes;
            playerAttackBar.goal_story = 10 * date.hatesStory;
        }
        else
        {
            SceneManager.LoadScene("Menu");
        }

        playerAttackBar.gameObject.SetActive(false);
    }
Example #9
0
 public static void LoadNextDate()
 {
     currentDate = dateSequence.Pop();
 }
Example #10
0
 public DateObject()
 {
     DateObject dateObject = new DateObject();
 }