コード例 #1
0
        /*public void HealHP(int HPHealed)
         * {
         *  if (Health + HPHealed >= MAX_HP)
         *  {
         *      Health = MAX_HP;
         *  }else
         *  {
         *      Health += HPHealed;
         *  }
         * }
         * public void NextItem()
         * {
         *  int yk = rightHand + 1;
         *  int cntItem = Inventory.totalNumberofItems;
         *  while (!inventory.isInStock(yk % cntItem) || yk % cntItem == 0
         || Items.allItems[yk % cntItem] is Arrow)
         ++yk;
         || rightHand = yk % cntItem;
         ||}
         ||public void PrevItem()
         ||{
         || int yk = rightHand - 1;
         || int cntItem = Inventory.totalNumberofItems;
         || while (!inventory.isInStock((yk + cntItem) % cntItem) || (yk + cntItem) % cntItem == 0
         || Items.allItems[(yk + cntItem) % cntItem] is Arrow)
         ||     --yk;
         || rightHand = (yk + cntItem) % cntItem;
         ||}*/
        /*
         * public void NextArrow()
         * {
         *  int yk = inventory.getCurrentArrow().id + 1;
         *  int cntItem = Inventory.totalNumberofItems;
         *  while (!inventory.isInStock(yk % cntItem) || !(Items.allItems[yk % cntItem] is Arrow))
         ++yk;
         *  inventory.setCurrentArrow(yk % cntItem);
         * }
         * public void PrevArrow()
         * {
         *  int yk = inventory.getCurrentArrow().id - 1;
         *  int cntItem = Inventory.totalNumberofItems;
         *  while (!inventory.isInStock((yk + cntItem) % cntItem) || !(Items.allItems[(yk + cntItem) % cntItem] is Arrow))
         *      --yk;
         *  inventory.setCurrentArrow(yk % cntItem);
         * }
         */
        /*
         * public string LargeString()
         * {
         *  StringBuilder ans = new StringBuilder();
         *  ans.Append(Health);
         *  ans.Append(" ");
         *  ans.Append(rightHand);
         *  ans.Append(" ");
         *  ans.Append(RightReloadTimer.ElapsedMilliseconds);
         *  ans.Append(" ");
         *  ans.Append(inventory.LargeString());
         *  return ans.ToString();
         * }
         * public string SmallString()
         * {
         *  StringBuilder ans = new StringBuilder();
         *  ans.Append(Health);
         *  ans.Append(" ");
         *  ans.Append(rightHand);
         *  ans.Append(inventory.SmallString());
         *  return ans.ToString();
         * }
         */
        public void TakeSmallString(string s)
        {
            var pla_inv = s.Split('#');
            var arr     = pla_inv[0].Split(' ');

            Health    = Utily.Parse(arr[0]);
            rightHand = Utily.Parse(arr[1]);
            inventory.TakeSmallString(pla_inv[1]);
        }
コード例 #2
0
        public void TakeLargeString(string s)
        {
            var arr = s.Split(' ');

            Mana               = Utily.Parse(arr[0]);
            currentArrow       = Utily.Parse(arr[1]);
            totalNumberofItems = Utily.Parse(arr[2]);
            for (int i = 0; i < totalNumberofItems; ++i)
            {
                inventory[i] = Utily.Parse(arr[3 + i]);
            }
        }
コード例 #3
0
ファイル: Arena.cs プロジェクト: SecondDerivative/ArenaClient
        public int TakeAllString(string s)
        {
            var BigBlock = s.Split('#');

            //map.TakeString(BigBlock[0]);
            TakeString(BigBlock[1], BigBlock[2], BigBlock[3]);
            var           pla    = BigBlock[4].Split(';');
            HashSet <int> IsUsed = new HashSet <int>();

            for (int i = 0; i < pla.Length; i++)
            {
                int ind = pla[i].IndexOf(' ');
                int tag = Utily.Parse(pla[i].Substring(0, ind));
                if (!players.ContainsKey(tag))
                {
                    players.Add(tag, new Player());
                }
                else
                {
                    IsUsed.Add(tag);
                }
                players[tag].TakeSmallString(pla[i].Substring(ind + 1));
            }
            int MainPlayerTag;
            {
                int ind = BigBlock[5].IndexOf(' ');
                int tag = Utily.Parse(BigBlock[5].Substring(0, ind));
                if (!players.ContainsKey(tag))
                {
                    players.Add(tag, new Player());
                }
                else
                {
                    IsUsed.Add(tag);
                }
                players[tag].TakeLargeString(BigBlock[5].Substring(ind + 1));
                MainPlayerTag = tag;
            }
            List <int> ForRemove = new List <int>();

            foreach (var i in players)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                players.Remove(i);
            }
            return(MainPlayerTag);
        }
