コード例 #1
0
        // adds to existing amount or sets to amount if not existing
        public virtual void AddReputation(Faction faction, int reputationAmount, bool notify = true)
        {
            //Debug.Log(baseCharacter.gameObject.name + ".CharacterFactionmanager.AddReputation(" + faction.DisplayName + ", " + reputationAmount + ", " + notify + ")");
            bool foundReputation = false;

            foreach (FactionDisposition factionDisposition in DispositionDictionary)
            {
                //Debug.Log(gameObject.name + ".PlayerFactionManager.AddReputation(" + realFaction.DisplayName + ", " + reputationAmount + "): checking a disposition in my dictionary");
                if (factionDisposition.Faction == faction)
                {
                    //Debug.Log(baseCharacter.gameObject.name + ".PlayerFactionManager.AddReputation(" + faction.DisplayName + ", " + reputationAmount + ") existing reputation: " + factionDisposition.disposition);
                    factionDisposition.disposition += (float)reputationAmount;
                    foundReputation = true;
                    break;
                }
            }
            if (!foundReputation)
            {
                FactionDisposition _factionDisposition = new FactionDisposition();
                _factionDisposition.Faction     = faction;
                _factionDisposition.disposition = Faction.RelationWith(baseCharacter, faction) + (float)reputationAmount;
                DispositionDictionary.Add(_factionDisposition);
            }
            if (notify)
            {
                NotifyOnReputationChange();
            }
        }
コード例 #2
0
        // ignores if exiting, otherwise sets to amount.  This allows leaving and re-joining factions without losing reputation with them
        public virtual void SetReputation(Faction newFaction)
        {
            //Debug.Log(gameObject.name + ".PlayerFactionManager.SetReputation(" + newFaction + ")");
            foreach (FactionDisposition factionDisposition in MyDispositionDictionary)
            {
                if (factionDisposition.MyFaction == newFaction)
                {
                    return;
                }
            }
            FactionDisposition _factionDisposition = new FactionDisposition();

            _factionDisposition.MyFaction   = newFaction;
            _factionDisposition.disposition = Faction.RelationWith(baseCharacter, newFaction);
            MyDispositionDictionary.Add(_factionDisposition);
            OnReputationChange();
        }
コード例 #3
0
        // ignores if existing, otherwise sets to amount.  This allows leaving and re-joining factions without losing reputation with them
        public virtual void SetReputation(Faction newFaction)
        {
            //Debug.Log(baseCharacter.gameObject.name + ".CharacterFactionmanager.SetReputation(" + (newFaction == null ? "null" : newFaction.DisplayName) + ")");
            foreach (FactionDisposition factionDisposition in DispositionDictionary)
            {
                if (factionDisposition.Faction == newFaction)
                {
                    return;
                }
            }
            FactionDisposition _factionDisposition = new FactionDisposition();

            _factionDisposition.Faction     = newFaction;
            _factionDisposition.disposition = Faction.RelationWith(baseCharacter, newFaction);
            DispositionDictionary.Add(_factionDisposition);
            NotifyOnReputationChange();
        }
コード例 #4
0
        // ignores if exiting, otherwise sets to amount.  This allows leaving and re-joining factions without losing reputation with them
        public void SetReputation(string newFactionName)
        {
            //Debug.Log(gameObject.name + ".PlayerFactionManager.SetReputation(" + newFaction + ")");
            foreach (FactionDisposition factionDisposition in MyDispositionDictionary)
            {
                if (factionDisposition.factionName == newFactionName)
                {
                    return;
                }
            }
            FactionDisposition _factionDisposition = new FactionDisposition();

            _factionDisposition.factionName = newFactionName;
            _factionDisposition.disposition = Faction.RelationWith(baseCharacter, newFactionName);
            MyDispositionDictionary.Add(_factionDisposition);
            SystemEventManager.MyInstance.NotifyOnReputationChange();
        }
コード例 #5
0
        // adds to existing amount or sets to amount if not existing
        public virtual void AddReputation(Faction faction, 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 (factionDisposition.MyFaction == faction)
                {
                    //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.MyFaction   = faction;
            _factionDisposition.disposition = Faction.RelationWith(baseCharacter, faction) + (float)reputationAmount;
            MyDispositionDictionary.Add(_factionDisposition);
            OnReputationChange();
        }
コード例 #6
0
        // 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();
        }