Ejemplo n.º 1
0
        public StoreSaveState Load(ResourceRegistry resourceRegistry, FactoryRegistry factoryRegistry, ModifierRegistry modiferRegistry)
        {
            string         path    = string.Format(@"{0}{1}", directoryPath, FILE_NAME);
            StoreSaveState storage = null;

            try
            {
                using (FileStream fileStream = new FileStream(path, FileMode.Open))
                {
                    using (StreamReader reader = new StreamReader(fileStream))
                    {
                        storage = JsonConvert.DeserializeObject <StoreSaveState>(reader.ReadToEnd());
                    }
                }
            }
            catch (FileNotFoundException)
            {
                throw new FileNotFoundException(string.Format("An existing save file could not be found to load at: {0}", path));
            }

            ResourceCheckpoint checkpoint = new ResourceCheckpoint(storage.ResourceCheckpoint.CheckpointTimeUTC,
                                                                   storage.ResourceCheckpoint.ResourceAmounts,
                                                                   resourceRegistry);

            FactoryManager  factoryManager  = new FactoryManager(storage.FactoryManager.FactoryAmounts, factoryRegistry);
            ModifierManager modifierManager = new ModifierManager(storage.ModiferManager.ModifierDurations, modiferRegistry);

            return(new StoreSaveState()
            {
                ResourceCheckpoint = checkpoint, FactoryManager = factoryManager, ModiferManager = modifierManager
            });
        }
Ejemplo n.º 2
0
    public void AddNewModifier(string modifierName)
    {
        var modifier = ModifierManager.GetModifier(modifierName);

        //免疫的状态下要判断是否能加上buff
        if (!GetModifierState(Modifier_State.MODIFIER_STATE_INVULNERABLE) || (modifier.attributes & ModifierAttribute.MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE) > 0)
        {
            //判断buff是否能叠加
            if ((modifier.attributes & ModifierAttribute.MODIFIER_ATTRIBUTE_MULTIPLE) > 0)
            {
                modifiers.Add(new BaseModifier(modifierName));
            }
            else              //不能叠加,就刷新buff
            {
                bool hasModifier = false;
                int  count       = modifiers.Count;
                for (int i = 0; i < count; i++)
                {
                    if (modifiers[i].Name == modifier.name)
                    {
                        modifiers[i].ForceRefresh();
                        hasModifier = true;
                        break;
                    }
                }
                if (!hasModifier)
                {
                    modifiers.Add(new BaseModifier(modifierName));
                }
            }
        }

        //TriggerModifierEvent(ModifierEventType)
    }
Ejemplo n.º 3
0
        public override void Invoke(ItemStack itemStack)
        {
            List <ValueMod> valueMods = new List <ValueMod>();

            ValueMod[] itemStackMods = itemStack.ExplicitMods;

            Mod[] availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray());
            availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel);
            foreach (ValueMod explicitMod in itemStackMods)
            {
                valueMods.Add(explicitMod);
            }
            switch (m_CountType)
            {
            case CountType.Single:
                RetierSingle(ref valueMods, availableMods);
                break;

            case CountType.Value:
                RetierCount(ref valueMods, m_Count, availableMods);
                break;

            case CountType.All:
                RetierAll(ref valueMods, availableMods);
                break;
            }
            itemStack.ExplicitMods = valueMods.ToArray();
        }
        public void CreateCharacter(Library.Character character, IEnumerable <int> skills)
        {
            var skillManager = new SkillManager();
            var modManager   = new ModifierManager();

            SetSpeed(character);
            SetMaxHp(character);

            var stats = new Library.CharStats();

            stats.CharacterID = character.CharacterID;
            stats.HP          = character.MaxHP;
            stats.PB          = 2;

            modManager.SetModifiers(character, stats);
            SetSavingThrows(character, stats);
            skillManager.SetSkills(stats);
            skillManager.UpdateSkills(skills.ToList(), stats);

            AddCharacter(character);
            Save();

            AddCharStats(stats);
            Save();
        }
Ejemplo n.º 5
0
    private void Awake()
    {
        enemies       = new List <MoveDownScreen>();
        bullets       = new List <EnemyBullet>();
        playerBullets = new List <PlayerBullet>();

        modifiers = GetComponent <ModifierManager>();
    }
Ejemplo n.º 6
0
        public void Load()
        {
            StoreSaveState saveState = storeIO.Load(resourceRegistry, factoryRegistry, modifierRegistry);

            ResourceCheckpoint = saveState.ResourceCheckpoint;
            FactoryManager     = saveState.FactoryManager;
            ModifierManager    = saveState.ModiferManager;
        }
