Exemplo n.º 1
0
        public List <Pet> FindAllPetsByColor(PetColor theColor, FilterModel filter = null)
        {
            List <PetColorPet> petColorPets = _ctx.PetColorPets.Where(cp => cp.petColor == theColor).ToList();
            IEnumerable <Pet>  thePets      = new List <Pet>();

            foreach (var colorPet in petColorPets)
            {
                thePets = thePets.Concat(new List <Pet> {
                    colorPet.Pet
                });
            }
            if (filter == null)
            {
                return(thePets.ToList());
            }
            else
            {
                thePets.Skip((filter.CurrentPage - 1) * filter.ItemsPrPage)
                .Take(filter.ItemsPrPage);

                if (string.IsNullOrEmpty(filter.SortOrder))
                {
                    return(thePets.ToList());
                }
                else if (filter.SortOrder.ToLower().Equals("desc"))
                {
                    return(thePets.OrderByDescending(p => p.PetName).ToList());
                }
                else
                {
                    return(thePets.OrderBy(p => p.PetName).ToList());
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Given the pet color name, find the sprites that needs to be swapped and swap them
 /// </summary>
 /// <param name="petColor">Pet color.</param>
 private void SwapColor(PetColor color)
 {
     if (color == PetColor.OrangeYellow)
     {
         return;             // This is the default sprite already
     }
     else
     {
         if (sprite1 != null)
         {
             Sprite spriteLoaded = Resources.Load <Sprite>(sprite1Prefix + color.ToString());
             sprite1.sprite = spriteLoaded;
         }
         if (sprite2 != null)
         {
             Sprite spriteLoaded = Resources.Load <Sprite>(sprite2Prefix + color.ToString());
             sprite2.sprite = spriteLoaded;
         }
         if (sprite3 != null)
         {
             Sprite spriteLoaded = Resources.Load <Sprite>(sprite3Prefix + color.ToString());
             sprite3.sprite = spriteLoaded;
         }
         if (sprite4 != null)
         {
             Sprite spriteLoaded = Resources.Load <Sprite>(sprite4Prefix + color.ToString());
             sprite4.sprite = spriteLoaded;
         }
         if (sprite5 != null)
         {
             Sprite spriteLoaded = Resources.Load <Sprite>(sprite5Prefix + color.ToString());
             sprite5.sprite = spriteLoaded;
         }
     }
 }
Exemplo n.º 3
0
        public PetColor AddNewPetColor(PetColor theNewColor)
        {
            var theColor = _ctx.PetColors.Add(theNewColor).Entity;

            _ctx.SaveChanges();
            return(theColor);
        }
Exemplo n.º 4
0
        public PetColor DeletePetColor(PetColor toBeDeletedPetColor)
        {
            var deletedColor = _ctx.Remove(toBeDeletedPetColor).Entity;

            _ctx.SaveChanges();
            return(deletedColor);
        }
        public List <Pet> FindAllPetsByColor(PetColor pcolor, FilterModel filter = null)
        {
            List <PetColorPet> coloredPets = _ptx.PetColorPet.Where(p => p.PetColor == pcolor).ToList();
            IEnumerable <Pet>  pets        = new List <Pet>();

            foreach (var colorpets in coloredPets)
            {
                pets = pets.Concat(new List <Pet> {
                    colorpets.Pet
                });
            }
            if (filter == null)
            {
                return(pets.ToList());
            }
            else
            {
                pets.Skip(filter.CurrentPage - 1 * filter.ItemsOnPage).Take(filter.ItemsOnPage);

                if (string.IsNullOrEmpty(filter.OrganizeOrder))
                {
                    return(pets.ToList());
                }
                else if (filter.OrganizeOrder.ToLower().Equals("desc"))
                {
                    return(pets.OrderByDescending(p => p.Name).ToList());
                }
                else
                {
                    return(pets.OrderBy(p => p.Name).ToList());
                }
            }
        }
Exemplo n.º 6
0
        public PetColor UpdatePetColor(PetColor theNewPetColor)
        {
            var updatedColor = _ctx.Update(theNewPetColor).Entity;

            _ctx.SaveChanges();
            return(updatedColor);
        }
        public PetColor CreatePetColor(PetColor newPetColor)
        {
            var petColor = _ptx.Add(newPetColor).Entity;

            _ptx.SaveChanges();
            return(petColor);
        }
        public PetColor DeletePetColor(PetColor deletePetColor)
        {
            var deleteColor = _ptx.Remove(deletePetColor).Entity;

            _ptx.SaveChanges();
            return(deleteColor);
        }
        public PetColor UpdatePetColor(PetColor updatePetColor)
        {
            var updatecolor = _ptx.Update(updatePetColor).Entity;

            _ptx.SaveChanges();
            return(updatecolor);
        }
Exemplo n.º 10
0
 public PetUpgradeRequirement(XElement element)
 {
     m_Color   = (PetColor)Enum.Parse(typeof(PetColor), element.GetString("color"));
     m_Entries = element.Elements("element").Select(e => {
         return(new IDCountPair(e));
     }).ToList();
 }
Exemplo n.º 11
0
 public void ParseInfo(Hashtable info)
 {
     m_Raw      = info;
     m_Id       = info.GetValueString((int)SPC.Id);
     m_Binded   = info.GetValueBool((int)SPC.Binded);
     m_PetColor = (PetColor)info.GetValueInt((int)SPC.PetColor, (int)PetColor.gray);
     isNew      = info.GetValueBool((int)SPC.IsNew);
 }
Exemplo n.º 12
0
 public void ParseInfo(Hashtable info)
 {
     m_Raw    = info;
     m_Id     = info.GetValue <string>((int)SPC.Id, string.Empty);
     m_Binded = info.GetValue <bool>((int)SPC.Binded, false);
     m_Color  = (PetColor)info.GetValue <int>((int)SPC.PetColor, (int)PetColor.gray);
     isNew    = info.GetValue <bool>((int)SPC.IsNew, false);
 }
Exemplo n.º 13
0
        public PetSchemeObject(string id, PetColor petColor, bool binded = false)
        {
            m_Id     = id;
            m_Binded = binded;
            m_Color  = petColor;
            isNew    = true;

            m_Raw = GetInfo();
        }
Exemplo n.º 14
0
 public void ChangeColor(PetColor petColorEnum)
 {
     // Sould we do sanity color checking here?
     if (true)
     {
         IsDirty  = true;
         PetColor = petColorEnum.ToString();
     }
 }
Exemplo n.º 15
0
        public PetColorDropData GetColor(PetColor color)
        {
            PetColorDropData colorData;

            if (m_DropColors.TryGetValue(color, out colorData))
            {
                return(colorData);
            }
            return(null);
        }
Exemplo n.º 16
0
        public PetColorData GetColor(PetColor name)
        {
            PetColorData data;

            if (m_PetColors.TryGetValue(name, out data))
            {
                return(data);
            }
            return(null);
        }
Exemplo n.º 17
0
 private List <PetActiveSkill> GetActiveSkills(PetColor color, PetParameters parameters, PetDropSettings settings, PetSkillCollection skills)
 {
     if (settings.generateActiveSkills)
     {
         return(GenerateActiveSkills(color, parameters, skills));
     }
     else
     {
         return(settings.overwriteActiveSkills.Take(parameters.activeSkillCountTable[color]).ToList());
     }
 }
Exemplo n.º 18
0
 public PetUpgradeRequirement(XElement element)
 {
     m_Color   = (PetColor)Enum.Parse(typeof(PetColor), element.GetString("color"));
     m_Entries = element.Elements("element").Select(e => {
         IDCountPair pair = new IDCountPair {
             ID    = e.GetString("id"),
             count = e.GetInt("count")
         };
         return(pair);
     }).ToList();
 }
Exemplo n.º 19
0
        public DropItem Create(XElement element)
        {
            InventoryObjectType type = (InventoryObjectType)Enum.Parse(typeof(InventoryObjectType), element.GetString("type"));
            int   min  = element.GetInt("min");
            int   max  = element.GetInt("max");
            float prob = element.GetFloat("prob");

            switch (type)
            {
            case InventoryObjectType.Weapon:
                return(new WeaponDropItem(min, max, prob));

            case InventoryObjectType.Scheme:
                return(new SchemeDropItem(min, max, prob));

            case InventoryObjectType.Material: {
                string template = element.GetString("template");
                return(new MaterialDropItem(template, min, max, prob));
            }

            case InventoryObjectType.nebula_element: {
                string template = element.GetString("template");
                return(new NebulaElementDropItem(template, min, max, prob));
            }

            case InventoryObjectType.craft_resource: {
                string template = element.GetString("template");
                return(new CraftResourceDropItem(template, min, max, prob));
            }

            case InventoryObjectType.pet_scheme: {
                PetColor color    = (PetColor)Enum.Parse(typeof(PetColor), element.GetString("color"));
                string   template = element.GetString("template");
                return(new PetSchemeDropItem(template, color, min, max, prob));
            }

            case InventoryObjectType.contract_item: {
                string template = element.GetString("template");
                string contract = element.GetString("contract");
                return(new ContractObjectDropItem(template, contract, min, max, prob));
            }

            case InventoryObjectType.planet_resource_hangar: {
                return(new PlanetHangarDropItem(min, max, prob));
            }

            case InventoryObjectType.planet_resource_accelerator: {
                return(new PlanetResourceAcceleratorDropItem(min, max, prob));
            }

            default:
                return(null);
            }
        }
Exemplo n.º 20
0
 public IntFloatPetParameter GetParameter(PetColor color)
 {
     if (m_Parameters.ContainsKey(color))
     {
         IntFloatPetParameter parameter;
         if (m_Parameters.TryGetValue(color, out parameter))
         {
             return(parameter);
         }
     }
     return(null);
 }
Exemplo n.º 21
0
 public PetInfo()
 {
     m_Id           = Guid.NewGuid().ToString();
     m_Exp          = 0;
     m_Color        = PetColor.gray;
     m_Type         = string.Empty;
     m_PassiveSkill = -1;
     m_ActiveSkills = new List <PetActiveSkill>();
     m_Active       = false;
     m_DamageType   = WeaponDamageType.damage;
     m_KilledTime   = 0;
     m_Mastery      = 0;
 }
Exemplo n.º 22
0
        public static AbstractFactory GetFactory(PetColor color)
        {
            AbstractFactory factory = null;

            switch (color)
            {
            case PetColor.BLACK:
                factory = _blackPet;
                break;

            case PetColor.WHITE:
                factory = _whitePet;
                break;
            }

            return(factory);
        }
Exemplo n.º 23
0
        private void GeneratePetScheme(Race race, string template, PetColor color, int count, ConcurrentDictionary <string, ServerInventoryItem> newObjects)
        {
            if (string.IsNullOrEmpty(template))
            {
                if (race != Race.None)
                {
                    template = resource.petParameters.defaultModels[race];
                }
                else
                {
                    template = "hp_1";
                }
            }
            PetSchemeObject obj = new PetSchemeObject(template, color, false);

            newObjects.TryAdd(obj.Id, new ServerInventoryItem(obj, count));
        }
Exemplo n.º 24
0
 public ActionResult <PetColor> Post([FromBody] PetColor theNewColor)
 {
     if (string.IsNullOrEmpty(theNewColor.PetColorName))
     {
         return(BadRequest("You need to enter a name to create a new Color."));
     }
     else
     {
         try
         {
             return(Created("Successfully created the following petColor", _petColorService.AddNewPetColor(theNewColor)));
         }
         catch (Exception e)
         {
             return(StatusCode(500, e.Message));
         }
     }
 }
Exemplo n.º 25
0
 public ActionResult <PetColor> Post([FromBody] PetColor newPetColor)
 {
     if (string.IsNullOrEmpty(newPetColor.NameOfPetColor))
     {
         return(BadRequest("Write a name for a new color. COME ON! Kindergarteners can do this!"));
     }
     else
     {
         try
         {
             return(Created("Created this new color", _petColorService.CreatePetColor(newPetColor)));
         }
         catch (Exception e)
         {
             return(StatusCode(500, e.Message));
         }
     }
 }
Exemplo n.º 26
0
 public ActionResult <PetColor> Get(int id)
 {
     try
     {
         PetColor theColor = _petColorService.FindPetColorByIdWithPets(id);
         if (theColor == null)
         {
             return(NotFound("I am sorry could not find a type with that Id."));
         }
         else
         {
             return(Ok(theColor));
         }
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
Exemplo n.º 27
0
 public ActionResult <PetColor> Get(int id)
 {
     try
     {
         PetColor color = _petColorService.FindPetColorWithIDwithPets(id);
         if (color == null)
         {
             return(NotFound("There's no color with that id!"));
         }
         else
         {
             return(Ok(color));
         }
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
Exemplo n.º 28
0
 public ActionResult <PetColor> Put(int id, [FromBody] PetColor theUpdatedPetColor)
 {
     if (id != theUpdatedPetColor.PetColorId || id == 0)
     {
         return(BadRequest("The Id's must match, and may not be 0."));
     }
     else if (string.IsNullOrEmpty(theUpdatedPetColor.PetColorName))
     {
         return(BadRequest("You need to enter a name for the updated color."));
     }
     else
     {
         try
         {
             return(Accepted(_petColorService.UpdatePetColor(theUpdatedPetColor)));
         }
         catch (Exception e)
         {
             return(StatusCode(500, e.Message));
         }
     }
 }
Exemplo n.º 29
0
 public ActionResult <PetColor> Put(int id, [FromBody] PetColor updatePetColor)
 {
     if (id != updatePetColor.ID || id == 0)
     {
         return(BadRequest("Ids must match, and they can't be 0. What are you even doing now!"));
     }
     else if (string.IsNullOrEmpty(updatePetColor.NameOfPetColor))
     {
         return(BadRequest("Write a name for the updated color, pal!"));
     }
     else
     {
         try
         {
             return(Accepted(_petColorService.UpdatePetColor(updatePetColor)));
         }
         catch (Exception e)
         {
             return(StatusCode(500, e.Message));
         }
     }
 }
Exemplo n.º 30
0
        public static ObjectColor Pet2ObjColor(PetColor color)
        {
            switch (color)
            {
            case PetColor.gray:
            case PetColor.white:
                return(ObjectColor.white);

            case PetColor.blue:
                return(ObjectColor.blue);

            case PetColor.yellow:
                return(ObjectColor.yellow);

            case PetColor.green:
                return(ObjectColor.green);

            case PetColor.orange:
                return(ObjectColor.orange);

            default:
                return(ObjectColor.white);
            }
        }