Exemplo n.º 1
0
        public Potion RandomPotion(WIFlags flags)
        {
            //default potion is health
            Potion potion = null;

            if (potion == null)
            {
                potion = mPotionLookup["healthbooster"];
            }

            return(potion);
        }
Exemplo n.º 2
0
 public static void InitializeAvatar(PotionAvatar potionAvatar)
 {
     try {
         Potion potion = null;
         if (string.IsNullOrEmpty(potionAvatar.State.PotionName))
         {
             //get a potion name - start by getting the potion's flags
             WIFlags     flags       = null;
             IStackOwner potionOwner = null;
             if (potionAvatar.worlditem.Group.HasOwner(out potionOwner))
             {
                 WorldItem worlditem = null;
                 if (potionOwner.IsWorldItem)
                 {
                     Structure structure = null;
                     City      city      = null;
                     if (potionOwner.worlditem.Is <Structure>(out structure))
                     {
                         flags = structure.State.StructureFlags;
                     }
                     else if (potionOwner.worlditem.Is <City>(out city))
                     {
                         flags = city.State.StructureFlags;
                     }
                 }
             }
             //if we couldn't find the flags
             if (flags == null)
             {
                 //just get the chunk flags
                 WorldChunk chunk = potionAvatar.worlditem.Group.GetParentChunk();
                 flags = GameWorld.Get.CurrentRegion.StructureFlags;
             }
             potion                        = Get.RandomPotion(flags);
             potionAvatar.Props            = potion;
             potionAvatar.State.PotionName = potion.Name;
             potionAvatar.worlditem.Props.Local.Subcategory = potion.Name;
         }
         else
         {
             if (mPotionLookup.TryGetValue(potionAvatar.State.PotionName, out potion))
             {
                 potionAvatar.Props = potion;
             }
         }
         //potion is guaranteed to return a health potion
         //potions are guaranteed to have one renderer
         Renderer renderer       = potionAvatar.worlditem.Renderers[0];
         Material potionMaterial = new Material(renderer.sharedMaterial);                                                //instance the material
         potionMaterial.SetColor("_SkinColor", Colors.Get.ColorFromFlagset(potion.PotionType, "PotionType"));
         potionMaterial.SetColor("_EyeColor", Colors.Get.ByName(potion.ContainerColor));
         if (potion.UseCustomColor)
         {
             potionMaterial.SetColor("_HairColor", potion.CustomPotionColor);
         }
         else
         {
             potionMaterial.SetColor("_EyeColor", Colors.Get.ByName(potion.PotionColor));
         }
     } catch (Exception e) {
         Debug.LogError("Error when initializing potion: " + e.ToString());
     }
 }