Ejemplo n.º 7
0
 public BaseModifier(string modifierName)
 {
     eventActions   = new Dictionary <ModifierEventType, List <BaseAction> >();
     properties     = new Dictionary <Modifier_Property, AbilitySpecial>();
     modifierParams = ModifierManager.GetModifier(modifierName);
     isAura         = modifierParams.isAura;
     isOrb          = eventActions.ContainsKey(ModifierEventType.Orb);
     if (isAura)
     {
         auraRadius = modifierParams.auraRadius;
         auraTarget = new EntityTarget(modifierParams.auraTargetTeam, modifierParams.auraTargetType, modifierParams.auraTargetFlags);
     }
     //name = modifierName;
 }
        public override void GenerateAttributes(ProceduralLevel level)
        {
            //check if attribute from tag or random
            float minAttributeCount = m_MinimumAttributeCount.Evaluate(level.Difficulty);
            float maxAttributeCount = m_MaximumAttributeCount.Evaluate(level.Difficulty);

            int attributeCount = (int)Math.Round(Random.Range(minAttributeCount, maxAttributeCount));

            List <ValueMod> attributes = new List <ValueMod>();

            for (int i = 0; i < attributeCount; i++)
            {
                float  roll         = Random.Range(0.0f, 1.0f);
                Mod[]  rollableMods = null;
                string tag          = "";
                if (roll <= m_ChanceToPickAttributeFromTag)
                {
                    if (level.TagList.Count > 0)
                    {
                        int tagRoll = Random.Range(0, level.TagList.Count);
                        rollableMods = ModifierManager.GetModifiersForDomainAndTag(2, level.TagList[tagRoll].Identifier);
                        tag          = level.TagList[tagRoll].Identifier;
                    }
                    if (rollableMods == null || rollableMods.Length == 0)
                    {
                        rollableMods = ModifierManager.GetModifiersForDomain(2);
                        tag          = m_DefaultTag.Identifier;
                    }
                }
                else
                {
                    rollableMods = ModifierManager.GetModifiersForDomain(2);
                    tag          = m_DefaultTag.Identifier;
                }

                if (rollableMods == null)
                {
                    continue;
                }
                ValueMod valueMod = ModUtils.Roll(rollableMods.ToArray(), tag);
                if (valueMod == null)
                {
                    continue;
                }
                attributes.Add(valueMod);
            }

            level.Attributes = attributes.ToArray();
        }
Ejemplo n.º 9
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            BuildCharacterModifierList(fileName);
            isReady = true;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 10
0
        private void Awake()
        {
            _playerState     = FindObjectOfType <PlayerState>();
            _modifierManager = FindObjectOfType <ModifierManager>();

            GetComponentInChildren <Text>().text = type.ToString();

            _button = GetComponent <Button>();

            _button.onClick.AddListener(() =>
                                        Messenger <ModifierType.Type> .Broadcast(GameEvent.MODIFIER_USED, type)
                                        );

            _target  = ModifierType.GetTarget(type);
            _feature = ModifierType.GetFeature(type);
        }
Ejemplo n.º 11
0
    private void Awake()
    {
        statManager     = Resources.Load("StatManager") as StatManager;
        skillManager    = Resources.Load("SkillManager") as SkillManager;
        modifierManager = Resources.Load("ModifierManager") as ModifierManager;

        ScriptableObject statManagerClone = Instantiate(statManager);

        statManager = statManagerClone as StatManager;

        ScriptableObject skillManagerClone = Instantiate(skillManager);

        skillManager = skillManagerClone as SkillManager;

        ScriptableObject modifierManagerClone = Instantiate(modifierManager);

        modifierManager = modifierManagerClone as ModifierManager;
    }
