Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Audio;
  7. using Microsoft.Xna.Framework.Content;
  8. using Microsoft.Xna.Framework.GamerServices;
  9. using Microsoft.Xna.Framework.Graphics;
  10. using Microsoft.Xna.Framework.Input;
  11. using Microsoft.Xna.Framework.Media;
  12. using Microsoft.Xna.Framework.Net;
  13. using Microsoft.Xna.Framework.Storage;
  14. using System.IO;
  15.  
  16. namespace Platformer
  17. {
  18.     public class Level
  19.     {
  20.         //Content
  21.         private int[] x = new int[100 * 16];
  22.         private int[] y = new int[100 * 16];
  23.  
  24.         StreamReader stream;
  25.         Tank pl1;
  26.         Tank pl2;
  27.  
  28.         public Level(StreamReader fajl, ref Tank p1, ref Tank p2)
  29.         {
  30.             stream = fajl;
  31.            
  32.             pl1 = p1;
  33.             pl2 = p2;
  34.  
  35.             init();
  36.         }
  37.  
  38.         public void init()
  39.         {
  40.             int i = 0;
  41.  
  42.             while (!stream.EndOfStream)
  43.             {
  44.                 string sor = stream.ReadLine();
  45.                 string[] splitelt = sor.Split(',');
  46.  
  47.                 if (i <= 1)
  48.                 {
  49.                     if (i == 0)
  50.                         pl1.SetPos(new Vector2(Convert.ToInt32(splitelt[0]), Convert.ToInt32(splitelt[1])));
  51.  
  52.                     if (i == 1)
  53.                         pl2.SetPos(new Vector2(Convert.ToInt32(splitelt[0]), Convert.ToInt32(splitelt[1])));
  54.                 }
  55.                 else
  56.                 {
  57.                     x[i] = Convert.ToInt32(splitelt[0]);
  58.                     y[i] = Convert.ToInt32(splitelt[1]);
  59.                 }
  60.  
  61.                 i += 1;
  62.             }
  63.         }
  64.  
  65.         public int[] GetContentX()
  66.         {
  67.             return x;
  68.         }
  69.         public int[] GetContentY()
  70.         {
  71.             return y;
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement