示例#1
0
    public void publishPaper(int hid, int venueThreshold)
    {
        Debug.Log("Paper " + hid + " published!");
        characters[currPlayer].removeUnpublishedFindings(hid);
        characters[currPlayer].gainOneNumPublication();
        Hypothesis     hyp = ResourceLibrary.hypothesisLib[hid];
        HypothesisGrid g   = null;

        foreach (MapGrid grid in map.getMapGrids())
        {
            if (grid is HypothesisGrid && ((HypothesisGrid)grid).hypothesisIdx == hid)
            {
                ((HypothesisGrid)grid).setPublished();
                g = (HypothesisGrid)grid;
            }
        }
        Debug.Log("currPlayer: " + currPlayer);
        Debug.Log("investigation: " + g.investigation.Keys);
        Debug.Log(hotness[hyp.type]);
        characters[currPlayer].publishedFindings.Add(hid);
        int fame2gain = hyp.significance * g.investigation[currPlayer] * hotness[hyp.type] * venueThreshold;

        characters[currPlayer].gainFame(fame2gain);
        Debug.Log("Player " + currPlayer + "gained " + fame2gain + " fame");
    }
示例#2
0
    public void investLifeInHypothesis()
    {
        int            gridIdx = characters[currPlayer].getGridLoc();
        HypothesisGrid grid    = map.getMapGrids()[gridIdx].GetComponent <HypothesisGrid>();
        Hypothesis     hyp     = ResourceLibrary.hypothesisLib[grid.hypothesisIdx];

        characters[currPlayer].loseLife(hyp.numYears);
        // We now assume that each hypothesis grid can only be occupied by one player, so the following can be simplified
        if (grid.investigation.ContainsKey(currPlayer))
        {
            grid.investigation[currPlayer] += hyp.numYears;
        }
        else
        {
            grid.investigation.Add(currPlayer, hyp.numYears);
        }
        playSFX(Resources.Load <AudioClip>(ResourceLibrary.randomEventSFX));
        map.getMapGrids()[gridIdx].GetComponent <SpriteRenderer>().color = characterColorMarks[currPlayer];
    }
