示例#1
0
    private void setNameAndFlavor(string type, NodeStats ns)
    {
        // Get name of nodes from xml
        //XmlDocument nodeNameCollection = new XmlDocument();
        //nodeNameCollection.Load("assets/scripts/XML/NodeNode.xml");
        XmlDocument nodeNameCollection = new XmlDocument();
        TextAsset textAsset = Resources.Load("XML/NodeNode", typeof(TextAsset)) as TextAsset;
        nodeNameCollection.LoadXml(textAsset.text);

        XmlNodeList nameList = nodeNameCollection.SelectNodes("NodeNode/" + type + "/nodeFlavour");
        int selectedTitle = Random.Range(0, 5);
        ns.nodeEvent.SetLocType(selectedTitle);
        /*switch (ns.nodeEvent.locType)
        {
            case Location.MINE:
                selectedTitle = 0;
                break;
            case Location.QUARRY:
                selectedTitle = 1;
                break;
            case Location.WRECKAGE:
                selectedTitle = 2;
                break;
            case Location.FACTORY:
                selectedTitle = 3;
                break;
            case Location.VILLAGE:
                selectedTitle = 4;
                break;
            case Location.FOREST:
                selectedTitle = 0;
                break;
            case Location.ROCKFORMATION:
                selectedTitle = 1;
                break;
            case Location.MAGICSITE:
                selectedTitle = 2;
                break;
            case Location.LAKE:
                selectedTitle = 3;
                break;
            case Location.RUINS:
                selectedTitle = 4;
                break;

        }
        */
        string titlename = nameList.Item(selectedTitle).SelectSingleNode("name").InnerText;
        string flavour = nameList.Item(selectedTitle).SelectSingleNode("flavour").InnerText;
        ns.TitleName = titlename;
        //ns.islandName = DataManager.instance.ActiveNode.islandName;
        ns.FlavourText = flavour;
    }
示例#2
0
    /// <summary>
    /// Generates the stats for the individual nodes in the world node
    /// </summary>
    /// <param name="newNode"></param>
    private void generateNodeStats(Vector3 position, NodeType type)
    {
        WorldNodeStats wns = new WorldNodeStats();
        // Set position and type
        wns.Position = position;
        wns.Type = type;

        //check for duplications
        bool duplicate = false;

        foreach (WorldNodeStats wn in DataManager.instance.Nodes)
        {
            if (wn.Position == wns.Position)
            {
                if (wns.Type == NodeType.GOAL && wn.Type != NodeType.GOAL)
                {
                    wn.Type = NodeType.GOAL;
                }
                //Debug.Log("Duplicate found and removed");
                duplicate = true;
                break;
            }
        }

        // if there is no duplicate
        if (!duplicate)
        {
            // Assign faction
            int[] ranFacArr = DataManager.randomArray(DataManager.instance.Factions.Count);
            int countFac = 0;
            foreach (KeyValuePair<string, Faction> pair in DataManager.instance.Factions)
            {
                if (ranFacArr[0] == countFac)
                {
                    wns.NodeFaction = pair.Value;
                }
                countFac++;
            }
            // Set name and description
            XmlDocument worldNodesDoc = new XmlDocument();
            TextAsset textAsset = Resources.Load("XML/WorldNode", typeof(TextAsset)) as TextAsset;
            //XmlDocument xmlDoc = new XmlDocument();
            worldNodesDoc.LoadXml(textAsset.text);
            //worldNodesDoc.Load("assets/scripts/XML/WorldNode.xml");
            XmlNodeList worldNodes = worldNodesDoc.SelectNodes("WorldNodes/WorldNode");
            int[] nameOrder = DataManager.randomArray(worldNodes.Count);

            wns.WorldName = worldNodes[nameOrder[0]].SelectSingleNode("name").InnerText;

            //Set description based on faction
            //wns.Description = worldNodes[nameOrder[0]].SelectSingleNode("description").InnerText;

            wns.Description = "You spot an island floating in the distance. It seems to be controlled by the " + wns.NodeFaction.BoardName;

            // set the events
            int[] eventTypeOrder = DataManager.randomArray(2);
            int numIntNodes = eventTypeOrder.Length;

            for (int j = 0; j < numIntNodes; j++)
            {
                // The position of the nodes are currently just at 3 different points
                Vector3 intNodePos = new Vector3(-5 + j * 5, 0);
                NodeStats ns = new NodeStats();
                Event ev = new Event();
                ns.Position = intNodePos;
                ns.nodeEvent = ev;
                ns.setEventType(eventTypeOrder[j]);
                wns.Nodes.Add(ns);
                switch (ns.type)
                {
                    case EventSpec.GATHER:
                        setNameAndFlavor("Gather", ns);
                        break;/*
                    case EventSpec.DIPLOMACY:
                        setNameAndFlavor("Diplomacy", ns);
                        break;*/
                    case EventSpec.RESEARCH:
                        setNameAndFlavor("Research", ns);
                        break;
                }
            }
            DataManager.instance.Nodes.Add(wns);
        }
    }