Exemplo n.º 1
0
 private void pickOtherSpecial()
 {
     Debug.Log("Picking Fight Event");
     fight = new SpecialResults();
     specEv = true;
     specialPanel.SetActive(true);
     XmlDocument doc = new XmlDocument();
     //XmlDocument xmlDoc = new XmlDocument();
     //XmlDocument nodeNameCollection = new XmlDocument();
     TextAsset textAsset = Resources.Load("XML/SpecialEvents", typeof(TextAsset)) as TextAsset;
     doc.LoadXml(textAsset.text);
     //doc.Load(specEvPath);
     XmlNodeList fights = doc.SelectNodes("specialEvents/fightevent");
     int a = UnityEngine.Random.Range(0, fights.Count);
     string faction1 = fights[a].SelectSingleNode("faction1").InnerText;
     string faction2 = fights[a].SelectSingleNode("faction2").InnerText;
     string intro = fights[a].SelectSingleNode("intro").InnerText;
     string body = fights[a].SelectSingleNode("body").InnerText;
     string extra = fights[a].SelectSingleNode("extra").InnerText;
     string eventflavor = intro + faction1 + body + faction2 + extra;
     string button1text = fights[a].SelectSingleNode("button").InnerText + faction1;
     string button2text = fights[a].SelectSingleNode("button").InnerText + faction2;
     string button3text = "Leave the island and let them settle their own fight.";
     string resultflavor = fights[a].SelectSingleNode("text").InnerText;
     int repvalue = int.Parse(fights[a].SelectSingleNode("value").InnerText);
     fight.neutral = int.Parse(fights[a].SelectSingleNode("neutral").InnerText);
     fight.reputations.Add(faction1, repvalue);
     fight.reputations.Add(faction2, repvalue);
     fight.resultflavor = resultflavor;
     // set the flavors
     specialPanel.transform.FindChild("FlavourScreen").FindChild("EventText").GetComponent<Text>().text = eventflavor;
     specialPanel.transform.FindChild("ButtonController").GetChild(0).FindChild("Text").GetComponent<Text>().text = button1text;
     specialPanel.transform.FindChild("ButtonController").GetChild(1).FindChild("Text").GetComponent<Text>().text = button2text;
     specialPanel.transform.FindChild("ButtonController").GetChild(2).gameObject.SetActive(true);
     specialPanel.transform.FindChild("ButtonController").GetChild(2).FindChild("Text").GetComponent<Text>().text = button3text;
     
 }
Exemplo n.º 2
0
    private string getFlavor(SpecialResults sr)
    {
        string res = "";
        foreach (string k in sr.reputations.Keys)
        {
            res += "Reptutation change: " + k + ": " + sr.reputations[k] + "\n";
            DataManager.instance.Player.AddReputation(DataManager.instance.Factions[k], sr.reputations[k]);
        }
        foreach (string k in sr.resources.Keys)
        {
            if (k == "crewMember")
            {
                switch (sr.resources[k])
                {
                    case 1:
                        res += "Crew gained: injured." + "\n";
                        break;
                    case 10:
                        res += "Crew gained: healthy" + "\n";
                        break;
                    case -1:
                        res += "Crew injured.\n";
                        break;
                    case -10:
                        res += "Castle crew dead.\n";
                        break;
                }
            }
            else
            {
                string name = "";
                switch (k)
                {
                    case "sciencePoint":
                        name = "Alchemy Point";
                        break;
                    case "energyPoint":
                        name = "Crystal Charge";
                        break;
                    case "scrap":
                        name = "Building Material";
                        break;
                }
                res += "Resource gained: " + name + ": " + sr.resources[k] + "\n";
            }
        }
        foreach (string k in sr.rooms.Keys)
        {
            string roomName = "";
            string roomRes = "";
            if (k == "randomRoom")
            {
                List<Piece> tempRooms = new List<Piece>();
                foreach (KeyValuePair<string, Piece> piecePair in DataManager.instance.BoardPieces)
                {
                    if (piecePair.Value.Type == BoardType.ROOM)
                    {
                        tempRooms.Add(piecePair.Value);
                    }
                }
                int[] roomOrder = DataManager.randomArray(tempRooms.Count);
                Piece outPiece = tempRooms[roomOrder[0]];
                roomName = outPiece.BoardName;
            }
            else if (k == "labRoom")
            {
                roomName = "Alchemy Lab";
            }
            switch (sr.rooms[k])
            {
                case 1:
                    roomRes = " Created.";
                    break;
                case -1:
                    roomRes = " Damaged.";
                    break;
                case -10:
                    roomRes = " Destroyed.";
                    break;
            }

            res += "Room change: " + roomName + roomRes + "\n";
        }
        return res;
    }
Exemplo n.º 3
0
    public void leaveButtonClicked()
    {
        SpecialResults sr2 = new SpecialResults();
        XmlDocument doc = new XmlDocument();
        //XmlDocument xmlDoc = new XmlDocument();
        //XmlDocument nodeNameCollection = new XmlDocument();
        TextAsset textAsset = Resources.Load("XML/SpecialEvents", typeof(TextAsset)) as TextAsset;
        doc.LoadXml(textAsset.text);
       // doc.Load(specEvPath);
        GameObject[] nodes = GameObject.FindGameObjectsWithTag("LocationNode");
        for (int i = 0; i < nodes.Length; i++)
        {
            nodes[i].SetActive(false);
        }
        specialPanel.SetActive(false);
        resultPanel.SetActive(true);
        if (!specEv)
        {
            resultPanel.transform.FindChild("ResolutionScreen").FindChild("ResolutionText").GetComponent<Text>().text = allegiance2;
            XmlNodeList results = doc.SelectNodes(locationButton2);
            Debug.Log("Size of results: " + results.Count);
            foreach (XmlNode xn in results)
            {
                int value = int.Parse(xn.SelectSingleNode("neutral").InnerText);
                string name = xn.SelectSingleNode("name").InnerText;
                Debug.Log(xn.SelectSingleNode("type").InnerText);
                switch (xn.SelectSingleNode("type").InnerText)
                {
                    case "reputation":
                        sr2.reputations.Add(name, value);
                        break;
                    case "resource":
                        sr2.resources.Add(name, value);
                        break;
                    case "room":
                        sr2.rooms.Add(name, value);
                        break;
                }
            }
            resultPanel.transform.FindChild("OutcomeScreen").FindChild("Outcome").GetComponent<Text>().text = getFlavor(sr2);

        }
        else
        {
            resultPanel.transform.FindChild("ResolutionScreen").FindChild("ResolutionText").GetComponent<Text>().text = fight.resultflavor;
            string outcomeText = "";
            foreach (string s in fight.reputations.Keys)
            {
                outcomeText += s + ": -" + fight.neutral + "\n";
                DataManager.instance.Player.AddReputation(DataManager.instance.Factions[s], (-1) * fight.neutral);
            }
            resultPanel.transform.FindChild("ResolutionScreen").FindChild("ResolutionText").GetComponent<Text>().text = "You leave without interfering.";
            resultPanel.transform.FindChild("OutcomeScreen").FindChild("Outcome").GetComponent<Text>().text = outcomeText;
            fight = null;
        }
        DataManager.instance.ActiveDiplomaticEvent = null;// new SavedResult() ;
        DataManager.instance.specialActive = false;
    }