예제 #1
0
    /// <summary>
    /// Trigger on flasher chekcs for null
    /// </summary>

    public static void Trigger(this Flasher flasher)
    {
        if (flasher != null)
        {
            flasher.Flash();
        }
    }
예제 #2
0
    IEnumerator CutScene()
    {
        _player.SendMessage("StartCutscene");

        Debug.Log("CutSceneStarted");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Huh...? What is that?", 0.1f)));

        yield return(new WaitForSeconds(1f));

        _player.SendMessage("DisplayText", "");
        _cam.SendMessage("ChangeTarget", _target);
        _source.PlayOneShot(_gueSound);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Uhh...", 0.25f)));

        yield return(new WaitForSeconds(1f));

        _cam.SendMessage("ChangeTarget", _player.transform);
        _victim.SendMessage("DisplayText", "");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I am scared...\nWhat is this place?", 0.1f)));

        yield return(new WaitForSeconds(0.75f));

        _player.SendMessage("DisplayText", "");
        yield return(StartCoroutine(_flasherWhite.Flash()));

        Debug.Log("CutSceneEnded");
        _player.SendMessage("EndCutscene");
        Destroy(gameObject);
    }
예제 #3
0
    IEnumerator PlayCutscene()
    {
        Debug.Log("CutsceneStarted");
        yield return(StartCoroutine(_flasherWhite.Flash()));

        yield return(StartCoroutine(_fader.FadeOut()));

        _cam.SendMessage("ChangeTarget", _player.transform);
        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(_fader.FadeIn()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahhh...", 0.15f)));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "My head...", 0.15f)));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Where am I?", 0.15f)));

        yield return(new WaitForSeconds(0.55f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I was...visiting...", 0.15f)));

        yield return(new WaitForSeconds(0.55f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "...him...", 0.25f)));

        yield return(new WaitForSeconds(0.575f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Wasn't I...?", 0.15f)));

        yield return(new WaitForSeconds(0.55f));

        _player.SendMessage("DisplayText", "");
        yield return(StartCoroutine(_flasherWhite.Flash()));

        Debug.Log("CutSceneEnded");
        _player.SendMessage("EndCutscene");
        Destroy(gameObject);
    }
예제 #4
0
    IEnumerator Invulnerable(float duration)
    {
        int FlashAmount = (int)duration * 10;

        if (flasher)
        {
            flasher.Flash(0, FlashAmount);
        }

        while (duration > 0)
        {
            timeOfLastHurt = Time.time;

            duration -= Time.deltaTime;

            yield return(0);
        }
    }
예제 #5
0
    protected void OnTriggerEnter2D(Collider2D other)
    {
        var damageDealer = other.GetComponent <DamageDealer> ();

        if (damageDealer != null)
        {
            ProcessHit(damageDealer);
            _flasher.Flash();
        }
    }
예제 #6
0
 private void NotifyError()
 {
     if (ThermoMath.got_error)
     {
         error_flasher.Flash();
         error_message.enabled = true;
     }
     else
     {
         Debug.Log("ThermoState was signaled to notify of a math state instability, but ThermoMath does not indicate an error occurred.");
     }
 }
예제 #7
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        var damageDealer = collider.GetComponent <DamageDealer> ();

        if (damageDealer != null)
        {
            _flasher.Flash();
            ProcessHit(damageDealer);
        }

        if (collider.tag == "Gravity")
        {
            gravityEffect = true;
        }
    }
예제 #8
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("Require program to run");
                Environment.Exit(1);
            }

            var file = args[0];

            var programFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file);

            string source = File.ReadAllText(programFile);

            var binary = Assembler.Assemble(source);

            var memory    = new Memory(0x10000);
            var console   = new SystemConsole(memory, CONSOLE_ADDRESS, WIDTH, HEIGHT);
            var processor = new Processor(memory, 0x800);
            var flasher   = new Flasher(memory);

            flasher.Flash(binary);

            var instructions = 0;

            processor.Tick += (o, e) =>
            {
                instructions++;
            };
            processor.Halt += (o, e) => console.Close();

            var start = DateTime.Now;

            processor.Run();
            var end = DateTime.Now;

            var duration = end - start;

            var instructionsPerSecond = instructions / (duration.TotalMilliseconds / 1000.0);

            System.Console.WriteLine($"Ran {instructions} instructions in {duration}");
            System.Console.WriteLine($"{instructionsPerSecond} instructions per second");

            if (Debugger.IsAttached)
            {
                System.Console.ReadLine();
            }
        }
