Ejemplo n.º 1
0
 public void NewGameClicked()
 {
     StateSaver.Reset();
     StartCoroutine(bout.FadeInBlack());
     StateSaver.Save();
     SceneManager.LoadSceneAsync(StateSaver.areaNames[(int)StateSaver.Area.Base]);
 }
        public MachineControlsViewModel(SimpleSimulator simulator, IUserInputService userInputService, StateSaver stateSaver) : base(simulator)
        {
            OpenCommand = new Command(() =>
            {
                FileInfo file = userInputService.GetOpenFileName();

                if (file != null)
                {
                    Memory memory = stateSaver.LoadMemory(file);
                    for (int i = 0; i <= byte.MaxValue; i++)
                        simulator.Memory[(byte)i] = memory[(byte)i];
                }
            }, () => simulator.Machine.State != Machine.MachineState.Running, simulator);

            SaveCommand = new Command(() =>
            {
                FileInfo file = userInputService.GetSaveFileName();

                if (file != null)
                    stateSaver.SaveMemory(simulator.Memory, file);
            }, () => simulator.Machine.State != Machine.MachineState.Running, simulator);

            RunCommand = new Command(() => Task.Run(() => simulator.Machine.Run(25)), () => simulator.Machine.State != Machine.MachineState.Running, simulator);

            StepCommand = new Command(() => simulator.Machine.Step(), () => true, simulator);

            BreakCommand = new Command(() => simulator.Machine.Break(), () => simulator.Machine.State == Machine.MachineState.Running, simulator);

            ClearMemoryCommand = new Command(() => simulator.Memory.Clear(), () => true, simulator);

            ClearRegistersCommand = new Command(() => simulator.Registers.Clear(), () => true, simulator);
        }
Ejemplo n.º 3
0
    void Awake()
    {
        savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
        GameObject playerStartPoint = GameObject.FindWithTag("PlayerStart");

        savedState.player.transform.SetPositionAndRotation(playerStartPoint.transform.position, playerStartPoint.transform.rotation);
    }
Ejemplo n.º 4
0
 // Add food to stores, save the game, and leave the area
 void GoToScene()
 {
     StateSaver.gameState.AddFood(player.GetFoodFound());
     StateSaver.Save();
     StateSaver.gameState.curArea = StateSaver.gameState.areas [(int)togo];
     SceneManager.LoadSceneAsync(StateSaver.areas[(int)togo].name);
 }
Ejemplo n.º 5
0
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         StateSaver          s  = new StateSaver();
         StateSaver.GameData gd = new StateSaver.GameData(jewels, jewelsPerSecond, buildings, upgrades,
                                                          events, jewelsPerClick, multiplier, clickMultiplier, lifetimejewels);
         s.Save(gd);
     }
 }
Ejemplo n.º 6
0
 private void Awake()
 {
     //Prepare singleton instance
     if (instance != null)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(instance.gameObject);
     }
 }
Ejemplo n.º 7
0
 public override T Deserialize <T>(string key)
 {
     try {
         var serializedObj = StateSaver.Load(key);
         if (string.IsNullOrEmpty(serializedObj))
         {
             throw new NotSavedException(key);
         }
         var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
         using (var reader = new StringReader(serializedObj)) {
             return((T)serializer.Deserialize(reader));
         }
     }
     catch (IOException) {
         throw new NotSavedException(key);
     }
 }
Ejemplo n.º 8
0
    IEnumerator ActivateMenuWithDelay()
    {
        savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
        yield return(new WaitUntil(() => savedState != null));

        if (savedState.debugMode)
        {
            savedState.ui.counterInput.enableInputField(doThis.doThisOnTrue, new string[] { "fire", "cactus", "river", "tree", "shark" });
        }
        else
        {
            savedState.ui.counterInput.enableInputField(doThis.doThisOnTrue, new string[] { "start" });
        }
        savedState.ui.toMainMenuDisplay();

        savedState.playerHandler.playerController.runSpeed = 0.0f;
    }
