コード例 #1
0
ファイル: SeedConverter.cs プロジェクト: jaywgraves/seedQuest
    /// <summary>
    /// Returns recovered seed which as been decodes from a list of interactions
    /// </summary>
    public string DecodeSeed(InteractableLog log)
    {
        int[]      encodedInteractions = EncodeInteractions(log);
        List <int> bitList             = SeedToByte.customList(3, 4, 2, 4, 4);

        return(converter.getSeed(encodedInteractions, bitList));
    }
コード例 #2
0
    // To get the seed from the player's actions, including site, spot and action values
    public void getSeedFromData()
    {
        int[] playerChoices = new int[24];

        // Get the seed from the player's choices
        string seed = seedToByte.getSeed(playerChoices);

        //Debug.Log("Seed: " + seed);
    }
コード例 #3
0
    public string getSentenceFromActions(int[] actions)
    {
        string seed = seeds.getSeed(actions);

        byte[]     seedBytes     = HexStringToByteArray(seed);
        BitArray   bits          = byteToBits(seedBytes);
        List <int> wordListSizes = new List <int> {
            11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
        };

        int[]      wordIndeces     = seeds.bitToActions(bits, wordListSizes);
        List <int> wordIndecesList = new List <int>();

        for (int i = 0; i < wordIndeces.Length; i++)
        {
            wordIndecesList.Add(wordIndeces[i]);
        }

        string words = getMnemonicSentence(wordIndecesList);

        return(words);
    }
コード例 #4
0
    // Test to make sure actions can be retrieved from a BIP39 sentence
    public int[] testGetActions()
    {
        int[] passed = new int[2];
        passed[1] = 1;

        string testingHex = "3720B091810D8127C55630F55DD2275C05";
        string testWords  = "ugly call give address amount venture misery dose quick spoil weekend inspire";

        int[]  actions = bpc.getActionsFromSentence(testWords);
        string seed    = seeds.getSeed(actions);

        if (testingHex == seed)
        {
            passed[0] = 1;
        }
        else
        {
            Debug.Log("BIP39 test converting sentence to actions failed");
        }

        return(passed);
    }
コード例 #5
0
 /// <summary>
 /// Returns recovered seed which as been decodes from a list of interactions
 /// </summary>
 public string DecodeSeed(InteractableLog log)
 {
     int[] encodedInteractions = EncodeInteractions(log);
     return(converter.getSeed(encodedInteractions));
 }
コード例 #6
0
    void Update()
    {
        // This code is for controlling the player character
        CharacterController controller = GetComponent <CharacterController>();

        if (controller.isGrounded && pauseActive == false)
        {
            transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0);

            moveDirection = new Vector3(Input.GetAxis("Strafe"), 0, Input.GetAxis("Vertical"));

            moveDirection  = transform.TransformDirection(moveDirection);
            moveDirection *= speed;
            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }


        // If near an item, show prompt to take it, and allow player to take it
        if (nearItem == true)
        {
            // Executed if the player takes the item
            if (Input.GetButtonDown("F_in") && pauseActive == false)
            {
                takeItem();
            }
        }

        if (seedBoxActive == true)
        {
            if (Input.GetButtonDown("F_in"))
            {
                seedBox.SetActive(false);
                seedBoxActive = false;
            }
        }

        // If near an entrance, show prompt to enter
        if (nearEntrance == true)
        {
            //Executed if the player activates the entrance
            if (Input.GetButtonDown("F_in"))
            {
                enterArea();
            }
        }

        // Display or hide action log
        if (Input.GetButtonDown("G_in"))
        {
            if (logVisible == false)
            {
                logVisible = true;
                logDisplay.SetActive(true);
            }
            else
            {
                logVisible = false;
                logDisplay.SetActive(false);
            }
        }

        // Display or hide inventory
        if (Input.GetButtonDown("I_in"))
        {
            if (invVisible == false)
            {
                invVisible = true;
                inventory.GetComponent <InventoryOperator>().show();
            }
            else
            {
                invVisible = false;
                inventory.GetComponent <InventoryOperator>().hide();
            }
        }

        // Add actions to the action log
        // This should only be used for testing purposes
        if (Input.GetButtonDown("T_in"))
        {
            if (actionIndex >= 35)
            {
                // send action log of ints to the seedToByte script
                int[] actTemp = playerLog.GetComponent <playerLog>().getActions();
                seed = seedScriptor.getSeed(actTemp);
                Debug.Log("Your seed is: " + seed);
                seedBox.GetComponentInChildren <Text>().text = "Your seed is: " + seed;
                seedBox.SetActive(true);
                seedBoxActive = true;
            }

            else
            {
                playerLog.GetComponent <playerLog>().actionLogger(testActionArr[actionIndex % 9]);
            }
            actionIndex += 1;
        }

        // Display or hide pause menu, and pause or unpause game
        if (Input.GetButtonDown("Cancel"))
        {
            if (pauseActive == false)
            {
                activatePause();
            }
            else
            {
                deactivatePause();
                //Debug.Log("Unpausing from ESC...");
            }
        }

        // After checking for input, move the character
        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);

        // Set the walking animation
        if (moveDirection.z != 0)
        {
            animator.SetBool("Walk", true);
        }
        else
        {
            animator.SetBool("Walk", false);
        }
    }
