Beispiel #1
0
    void Start()
    {
        dialogueList       = new Dictionary <string, Dictionary <string, List <string> > >();
        portraitList       = new Dictionary <string, Sprite>();
        charSpriteList     = new Dictionary <string, Sprite>();
        requestList        = new Dictionary <string, List <Request> >();
        npcGivenList       = new Dictionary <string, List <object> >();
        knownAttributes    = new Dictionary <Ingredient, List <Ingredient.Attributes> >();
        brewingIngredients = new Ingredient[3];

        activeItem       = null;
        activeSpell      = null;
        ingredientCount  = 0;
        garden           = GameObject.Find("GardenManager").GetComponent <Garden>();
        gatheringManager = GameObject.Find("GatheringManager").GetComponent <GatheringManager>();

        CreateIngredients();
        CreateSeeds();
        CreateSpells();
        CreateInventory();
        CreateNPCs();
        LoadNPCData();

        DontDestroyOnLoad(GameObject.Find("EventSystem"));
        //Just for force spawning inventory items for testing
        // Inventory.Testing();
        Cursor.SetCursor(Resources.Load <Texture2D>("Cursors/Default Mouse"), Vector2.zero, CursorMode.Auto);
    }
Beispiel #2
0
        internal static async Task <bool> CastAura(uint spellId, int delay, int auraId = -1)
        {
            var result = false;

            if (auraId == -1 || !Core.Player.HasAura(

#if !RB_CN
                    (uint)
#endif
                    auraId))
            {
                SpellData spellData;
                if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[spellId]))
                {
                    await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(DataManager.SpellCache[spellId]));
                }

                result = ActionManager.DoAction(spellId, Core.Player);
                var ticks = 0;
                while (result == false && ticks++ < 5 && Behaviors.ShouldContinue)
                {
                    result = ActionManager.DoAction(spellId, Core.Player);
                    await Coroutine.Yield();
                }

                if (result)
                {
                    Logger.Instance.Info("Casted Aura -> {0}", spellData.Name);
                }
                else
                {
                    Logger.Instance.Error("Failed to cast Aura -> {0}", spellData.Name);
                }

                //Wait till we have the aura
                await Coroutine.Wait(3500, () => Core.Player.HasAura(

#if !RB_CN
                                         (uint)
#endif
                                         auraId));

                if (delay > 0)
                {
                    await Coroutine.Sleep(delay);
                }
                else
                {
                    await Coroutine.Yield();
                }
            }

            return(result);
        }
Beispiel #3
0
        protected internal static async Task Wait()
        {
            if (GatheringManager.ShouldPause(DataManager.SpellCache[(uint)Ability.Preparation]))
            {
                var ticks = 0;
                while (ticks++ < 60 && Behaviors.ShouldContinue)
                {
                    if (!GatheringManager.ShouldPause(DataManager.SpellCache[(uint)Ability.Preparation]))
                    {
                        break;
                    }

                    await Coroutine.Yield();
                }
            }
        }
Beispiel #4
0
        internal static async Task <bool> Cast(uint id, int delay)
        {
            //TODO: check affinity, cost type, spell type, and add more informational logging and procedures to casting
            //Wait till we can cast the spell
            SpellData spellData;

            if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[id]))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }

            var result = ActionManager.DoAction(id, Core.Player);

            var ticks = 0;

            while (result == false && ticks++ < 10 && Behaviors.ShouldContinue)
            {
                result = ActionManager.DoAction(id, Core.Player);
                await Coroutine.Yield();
            }

            if (result)
            {
                Logger.Instance.Info("Casted Ability -> {0}", spellData.Name);
            }
            else
            {
                Logger.Instance.Error("Failed to cast Ability -> {0}", spellData.Name);
            }

            //Wait till we can cast again
            if (GatheringManager.ShouldPause(spellData))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }
            if (delay > 0)
            {
                await Coroutine.Sleep(delay);
            }
            else
            {
                await Coroutine.Yield();
            }

            return(result);
        }
 private QuestionnaireService Create()
 {
     _userValidation          = Substitute.For <IUserValidation>();
     _respondentsRepository   = Substitute.For <IRespondentsRepository>();
     _vksocialNetworkGrabber  = Substitute.For <GatheringManager <SocialNetworkDataVkontakte> >();
     _fbsocialNetworkGrabber  = Substitute.For <GatheringManager <SocialNetworkDataFacebook> >();
     _questionnaireRepository = Substitute.For <IQuestionnaireRepository>();
     _log         = Substitute.For <ILogger>();
     _outcomputer = Substitute.For <IOutcomeComputer>();
     _congruenceOutcomeComputer = Substitute.For <CongruenceOutcomeComputer>();
     return(new QuestionnaireService(_userValidation,
                                     _respondentsRepository,
                                     _questionnaireRepository,
                                     _fbsocialNetworkGrabber,
                                     _vksocialNetworkGrabber,
                                     _log,
                                     _outcomputer,
                                     _congruenceOutcomeComputer
                                     ));
 }
        public QuestionnaireService(IUserValidation userValidation,
                                    IRespondentsRepository respondentsRepository,
                                    IQuestionnaireRepository questionnaireRepository,
                                    GatheringManager <SocialNetworkDataFacebook> gfb,
                                    GatheringManager <SocialNetworkDataVkontakte> gvk,
                                    ILogger log,
                                    IOutcomeComputer outcomeComputer,
                                    CongruenceOutcomeComputer congruenceOutcomeComputer)
        {
            OperationContext.Current.InstanceContext.Closed += InstanceContextClosed;

            _userValidation          = userValidation;
            _respondentsRepository   = respondentsRepository;
            _questionnaireRepository = questionnaireRepository;
            _log                       = log;
            _gfb                       = gfb;
            _gvk                       = gvk;
            _outcomeComputer           = outcomeComputer;
            _congruenceOutcomeComputer = congruenceOutcomeComputer;
        }
