示例#1
0
        public void ShortUpDateArrow(int Tag, int Time)
        {
            MArrow Ar = arrows[Tag];
            Tuple <double, double> Line = new Tuple <double, double>(Time * Ar.Speed.Item1 / 4.0, Time * Ar.Speed.Item2 / 4.0);

            if (IsEntityInSquare(Ar, true))
            {
                this.ForDelArrow.Enqueue(Tag);
                Q.Enqueue(new MEventDestroyArrow(Tag));
                return;
            }
            arrows[Tag].x += Line.Item1;
            arrows[Tag].y += Line.Item2;
            foreach (var p in players)
            {
                if (IsCrossEntity(p.Value, Ar))
                {
                    Q.Enqueue(new MEventArrowHit(Tag, p.Key));
                    this.ForDelArrow.Enqueue(Tag);
                    return;
                }
            }
            if (IsEntityInSquare(arrows[Tag], true))
            {
                Q.Enqueue(new MEventDestroyArrow(Tag));
                this.ForDelArrow.Enqueue(Tag);
            }
        }
示例#2
0
        public static MArrow Load(string save)
        {
            string[] args = save.Split().ToArray();
            int      Tag = int.Parse(args[0]);
            double   x = double.Parse(args[1]), y = double.Parse(args[2]);
            MArrow   Ar = new MArrow(Tag, x, y);

            return(Ar);
        }
示例#3
0
        public static MArrow Load(string save)
        {
            string[] args = save.Split().ToArray();
            int      Tag  = int.Parse(args[0]);
            bool     tmp;
            bool     Exist = Boolean.TryParse(args[1], out tmp);
            double   x = double.Parse(args[2]), y = double.Parse(args[3]);
            MArrow   Ar = new MArrow(Tag, x, y, double.Parse(args[4]), double.Parse(args[5]));

            Ar.Exist = Exist;
            return(Ar);
        }
示例#4
0
        public void LoadMap(string path)
        {
            using (StreamReader sr = File.OpenText(path))
            {
                string        s    = "";
                List <string> args = new List <string>();
                while ((s = sr.ReadLine()) != null)
                {
                    args.Add(s);
                }
                int[] tmp = args[0].Split().Select(x => int.Parse(x)).ToArray();
                this.width = tmp[0]; this.height = tmp[1];
                int couPl = int.Parse(args[1]);
                this.players = new Dictionary <int, MPlayer>();
                for (int i = 2; i < couPl + 2; ++i)
                {
                    string   stmp = args[i];
                    string[] Tmp  = stmp.Split().ToArray();
                    this.players.Add(int.Parse(Tmp[0]), MPlayer.Load(stmp));
                }
                int couArr = int.Parse(args[couPl + 2]);
                this.arrows = new Dictionary <int, MArrow>();
                for (int i = couPl + 3; i < couPl + 3 + couArr; ++i)
                {
                    string   stmp = args[i];
                    string[] Tmp  = stmp.Split().ToArray();
                    this.arrows.Add(int.Parse(Tmp[0]), MArrow.Load(stmp));
                }
                int couDro = int.Parse(args[couArr + couPl + 3]);
                this.drops = new Dictionary <int, MDrop>();
                for (int i = couPl + 4 + couArr; i < couPl + 4 + couArr + couDro; ++i)
                {
                    string   stmp = args[i];
                    string[] Tmp  = stmp.Split().ToArray();
                    this.drops.Add(int.Parse(Tmp[0]), MDrop.Load(stmp));
                }
                int nowline    = 4 + couArr + couDro + couPl;
                int countSpawn = int.Parse(args[nowline]);
                ++nowline;
                spawners = new List <Tuple <double, double> >();
                for (int i = 0; i < countSpawn; ++i)
                {
                    int x = int.Parse(args[nowline].Split()[0]), y = int.Parse(args[nowline].Split()[1]);
                    ++nowline;
                    spawners.Add(Utily.MakePair <double>(x, y));
                }
                int countSpawnDrop = int.Parse(args[nowline]);
                ++nowline;
                dropSpawners = new List <DropSpawner>();
                for (int i = 0; i < countSpawnDrop; ++i)
                {
                    int x = int.Parse(args[nowline].Split()[0]), y = int.Parse(args[nowline].Split()[1]);
                    int cnt = int.Parse(args[nowline].Split()[2]), id = int.Parse(args[nowline].Split()[3]);
                    ++nowline;
                    dropSpawners.Add(new DropSpawner(x, y, id, cnt));
                }
                tmp         = args[nowline].Split().Select(x => int.Parse(x)).ToArray();
                this.Pwidth = tmp[0] + 2; this.Pheight = tmp[1] + 2;
                this.Field  = new List <List <Square> >();
                for (int x = 0; x < this.Pwidth; ++x)
                {
                    this.Field.Add(new List <Square>());
                }

                for (int i = 0; i < this.Pwidth; i++)
                {
                    this.Field[i].Add(new Square(i, 0, 1));
                }
                for (int i = 1; i < this.Pheight - 1; i++)
                {
                    this.Field[0].Add(new Square(0, i, 1));
                    this.Field[this.Pwidth - 1].Add(new Square(this.Pwidth - 1, i, 1));
                }
                for (int y = 1; y < this.Pheight - 1; ++y)
                {
                    string line = args[y + nowline].Trim();
                    int[]  agrs = line.Split().Select(x => int.Parse(x)).ToArray();
                    for (int x = 1; x < Pwidth - 1; ++x)
                    {
                        this.Field[x].Add(new Square(x, y, agrs[x - 1]));
                    }
                }
                for (int i = 0; i < this.Pwidth; i++)
                {
                    this.Field[i].Add(new Square(i, this.Pheight - 1, 1));
                }
            }
        }