예제 #9
0
 public void FlashIfNeeded(bool flash)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         if (!IsActive)
         {
             if (flash)
             {
                 Flasher.Flash(this);
             }
             else
             {
                 Flasher.Stop(this);
             }
         }
     }));
 }
예제 #10
0
    //sender is the rigidbody you collided with
    public void GetDamage(float impactForce, Rigidbody2D sender)
    {
        //Everytime any contact happens
        CameraShaker.Instance.ShakeOnce(2, 5, 0, 0.2f);



        if (impactForce > minImpactForce)
        {
            //This means game over, the center ball dies :(
            if (isCenterBall)
            {
                //There is no gameover in debug mode
                if (GameManager.main.DEBUG_MODE)
                {
                    return;
                }

                //Knockback
                rb.isKinematic     = false;
                rb.velocity        = 13 * -sender.transform.position.normalized;
                rb.angularVelocity = Random.Range(200f, -200f);

                //-flash
                flasher.Flash(2, 0.02f);

                //Death particle for center ball
                ParticleManager.main.play(3, transform.position);

                //Wery important thing
                face.parts[0].localScale = Vector3.one * 0.156f;

                //Call the game manager and loose the game.
                GameManager.main.Loose();
            }
            //Everytime another ball gets hit
            else
            {
                //Loose hp
                hp--;

                //-flash
                flasher.Flash(1, 0.08f);
                CameraShaker.Instance.ShakeOnce(2, 7, 0, 0.3f);

                //-freeze
                SlowMo.main.Freeze(5);

                ParticleManager.main.play(0, transform.position, colorList[hp + 1]);

                //Change color
                sprite.color = colorList[hp];

                foreach (SpriteRenderer sprite in eyeSprites)
                {
                    sprite.color = colorList[hp];
                }

                if (hp <= 0)
                {
                    Die();
                }
            }
        }
    }