Ejemplo n.º 9
0
        public void ShouldBeAbleToSaveMemoryState()
        {
            Memory expectedMemory = new Memory();

            Random random = new Random();
            for (int address = 0; address <= byte.MaxValue; address++)
                expectedMemory[(byte)address] = (byte)random.Next(0x00, byte.MaxValue);

            StateSaver stateSaver = new StateSaver();
            stateSaver.SaveMemory(expectedMemory, _memorySaveFile);

            FileAssert.Exists(_memorySaveFile);

            Memory actualMemory = stateSaver.LoadMemory(_memorySaveFile);

            for (int address = 0; address <= byte.MaxValue; address++)
                Assert.AreEqual(expectedMemory[(byte)address], actualMemory[(byte)address]);
        }
Ejemplo n.º 10
0
        public void ShouldBeAbleToSaveRegistersState()
        {
            Registers expectedRegisters = new Registers();

            Random random = new Random();
            for (byte register = 0; register <= 0x0F; register++)
                expectedRegisters[register] = (byte)random.Next(0x00, byte.MaxValue);

            StateSaver stateSaver = new StateSaver();
            stateSaver.SaveRegisters(expectedRegisters, _registersSaveFile);

            FileAssert.Exists(_registersSaveFile);

            Registers actualRegisters = stateSaver.LoadRegisters(_registersSaveFile);

            for (byte register = 0; register < 0x0F; register++)
                Assert.AreEqual(expectedRegisters[register], actualRegisters[register]);
        }
Ejemplo n.º 11
0
        public void ShouldBeAbleToSaveMachineState()
        {
            Memory memory = new Memory();
            memory.LoadInstructions(SamplePrograms.HelloWorldInstructions);

            Machine expectedMachine = new Machine(memory, new Registers());
            expectedMachine.Run();

            StateSaver stateSaver = new StateSaver();
            stateSaver.SaveMachine(expectedMachine, _machineSaveFile);

            FileAssert.Exists(_machineSaveFile);

            Machine actualMachine = stateSaver.LoadMachine(_machineSaveFile);

            Assert.AreEqual(expectedMachine.State, actualMachine.State);
            Assert.AreEqual(expectedMachine.InstructionRegister, actualMachine.InstructionRegister);
            Assert.AreEqual(expectedMachine.ProgramCounter, actualMachine.ProgramCounter);
        }
Ejemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        StartCoroutine(bout.FadeInBlack());
        Screen.fullScreen = false;
        Resolution[] all = Screen.resolutions;
        possibleRes = new Dictionary <string, Resolution> ();
        currentX    = Screen.currentResolution.width;
        currentY    = Screen.currentResolution.height;
        newButton.SetActive(true);
        loadButton.SetActive(StateSaver.Load());
        settingsButton.SetActive(true);
        exitButton.SetActive(true);
        windowedButton.SetActive(false);
        rtToMainButton.SetActive(false);
        resDrop.SetActive(false);
        fullscreenButton.SetActive(false);
        drop = resDrop.GetComponent <Dropdown> ();
        drop.ClearOptions();
        options = new List <string>();
        int curVal = 0;

        foreach (Resolution r in all)
        {
            string tmp = r.width + " x " + r.height;
            if (!possibleRes.ContainsKey(tmp))
            {
                if (r.width == Screen.width && r.height == Screen.height)
                {
                    curVal = options.Count;
                }
                options.Add(tmp);
                possibleRes.Add(tmp, r);
            }
        }
        drop.AddOptions(options);
        drop.value = curVal;
        drop.onValueChanged.AddListener(delegate { dropHandle(drop); });
        dropHandle(drop);
    }
Ejemplo n.º 13
0
 void Awake()
 {
     savedState = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
 }
Ejemplo n.º 14
0
 void Awake()
 {
     isFirstTime  = false;
     thisObstacle = gameObject.transform.parent.GetComponent(typeof(ObstacleType)) as ObstacleType;
     savedState   = (GameObject.FindWithTag("StateSaver")).GetComponent(typeof(StateSaver)) as StateSaver;
 }