示例#3
0
    public void executeGrid(int gridIdx)
    {
        MapGrid grid = map.getMapGrids()[gridIdx];

        if (grid is HypothesisGrid)
        {
            HypothesisGrid hgrid = (HypothesisGrid)grid;
            if (!characters[currPlayer].CompareTag("Experiments") && hgrid.investigation.Count > 0 && !hgrid.investigation.ContainsKey(currPlayer))
            {
                characterTurnEnds();
                return;
            }
            Debug.Log("Player " + characters[currPlayer].name + " arrived at a hypothesis grid.");
            if (characters[currPlayer].CompareTag("Player"))
            {
                HypothesisGrid hyGrid     = (HypothesisGrid)grid;
                Hypothesis     hypothesis = ResourceLibrary.hypothesisLib[hyGrid.hypothesisIdx];
                showDialog(hypothesisGridDialog);
                string investigationText = "";
                if (hyGrid.investigation.Count <= 0)
                {
                    investigationText = "nobody has investigated in this.";
                }
                foreach (int idx in hyGrid.investigation.Keys)
                {
                    investigationText += idx + "-" + hyGrid.investigation[idx] + " ";
                }
                hypothesisGridDialog.transform.Find("HypothesisText").GetComponent <Text>().text        = hypothesis.content;
                hypothesisGridDialog.transform.Find("SignificanceIndicator").GetComponent <Text>().text = "Potential Significance of Contribution: " + hypothesis.significance;
                hypothesisGridDialog.transform.Find("YesBtn").Find("Text").GetComponent <Text>().text   = "Yes, I'll dedicate " + hypothesis.numYears + " years of my life to this";
                hypothesisGridDialog.transform.Find("ProgressIndicator").GetComponent <Text>().text     = "Current Investigation Progress: " + investigationText;
                hypothesisGridDialog.transform.Find("HotnessIndicator").GetComponent <Text>().text      = "Hotness of the Topic: " + hotness[hypothesis.type].ToString();

                hypothesisGridDialog.transform.Find("SelectPhDStudents").GetComponent <PhDStudentInvestView>().updateList();
            }
            else
            {
                if (characters[currPlayer].CompareTag("Experiments"))
                {
                    Debug.Log("Experiments arrived at a hypothesis grid.");
                    HypothesisGrid hyGrid     = (HypothesisGrid)grid;
                    Hypothesis     hypothesis = ResourceLibrary.hypothesisLib[hyGrid.hypothesisIdx];
                    if (hyGrid.investigation.Count <= 0 || hyGrid.verified)
                    {
                        showDialog(noMeaningfulResultsDialog);
                    }
                    else
                    {
                        Debug.Log("Some hypothesis should be verified...");
                        string investigationText = "";
                        int    mostDevotedPlayer = 0;
                        foreach (int idx in hyGrid.investigation.Keys)
                        {
                            investigationText += idx + ": " + hyGrid.investigation[idx] + " ";
                            if (hyGrid.investigation[idx] > mostDevotedPlayer)
                            {
                                mostDevotedPlayer = idx;
                            }
                        }
                        showDialog(hypothesisVerifiedDialog);
                        playSFX(Resources.Load <AudioClip>(ResourceLibrary.randomEventSFX));
                        hypothesisVerifiedDialog.transform.Find("HypothesisText").GetComponent <Text>().text        = hypothesis.content;
                        hypothesisVerifiedDialog.transform.Find("SignificanceIndicator").GetComponent <Text>().text = "Potential Significance of Contribution: " + hypothesis.significance;
                        hypothesisVerifiedDialog.transform.Find("ProgressIndicator").GetComponent <Text>().text     = "Current Investigation Progress: " + investigationText;
                        hypothesisVerifiedDialog.transform.Find("HotnessIndicator").GetComponent <Text>().text      = "Hotness of the Topic: " + hotness[hypothesis.type].ToString();
                        characters[mostDevotedPlayer].addUnpublishedFinding(hyGrid.hypothesisIdx);
                        hyGrid.setVerified();
                    }
                }
                else
                {
                    // Currently AI players will always invest
                    Hypothesis hyp = ResourceLibrary.hypothesisLib[hgrid.hypothesisIdx];
                    investLifeInHypothesis();
                    showInfoWindow(characters[currPlayer].name + " has spent " + hyp.numYears + " years to establish the hypothesis:\n\n" + hyp.content);
                }
            }
        }
        else if (grid is PublicationGrid && !characters[currPlayer].CompareTag("Experiments"))
        {
            PublicationVenue pv = ResourceLibrary.publicationVenueLib[rnd.Next(0, ResourceLibrary.publicationVenueLib.Length)];
            if (characters[currPlayer].CompareTag("Player"))
            {
                showDialog(publicationDialog);
                Transform findingsContainer = publicationDialog.transform.Find("Findings");
                Text      text = publicationDialog.transform.Find("NoTheoryIndicator").GetComponent <Text>();
                publicationDialog.transform.Find("PromptText").GetComponent <Text>().text = "Would you like to submit any of your unpublished fidings shown delow to the " + pv.name + "?";
                foreach (Transform child in findingsContainer)
                {
                    GameObject.Destroy(child.gameObject);
                }
                if (characters[currPlayer].getUnpublishedFidings().Length <= 0)
                {
                    text.text = "You do not have any unpublished theories.";
                }
                else
                {
                    text.text = "";
                }
                for (int i = 0; i < characters[currPlayer].getUnpublishedFidings().Length; i++)
                {
                    GameObject btn = GameObject.Instantiate(Resources.Load <GameObject>(ResourceLibrary.paperSubmitBtn), findingsContainer);
                    btn.GetComponent <RectTransform>().anchoredPosition = new Vector2(0.0f, -50.0f * i);
                    btn.GetComponentInChildren <Text>().text            = ResourceLibrary.hypothesisLib[(int)characters[currPlayer].getUnpublishedFidings()[i]].title;
                    int hid = (int)characters[currPlayer].getUnpublishedFidings()[i];
                    Debug.Log("hid: " + hid);
                    btn.GetComponentInChildren <Button>().onClick.AddListener(() => publishPaper(hid, pv.thereshold));
                }
                //Debug.Log("Player " + currPlayer + " arrived at a publication grid.");
                //PublicationGrid pGrid = (PublicationGrid)grid;
                //pGrid.DoGridStuff(characters[currPlayer]);
            }
            else
            {
                // Currently AI players will always publish all findings
                string paperlist = "";
                foreach (int idx in characters[currPlayer].getUnpublishedFidings())
                {
                    publishPaper(idx, pv.thereshold);
                    paperlist += (ResourceLibrary.hypothesisLib[idx].title + ":\n" + ResourceLibrary.hypothesisLib[idx].content + "\n");
                }

                if (characters[currPlayer].getUnpublishedFidings().Length > 0)
                {
                    showInfoWindow(characters[currPlayer].name + " has published the following results:\n" + paperlist);
                }
                else
                {
                    characterTurnEnds();
                }
            }
        }
        else if (grid is RandomEventGrid && !characters[currPlayer].CompareTag("Experiments"))
        {
            Instantiate(Resources.Load <GameObject>(ResourceLibrary.randomEventPrefabs[rnd.Next(0, ResourceLibrary.randomEventPrefabs.Length)]), GameObject.FindGameObjectWithTag("Canvas").transform);
            playSFX(Resources.Load <AudioClip>(ResourceLibrary.randomEventSFX));
        }
        else if (grid is BargainGrid && currPlayer == 0)
        {
            showDialog(evilBargainShop);
        }
        else if (grid is RecruitmentGrid && currPlayer == 0)
        {
            showDialog(recruitmentDialog);
        }
        else
        {
            characterTurnEnds();
        }
    }