コード例 #1
0
ファイル: Run.cs プロジェクト: espilioto/TFOI
 public bool AddItem(Items item)
 {
     if (item.Id == "73")                            //if the item is cube of meat...
     {
         if (_cubeOfMeatLevel == 0)
         {
             RunItems.Add(item);
             _cubeOfMeatLevel++;
             return true;
         }
         else if (_cubeOfMeatLevel == 1)
         {
             RunItems.Add(Items.List.Find(com => com.Id == "73_2"));
             _cubeOfMeatLevel++;
             return true;
         }
         else if (_cubeOfMeatLevel == 2)
         {
             RunItems.Add(Items.List.Find(com => com.Id == "73_3"));
             _cubeOfMeatLevel++;
             return true;
         }
         else if (_cubeOfMeatLevel == 3)
         {
             RunItems.Add(Items.List.Find(com => com.Id == "73_4"));
             _cubeOfMeatLevel++;
             return true;
         }
         else
         {
             RunItems.Add(item);
             _cubeOfMeatLevel = 1;
             return true;
         }
     }
     else if (item.Id == "207")                      //...or ball of bandages, display upgrade instead of the lvl 1 orbital
     {
         if (_ballOfBandagesLevel == 0)
         {
             RunItems.Add(item);
             _ballOfBandagesLevel++;
             return true;
         }
         else if (_ballOfBandagesLevel == 1)
         {
             var asd = (Items.List.Find(bob => bob.Id == "207_2"));
             RunItems.Add(asd);
             _ballOfBandagesLevel++;
             return true;
         }
         else if (_ballOfBandagesLevel == 2)
         {
             RunItems.Add(Items.List.Find(bob => bob.Id == "207_3"));
             _ballOfBandagesLevel++;
             return true;
         }
         else if (_ballOfBandagesLevel == 3)
         {
             RunItems.Add(Items.List.Find(bob => bob.Id == "207_4"));
             _ballOfBandagesLevel++;
             return true;
         }
         else
         {
             RunItems.Add(item);
             _ballOfBandagesLevel = 1;
             return true;
         }
     }
     else if (!RunItems.Contains(item))               //check if the player already has picked up this item
     {
         RunItems.Add(item);
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #2
0
ファイル: Items.cs プロジェクト: espilioto/TFOI
        public static void ParseJsonItemList()
        {
            string json = File.ReadAllText(Environment.CurrentDirectory + @"\resources\JSON\JsonItemList.json");
            dynamic deserializedItems = JsonConvert.DeserializeObject(json);

            foreach (var jsonItem in deserializedItems)
            {
                var item = new Items();

                item.Id = jsonItem.Name;                                     //these four properties (should) exist for every item
                item.Name = jsonItem.First["name"];
                item.Text = jsonItem.First["text"];

                if (File.Exists(Environment.CurrentDirectory + @"\Resources\images\collectibles\" + item.Id + ".png"))
                {
                    item.Icon = new Bitmap(Environment.CurrentDirectory + @"\Resources\images\collectibles\" + item.Id + ".png");
                }
                else
                {
                    item.Icon = new Bitmap(Environment.CurrentDirectory + @"\Resources\images\collectibles\qm.png");
                }

                if (jsonItem.First["details"] != null)                                                              //string
                {
                    item.Details = jsonItem.First["details"];
                    item.DetailsString += item.Details.ToUpper() + Environment.NewLine;
                }

                if (jsonItem.First["health"] != null)                                                              //int
                {
                    item.Health = jsonItem.First["health"];
                    item.DetailsString += "HP: " + item.Health.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["soulhearts"] != null)
                {
                    item.SoulHearts = jsonItem.First["soulhearts"];
                    item.DetailsString += "SOUL HEARTS +" + item.SoulHearts.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["sinhearts"] != null)
                {
                    item.SinHearts = jsonItem.First["sinhearts"];
                    item.DetailsString += "SIN HEARTS +" + item.SinHearts.ToString() + Environment.NewLine;
                }

                if (jsonItem.First["healthOnly"] != null)                                                        //bool
                {
                    item.HealthOnly = jsonItem.First["healthOnly"];
                }
                if (jsonItem.First["space"] != null)
                {
                    item.Space = jsonItem.First["space"];
                }

                if (jsonItem.First["tform"] != null)                                                            //transformations
                {
                    item.Tform = jsonItem.First["tform"];
                }

                if (jsonItem.First["delay"] != null)                                                             //float
                {
                    item.Delay = jsonItem.First["delay"];
                    item.DetailsString += "TEAR DELAY: " + item.Delay.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["delayX"] != null)
                {
                    item.DelayX = jsonItem.First["delayX"];
                    item.DetailsString += "TEAR DELAY MULTI: " + item.DelayX.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["dmg"] != null)
                {
                    item.Damage = jsonItem.First["dmg"];
                    item.DetailsString += "DAMAGE: " + item.Damage.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["dmgX"] != null)
                {
                    item.DamageX = jsonItem.First["dmgX"];
                    item.DetailsString += "TEAR DAMAGE MULTI: " + item.DamageX.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["range"] != null)
                {
                    item.Range = jsonItem.First["range"];
                    item.DetailsString += "RANGE: " + item.Range.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["tears"] != null)
                {
                    item.Tears = jsonItem.First["tears"];
                    item.DetailsString += "TEARS: " + item.Tears.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["height"] != null)
                {
                    item.TearHeight = jsonItem.First["height"];
                    item.DetailsString += "TEAR HEIGHT: " + item.TearHeight.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["shotspeed"] != null)
                {
                    item.ShotSpeed = jsonItem.First["shotspeed"];
                    item.DetailsString += "SHOT SPEED: " + item.ShotSpeed.ToString() + Environment.NewLine;
                }
                if (jsonItem.First["speed"] != null)
                {
                    item.Speed = jsonItem.First["speed"];
                    item.DetailsString += "SPEED: " + item.Speed.ToString() + Environment.NewLine;
                }

                if (!string.IsNullOrEmpty(item.DetailsString))
                    if (item.DetailsString.EndsWith(Environment.NewLine))
                        item.DetailsString = item.DetailsString.TrimEnd(Environment.NewLine.ToCharArray());

                Items.List.Add(item);
            }
        }