public void Receiving_IPeerReputationChange_Can_Increase_Rep()
        {
            var peerReputationChange = Substitute.For <IPeerReputationChange>();
            var pid = PeerIdHelper.GetPeerId("some_peer");

            peerReputationChange.PeerId.Returns(pid);
            peerReputationChange.ReputationEvent.Returns(Substitute.For <IReputationEvents>());
            peerReputationChange.ReputationEvent.Amount.Returns(100);

            var results    = new List <Peer>();
            var subbedPeer = new Peer
            {
                PeerId     = pid,
                Reputation = 100
            };

            results.Add(subbedPeer);
            SetRepoReturnValue(results);

            var reputationManager = new ReputationManager(_subbedPeerRepository, _subbedLogger);

            reputationManager.OnNext(peerReputationChange);

            _testScheduler.Start();

            _subbedPeerRepository.ReceivedWithAnyArgs(1).GetAll();
            _subbedPeerRepository.ReceivedWithAnyArgs(1).Update(Arg.Is <Peer>(r => r.Reputation == 200));
        }
    // Use this for initialization
    void Start()
    {
        // size changing
        float scaleModifier = Random.Range(minScale, maxScale);

        transform.localScale = scaleModifier * new Vector3(1, 1, 1);

        // reputation manager init
        reputationManager = GameObject.FindGameObjectWithTag("UI").GetComponent <ReputationManager>();
        reputationManager.planetControllers.Add(this);
        reputationManager.maxReputation += maximumSatisfaction;

        // satisfaction init
        randomFrame  = Random.Range(-10, 10);
        satisfaction = Random.Range(revolutionSatisfaction, maximumSatisfaction);

        // sprite renderer
        SpriteRenderer sr = GetComponent <SpriteRenderer>();

        sr.sprite = planetSprites[Random.Range(0, planetSprites.Length)];

        // indicatior setup
        indicatorSprite.transform.localPosition = new Vector3(-maxIndicatorSize / 2, indicatorSprite.transform.localPosition.y, 0);

        // start with no event
        StopEvents();
    }
 private void Awake()
 {
     HeroManager.Initialize();
     ReputationManager.Initialize();
     QuestManager.Initialize();
     InventoryManager.Initialize();
     BlacksmithManager.Initialize();
 }
 void Awake()
 {
     if(master == null){
         master = this;
     } else if (master != this){
         Destroy(gameObject);
     }
 }
