コード例 #1
0
    private void Start()
    {
        rsp = GetComponent <RandomSlotPopulator>();

        //-1 here so it goes from 0 to n-1 instead of 1 to n
        totalRows = Mathf.CeilToInt((Globals.GameVars.playerShipVariables.ship.crew * 1.0f) / rsp.CrewPerRow) - 1;

        //To center the next row, you need to scroll the height of the crew card plus the distance between rows
        scrollDistance = rsp.crewCard.GetComponent <RectTransform>().rect.height + rsp.padding;
        CheckButtons();
    }
コード例 #2
0
    private void OnEnable()
    {
        if (rsp == null)
        {
            rsp = GetComponent <RandomSlotPopulator>();
        }
        cloutChange = 0;

        alreadyTriedRunning     = false;
        alreadyTriedNegotiating = false;

        foreach (ButtonExplanation button in negotiateButtons)
        {
            button.SetExplanationText("The pirates may let you go\nYou will be known as a coward");
            button.GetComponentInChildren <Button>().interactable = true;
        }

        //check true zones, out of those, have a pirate type spawn from one of the "true" areas
        //no pirates should appear if there aren't any actve zones
        if (Globals.GameVars.playerShipVariables.zonesList.Count > 0)
        {
            //below line is unneeded
            //int randomPirateTypeFromActiveZones = UnityEngine.Random.Range(1, Globals.GameVars.playerShipVariables.zonesList.Count);

            string randomPirateTypeName = Globals.GameVars.playerShipVariables.zonesList.RandomElement();

            PirateType theType = Globals.GameVars.PirateTypes.FirstOrDefault(t => t.name == randomPirateTypeName);
            //Debug.Log("theType = " + theType);
            rsp.SetPirateType(theType);
            //Debug.Log("Pirate type in game is: " + rsp.GetType());
        }
        else
        {
            //temporary code
            //rsp.SetPirateType(Globals.GameVars.PirateTypes.RandomElement());
        }

        runChance = CalculateRunChance();
        foreach (ButtonExplanation button in runButtons)
        {
            button.SetExplanationText($"{runChance * 100}% success chance\nYou will be known as a coward");
            button.GetComponentInChildren <Button>().interactable = true;
        }



        string     pirateTypeText = "";
        CrewMember pirateKnower   = CrewFromPirateHometown(rsp.CurrentPirates);

        if (pirateKnower != null)
        {
            string typeInfo = Globals.GameVars.pirateTypeIntroText[0];
            typeInfo = typeInfo.Replace("{0}", pirateKnower.name);
            typeInfo = typeInfo.Replace("{1}", rsp.CurrentPirates.name);

            //commented out the "1 + " to test for text matching up to type of Pirate in PMG
            //works as of 08/14/2020
            pirateTypeText = typeInfo + " " + Globals.GameVars.pirateTypeIntroText[/*1 + */ rsp.CurrentPirates.ID];
            Debug.Log("current pirate ID: " + rsp.CurrentPirates.ID);
        }
        else
        {
            pirateTypeText = $"You ask around your crew, but it doesn't seem like any of them are from the same region as the pirates. You think they may be {rsp.CurrentPirates.name}. " +
                             "Perhaps if you had more cities in your network you would have some advance warning of how they fight.";
        }

        mgInfo.gameObject.SetActive(true);
        mgInfo.DisplayText(
            Globals.GameVars.pirateTitles[0],
            Globals.GameVars.pirateSubtitles[0],
            Globals.GameVars.pirateStartText[0] + "\n\n" + pirateTypeText + "\n\n" + pirateInstructions + "\n\n" + Globals.GameVars.pirateStartText[UnityEngine.Random.Range(1, Globals.GameVars.pirateStartText.Count)],
            pirateIcon,
            MiniGameInfoScreen.MiniGame.Pirates);
    }
コード例 #3
0
 public void SetRSP(RandomSlotPopulator r)
 {
     rsp = r;
 }