Example #1
0
File: BBC.cs Project: YAAnon/YAAB
    public static void bbc(string[] command)
    {
        string pageToRetrieve = "", retrievedPage;

        if (command.Length != 2)
        {
            BaseFunctions.message("Possible combinations are: \"?bbc \" + (\"tech\" | \"world\" | \"top\" | \"sci\")");
            return;
        }

        switch (command[1])
        {
            case "tech":
                pageToRetrieve = "http://feeds.bbci.co.uk/news/technology/rss.xml";
                break;

            case "sci":
                pageToRetrieve = "http://feeds.bbci.co.uk/news/science_and_environment/rss.xml";
                break;

            case "world":
                pageToRetrieve = "http://feeds.bbci.co.uk/news/world/rss.xml";
                break;

            case "top":
                pageToRetrieve = "http://feeds.bbci.co.uk/news/rss.xml";
                break;
        }

        if(pageToRetrieve == "")
            BaseFunctions.message("Bad command - possible combinations are: \"?bbc \" + (\"tech\" | \"world\" | \"top\" | \"sci\")");

        retrievedPage = fetchUrl(pageToRetrieve);

        xmlReader = XmlReader.Create(new StringReader(retrievedPage)); // create xmlreader to parse the page
        Console.WriteLine("got xml data");

        xmlReader.ReadToFollowing("title"); //the BBC put two title's in their rss feeds, so this skips one

        BaseFunctions.message(returnContent("title"));

        for (int i = 0; i < 3; i++)
        {
            string message;
            message = "--- " + returnContent("title") + " - " + returnContent("guid");

            BaseFunctions.message(message);

            System.Threading.Thread.Sleep(50);
        }
    }
Example #2
0
    private static int[][][] loadSpriteLayer(XmlReader mapReader, int levelNum)
    {
        int[][][] layer;

        int width = Int32.Parse(mapReader[1]);
        int height = Int32.Parse(mapReader[2]);

        layer = new int[height][][];
        for (int i = 0; i < height; i++) {
            layer[i] = new int[width][];
            for (int j = 0; j < width; j++) {
                layer[i][j] = new int[4];
            }
        }

        for (int i = 0; i < height * width; i++) {
            mapReader.ReadToFollowing("tile");
            uint val = UInt32.Parse(mapReader[0]);
            int sprite = 0;

            int xflip = 0;
            xflip = (int)(val & (1 << 31));
            if (xflip != 0) {
                xflip = 1;

                if (sprite != 0) {
                    sprite = (int)sprite & ~(1 << 31);
                } else {
                    sprite = (int)val & ~(1 << 31);
                }
            }

            int yflip = 0;
            yflip = (int)(val & (1 << 30));
            if (yflip != 0) {
                yflip = 1;
                if (sprite != 0) {
                    sprite = (int)sprite & ~(1 << 30);
                } else {
                    sprite = (int)val & ~(1 << 30);
                }
            }

            int rotate = 0;
            rotate = (int)(val & (1 << 29));
            if (rotate != 0) {
                rotate = 1;
                if (sprite != 0) {
                    sprite = (int)sprite & ~(1 << 29);
                } else {
                    sprite = (int)val & ~(1 << 29);
                }
            }

            if (sprite == 0) {
                sprite = (int)val;
            }

            layer[i / width][i % width][0] = sprite;
            layer[i / width][i % width][1] = xflip;
            layer[i / width][i % width][2] = yflip;
            layer[i / width][i % width][3] = rotate;
        }
        return layer;
    }
Example #3
0
    private static int[,] loadCollisionLayer(XmlReader mapReader)
    {
        int[,] layer;

        int width = Int32.Parse(mapReader[1]);
        int height = Int32.Parse(mapReader[2]);

        layer = new int[height, width];
        for (int i = 0; i < height * width; i++) {
            mapReader.ReadToFollowing("tile");
            uint col = UInt32.Parse(mapReader[0]);
            if (col != 0)
                layer[i / width, i % width] = (int)col;
            else
                layer[i / width, i % width] = 0;
        }
        return layer;
    }
Example #4
0
	/// <summary>
	/// Load an instance using the specified reader.
	/// </summary>
	/// <param name="reader">Reader.</param>
	public override void Load (XmlReader reader)
	{
		reader.ReadToFollowing ("Wizard");
		base.Load (reader);
		reader.ReadEndElement ();
	}
	private void LoadEnemies(XmlReader reader) {
		reader.ReadStartElement("Enemies");

		GameObject enemy = null;
		bool enemyToParse = reader.ReadToFollowing ("Enemy");
		Debug.Log ("Started parsing enemies..." + enemyToParse);
		do {
			if(!enemyToParse)
				break;
			
			Debug.Log ("Found an enemy");
			switch (reader.GetAttribute ("Type")) {
			case "Bat":
				enemy = Instantiate (prefabDictionary ["Bat"]);
				break;
			case "Blob":
				enemy = Instantiate (prefabDictionary ["Blob"]);
				break;
			} 
			enemy.GetComponent<Enemy> ().Load (reader);
		} while(reader.ReadToNextSibling("Enemy"));

	}
Example #6
0
	protected void LoadPosition(XmlReader reader) {
		reader.ReadToFollowing ("Position");
		reader.ReadToDescendant ("x");
		Vector3 loadedPosition = new Vector3 ();
		loadedPosition.x = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("y");
		loadedPosition.y = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("z");
		loadedPosition.z = reader.ReadElementContentAsFloat ();
		transform.position = loadedPosition;
		reader.ReadEndElement ();
	}
Example #7
0
	protected virtual void LoadStatus (XmlReader reader) {
		reader.ReadToFollowing ("Status");
		reader.ReadToDescendant ("HP");
		HP = reader.ReadElementContentAsInt ();
	}