コード例 #1
0
        public int AddPlayer(string name)
        {
            int tag = Utily.GetTag();

            players[tag] = new Player();
            players[tag].respawn();
            ArenaPlayer[tag] = new APlayer(name);
            map.AddPlayer(tag);
            map.SpawnPlayer(tag);
            return(tag);
        }
コード例 #2
0
        public void Update()
        {
            map.UpDate();
            MEvent Event;

            while ((Event = map.NextEvent()) != null)
            {
                if (Event.Type == MEvents.PlayerArrow)
                {
                    int TagArrow  = ((MEventArrowHit)Event).TagArrow;
                    int TagPlayer = ((MEventArrowHit)Event).TagPlayer;
                    players[TagPlayer].recieveDamage(Arrows[TagArrow].dmg);
                    if (players[TagPlayer].isDead())
                    {
                        if (ArenaPlayer.ContainsKey(Arrows[TagArrow].creater))
                        {
                            ArenaPlayer[Arrows[TagArrow].creater].AddKill();
                        }
                        ArenaPlayer[TagPlayer].AddDeath();
                        if (players[TagPlayer].rightHand != 1)
                        {
                            int NewTag = Utily.GetTag();
                            Drops.Add(NewTag, new ADrop(1, players[TagPlayer].rightHand));
                            map.SpawnDrops(NewTag, map.players[TagPlayer].x, map.players[TagPlayer].y);
                        }
                        map.SpawnPlayer(TagPlayer);
                        players[TagPlayer].respawn();
                    }
                    Arrows.Remove(TagArrow);
                }
                if (Event.Type == MEvents.PlayerDrop)
                {
                    var drop = Drops[((MEventDrop)Event).TagDrop];
                    players[((MEventDrop)Event).TagPlayer].pickedUpItem(drop.id, drop.Count);
                    Drops.Remove(((MEventDrop)Event).TagDrop);
                    if (((MEventDrop)Event).BySpawner)
                    {
                        DropForRespawn.Enqueue(Utily.MakePair <long, int>(timer.ElapsedMilliseconds, ((MEventDrop)Event).NumSpawner));
                    }
                }
                if (Event.Type == MEvents.DestroyArrow)
                {
                    Arrows.Remove(((MEventDestroyArrow)Event).TagArrow);
                }
            }
            while (DropForRespawn.Count > 0 && DropForRespawn.Peek().Item1 + WaitRespawnDrop < timer.ElapsedMilliseconds)
            {
                int num = DropForRespawn.Dequeue().Item2;
                int tag = Utily.GetTag();
                map.SpawnDrops(num, tag);
                Drops.Add(tag, new ADrop(map.dropSpawners[num].count, map.dropSpawners[num].id));
            }
        }
コード例 #3
0
        public static MPlayer Load(string save)
        {
            string[] args = save.Split().ToArray();
            bool     tmp;
            bool     Exist = Boolean.TryParse(args[0], out tmp);
            double   x = double.Parse(args[1]), y = double.Parse(args[2]);
            Tuple <double, double> Speed = new Tuple <double, double>(double.Parse(args[3]), double.Parse(args[4]));
            MPlayer Pl = new MPlayer(Utily.GetTag(), x, y);

            Pl.Speed = Speed;
            Pl.Exist = Exist;
            return(Pl);
        }
コード例 #4
0
 public void NewMap(string name)
 {
     map = new Map("./data/Maps/" + name + ".txt");
     foreach (var i in players)
     {
         map.AddPlayer(i.Key);
         players[i.Key].respawn();
     }
     Arrows.Clear();
     Drops.Clear();
     DropForRespawn.Clear();
     for (int i = 0; i < map.dropSpawners.Count; ++i)
     {
         int tag = Utily.GetTag();
         map.SpawnDrops(i, tag);
         Drops.Add(tag, new ADrop(map.dropSpawners[i].count, map.dropSpawners[i].id));
     }
     timer.Restart();
 }
コード例 #5
0
        public int FirePlayer(int tag, Tuple <double, double> vect)
        {
            int dmg = players[tag].attack();

            if (dmg <= 0)
            {
                return(-1);
            }
            Tuple <double, double> NewVect = Utily.Normalizing(vect, players[tag].ArrowSpeed());
            int arTag = Utily.GetTag();
            int nowid = players[tag].inventory.getCurrentArrow().id;

            if (players[tag].getItemRight() is Magic)
            {
                nowid = players[tag].rightHand;
            }
            Arrows[arTag] = new AArow(tag, dmg, nowid);
            map.FirePlayer(tag, arTag, NewVect.Item1, NewVect.Item2);
            return(arTag);
        }