Beispiel #1
0
        public void LoadAbility(string abilityName)
        {
            //Debug.Log(gameObject.name + ".PlayerAbilityManager.LoadAbility(" + abilityName + ")");
            IAbility ability = SystemAbilityManager.MyInstance.GetResource(abilityName) as IAbility;

            if (ability != null)
            {
                // if we renamed an ability, old save data could load a null.  prevent invalid abilities from loading.
                bool isAutoAttack = false;
                if (ability is AnimatedAbility && (ability as AnimatedAbility).IsAutoAttack)
                {
                    isAutoAttack = true;
                }
                if (isAutoAttack && autoAttackAbility != null)
                {
                    // can't learn 2 auto-attacks
                    return;
                }

                string keyName = SystemResourceManager.prepareStringForMatch(abilityName);
                if (!abilityList.ContainsKey(keyName))
                {
                    //Debug.Log("PlayerAbilityManager.LoadAbility(" + abilityName + "): found it!");
                    if (ability is AnimatedAbility && (ability as AnimatedAbility).IsAutoAttack == true)
                    {
                        UnLearnDefaultAutoAttackAbility();
                        //Debug.Log(gameObject.name + ".PlayerAbilityManager.LoadAbility(" + abilityName + "): is auto-attack!");
                        autoAttackAbility = ability as BaseAbility;
                    }
                    abilityList[keyName] = ability;
                }
            }
        }
