Exemplo n.º 1
0
        private void ActivateButton(ScreenNode screen, int packSize, int index, bool priceActivity, bool xPriceActivity)
        {
            EntityBehaviour behaviour = screen.buyItemPacksButtons.BuyButtons[index];

            behaviour.GetComponent <ItemPackButtonComponent>().Count = packSize;
            behaviour.GetComponent <UniversalPriceButtonComponent>().PriceActivity  = priceActivity;
            behaviour.GetComponent <UniversalPriceButtonComponent>().XPriceActivity = xPriceActivity;
            behaviour.gameObject.SetActive(true);
            base.NewEvent <SetBuyItemPackButtonInfoEvent>().Attach(behaviour.Entity).Schedule();
        }
Exemplo n.º 2
0
        void CheckRequiredComponents(EntityBehaviour entity)
        {
            errors.Clear();

            if (!fieldInfo.IsDefined(typeof(EntityRequiresAttribute), true))
            {
                return;
            }

            var attribute = fieldInfo.GetAttribute <EntityRequiresAttribute>(true);

            if (entity == null && !attribute.CanBeNull)
            {
                errors.Add(string.Format("Field cannot be null.").ToGUIContent());
            }

            if (entity == null)
            {
                return;
            }

            for (int j = 0; j < attribute.Types.Length; j++)
            {
                var type = attribute.Types[j];

                if (type != null && typeof(IComponent).IsAssignableFrom(type) && entity.GetComponent(type) == null)
                {
                    errors.Add(string.Format("Missing required component: {0}", type.Name).ToGUIContent());
                }
            }
        }