Ejemplo n.º 12
0
        public override void Invoke(ItemStack itemStack)
        {
            Mod[]           availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray());
            List <ValueMod> valueMods     = new List <ValueMod>();

            foreach (ValueMod explicitMod in itemStack.ExplicitMods)
            {
                valueMods.Add(explicitMod);
            }
            availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel);
            availableMods = ModUtils.Filter(availableMods, valueMods.ToArray());
            ValueMod valueMod = ModUtils.Roll(availableMods, itemStack.Item.Tags.ToArray());

            if (valueMod == null)
            {
                return;
            }
            valueMods.Add(valueMod);
            itemStack.ExplicitMods = valueMods.ToArray();
        }
        public override void Notify(Entity activeStats, ActionContext actionContext)
        {
            if (activeStats.GetStat(ModType.Identifier).Calculated == 0.0f)
            {
                return;
            }
            DropRate[] dropRates = DropManager.GetDropRates(activeStats.Description.Enemy);

            List <ItemStack> rolledItemStacks = new List <ItemStack>();

            foreach (DropRate dropRate in dropRates)
            {
                //TODO maxlevel from enemy? and rate multiplier = magic find
                rolledItemStacks.AddRange(dropRate.Roll((int)activeStats.GetStat("core.modtypes.ship.level").Calculated,
                                                        1.0f + PlayerManager.PlayerController.Entity.GetStat("core.modtypes.utility.magicfind").Calculated));
            }

            foreach (ItemStack rolledItemStack in rolledItemStacks)
            {
                ModifierManager.ModifyItemStack(rolledItemStack);
                DropManager.GenerateDrop(rolledItemStack, activeStats.EntityBehaviour.transform.position);
            }
        }
        public override void Invoke(ItemStack itemStack)
        {
            if (itemStack == null)
            {
                return;
            }
            int count = (int)m_ExplicitCount.Evaluate(UnityEngine.Random.Range(0.0f, 1.0f));

            Mod[] availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray());
            availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel);
            List <ValueMod> valueMods = new List <ValueMod>();

            for (int i = 0; i < count; i++)
            {
                availableMods = ModUtils.Filter(availableMods, valueMods.ToArray());
                ValueMod valueMod = ModUtils.Roll(availableMods, itemStack.Item.Tags.ToArray());
                if (valueMod != null)
                {
                    valueMods.Add(valueMod);
                }
            }
            itemStack.ExplicitMods = valueMods.ToArray();
        }
Ejemplo n.º 15
0
 public Dictionary <Guid, double> Produce(ResourceCheckpoint lastCheckpoint, Dictionary <Guid, double> resourceTotals, ModifierManager modifierManager)
 {
     for (int i = 0; i < Count; i++)
     {
         resourceTotals = Factory.Produce(lastCheckpoint, resourceTotals, modifierManager);
     }
     return(resourceTotals);
 }
Ejemplo n.º 16
0
 public ShipCollisionChecker(IShip ship)
 {
     _ship = ship;
     _shipModifierManager = new ModifierManager(ship);
     _isInteracted        = false;
 }
Ejemplo n.º 17
0
        internal Dictionary <Guid, double> Produce(ResourceCheckpoint lastCheckpoint, Dictionary <Guid, double> resourceTotals, ModifierManager modifierManager)
        {
            DateTime checkpointTimeUTC = lastCheckpoint.CheckpointTimeUTC;

            double operationalSeconds = double.MaxValue;

            foreach (Consumer consumer in consumers)
            {
                Resource resource = consumer.resource;
                resourceTotals.TryGetValue(resource.id, out double resourceCount);

                double potentialConsumption = consumer.GetConsumption(checkpointTimeUTC);
                double consumption          = Math.Min(potentialConsumption, resourceCount);

                double consumerOperationalSeconds = consumption / consumer.ConsumptionPerSecond;
                operationalSeconds = Math.Min(operationalSeconds, consumerOperationalSeconds);
            }

            //Shortcircuit if not operational for any amount of time.
            if (operationalSeconds == 0)
            {
                return(resourceTotals);
            }

            foreach (Consumer consumer in consumers)
            {
                double consumption = operationalSeconds * consumer.ConsumptionPerSecond;

                Resource resource = consumer.resource;
                resourceTotals.TryGetValue(resource.id, out double resourceCount);

                if (resourceTotals.ContainsKey(resource.id))
                {
                    resourceTotals[resource.id] = resourceCount - consumption;
                }
            }

            foreach (Provider provider in providers)
            {
                double provision;
                if (consumers.Count == 0)
                {
                    provision = provider.GetProvision(checkpointTimeUTC);
                }
                else
                {
                    provision = operationalSeconds * provider.ProvisionPerSecond;
                }

                double modifedProvision = modifierManager.GetModifiedAmount(new ResourceAmount(provider.resource, provision), lastCheckpoint);

                Resource resource = provider.resource;
                resourceTotals.TryGetValue(resource.id, out double resourceCount);

                if (resourceTotals.ContainsKey(resource.id))
                {
                    resourceTotals[resource.id] = resourceCount + modifedProvision;
                }
                else
                {
                    resourceTotals.Add(resource.id, resourceCount + modifedProvision);
                }
            }

            return(resourceTotals);
        }
Ejemplo n.º 18
0
 public Dictionary <Guid, double> Produce(ResourceCheckpoint lastCheckpoint, Dictionary <Guid, double> resourceTotals, ModifierManager modifierManager)
 {
     foreach (FactoryAmount factoryAmount in FactoryAmounts)
     {
         resourceTotals = factoryAmount.Produce(lastCheckpoint, resourceTotals, modifierManager);
     }
     return(resourceTotals);
 }
Ejemplo n.º 19
0
 public void InitializeModifierManager(List <ModifierDuration> startingModifiers)
 {
     ModifierManager = new ModifierManager(startingModifiers);
 }