Beispiel #2
0
        public void UpdateKillCount(BaseCharacter character, float creditPercent)
        {
            //Debug.Log("KillObjective.UpdateKillCount()");

            bool completeBefore = IsComplete;

            if (completeBefore)
            {
                return;
            }

            // INVESTIGATE IF STRING MATCH CAN BE REPLACED WITH TYPE.GETTYPE DIRECT MATCH
            if (character.GetType() == Type.GetType(MyType) || SystemResourceManager.MatchResource(character.CharacterName, MyType) || SystemResourceManager.MatchResource(character.Faction.DisplayName, MyType))
            {
                CurrentAmount++;
                quest.CheckCompletion();
                if (CurrentAmount <= MyAmount && !quest.MyIsAchievement && CurrentAmount != 0)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", DisplayName, Mathf.Clamp(CurrentAmount, 0, MyAmount), MyAmount));
                }
                if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("Learn {0} {1}: Objective Complete", CurrentAmount, DisplayName));
                }
            }
        }
        // converts the currency amount to its base currency and returns it
        public static int GetConvertedValue(Currency currency, int currencyAmount)
        {
            CurrencyGroup currencyGroup = FindCurrencyGroup(currency);

            if (currencyGroup != null)
            {
                // attemp redistribution
                Currency baseCurrency = currencyGroup.MyBaseCurrency;
                // convert everything in the group to the base amount
                if (SystemResourceManager.MatchResource(currency.MyName, currencyGroup.MyBaseCurrency.MyName))
                {
                    return(currencyAmount);
                }
                // the currency needs conversion
                foreach (CurrencyGroupRate currencyGroupRate in currencyGroup.MyCurrencyGroupRates)
                {
                    if (SystemResourceManager.MatchResource(currencyGroupRate.MyCurrency.MyName, currency.MyName))
                    {
                        return(currencyGroupRate.MyBaseMultiple * currencyAmount);
                    }
                }
                return(currencyAmount);
            }
            return(currencyAmount);
        }
        public void CheckInteractableName(string interactableName, bool interactionComplete)
        {
            //Debug.Log("UseInteractableObjective.CheckInteractableName()");
            bool completeBefore = IsComplete;

            if (completeBefore)
            {
                return;
            }
            if (SystemResourceManager.MatchResource(interactableName, MyType))
            {
                if (!interactionComplete && requireCompletion == true)
                {
                    return;
                }
                if (requireCompletion == false && interactionComplete)
                {
                    return;
                }
                if (CurrentAmount < MyAmount)
                {
                    CurrentAmount++;
                    quest.CheckCompletion();
                }
                if (CurrentAmount <= MyAmount && !quest.MyIsAchievement && CurrentAmount != 0)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", DisplayName, Mathf.Clamp(CurrentAmount, 0, MyAmount), MyAmount));
                }
                if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: Objective Complete", DisplayName));
                }
            }
        }
        public void UpdateKillCount(BaseCharacter character, float creditPercent)
        {
            //Debug.Log("KillObjective.UpdateKillCount()");

            bool completeBefore = IsComplete;

            if (completeBefore)
            {
                return;
            }

            if (character.GetType() == Type.GetType(MyType) || SystemResourceManager.MatchResource(character.MyCharacterName, MyType) || SystemResourceManager.MatchResource(character.MyFactionName, MyType))
            {
                MyCurrentAmount++;
                quest.CheckCompletion();
                if (MyCurrentAmount <= MyAmount && !quest.MyIsAchievement && MyCurrentAmount != 0)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", MyType, Mathf.Clamp(MyCurrentAmount, 0, MyAmount), MyAmount));
                }
                if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("Learn {0} {1}: Objective Complete", MyCurrentAmount, MyType));
                }
            }
        }
        public float GetReputationValue(Faction faction)
        {
            //Debug.Log(gameObject.name + ".CharacterFactionManager.RelationWith(" + faction.MyName + "): checking personal status dictionary and status effects to get special dispositions toward faction");

            // checking personal dictionary before status effects?
            foreach (FactionDisposition factionDisposition in MyDispositionDictionary)
            {
                if (SystemResourceManager.MatchResource(factionDisposition.factionName, faction.MyName))
                {
                    //Debug.Log("CharacterFactionManager.RelationWith(" + faction.MyName + "): dictionary contained: " + faction.MyName + "; returning value: " + factionDisposition.disposition);
                    return(factionDisposition.disposition);
                }
            }

            // checking status effect disposition modifiers
            foreach (StatusEffectNode statusEffectNode in baseCharacter.MyCharacterStats.MyStatusEffects.Values)
            {
                foreach (FactionDisposition factionDisposition in statusEffectNode.MyStatusEffect.MyFactionModifiers)
                {
                    //Debug.Log(gameObject.name + "Faction.RelationWith(" + faction.MyName + "): " + statusEffect.MyName + " had disposition: " + factionDisposition.factionName + ": " + factionDisposition.disposition);
                    if (SystemResourceManager.MatchResource(factionDisposition.factionName, faction.MyName))
                    {
                        //Debug.Log(gameObject.name + "Faction.RelationWith(" + faction.MyName + "): found special disposition in status effects and it matches the requested faction: " + factionDisposition.factionName + ": " + factionDisposition.disposition);
                        return(factionDisposition.disposition);
                    }
                }
            }

            // hmm, should this return Faction.getreputationvalue instead?
            return(0f);
        }
 public void UpdateItemCount(Item item)
 {
     // change this with check reference to item prefab in the future
     if (SystemResourceManager.MatchResource(MyType, item.MyName))
     {
         UpdateCompletionCount();
     }
 }
 public void UpdateCompletionCount(Skill skill)
 {
     if (!SystemResourceManager.MatchResource(skill.MyName, MyType))
     {
         // some other skill than this one was learned.  no need to check.
         return;
     }
     UpdateCompletionCount();
 }
        public void CheckPetSpawn(IAbilityCaster source, GameObject target, AbilityEffectContext abilityEffectInput)
        {
            //Debug.Log(MyName + ".PetEffect.CheckPetSpawn()");
            List <CharacterUnit> unitsToRemove = new List <CharacterUnit>();

            foreach (CharacterUnit characterUnit in petUnits)
            {
                //if (characterUnit != null) {
                if (characterUnit.MyCharacter.CharacterStats.IsAlive == false)
                {
                    //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): ADDING DEAD PET TO REMOVE LIST");
                    unitsToRemove.Add(characterUnit);
                }
                //}
            }
            foreach (CharacterUnit characterUnit in unitsToRemove)
            {
                //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): REMOVING DEAD PET");
                petUnits.Remove(characterUnit);
            }
            if (petUnits.Count == 0)
            {
                //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): SPAWNING PETS");
                // spawn pet
                List <AbilityEffect> castList = new List <AbilityEffect>();
                foreach (AbilityEffect petEffect in realPetEffectList)
                {
                    //if (source.MyCharacterAbilityManager.HasAbility(petAbilityName)) {
                    if (SystemResourceManager.MatchResource(petEffect.DisplayName, DisplayName))
                    {
                        Debug.LogError(DisplayName + ".PerformAbilityEffects(): circular reference detected.  Tried to cast self.  CHECK INSPECTOR AND FIX ABILITY EFFECT CONFIGURATION!!!");
                    }
                    else
                    {
                        //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): adding to cast list");
                        castList.Add(petEffect);
                    }
                    //}
                }
                if (castList.Count > 0)
                {
                    //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): castlist.count: " + castList.Count);
                    Dictionary <PrefabProfile, GameObject> rawObjectList = PerformAbilityEffects(source, target, abilityEffectInput, castList);
                    foreach (KeyValuePair <PrefabProfile, GameObject> tmpObject in rawObjectList)
                    {
                        //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): LOOPING THROUGH RAW OBJECT LIST ");
                        CharacterUnit _characterUnit = tmpObject.Value.GetComponent <CharacterUnit>();
                        if (_characterUnit != null)
                        {
                            //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): ADDING PET TO UNIT LIST");
                            petUnits.Add(_characterUnit);
                        }
                    }
                }
            }
        }
        public void LoadAbility(string abilityName)
        {
            //Debug.Log("PlayerAbilityManager.LoadAbility(" + abilityName + ")");
            IAbility ability = SystemAbilityManager.MyInstance.GetResource(abilityName) as IAbility;

            if (ability != null)
            {
                // if we renamed an ability, old save data could load a null.  prevent invalid abilities from loading.
                string keyName = SystemResourceManager.prepareStringForMatch(abilityName);
                if (!abilityList.ContainsKey(keyName))
                {
                    //Debug.Log("PlayerAbilityManager.LoadAbility(" + abilityName + "): found it!");
                    abilityList[keyName] = ability;
                }
            }
        }
        // for casting
        public void UpdateCastCount(BaseAbility baseAbility)
        {
            bool completeBefore = IsComplete;

            if (SystemResourceManager.MatchResource(baseAbility.MyName, MyType))
            {
                MyCurrentAmount++;
                quest.CheckCompletion();
                if (MyCurrentAmount <= MyAmount && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", MyType, MyCurrentAmount, MyAmount));
                }
                if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("Learn {0} {1}: Objective Complete", MyCurrentAmount, MyType));
                }
            }
        }
        // adds to existing amount or sets to amount if not existing
        public void AddReputation(string factionName, int reputationAmount)
        {
            //Debug.Log(gameObject.name + ".PlayerFactionManager.AddReputation(" + realFaction.MyName + ", " + reputationAmount + ")");
            //bool foundReputation = false;
            foreach (FactionDisposition factionDisposition in MyDispositionDictionary)
            {
                //Debug.Log(gameObject.name + ".PlayerFactionManager.AddReputation(" + realFaction.MyName + ", " + reputationAmount + "): checking a disposition in my dictionary");
                if (SystemResourceManager.MatchResource(factionDisposition.factionName, factionName))
                {
                    //Debug.Log(gameObject.name + ".PlayerFactionManager.AddReputation(" + realFaction.MyName + ", " + reputationAmount + "): checking a disposition in my dictionary MATCHED: adding reputation");
                    factionDisposition.disposition += (float)reputationAmount;
                    return;
                }
            }
            FactionDisposition _factionDisposition = new FactionDisposition();

            _factionDisposition.factionName = factionName;
            _factionDisposition.disposition = Faction.RelationWith(baseCharacter, factionName) + (float)reputationAmount;
            MyDispositionDictionary.Add(_factionDisposition);
            SystemEventManager.MyInstance.NotifyOnReputationChange();
        }
