コード例 #1
0
ファイル: TrainingText.cs プロジェクト: eXish/Training-Text
    // Gets information
    private void Start()
    {
        // Gets edgework and day of the week
        lastSerialDigit = Bomb.GetSerialNumberNumbers().Last();
        batteryCount    = Bomb.GetBatteryCount();

        if (Bomb.GetPortCount(Port.Serial) > 0)
        {
            hasSerialPort = true;
        }

        foreach (object[] plate in Bomb.GetPortPlates())
        {
            if (plate.Length == 0)
            {
                hasEmptyPlate = true;
                break;
            }
        }


        // Gets the list of flavor texts and chooses a random text
        flavorTexts = AllFlavorTexts.AddFlavorTexts();
        module      = flavorTexts.getRandomFlavorText();

        // Formats the flavor text for logging
        string modifiedFlavorText = module.getFlavorText();

        modifiedFlavorText = modifiedFlavorText.Replace('\n', ' ');

        Debug.LogFormat("[Training Text #{0}] The module selected was {1}.", moduleId, module.getModuleName());
        Debug.LogFormat("[Training Text #{0}] The flavor text is: {1}", moduleId, modifiedFlavorText);
        Debug.LogFormat("[Training Text #{0}] The module was released on {1}/{2}/{3}.", moduleId, module.getMonth(), module.getDay(), module.getYear());


        // Sets a random time on the clock
        currentTime = UnityEngine.Random.Range(0, 1440);

        CalculateCorrectTime();
        DisplayCurrentTime();

        FlavorText.text = module.getFlavorText();
    }
コード例 #2
0
ファイル: TrainingText.cs プロジェクト: eXish/Training-Text
    // Calculates correct time
    private void CalculateCorrectTime()
    {
        correctTime += module.getMonth() * 60;
        correctTime += module.getDay();

        if (lastSerialDigit % 2 == 0)
        {
            correctTime += 720;
        }

        Debug.LogFormat("[Training Text #{0}] The unmodified time is {1}", moduleId, FormatTime(correctTime));


        // Modifies the time
        bool rulesApplied = false;

        if (module.getYear() < 2017)
        {
            correctTime  = ModifyTime(correctTime + 45);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The module was released before 2017. (+45 minutes)", moduleId);
        }

        if (module.getHasQuotes() == true)
        {
            correctTime  = ModifyTime(correctTime + 20);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The module's flavor text has quotation marks. (+20 minutes)", moduleId);
        }

        if (module.getStartsDP() == true)
        {
            correctTime  = ModifyTime(correctTime - 30);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The module's name starts with a letter between D and P. (-30 minutes)", moduleId);
        }

        if (module.getMonth() == 1)
        {
            correctTime  = ModifyTime(correctTime - 300);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The module was released in January. (-5 hours)", moduleId);
        }

        if (Bomb.GetSolvableModuleNames().Count(x => x.Contains("Training Text")) > 1)
        {
            correctTime  = ModifyTime(correctTime + 60);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] There is another Training Text module on the bomb. (+1 hour)", moduleId);
        }

        if (hasSerialPort == true)
        {
            correctTime  = ModifyTime(correctTime + 5);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The bomb has a serial port. (+5 minutes)", moduleId);
        }

        if (hasEmptyPlate == true)
        {
            correctTime  = ModifyTime(correctTime - 90);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The bomb has an empty port plate. (-90 minutes)", moduleId);
        }

        if (batteryCount == 0)
        {
            correctTime  = ModifyTime(correctTime - 10);
            rulesApplied = true;
            Debug.LogFormat("[Training Text #{0}] The bomb has no batteries. (-10 minutes)", moduleId);
        }

        if (rulesApplied == false)
        {
            Debug.LogFormat("[Training Text #{0}] No rules from Step 3 applied.", moduleId);
        }

        else
        {
            Debug.LogFormat("[Training Text #{0}] The time after Step 3 is {1}", moduleId, FormatTime(correctTime));
        }

        // If the specified module is on the bomb
        if (Bomb.GetSolvableModuleNames().Count(x => x.Contains(module.getModuleName())) > 0)
        {
            Debug.LogFormat("[Training Text #{0}] The module selected is present on the bomb.", moduleId);
            correctTime = ModifyTime(correctTime + 1110);
        }

        Debug.LogFormat("[Training Text #{0}] The correct time to submit is {1}", moduleId, FormatTime(correctTime));
    }