コード例 #4
0
 /*
  * public string LargeString()
  * {
  *  StringBuilder ans = new StringBuilder();
  *  ans.Append(Mana);
  *  ans.Append(" ");
  *  ans.Append(currentArrow);
  *  ans.Append(" ");
  *  ans.Append(totalNumberofItems);
  *  for (int i = 0; i < totalNumberofItems; i++)
  *  {
  *      ans.Append(" ");
  *      ans.Append(inventory[i]);
  *  }
  *  return ans.ToString();
  * }
  * public string SmallString()
  * {
  *  return currentArrow.ToString();
  * }
  */
 public void TakeSmallString(string s)
 {
     currentArrow = Utily.Parse(s);
 }
コード例 #5
0
ファイル: Arena.cs プロジェクト: SecondDerivative/ArenaClient
        public void TakeString(string Arrow, string Drop, string Player)
        {
            var           arr    = Arrow.Split(',');
            HashSet <int> IsUsed = new HashSet <int>();

            for (int i = 0; i < arr.Length; i++)
            {
                var small = arr[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int dmg   = Utily.Parse(small[1]);
                int id    = Utily.Parse(small[2]);
                if (Arrows.ContainsKey(tag))
                {
                    Arrows[tag].dmg = dmg;
                    Arrows[tag].id  = id;
                }
                else
                {
                    Arrows.Add(tag, new AArrow(dmg, id));
                    ArrowEvent.Enqueue(tag);
                }
                IsUsed.Add(tag);
            }
            List <int> ForRemove = new List <int>();

            foreach (var i in Arrows)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                    ArrowEvent.Enqueue(-i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                Arrows.Remove(i);
            }

            var dro = Drop.Split(',');

            IsUsed.Clear();
            for (int i = 0; i < arr.Length; i++)
            {
                var small = dro[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int cnt   = Utily.Parse(small[1]);
                int id    = Utily.Parse(small[2]);
                if (Drops.ContainsKey(tag))
                {
                    Drops[tag].Count = cnt;
                    Drops[tag].id    = id;
                }
                else
                {
                    Drops.Add(tag, new ADrop(cnt, id));
                    DropEvent.Enqueue(tag);
                }
                IsUsed.Add(tag);
            }
            ForRemove.Clear();
            foreach (var i in Drops)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                    DropEvent.Enqueue(-i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                Drops.Remove(i);
            }

            var pla = Player.Split(',');

            IsUsed.Clear();
            for (int i = 0; i < arr.Length; i++)
            {
                var small = pla[i].Split(' ');
                int tag   = Utily.Parse(small[0]);
                int kill  = Utily.Parse(small[1]);
                int death = Utily.Parse(small[2]);
                if (ArenaPlayer.ContainsKey(tag))
                {
                    ArenaPlayer[tag].RealName = small[3];
                    IsUsed.Add(tag);
                }
                else
                {
                    ArenaPlayer.Add(tag, new APlayer(small[3]));
                }
                ArenaPlayer[tag].Kill  = kill;
                ArenaPlayer[tag].Death = death;
            }
            ForRemove.Clear();
            foreach (var i in ArenaPlayer)
            {
                if (!IsUsed.Contains(i.Key))
                {
                    ForRemove.Add(i.Key);
                }
            }
            foreach (var i in ForRemove)
            {
                ArenaPlayer.Remove(i);
            }
        }