Beispiel #5
0
        public static QuestInstance GenerateQuestInstance(QuestSourceTypes forcedType)
        {
            int questDuration = m_QuestDurationChoser.GetRandomValue();
            int itemRewardChance;

            IQuestReward additionalReward = null;
            IQuestSource qSource;

            switch (forcedType)
            {
            default:
            case QuestSourceTypes.FACTION:
                qSource = ReputationManager.GetRandomFaction();
                QuestSourceFaction factionSource = qSource as QuestSourceFaction;
                itemRewardChance = 25;

                if (Random.Range(0, daysSinceHeroRecruit) == 0)
                {
                    additionalReward     = new QuestRewardHero(factionSource);
                    daysSinceHeroRecruit = Random.Range(10, 20);
                }
                else if (Random.Range(0, daysSinceFactionRecruit) == 0)
                {
                    additionalReward        = new QuestRewardFaction(factionSource.AverageHeroLevel + Random.Range(3, 6));
                    daysSinceFactionRecruit = Random.Range(25, 35);
                }

                daysSinceHeroRecruit--;
                daysSinceFactionRecruit--;
                break;

            case QuestSourceTypes.PERSON:
                qSource          = ReputationGenerator.GenerateReputationInstance(new QuestSourcePerson(EnumUtility.GetRandomEnumValue <ReputationBiases>()));
                itemRewardChance = 5;
                break;

            case QuestSourceTypes.RUMOR:
                qSource          = ReputationGenerator.GenerateReputationInstance(new QuestSourceRumor());
                itemRewardChance = 15;
                break;
            }

            QuestInstance quest = GenerateQuestInstance(qSource, questDuration);

            quest.AdditionalReward = additionalReward;
            quest.PartySize        = m_PartySizeChoser.GetRandomValue();

            if (Random.Range(0, itemRewardChance) == 0)
            {
                GameItem itemReward = GameItemGenerator.GenerateItem(GameItemTypes.UNKNOWN, GetItemRarityForDifficulty(quest.DifficultyLevel));
                quest.HandlerItemReward = new QuestRewardItem(itemReward);
            }

            return(quest);
        }
        public void Can_Merge_Streams_And_Read_Items_Pushed_On_Separate_Streams()
        {
            var pid1 = PeerIdHelper.GetPeerId("peer1");
            var pid2 = PeerIdHelper.GetPeerId("peer2");

            var results = new List <Peer>();

            var subbedPeer1 = new Peer
            {
                PeerId     = pid1,
                Reputation = 100
            };

            var peerReputationChangeEvent1 = Substitute.For <IPeerReputationChange>();

            peerReputationChangeEvent1.PeerId.Returns(pid1);

            var subbedPeer2 = new Peer
            {
                PeerId     = pid2,
                Reputation = 200
            };

            var peerReputationChangeEvent2 = Substitute.For <IPeerReputationChange>();

            peerReputationChangeEvent2.PeerId.Returns(pid2);

            results.Add(subbedPeer1);
            results.Add(subbedPeer2);

            SetRepoReturnValue(results);

            var reputationManager = new ReputationManager(_subbedPeerRepository, _subbedLogger);

            var secondStreamSubject = new ReplaySubject <IPeerReputationChange>(1, _testScheduler);
            var messageStream       = secondStreamSubject.AsObservable();

            messageStream.Subscribe(reputationChange => Substitute.For <ILogger>());

            reputationManager.MergeReputationStream(messageStream);

            var streamObserver = Substitute.For <IObserver <IPeerReputationChange> >();

            using (reputationManager.MergedEventStream.Subscribe(streamObserver.OnNext))
            {
                reputationManager.ReputationEvent.OnNext(peerReputationChangeEvent1);
                secondStreamSubject.OnNext(peerReputationChangeEvent2);

                _testScheduler.Start();

                streamObserver.Received(1).OnNext(Arg.Is <IPeerReputationChange>(r => r.PeerId.Equals(pid1)));
                streamObserver.Received(1).OnNext(Arg.Is <IPeerReputationChange>(r => r.PeerId.Equals(pid2)));
            }
        }
Beispiel #7
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Beispiel #8
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }

        Build();
    }
Beispiel #9
0
 void Awake()
 {
     #region Singleton
     // Found a duplicate instance of this class, destroy it!
     if (singleton != null && singleton != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         // Create singleton instance
         singleton = this;
         DontDestroyOnLoad(this.gameObject);
     }
     #endregion
     Reputation = 50;
 }
Beispiel #10
0
    public void Initialize()
    {
        List <IManager> managers = new List <IManager>();

        managers.Add(scene1Text  = CreateInstance(typeof(Scene1Text)) as Scene1Text);
        managers.Add(bgManager   = GameObject.FindObjectOfType <BackgroundManager>());
        managers.Add(textManager = GameObject.FindObjectOfType <TextManager>());

        wardrobeManager = CreateInstance(typeof(WardrobeManager)) as WardrobeManager;
        loadManager     = FindObjectOfType <LoadManager>();
        foreach (var i in managers)
        {
            i.Initialize();
        }

        reputationManager = GameObject.FindObjectOfType <ReputationManager>();

        BackgroundManager.curBackground = BackgroundManager.backgroundsList[0];
        bgManager.ChangeBackground();
        SceneManager.sceneLoaded += OnLevelLoaded;

        relationsData = new RelationsData();
        RelationsData.LoadData();

        int ready = 0;

        while (ready < managers.Count)
        {
            foreach (var i in managers)
            {
                if (i.status == ManagerStatus.Online)
                {
                    ready++;
                }
            }
        }
        status = ManagerStatus.Online;
    }