Beispiel #13
0
        public void CheckPetSpawn(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectInput)
        {
            //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn()");
            CharacterPetManager characterPetManager = null;

            if ((source as BaseCharacter) is BaseCharacter)
            {
                characterPetManager = (source as BaseCharacter).CharacterPetManager;
            }
            else
            {
                //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): source is not basecharacter");
                return;
            }

            List <AbilityEffect> castList = new List <AbilityEffect>();

            foreach (SummonEffect petEffect in petEffectList)
            {
                if (SystemResourceManager.MatchResource(petEffect.DisplayName, DisplayName))
                {
                    Debug.LogError(DisplayName + ".PerformAbilityEffects(): circular reference detected.  Tried to cast self.  CHECK INSPECTOR AND FIX ABILITY EFFECT CONFIGURATION!!!");
                }
                else
                {
                    //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): adding to cast list");
                    if (petEffect.UnitProfile != null &&
                        characterPetManager.ActiveUnitProfiles.ContainsKey(petEffect.UnitProfile) == false)
                    {
                        //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): adding cast:" + petEffect.DisplayName);
                        castList.Add(petEffect);
                    }
                }
            }
            if (castList.Count > 0)
            {
                //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): castlist.count: " + castList.Count);
                Dictionary <PrefabProfile, GameObject> rawObjectList = PerformAbilityEffects(source, target, abilityEffectInput, castList);
            }
        }
        // NEW (HOPEFULLY) SAFE COMPLETION CHECK CODE THAT SHOULDN'T RESULT IN RUNAWAY STACK OVERFLOW ETC
        public void CheckCompletionCount(Dialog dialog)
        {
            bool completeBefore = IsComplete;

            if (completeBefore)
            {
                return;
            }

            if (SystemResourceManager.MatchResource(MyType, dialog.DisplayName))
            {
                CurrentAmount++;
                quest.CheckCompletion();
                if (CurrentAmount <= MyAmount && !quest.MyIsAchievement && CurrentAmount != 0)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", DisplayName, Mathf.Clamp(CurrentAmount, 0, MyAmount), MyAmount));
                }
                if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
                {
                    MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: Objective Complete", DisplayName));
                }
            }
        }
