/// <summary>
 /// An ItemAbility has been activated or deactivated.
 /// </summary>
 /// <param name="itemAbility">The ItemAbility activated or deactivated.</param>
 /// <param name="active">Was the ItemAbility activated?</param>
 private void OnItemAbilityActive(ItemAbility itemAbility, bool active)
 {
     if (itemAbility is EquipUnequip)
     {
         // Keep a count of the number of EquipUnequip abilities started. This will allow the ability to call ItemToggled when no more
         // EquipUnequip abilities are active.
         if (active)
         {
             m_ActiveEquipUnequipAbilities.Add(itemAbility);
         }
         else
         {
             m_ActiveEquipUnequipAbilities.Remove(itemAbility);
         }
         if (m_ActiveEquipUnequipAbilities.Count == 0 && m_CanStopAbility)
         {
             ItemToggled();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <param name="checkAttributes">Should the use attributes be checked?</param>
        /// <returns>True if the item can be used.</returns>
        protected bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState, bool checkAttributes)
        {
            // Prevent the item from being used too soon.
            if (Time.time < m_NextAllowedUseTime)
            {
                return(false);
            }

            // The attribute may prevent the item from being used (such as if the character doesn't have enough stamina to use the item).
            if (checkAttributes && InvalidUseAttributes())
            {
                // The item can no longer be used. Stop the ability.
                if (abilityState != UseAbilityState.Start)
                {
                    itemAbility.StopAbility();
                }
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Can the item be used?
        /// </summary>
        /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
        /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
        /// <returns>True if the item can be used.</returns>
        public virtual bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
        {
            // Prevent the item from being used too soon.
            if (Time.time < m_NextAllowedUseTime)
            {
                return(false);
            }

            // The attribute may prevent the item from being used (such as if the character doesn't have enough stamina to use the item).
            if ((m_UseAttribute != null && !m_UseAttribute.IsValid(abilityState == UseAbilityState.Start ? 0 : -m_UseAttributeAmount)) ||
                (m_CharacterUseAttribute != null && !m_CharacterUseAttribute.IsValid(abilityState == UseAbilityState.Start ? 0 : -m_CharacterUseAttributeAmount)))
            {
                // The item can no longer be used. Stop the ability.
                if (abilityState != UseAbilityState.Start)
                {
                    itemAbility.StopAbility();
                }
                return(false);
            }

            return(true);
        }
Example #4
0
 /// <summary>
 /// Can the item be used?
 /// </summary>
 /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
 /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
 /// <returns>True if the item can be used.</returns>
 public override bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
 {
     if (!base.CanUseItem(itemAbility, abilityState))
     {
         return(false);
     }
     if (abilityState == UseAbilityState.Update)
     {
         // Don't allow the item to continue to be reused if it can no longer be used.
         if (m_Used && CanStopItemUse())
         {
             return(false);
         }
     }
     else if (abilityState == UseAbilityState.Start)
     {
         // Certain items require the character to be grounded.
         if (m_RequireGrounded && !m_CharacterLocomotion.Grounded)
         {
             return(false);
         }
         // The item can't start if it is in the process of being stopped.
         if (m_Stopping)
         {
             return(false);
         }
         // If the cast isn't valid then the item shouldn't start.
         if (m_Direction == CastDirection.Target)
         {
             DetermineTargetColliders();
         }
         if (!DetermineCastValues(0, ref m_CastDirection, ref m_CastPosition, ref m_CastNormal))
         {
             return(false);
         }
     }
     return(true);
 }
Example #5
0
 /// <summary>
 /// The character's item ability has been started or stopped.
 /// </summary>
 /// <param name="itemAbility">The item ability which was started or stopped.</param>
 /// <param name="active">True if the ability was started, false if it was stopped.</param>
 private void OnItemAbilityActive(ItemAbility itemAbility, bool active)
 {
     // When an ability starts or stops it can prevent the camera from zooming.
     TryZoom(m_ZoomInput);
 }
Example #6
0
 /// <summary>
 /// Can the item be used?
 /// </summary>
 /// <param name="itemAbility">The itemAbility that is trying to use the item.</param>
 /// <param name="abilityState">The state of the Use ability when calling CanUseItem.</param>
 /// <param name="checkAttributes">Should the use attributes be checked?</param>
 /// <returns>True if the item can be used.</returns>
 public virtual bool CanUseItem(ItemAbility itemAbility, UseAbilityState abilityState)
 {
     return(CanUseItem(itemAbility, abilityState, true));
 }
Example #7
0
 // Use this for initialization
 public void Start()
 {
     itemAbility = GetComponent <ItemAbility>();
 }
Example #8
0
        /// <summary>
        /// Starts the item use.
        /// </summary>
        /// <param name="itemAbility">The item ability that is using the item.</param>
        public override void StartItemUse(ItemAbility itemAbility)
        {
            base.StartItemUse(itemAbility);

            ToggleFlashlight(!m_FlashlightPerpectiveProperties.Light.activeSelf);
        }
    /// <summary>
    /// Returns item being held by <paramref name="player"/>.
    /// </summary>
    /// <param name="player"></param>
    /// <returns></returns>
    public static Item Has(ItemAbility player)
    {
        Item value;

        return(holder.TryGetValue(player, out value) ? value : null);
    }
Example #10
0
    /// <summary>
    /// Does <paramref name="player"/> have an item?
    /// </summary>
    /// <param name="player"></param>
    /// <returns></returns>
    public static bool Contains(ItemAbility player)
    {
        Item value;

        return(holder.TryGetValue(player, out value) ? true : false);
    }
Example #11
0
 /// <summary>
 /// The character's item ability has been started or stopped.
 /// </summary>
 /// <param name="itemAbility">The item ability which was started or stopped.</param>
 /// <param name="active">True if the ability was started, false if it was stopped.</param>
 private void OnItemAbilityActive(ItemAbility itemAbility, bool active)
 {
     photonView.RPC("OnItemAbilityActiveRPC", RpcTarget.Others, itemAbility.Index, active);
 }
Example #12
0
File: Item.cs Project: mxgmn/GENW
    public override void Load(XmlNode xnode)
    {
        name = MyXml.GetString(xnode, "name");
        description = MyXml.GetString(xnode, "description");
        bonus = new Bonus(xnode);
        isArmor = MyXml.GetBool(xnode, "isArmor");
        hands = MyXml.GetInt(xnode, "hands");
        isStackable = MyXml.GetBool(xnode, "stackable");
        isEquippable = MyXml.GetBool(xnode, "equippable");
        isCraftable = MyXml.GetBool(xnode, "craftable");

        range = MyXml.GetInt(xnode, "range");
        if (range == 0) range = 1;

        string abilityName = MyXml.GetString(xnode, "ability");
        if (abilityName != "")
        {
            ability = new ItemAbility(BigBase.Instance.iAbilityTypes.Get(abilityName), this);
            isEquippable = true;
        }

        for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling)
        {
            if (xnode.Name == "component")
            {
                int amount = MyXml.GetInt(xnode, "amount");
                if (amount == 0) amount = 1;

                components.Add(new Tuple<CraftingComponent, int>(CraftingComponent.Get(MyXml.GetString(xnode, "name")), amount));
            }
        }

        if (hands > 0 || isArmor) isEquippable = true;
    }
Example #13
0
        private void CreateItemDisplay(ItemModel item, List <ItemModel> list)
        {
            var frame = new Frame();

            frame.CornerRadius = 5;
            frame.Padding      = new Thickness(15, 15, 5, 15);

            var layout = new StackLayout();

            layout.Orientation = StackOrientation.Horizontal;

            var Name = new Label();

            Name.Text = item.item;
            Name.VerticalTextAlignment = TextAlignment.Center;
            Name.Margin         = new Thickness(0, 0, 10, 0);
            Name.FontAttributes = FontAttributes.Bold;
            if (item.item.Contains("HealthPotion"))
            {
                Name.TextColor      = Color.FromHex("#F44336");
                frame.BorderColor   = Color.FromHex("#F44336");
                Name.FontAttributes = FontAttributes.Bold;
            }
            else
            {
                Name.TextColor      = Color.DarkTurquoise;
                frame.BorderColor   = Color.DarkTurquoise;
                Name.FontAttributes = FontAttributes.Bold;
            }


            var extras = new Label();

            extras.FontSize  = 10;
            extras.TextColor = Color.Black;
            extras.Text      = string.Format("{0}: {1} - {2} {3}",
                                             ItemInfoModel.ObtainItemString(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, false),
                                             ItemInfoModel.ObtainItemString(item.item, false));
            extras.HorizontalTextAlignment = TextAlignment.Center;
            extras.HorizontalOptions       = LayoutOptions.CenterAndExpand;
            extras.VerticalTextAlignment   = TextAlignment.Center;

            var button = new Button();

            button.HorizontalOptions = LayoutOptions.EndAndExpand;
            button.Text            = "USE";
            button.CornerRadius    = 5;
            button.BackgroundColor = Color.White;
            button.TextColor       = Color.Accent;


            button.Clicked += async(s, e) =>
            {
                if (battlesequence)
                {
                    battlesequence = false;
                    await Task.Run(async() =>
                    {
                        Animations.CloseStackLayout(layout, "closing", 30, 500);
                    });

                    Items.Children.Remove(frame);
                    pots.Remove(item); // Remove off list
                    string invetory = "";
                    foreach (ItemModel itemInv in pots)
                    {
                        if (!String.IsNullOrEmpty(itemInv.item))
                        {
                            invetory += itemInv.item + ","; // Create string for file
                        }
                    }
                    UserModel.Rewrite("Items:", invetory, dungeon.items.Localfile);

                    try
                    {
                        dungeon.items.Invfile.Object.Items = invetory;
                        await dungeon.items.UpdateInv();
                    }
                    catch { }

                    dungeon.itemInv.pots = this.pots;

                    await ItemAbility.FadeTo(0, 200);

                    DisableorEnableFrameLayouts(false, ItemAbility);

                    if (item.item.Contains("HealthPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterHP += buff;
                        await Announcer(string.Format("Healed for {0}", buff.ToString()), true);

                        CharacterHealth.Text = CharacterHP.ToString();
                        CharacterHealth.RelRotateTo(360, 500);
                        await CharacterHealth.ScaleTo(5, 300);

                        await CharacterHealth.ScaleTo(1, 300);
                    }
                    else if (item.item.Contains("MagicPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterMP += buff;
                        await Announcer(string.Format("Restored {0} Mana", buff.ToString()), true);

                        CharacterMana.Text = CharacterMP.ToString();
                        CharacterMana.RelRotateTo(360, 500);
                        await CharacterMana.ScaleTo(5, 300);

                        await CharacterMana.ScaleTo(1, 300);
                    }

                    await Announcer("BOSS TURN", false);

                    BossAttack();
                }
            };

            layout.Children.Add(Name);
            layout.Children.Add(extras);
            layout.Children.Add(button);

            frame.Content = layout;
            Items.Children.Add(frame);
        }
Example #14
0
 private void Awake()
 {
     itemAbility             = FindObjectOfType <ItemAbility>();
     itemAbility.OnItemPick += OnItemPick;
 }