Beispiel #11
0
        public bool CompleteQuest(HeroInstance[] heros)
        {
            //Check if the hero completed it or not
            int successRate = GetTotalSuccessRate(heros);

            int totalHeroes   = 0;
            int successHeroes = 0;

            for (int i = 0; i < heros.Length; i++)
            {
                HeroInstance hero = heros[i];
                if (hero == null)
                {
                    continue;
                }
                totalHeroes++;

                bool giveRewards = true;
                int  failChance  = UnityEngine.Random.Range(0, 101);
                if (failChance > successRate)
                {
                    failChance = UnityEngine.Random.Range(0, 101);
                    if (failChance < 100 - successRate + 20)
                    {
                        HeroManager.SetHeroToState(hero, HeroStates.DEAD);
                        giveRewards = false;
                    }
                    else
                    {
                        HeroManager.SetHeroToState(hero, HeroStates.WOUNDED);
                        hero.WoundedDays = ((100 - successRate) / 10) + 4;
                        successHeroes++;
                    }
                }
                else
                {
                    successHeroes++;
                }

                if (giveRewards)
                {
                    if (ItemRewards[i] != null)
                    {
                        ItemRewards[i].ApplyReward(hero);
                    }
                    if (AdditionalReward != null && i == 0)
                    {
                        AdditionalReward.ApplyReward(hero);
                    }

                    hero.Experience += ExperiencePoints;
                    QuestSourceFaction faction = HeroManager.GetHeroFaction(hero);
                    ReputationManager.GetReputationTracker(faction).ModifyReputation(ExperiencePoints * 0.1f);
                }

                HeroManager.SetHeroToState(hero, HeroStates.IDLE);
            }

            if (successHeroes == 0)
            {
                RefundQuestRewards(true, true);
                return(false);
            }
            else
            {
                if (HandlerItemReward != null)
                {
                    InventoryManager.OwnedItems.Add(HandlerItemReward.Item);
                }
                InventoryManager.Gold  += Mathf.RoundToInt(HandlerAverageExpectedGoldReward * UnityEngine.Random.Range(HANDLER_GOLD_VARIANCE_MIN, HANDLER_GOLD_VARIANCE_MAX));
                InventoryManager.Stars += DifficultyLevel;
                return(true);
            }
        }