Beispiel #7
0
        internal async Task <bool> ResolveGatherItem()
        {
            if (!GatheringManager.WindowOpen)
            {
                return(false);
            }

            var previousGatherItem = GatherItem;

            GatherItemIsFallback = false;
            GatherItem           = null;
            CollectableItem      = null;

            var windowItems = GatheringManager.GatheringWindowItems.ToArray();

            // TODO: move method to common so we use it on fish too
            if (InventoryItemCount() >= 140)
            {
                if (Items.Count > 0)
                {
                    if (
                        SetGatherItem(
                            windowItems.OrderByDescending(i => i.SlotIndex).Where(i => i.IsFilled && !i.IsUnknown && i.ItemId < 20).ToArray()))
                    {
                        return(true);
                    }
                }

                GatherItem =
                    windowItems.Where(i => i.IsFilled && !i.IsUnknown)
                    .OrderByDescending(i => i.ItemId)
                    .FirstOrDefault(i => i.ItemId < 20);

                if (GatherItem != null)
                {
                    return(true);
                }

                Logger.Warn(Localization.Localization.ExGather_FullInventory);
                return(false);
            }

            if (DiscoverUnknowns)
            {
                var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex);

                GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

                if (GatherItem != null)
                {
                    return(true);
                }
            }

            if (Items.Count > 0)
            {
                if (SetGatherItem(windowItems))
                {
                    return(true);
                }
            }

            if (Slot > -1 && Slot < 8)
            {
                GatherItem = GatheringManager.GetGatheringItemByIndex((uint)Slot);
            }

            if (GatherItem == null && (!AlwaysGather || GatherStrategy == GatherStrategy.TouchAndGo))
            {
                Poi.Clear(Localization.Localization.ExGather_SkipNode);

                await CloseGatheringWindow();

                return(false);
            }

            if (GatherItem != null)
            {
                return(true);
            }

            GatherItemIsFallback = true;

            GatherItem =
                windowItems.Where(i => i.IsFilled && !i.IsUnknown)
                .OrderByDescending(i => i.ItemId)
                .FirstOrDefault(i => i.ItemId < 20)     // Try to gather cluster/crystal/shard
                ?? windowItems.FirstOrDefault(
                    i => i.IsFilled && !i.IsUnknown && !i.ItemData.Unique && !i.ItemData.Untradeable && i.ItemData.ItemCount() > 0)
                // Try to collect items you have that stack
                ?? windowItems.Where(i => i.Amount > 0 && !i.ItemData.Unique && !i.ItemData.Untradeable)
                .OrderByDescending(i => i.SlotIndex)
                .FirstOrDefault();     // Take last item that is not unique or untradeable

            // Seems we only have unknowns.
            if (GatherItem == null)
            {
                var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex).ToArray();

                GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

                if (GatherItem != null)
                {
                    return(true);
                }

                Logger.Warn(Localization.Localization.ExGather_NothingToGather);

                return(false);
            }

            if (previousGatherItem == null || previousGatherItem.ItemId != GatherItem.ItemId)
            {
                Logger.Info(Localization.Localization.ExGather_NothingToGather2 + GatherItem.ItemData + Localization.Localization.ExGather_NothingToGather3);
            }

            return(true);
        }