Exemplo n.º 3
0
        public void RequestImage(NodeAddedEvent e, VisibleBattleNode battle, [JoinByMap] SingleNode <MapPreviewComponent> map, [JoinAll] ScreenNode screen)
        {
            base.Log.InfoFormat("RequestImage {0}", battle);
            RectTransform   item      = screen.lazyList.GetItem(battle.searchData.IndexInSearchResult);
            EntityBehaviour behaviour = Object.Instantiate <EntityBehaviour>(screen.battleSelectScreen.ItemContentPrefab);

            screen.lazyList.SetItemContent(battle.searchData.IndexInSearchResult, behaviour.GetComponent <RectTransform>());
            behaviour.BuildEntity(battle.Entity);
            screen.lazyList.UpdateSelection(battle.searchData.IndexInSearchResult);
            AssetRequestEvent eventInstance = new AssetRequestEvent();

            eventInstance.Init <MapPreviewDataComponent>(map.component.AssetGuid);
            base.ScheduleEvent(eventInstance, battle);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Attempt to trap a soul.
        /// </summary>
        /// <returns>True if entity is allowed to die after trap attempt.</returns>
        bool AttemptSoulTrap()
        {
            // Must have a peered DaggerfallEntityBehaviour and EntityEffectManager
            EntityEffectManager manager = (EntityBehaviour) ? EntityBehaviour.GetComponent <EntityEffectManager>() : null;

            if (!manager)
            {
                return(true);
            }

            // Find the soul trap incumbent
            SoulTrap soulTrapEffect = (SoulTrap)manager.FindIncumbentEffect <SoulTrap>();

            if (soulTrapEffect == null)
            {
                return(true);
            }

            // Roll chance for trap
            // If trap fails then entity should die as normal without trapping a soul
            // If trap succeeds and player has a free soul gem then entity should die after storing soul
            // If trap succeeds and player has no free soul gems then entity will not die until effect expires or fails
            if (soulTrapEffect.RollTrapChance())
            {
                // Attempt to fill an empty soul trap
                if (SoulTrap.FillEmptyTrapItem((MobileTypes)mobileEnemy.ID))
                {
                    // Trap filled, allow entity to die normally
                    DaggerfallUI.AddHUDText(TextManager.Instance.GetLocalizedText("trapSuccess"), 1.5f);
                    return(true);
                }
                else
                {
                    // No empty gems, keep entity tethered to life - player is alerted so they know what's happening
                    currentHealth = 1;
                    DaggerfallUI.AddHUDText(TextManager.Instance.GetLocalizedText("trapNoneEmpty"));
                    return(false);
                }
            }
            else
            {
                // Trap failed
                DaggerfallUI.AddHUDText(TextManager.Instance.GetLocalizedText("trapFail"), 1.5f);
                return(true);
            }
        }
        public int DecreaseHealth(int amount)
        {
            // Allow an active shield effect to mitigate incoming damage from all sources
            // Testing classic shows that Shield will mitigate physical, magical, and fall damage
            if (EntityBehaviour)
            {
                EntityEffectManager manager = EntityBehaviour.GetComponent <EntityEffectManager>();
                if (manager)
                {
                    Shield shield = (Shield)manager.FindIncumbentEffect <Shield>();
                    if (shield != null)
                    {
                        amount = shield.DamageShield(amount);
                    }
                }
            }

            return(SetHealth(currentHealth - amount));
        }
        void CheckRequiredComponents(EntityBehaviour entity)
        {
            errors.Clear();

            if (!fieldInfo.IsDefined(typeof(EntityRequiresAttribute), true))
                return;

            var attribute = fieldInfo.GetAttribute<EntityRequiresAttribute>(true);

            if (entity == null && !attribute.CanBeNull)
                errors.Add(string.Format("Field cannot be null.").ToGUIContent());

            if (entity == null)
                return;

            for (int j = 0; j < attribute.Types.Length; j++)
            {
                var type = attribute.Types[j];

                if (type != null && typeof(IComponent).IsAssignableFrom(type) && entity.GetComponent(type) == null)
                    errors.Add(string.Format("Missing required component: {0}", type.Name).ToGUIContent());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Attempt to trap a soul.
        /// </summary>
        /// <returns>True if entity is allowed to die after trap attempt.</returns>
        bool AttemptSoulTrap()
        {
            // Must have a peered DaggerfallEntityBehaviour and EntityEffectManager
            EntityEffectManager manager = (EntityBehaviour) ? EntityBehaviour.GetComponent <EntityEffectManager>() : null;

            if (!manager)
            {
                return(true);
            }

            // Find the soul trap incumbent
            SoulTrap soulTrapEffect = (SoulTrap)manager.FindIncumbentEffect <SoulTrap>();

            if (soulTrapEffect == null)
            {
                return(true);
            }

            // Roll chance for trap, or always succeed if Azura's Star is equipped.
            // If trap fails then entity should die as normal without trapping a soul
            // If trap succeeds and player has a free soul gem then entity should die after storing soul
            // If trap succeeds and player has no free soul gems then entity will not die until effect expires or fails
            bool azurasStarEquipped        = false;
            DaggerfallUnityItem azurasStar = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Amulet0);

            if (azurasStar != null && azurasStar.ContainsEnchantment(EnchantmentTypes.SpecialArtifactEffect, (short)ArtifactsSubTypes.Azuras_Star))
            {
                azurasStarEquipped = true;
            }
            else
            {
                azurasStar = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(Game.Items.EquipSlots.Amulet1);
                if (azurasStar != null && azurasStar.ContainsEnchantment(EnchantmentTypes.SpecialArtifactEffect, (short)ArtifactsSubTypes.Azuras_Star))
                {
                    azurasStarEquipped = true;
                }
            }

            if (azurasStarEquipped || soulTrapEffect.RollTrapChance())
            {
                // Attempt to fill an empty soul trap
                if (soulTrapEffect.FillEmptyTrapItem((MobileTypes)mobileEnemy.ID))
                {
                    // Trap filled, allow entity to die normally
                    DaggerfallUI.AddHUDText(TextManager.Instance.GetText("ClassicEffects", "trapSuccess"), 1.5f);
                    return(true);
                }
                else
                {
                    // No empty gems, keep entity tethered to life - player is alerted so they know what's happening
                    currentHealth = 1;
                    DaggerfallUI.AddHUDText(TextManager.Instance.GetText("ClassicEffects", "trapNoneEmpty"));
                    return(false);
                }
            }
            else
            {
                // Trap failed
                DaggerfallUI.AddHUDText(TextManager.Instance.GetText("ClassicEffects", "trapFail"), 1.5f);
                return(true);
            }
        }