Beispiel #15
0
        // for learning
        public void UpdateCompletionCount(BaseAbility baseAbility)
        {
            if (!SystemResourceManager.MatchResource(baseAbility.MyName, MyType))
            {
                // some other ability than this one was used.  no need to check.
                return;
            }
            bool completeBefore = IsComplete;

            if (completeBefore)
            {
                return;
            }
            MyCurrentAmount++;
            quest.CheckCompletion();
            if (MyCurrentAmount <= MyAmount && !quest.MyIsAchievement && MyCurrentAmount != 0)
            {
                MessageFeedManager.MyInstance.WriteMessage(string.Format("{0}: {1}/{2}", MyType, Mathf.Clamp(MyCurrentAmount, 0, MyAmount), MyAmount));
            }
            if (completeBefore == false && IsComplete && !quest.MyIsAchievement)
            {
                MessageFeedManager.MyInstance.WriteMessage(string.Format("Learn {0} {1}: Objective Complete", MyCurrentAmount, MyType));
            }
        }
        public bool HasReputationModifier(Faction faction)
        {
            if (faction == null)
            {
                return(false);
            }
            //Debug.Log(gameObject.name + ".CharacterFactionManager.HasReputationModifer(" + faction.MyName + "): searching for reputation modifer");

            // checking dictionary first
            //Debug.Log(gameObject.name + ".CharacterFactionManager.HasReputationModifer(" + faction.MyName + "): checking local disposition dictionary");
            foreach (FactionDisposition factionDisposition in MyDispositionDictionary)
            {
                if (SystemResourceManager.MatchResource(factionDisposition.factionName, faction.MyName))
                {
                    //Debug.Log(gameObject.name + ".CharacterFactionManager.HasReputationModifer(" + faction.MyName + "): name matched a disposition in local dictionary");
                    return(true);
                }
            }

            // checking status effects next
            //Debug.Log(gameObject.name + ".CharacterFactionManager.HasReputationModifer(" + faction.MyName + "): no match disposition dictionary, checking status effect buffs");
            foreach (StatusEffectNode statusEffectNode in baseCharacter.MyCharacterStats.MyStatusEffects.Values)
            {
                foreach (FactionDisposition factionDisposition in statusEffectNode.MyStatusEffect.MyFactionModifiers)
                {
                    //Debug.Log(gameObject.name + "Faction.RelationWith(" + faction.MyName + "): " + statusEffect.MyName + " had disposition: " + factionDisposition.factionName + ": " + factionDisposition.disposition);
                    if (SystemResourceManager.MatchResource(factionDisposition.factionName, faction.MyName))
                    {
                        //Debug.Log(gameObject.name + "Faction.RelationWith(" + faction.MyName + "): found special disposition in status effects and it matches the requested faction: " + factionDisposition.factionName + ": " + factionDisposition.disposition);
                        return(true);
                    }
                }
            }
            //Debug.Log(gameObject.name + ".CharacterFactionManager.HasReputationModifer(" + faction.MyName + "): no match disposition dictionary or buffs, return false");
            return(false);
        }