Ejemplo n.º 15
0
    // Use this for initialization
    void Awake()
    {
        StateSaver s = new StateSaver();

        StateSaver.GameData gd = new StateSaver.GameData();
        gd = s.Load();
        if (gd != null)
        {
            jewels          = gd.jewels;
            jewelsPerSecond = gd.jewelsPerSecond;
            jewelsPerClick  = gd.jewelsPerClick;
            multiplier      = gd.multiplier;
            clickMultiplier = gd.clickMultiplier;
            buildings       = gd.buildings;
            upgrades        = gd.upgrades;
            events          = gd.events;
            lifetimejewels  = gd.lifetimejewels;
        }
        else
        {
            jewels          = 0;
            jewelsPerSecond = 0;
            jewelsPerClick  = 1;
            multiplier      = 1;
            clickMultiplier = 1;

            //Building Upgrades
            Upgrade BasicPointerUpgrade = new Upgrade("Ambidextrous", 500, 1.5f, "Pointer", "Makes Pointers 50% better", 0, 0);
            Upgrade PointerUpgrade1     = new Upgrade("Stronger Fingers", 5000, 2f, "Pointer", "Makes Pointers 100% better", 25, 0);
            Upgrade PointerUpgrade2     = new Upgrade("Iron Fingers", 15000, 2f, "Pointer", "Makes Pointers 100% better", 50, 0);
            Upgrade PointerUpgrade3     = new Upgrade("Tap God", 200000, 2f, "Pointer", "Makes Pointers 100% better", 75, 0);

            Upgrade GrandmaUpgrade1 = new Upgrade("Better Pensions", 5000, 2f, "JewelGrandma", "Makes Grandmas 100% better", 25, 0);
            Upgrade GrandmaUpgrade2 = new Upgrade("Better Health-Care", 25000, 2f, "JewelGrandma", "Makes Grandmas 100% better", 50, 0);
            Upgrade GrandmaUpgrade3 = new Upgrade("Golden Inhaler", 250000, 2f, "JewelGrandma", "Makes Grandmas 100% better", 75, 0);

            Upgrade FarmUpgrade1 = new Upgrade("Stronger Hoes", 10000, 2f, "JewelFarm", "Makes Farms 100% better", 25, 0);
            Upgrade FarmUpgrade2 = new Upgrade("Better plows", 75000, 2f, "JewelFarm", "Makes Farms 100% better", 50, 0);
            Upgrade FarmUpgrade3 = new Upgrade("Bejeweled™ Tractor", 750000, 2f, "JewelFarm", "Makes Farms 100% better", 75, 0);

            Upgrade JewelMineUpgrade1 = new Upgrade("Stone Pickaxe", 50000, 2f, "JewelMine", "Makes Mines 100% better", 25, 0);
            Upgrade JewelMineUpgrade2 = new Upgrade("Iron Pickaxe", 200000, 2f, "JewelMine", "Makes Mines 100% better", 50, 0);
            Upgrade JewelMineUpgrade3 = new Upgrade("Diamond Pickaxe", 2000000, 2f, "JewelMine", "Makes Mines 100% better", 75, 0);

            Upgrade BankUpgrade1 = new Upgrade("Student Loans", 250000, 2f, "JewelBank", "Makes Banks 100% better", 25, 0);
            Upgrade BankUpgrade2 = new Upgrade("Bitcoin Investment", 850000, 2f, "JewelBank", "Makes Banks 100% better", 50, 0);
            Upgrade BankUpgrade3 = new Upgrade("BITCONNEEEEECT", 1500000, 2f, "JewelBank", "Makes Banks 100% better", 75, 0);

            Upgrade JewelCometUpgrade1 = new Upgrade("Starstruck", 1000000, 2f, "JewelComet", "Makes Comets 100% better", 25, 0);
            Upgrade JewelCometUpgrade2 = new Upgrade("Shooting Stars", 2500000, 2f, "JewelComet", "Makes Comets 100% better", 50, 0);
            Upgrade JewelCometUpgrade3 = new Upgrade("All Star", 5000000, 2f, "JewelComet", "Makes Comets 100% better", 75, 0);

            //General Upgrades
            Upgrade BasicGrandmaUpgrade   = new Upgrade("Grandma support", 3000, 1.5f, "JewelGrandma", "Makes Grandmas 50% better", 0, 0);
            Upgrade BasicFarmUpgrade      = new Upgrade("Jewel Fertilizer", 6000, 1.5f, "JewelFarm", "Makes Farms 50% better", 0, 0);
            Upgrade ExtremePointerUpgrade = new Upgrade("Thousand fingers", 1000000, 10f, "Pointer", "Makes Pointers 1000% better", 0, 0);

            upgrades = new List <Upgrade> {
                BasicPointerUpgrade, BasicGrandmaUpgrade, BasicFarmUpgrade,
                PointerUpgrade1, PointerUpgrade2, PointerUpgrade3,
                GrandmaUpgrade1, GrandmaUpgrade2, GrandmaUpgrade3,
                FarmUpgrade1, FarmUpgrade2, FarmUpgrade3,
                JewelMineUpgrade1, JewelMineUpgrade2, JewelMineUpgrade3,
                BankUpgrade1, BankUpgrade2, BankUpgrade3,
                JewelCometUpgrade1, JewelCometUpgrade2, JewelCometUpgrade3,
                ExtremePointerUpgrade,
            };

            Building Pointer      = new Building("Pointer", 10, 0.1f, 1.1f, buildingPath + "pointer");
            Building JewelGrandma = new Building("JewelGrandma", 100, 0.5f, 1.1f, buildingPath + "grandma");
            Building JewelFarm    = new Building("JewelFarm", 500, 2.5f, 1.1f, buildingPath + "jewelfarm");
            Building JewelMine    = new Building("JewelMine", 3000, 8, 1.1f, buildingPath + "jewelmine");
            Building JewelFactory = new Building("JewelFactory", 15000, 40, 1.1f, buildingPath + "jewelfactory");
            Building JewelBank    = new Building("JewelBank", 50000, 200, 1.1f, buildingPath + "bank");
            Building JewelComet   = new Building("JewelComet", 600000, 1000, 1.1f, buildingPath + "comet");


            buildings = new List <Building> {
                Pointer, JewelGrandma, JewelFarm, JewelMine, JewelFactory, JewelBank, JewelComet
            };

            JewelEvent DoubleJewelsEvent = new JewelEvent("Double Jewels", 1, 1, 20, 20f, 500);
            JewelEvent ClickMultiEvent   = new JewelEvent("8x jewels\nper tap", 0, 8, 20, 20f, 1000);
            JewelEvent TripleJewelsEvent = new JewelEvent("Triple Jevels!", 2, 1, 20, 10f, 50000);

            events = new List <JewelEvent> {
                DoubleJewelsEvent, ClickMultiEvent, TripleJewelsEvent
            };
        }
    }
