示例#1
0
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public static List <StoryLevelData> getStoryLevelDataFromXML(/*string level_Name*/)
    {
        List <StoryLevelData> levels  = new List <StoryLevelData>();
        XmlDocument           xml_doc = new XmlDocument();

        xml_doc.Load("Assets/Resources/level.xml");
        XmlNodeList levelsInfo;

        levelsInfo = xml_doc.SelectNodes("LEVELS/SURVIVAL/LEVEL");

        if (levelsInfo != null)
        {
            for (int i = 0; i < levelsInfo.Count; i++)
            {
                XmlNode        nextLevelInfo = levelsInfo.Item(i);
                StoryLevelData level         = new StoryLevelData();
                level.spaceshipForce    = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[0].InnerText);
                level.spaceshipMaxSpeed = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[1].InnerText);
                level.numberOfAliens    = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[2].InnerText);
                level.numberOfAsteroids = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[3].InnerText);
                level.forceAsteroids    = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[4].InnerText);
                level.numberOfTrash     = int.Parse(((XmlElement)nextLevelInfo).GetElementsByTagName("VARIABLE")[5].InnerText);
                levels.Add(level);
            }
        }
        return(levels);
    }
示例#2
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        //
        intro = GetComponent <StoryIntro>();
        intro.StartEvent();
        // Set the game mode
        gameManagerSingleton.CurrentGameMode = GameMode.Story;
        // Get the level data
        levelData = gameManagerSingleton.CurrentStoryLevelData;
        // Set the little aliens
        aliens = new List <GameObject>();
        for (int i = 0; i < levelData.numberOfAliens; i++)
        {
            // Debug.Log("Spawning little alien");
            if (alienPrefab != null)
            {
                // Revisar como organizarse con los límites
                float      x             = Random.Range(-80.0f, 80.0f);
                float      z             = Random.Range(0.0f, 180.0f);
                Vector3    alienPosition = new Vector3(x, 0, z);
                GameObject newAlien      = Instantiate(alienPrefab, alienPosition, Quaternion.identity);
                aliens.Add(newAlien);
            }
        }
        //
        playerWayPoints = new List <GameObject>(levelData.numberOfTrash);
        for (int i = 0; i < levelData.numberOfTrash; i++)
        {
            GameObject newWaypoint = Instantiate(trashPrefab, Vector3.zero, Quaternion.identity);
            newWaypoint.SetActive(false);
            playerWayPoints.Add(newWaypoint);
        }
        //
        hud = FindObjectOfType <HUDstory> ();

        // Assign the rest of the data
        // NOTE: This should be in BaseLevelManager, have to find the way
        asteroidManager.numAsteroids = levelData.numberOfAsteroids;
        ship.force    = levelData.spaceshipForce;
        ship.maxSpeed = levelData.spaceshipMaxSpeed;
    }