예제 #11
0
    IEnumerator CutScene()
    {
        Debug.Log("CutSceneStarted");
        var vrb = _victim.GetComponent <Rigidbody2D>();
        var prb = _player.GetComponent <Rigidbody2D>();

        _player.SendMessage("StartCutscene");

        _cam.SendMessage("ChangeTarget", _target);

        //Glue talks
        _source.PlayOneShot(_gueSound);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "A human, here in this realm?\nHow funny.", 0.1f)));

        yield return(new WaitForSeconds(1f));

        _source.PlayOneShot(_gueSound);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Your end is near, mortal.", 0.1f)));

        yield return(new WaitForSeconds(1f));

        _victim.SendMessage("DisplayText", "");
        //Glue attacks
        _music.SetActive(true);
        vrb.MovePosition(new Vector2(vrb.position.x - 0.95f, vrb.position.y));
        _source.PlayOneShot(_gueAttack);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahh!", 0.01f)));

        yield return(new WaitForSeconds(0.5f));

        //Cherry goes back
        _cam.SendMessage("ChangeTarget", _player.transform);
        prb.MovePosition(new Vector2(prb.position.x - 0.1f, prb.position.y));
        _player.SendMessage("DisplayText", "");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Yes, you are going to die here!", 0.05f)));

        yield return(new WaitForSeconds(1f));

        _victim.SendMessage("DisplayText", "");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "No...no...", 0.15f)));

        yield return(new WaitForSeconds(1f));

        _isActive = true;
        //Decision Time
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Flee (Q)?\nFight (E)?")));

        while (!_isDecided)
        {
            yield return(null);
        }
        _music.SetActive(false);
        if (_choosedAttack)
        {
            //Cherry Attacks
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I don't want to die!!!", 0.01f)));

            prb.MovePosition(new Vector2(prb.position.x + 0.15f, prb.position.y));
            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Huah! Die! Die!", 0.01f)));

            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            //Mark as Human
            _victim.GetComponent <SpriteRenderer>().sprite = _markHuman;
            _player.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Wha..? Cher...?", 0.1f)));

            yield return(new WaitForSeconds(0.25f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Ahh..uhhu..", 0.1f)));

            yield return(new WaitForSeconds(0.25f));

            _victim.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Mark?!", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            //Mark to Bloody Glue
            _victim.SendMessage("DisplayText", "");
            _victim.GetComponent <SpriteRenderer>().sprite = _markGlue;
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahhhh! Die!", 0.1f)));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(_flasherRed.Flash()));

            _player.SendMessage("DisplayText", "");
            //Fade Out
            //yield return new WaitForSeconds(0.5f);
            _source.PlayOneShot(_markScream);
            yield return(StartCoroutine(_faderRed.FadeOut()));

            _victim.GetComponent <SpriteRenderer>().sprite = _blood;
            vrb.MovePosition(new Vector2(vrb.position.x + 0.3f, vrb.position.y - 0.2f));
            yield return(new WaitForSeconds(3f));

            yield return(StartCoroutine(_faderRed.FadeIn()));

            // yield return StartCoroutine(_faderRed.FadeIn());
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "It's...it's over...?", 0.25f)));

            yield return(new WaitForSeconds(1f));

            yield return(StartCoroutine(_flasherWhite.Flash()));

            _player.SendMessage("DisplayText", "");
            Debug.Log("CutSceneEnded");
            _isActive = false;
            _player.SendMessage("EndCutscene");
            Destroy(gameObject);
        }
        else
        {
            //Cherry dies
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I am scared.", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I want to run.", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "But my legs are frozen!", 0.01f)));

            yield return(new WaitForSeconds(0.5f));

            _player.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Muhaha", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            _victim.SendMessage("DisplayText", "");
            vrb.MovePosition(new Vector2(vrb.position.x - 0.15f, vrb.position.y));
            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahhh.")));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(_flasherRed.Flash()));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Uhhh.")));

            _player.SendMessage("DisplayText", "");
            //Fade Out
            _source.PlayOneShot(_cherryScream);
            yield return(StartCoroutine(_faderRed.FadeOut()));

            _cam.SendMessage("ChangeTarget", _textScreen);
            yield return(new WaitForSeconds(2f));

            _endText.SetActive(true);
            yield return(StartCoroutine(_faderRed.FadeIn()));

            _restart = true;
        }
    }