Ejemplo n.º 16
0
 public void LoadGameClicked()
 {
     StartCoroutine(bout.FadeInBlack());
     StateSaver.Save();
     SceneManager.LoadSceneAsync(StateSaver.areaNames[(int)StateSaver.Area.Overworld]);
 }
Ejemplo n.º 17
0
 public StateSaverTests()
 {
     _stateSaver = new StateSaver();
 }
Ejemplo n.º 18
0
    // Update is called once per frame
    new void Update()
    {
        base.Update();
        if (!paused)
        {
            checkOutOfBounds();
        }
        if (!mySound.isPlaying)
        {
            mySound.clip = this.pantSound;
            mySound.loop = true;
            mySound.Play();
        }
        LayerMask    ignore = ~(1 << LayerMask.NameToLayer("Detection"));
        RaycastHit2D left   = Physics2D.Raycast(new Vector3(transform.position.x - this.GetComponent <BoxCollider2D> ().bounds.extents.x - 0.01f, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);
        RaycastHit2D middle = Physics2D.Raycast(new Vector3(transform.position.x, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);
        RaycastHit2D right  = Physics2D.Raycast(new Vector3(transform.position.x + this.GetComponent <BoxCollider2D> ().bounds.extents.x + 0.01f, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);

        Vector2 velToAdd = Vector2.zero;

        if (left.rigidbody != null && left.rigidbody.isKinematic && !left.collider.isTrigger)
        {
            velToAdd = left.rigidbody.velocity;
        }
        else if (middle.rigidbody != null && middle.rigidbody.isKinematic && !middle.collider.isTrigger)
        {
            velToAdd = middle.rigidbody.velocity;
        }
        else if (right.rigidbody != null && right.rigidbody.isKinematic && !right.collider.isTrigger)
        {
            velToAdd = right.rigidbody.velocity;
        }


        bool grounded = (left && left.collider && !left.collider.isTrigger) || (middle && middle.collider && !middle.collider.isTrigger) || (right && right.collider && !right.collider.isTrigger);

        if (paused || !hasControl)
        {
            rb.velocity = Vector2.zero + velToAdd;
        }
        else
        {
            float jump_speed = 0f;
            rb.velocity = new Vector2(0.0f, rb.velocity.y) + velToAdd;
            if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKey(KeyCode.UpArrow)) && grounded)
            {
                jump_speed  = jump + (0.1f * rb.velocity.x);
                rb.velocity = velToAdd + new Vector2(rb.velocity.x, jump_speed);
            }
            else if ((Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) && rb.velocity.x < speed)
            {
                rb.velocity = velToAdd + new Vector2(speed, rb.velocity.y);
            }
            else if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) && rb.velocity.x > -speed)
            {
                rb.velocity = velToAdd + new Vector2(-speed, rb.velocity.y);
            }

            if (dialogueAvail && Input.GetKey(KeyCode.F))
            {
                dialogueAvail = false;
                activeDialogue.BeginDialogue();
            }
            else if (Input.GetKeyUp(KeyCode.E) && abilityCont.SniffAvailable())
            {
                hasControl = false;
                roomManager.RevealSniffablesInCurRoom();
            }
            else if (Input.GetKeyUp(KeyCode.Q) && abilityCont.BarkAvailable())
            {
                if (!mySound.isPlaying || mySound.clip.Equals(pantSound))
                {
                    mySound.clip = barkSound;
                    mySound.loop = false;
                    mySound.Play();
                }
                Bark();
            }
            else if (Input.GetKeyUp(KeyCode.R) && abilityCont.SaveAvailable())
            {
                StateSaver.Save();
            }
            else if (Input.GetKeyUp(KeyCode.T))
            {
                RaycastHit2D botInFront = Physics2D.Raycast(new Vector3(transform.position.x + (this.transform.localScale.x * (this.GetComponent <BoxCollider2D>().bounds.extents.x + 0.01f)), transform.position.y, transform.position.z), new Vector2(this.transform.localScale.x, 0), 1.0f);
                if (botInFront.collider != null && botInFront.transform.GetComponent <Drone> () != null && abilityCont.TakedownAvailable())
                {
                    StartCoroutine("PreformTakedown", botInFront.transform.GetComponent <Drone>());
                }
            }
            else if (Input.GetKeyUp(KeyCode.I))
            {
                abilityCont.ToggleInfo();
            }
        }


        if (rb.velocity.x < 0)
        {
            this.transform.localScale = new Vector3(-1, this.transform.localScale.y, this.transform.localScale.z);
        }
        else if (rb.velocity.x > 0)
        {
            this.transform.localScale = new Vector3(1, this.transform.localScale.y, this.transform.localScale.z);
        }
    }