Beispiel #12
0
 public void Start()
 {
     mang = nonsMang;
 }
        /// <summary>
        ///
        /// </summary>
        internal bool SaveNewCreature()
        {
            XPQuery <CharacterBase> characters = new XPQuery <CharacterBase>(OneDatabase.Session);

            var characterList = from character in characters
                                where character.Oid == m_CharacterAccountGuid
                                select character;

            if (characterList.Count() > WOW_MAX_CHARACTER_COUNT)   // 人物过多
            {
                return(false);
            }

            CharacterBase newCharacter = new CharacterBase(OneDatabase.Session);

            this.Serial = newCharacter.Oid;
            newCharacter.CharacterName = this.Name;
            //newCharacter.Account = this.AccountGuid;
            newCharacter.Gender      = (byte)this.Gender;
            newCharacter.Skin        = (byte)this.Skin;
            newCharacter.Face        = (byte)this.Face;
            newCharacter.HairStyle   = (byte)this.HairColor;
            newCharacter.HairColor   = (byte)this.HairColor;
            newCharacter.FacialHair  = (byte)this.FacialHair;
            newCharacter.Race        = (byte)this.Race;
            newCharacter.Class       = (int)this.Class;
            newCharacter.Level       = (int)this.Level;
            newCharacter.MapId       = (int)this.MapId;
            newCharacter.ZoneId      = (int)this.ZoneId;
            newCharacter.PositionX   = this.X;
            newCharacter.PositionY   = this.Y;
            newCharacter.PositionZ   = this.Z;
            newCharacter.Orientation = this.O;
            newCharacter.Guild       = null;
            // 人物的坐骑航线标记点 32位值|32位值|32位值|32位值
            // 00000000000000000000000000000000|...|...|...
            // 以位域标示 1~TaxiId~32| 32~TaxiId~64|65~TaxiId~96|96~TaxiId~128
            newCharacter.TaxiMask     = this.TaxiMask;
            newCharacter.IsGhost      = false;
            newCharacter.IsCinematic  = false;
            newCharacter.IsNeedRename = false;
            newCharacter.TotalTime    = 0;
            newCharacter.LevelTime    = 0;
            newCharacter.LogoutTime   = DateTime.Now;
            newCharacter.CreatingTime = DateTime.Now;
            newCharacter.IsBanned     = false;
            newCharacter.IsDelete     = false;
            newCharacter.DeleteTime   = DateTime.Now;

            CharacterHomeBind newCharacterHomeBind = new CharacterHomeBind(OneDatabase.Session);

            //newCharacterHomeBind.Owner = newCharacter.Oid;
            newCharacterHomeBind.MapId     = (int)this.BindMapId;
            newCharacterHomeBind.ZoneId    = (int)this.BindZoneId;
            newCharacterHomeBind.PositionX = this.BindX;
            newCharacterHomeBind.PositionY = this.BindY;
            newCharacterHomeBind.PositionZ = this.BindZ;

            foreach (BaseSkill baseSkill in SkillManager.ToArray())
            {
                WowSkill wowSkill = baseSkill as WowSkill;
                if (wowSkill == null)
                {
                    continue;
                }

                if (wowSkill.Serial != 0)
                {
                    continue;
                }

                WowSkillTemplate wowSkillTemplate = wowSkill.SkillTemplate as WowSkillTemplate;
                if (wowSkillTemplate == null)
                {
                    continue;
                }

                CharacterSkill newCharactersSkill = new CharacterSkill(OneDatabase.Session);
                wowSkill.Serial = newCharactersSkill.Oid;

                //newCharactersSkill.Owner = newCharacter.Oid;
                newCharactersSkill.SkillId = wowSkillTemplate.Serial;
                newCharactersSkill.Value   = wowSkill.Level;
            }

            foreach (BaseSpell baseSpell in SpellManager.ToArray())
            {
                WowSpell wowSpell = baseSpell as WowSpell;
                if (wowSpell == null)
                {
                    continue;
                }

                if (wowSpell.Serial != 0)
                {
                    continue;
                }

                WowSpellTemplate wowSpellTemplate = baseSpell.SpellTemplate as WowSpellTemplate;
                if (wowSpellTemplate == null)
                {
                    continue;
                }

                CharacterSpell newCharacterSpell = new CharacterSpell(OneDatabase.Session);
                wowSpell.Serial = newCharacterSpell.Oid;

                //newCharacterSpell.Owner = newCharacter.Oid;
                newCharacterSpell.SpellId = wowSpellTemplate.Serial;
                //newCharacterSpell.Slot = baseSpell.Slot;
            }

            foreach (WowActionBar baseActionBar in ActionBarManager.ToArray())
            {
                WowActionBar wowActionBar = baseActionBar as WowActionBar;
                if (baseActionBar == null)
                {
                    continue;
                }

                if (wowActionBar.Serial != 0)
                {
                    continue;
                }

                CharacterActionBar newCharactersAction = new CharacterActionBar(OneDatabase.Session);
                wowActionBar.Serial = newCharactersAction.Oid;

                //newCharactersAction.Owner= newCharacter.Oid;
                newCharactersAction.Slot       = wowActionBar.ActionBarSlotId;
                newCharactersAction.ActionId   = wowActionBar.Action;
                newCharactersAction.ActionType = wowActionBar.Type;
            }

            foreach (BaseItem baseItem in BagManager.EquipmentBag.SubItemsToArray())
            {
                WowItem wowItem = baseItem as WowItem;
                if (wowItem == null)
                {
                    continue;
                }

                if (wowItem.Serial != 0)
                {
                    continue;
                }

                WowItemTemplate wowItemTemplate = wowItem.ItemTemplate as WowItemTemplate;
                if (wowItemTemplate == null)
                {
                    continue;
                }

                CharacterItem newCharactersItem = new CharacterItem(OneDatabase.Session);
                wowItem.Serial = newCharactersItem.Oid;

                //newCharactersItem.Owner = newCharacter.Oid;
                newCharactersItem.ItemTemplateGuid = (ulong)wowItemTemplate.Serial;
                newCharactersItem.Amount           = (int)wowItem.Amount;
                newCharactersItem.BagId            = (int)BagManager.EquipmentBag.Item.SlotId;
                newCharactersItem.SlotId           = (int)wowItem.SlotId;
            }

            foreach (WowReputation baseReputation in ReputationManager.ToArray())
            {
                WowReputation wowReputation = baseReputation as WowReputation;
                if (wowReputation == null)
                {
                    continue;
                }

                if (wowReputation.Serial != 0)
                {
                    continue;
                }

                CharacterReputation newCharacterReputation = new CharacterReputation(OneDatabase.Session);
                wowReputation.Serial = newCharacterReputation.Oid;

                //newCharacterReputation.Owner = newCharacter.Oid;
                newCharacterReputation.FactionId  = wowReputation.FactionId;
                newCharacterReputation.Reputation = wowReputation.Reputation;
                newCharacterReputation.Flag       = wowReputation.Flag;
            }

            return(true);
        }
 public void ApplyReward(HeroInstance hero)
 {
     ReputationManager.AddFaction(Faction);
 }