예제 #12
0
 public static void TestMethod1()
 {
     byte[] x = { 0, 0, 0 };
     Flasher.Flash(x);
 }
        public void AllU16FibonacciNumbers()
        {
            var memory    = new Memory(0x100);
            var processor = new Processor(memory, 0x10);
            var flasher   = new Flasher(memory);

            const ushort SEQUENCEADDRESS = 0x00a0;

            var source = new string[]
            {
                "START:",
                // initialize register values
                "LDVR 0 $R0",
                "LDVR 1 $R1",
                "LDVR 0x10 $R2",
                $"LDVR {SEQUENCEADDRESS} $R3",
                "LDVR 2 $R4",

                // Save R0 and R1 value to memory
                "STRR $R0 $R3",
                "CALL 0 INCREMENT",
                "POP $T1",     // return value count (0)

                "STRR $R1 $R3",
                "CALL 0 INCREMENT",
                "POP $T1",     // return value count (0)

                "LOOP:",
                // Check for overflow
                "AND $T0 $R2",
                "JNZ END",

                // calculate next Fibonacci number (R0 + R1 -> ACC)
                "ADD $R0 $R1",

                // Save Flag register for check later
                "MOVE $FLAG $T0",

                // Write Fibonacci number to memory
                "STRR $ACC $R3",

                // Shift all values, R1 -> R0, ACC -> R1
                "MOVE $R1 $R0",
                "MOVE $ACC $R1",

                // Increment address to save fibonnaci values at
                "CALL 0 INCREMENT",
                "POP $T1",     // return value count (0)

                "JUMP LOOP",

                "END:",
                "HALT",

                "INCREMENT:",
                "ADD $R3 $R4",
                "MOVE $ACC $R3",
                "RET 0"
            };

            var binary = Assembler.Assemble(string.Join(Environment.NewLine, source));

            flasher.Flash(binary);

            processor.Run();

            var expected = new ushort[]
            {
                0, 1, 1, 2, 3,
                5, 8, 13, 21, 34,
                55, 89, 144, 233, 377,
                610, 987, 1597, 2584, 4181,
                6765, 10946, 17711, 28657, 46368,
                // next value is 75025 which is > ushort max (65535)
                9489 // (75025 & 0xffff) => 9489
            };

            for (var i = 0; i < expected.Length; i++)
            {
                ushort address = (ushort)(SEQUENCEADDRESS + (2 * i));
                var    value   = expected[i];
                Assert.That(memory.GetU16(address), Is.EqualTo(value));
            }
        }
예제 #14
0
    IEnumerator CutScene()
    {
        Debug.Log("CutSceneStarted");
        _player.SendMessage("StartCutscene");
        isActive = true;

        _player.transform.localScale = new Vector3(-1, 1, 1);
        yield return(new WaitForSeconds(0.5f));

        _cam.SendMessage("ChangeTarget", _target);
        yield return(new WaitForSeconds(2f));

        _cam.SendMessage("ChangeTarget", _player.transform);
        _player.transform.localScale = new Vector3(1, 1, 1);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "What was that?", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Did I see...him?", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Where am I, dawm it!", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahh!")));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "My head still hurts...", 0.1f)));

        yield return(new WaitForSeconds(0.25f));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "!!")));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I remember...")));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ohnononono", 0.4f)));


        yield return(StartCoroutine(_fader.FadeOut()));

        _rainMusic.SetActive(false);
        _player.SendMessage("DisplayText", "");
        _cam.SendMessage("ChangeTarget", _textScreen.transform);
        yield return(new WaitForSeconds(1f));

        _music.SetActive(true);
        yield return(StartCoroutine(_fader.FadeIn()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "Mark and I went out....\n" +
                                                             "We were going to party\n" +
                                                             "and party hard we did.\n" +
                                                             "I remember.\n" +
                                                             "Mark and I shared something.\n" +
                                                             "LSD? I'm not sure.\n", 0.15f)));

        yield return(new WaitForSeconds(2f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "But I know, I definitely know...\n" +
                                                             "That it is my head,\n" +
                                                             "messing with me...\n" +
                                                             "And that means...\n", 0.15f)));

        _music.SetActive(false);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "I killed Mark.", 0.5f)));

        yield return(new WaitForSeconds(2f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "My mind went blank.\n" +
                                                             "My mind tricked me,\n" +
                                                             "made me do the most monstrous\n" +
                                                             "thing a human being can do.\n" +
                                                             "To kill.\n" +
                                                             "I am a monster, forever.", 0.15f)));

        yield return(new WaitForSeconds(2f));

        _textScreen.SendMessage("DisplayText", "");
        _music.SetActive(false);
        _endMessage.SetActive(true);

        yield return(StartCoroutine(_flasherWhite.Flash()));

        Debug.Log("CutSceneEnded");
        isActive = false;
    }