コード例 #7
0
ファイル: ActionLog.cs プロジェクト: jonnycrunch/seedQuest
    public string RecoverSeed(int[] actionArray)
    {
        string recoveredSeed = seedToByte.getSeed(actionArray);

        return(recoveredSeed);
    }
コード例 #8
0
    // Creates a custom learn mode - does the heavy lifting for the above two functions
    public static string learnTest(string input, bool random, bool iterative, bool tryToBreak)
    {
        string[] stringInputs = input.Split(null);
        int[]    scenes       = new int[InteractableConfig.SitesPerGame];
        int[]    actions      = new int[InteractableConfig.SitesPerGame + (InteractableConfig.SitesPerGame * InteractableConfig.ActionsPerSite * 2)];
        if (stringInputs.Length <= 0 || input == null || input == "")
        {
            return("Please enter at least one scene name for the custom learn path.");
        }
        Debug.Log("Input: " + input);
        Debug.Log("String input length: " + stringInputs.Length);

        for (int i = 0; i < InteractableConfig.SitesPerGame; i++)
        {
            // queue up the scenes entered by user into a seed
            if (i < stringInputs.Length)
            {
                if (sceneIndeces.ContainsKey(stringInputs[i]))
                {
                    scenes[i] = sceneIndeces[stringInputs[i]];
                }
                else if (fuzzySceneNames.ContainsKey(stringInputs[i]))
                {
                    scenes[i] = sceneIndeces[fuzzySceneNames[stringInputs[i]]];
                }
                else
                {
                    Debug.Log("Do not recognize scene name: " + stringInputs[i]);
                    return("Do not recognize scene name: " + stringInputs[i]);
                }
            }
            else
            {
                scenes[i] = 2;
            }
        }

        int counter = 0;

        // Create custom seed using the chosen scenes
        for (int i = 0; i < InteractableConfig.SitesPerGame; i++)
        {
            actions[i + i * InteractableConfig.ActionsPerSite * 2] = scenes[i];

            for (int j = 0; j < InteractableConfig.ActionsPerSite; j++)
            {
                if (iterative)
                {
                    actions[j * 2 + 1 + i + i * InteractableConfig.ActionsPerSite * 2] = counter % 16;
                }
                else if (random)
                {
                    actions[j * 2 + 1 + i + i * InteractableConfig.ActionsPerSite * 2] = UnityEngine.Random.Range(0, 100) % 16;
                }
                else if (tryToBreak)
                {
                    actions[j * 2 + 1 + i + i * InteractableConfig.ActionsPerSite * 2] = j + 13;
                }
                else
                {
                    actions[j * 2 + 1 + i + i * InteractableConfig.ActionsPerSite * 2] = j % 16;
                }

                actions[j * 2 + 2 + i + i * InteractableConfig.ActionsPerSite * 2] = j % 4;

                //if (iterative)
                //    Debug.Log("Counter " + counter % 16);
                counter++;
            }
        }

        SeedToByte seeds = new SeedToByte();
        string     seed  = seeds.getSeed(actions);

        Debug.Log("Artificial seed: " + seed);

        InteractablePathManager.SeedString = seed;
        InteractablePath.ResetPath();
        InteractablePathManager.Reset();
        if (GameManager.V2Menus)
        {
            WorldManager.Reset();
        }
        else
        {
            LevelSetManager.ResetCurrentLevels();
        }


        for (int i = 0; i < scenes.Length; i++)
        {
            if (GameManager.V2Menus)
            {
                WorldManager.Add(scenes[i]);
            }
            else
            {
                LevelSetManager.AddLevel(scenes[i]);
            }
        }

        GameManager.Mode  = GameMode.Rehearsal;
        GameManager.State = GameState.Play;
        InteractablePathManager.Initalize();

        if (fuzzySceneNames.ContainsKey(stringInputs[0]))
        {
            SceneManager.LoadScene(fuzzySceneNames[stringInputs[0]]);
            return("Loading custom seed. Scene: " + fuzzySceneNames[stringInputs[0]]);
        }
        else
        {
            Debug.Log("Could not find scene named " + stringInputs[0]);
        }

        SceneManager.LoadScene(stringInputs[0]);

        return("Loading custom seed. Scene: " + stringInputs[0]);
    }