public void Initialize(TraderRequestsSO requests, ProductTrader trader, WorldClock worldClock)
 {
     _trader = trader;
     InitializeRequestsTable();
     BindWorldClock(worldClock);
     BindScriptable(requests);
 }
Exemple #2
0
        /// <summary>
        /// Initializes the current instance
        /// </summary>
        /// <param name="clock">The clock.</param>
        /// <param name="isbacktest">if set to <c>true</c> [isbacktest].</param>
        public virtual void Initialize(WorldClock clock, bool isbacktest)
        {
            //Set items
            Clock      = clock;
            IsBacktest = isbacktest;

            //Set all possible currency symbol combinations
            var found = Enum.GetNames(typeof(CurrencyType));

            found.ForEach(basecurrency =>
            {
                var commodities = Enum.GetNames(typeof(CurrencyType));
                commodities.ForEach(com =>
                {
                    CurrencySymbols.Add(basecurrency + "/" + com, new[]
                    {
                        (CurrencyType)Enum.Parse(typeof(CurrencyType), basecurrency),
                        (CurrencyType)Enum.Parse(typeof(CurrencyType), com)
                    });
                });
            });

            //Get from config
            History = GetFromConfig();
            UpdateRange();
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Portfolio"/> class.
        /// </summary>
        /// <param name="clock">The clock.</param>
        /// <param name="actionscheduler">The actionscheduler.</param>
        /// <param name="brokerconnection">The brokerconnection.</param>
        /// <param name="brokermodel">The brokermodel.</param>
        /// <param name="currency">The currency.</param>
        /// <param name="eventrunner">The eventrunner.</param>
        /// <param name="exceptionhandler">The exceptionhandler.</param>
        /// <param name="orderTicketHandler">The order ticket handler.</param>
        /// <param name="brokeraccount">The brokeraccount.</param>
        /// <param name="cashmanager">The cashmanager.</param>
        /// <param name="runmode">The runmode.</param>
        /// <param name="datafeed">The datafeed.</param>
        /// <param name="benchmark">The benchmark.</param>
        /// <param name="id">The identifier.</param>
        public Portfolio(WorldClock clock, ActionsScheduler actionscheduler, BrokerConnection brokerconnection, BrokerModel brokermodel,
                         Currency currency, EventRunner eventrunner, ExceptionHandler exceptionhandler, OrderTicketHandler orderTicketHandler,
                         BrokerAccount brokeraccount, CashManager cashmanager, RunMode runmode, DataFeed datafeed, Benchmark benchmark, string id = "")
        {
            //Set references
            ActionsScheduler   = actionscheduler;
            BrokerAccount      = brokeraccount;
            BrokerConnection   = brokerconnection;
            BrokerModel        = brokermodel;
            Clock              = clock;
            Currency           = currency;
            EventRunner        = eventrunner;
            ExceptionHandler   = exceptionhandler;
            CashManager        = cashmanager;
            OrderTicketHandler = orderTicketHandler;
            _porfolioBenchmark = benchmark;

            //Set initial items
            Id            = id;
            IsBacktesting = runmode == RunMode.Backtester;
            OrderFactory  = new OrderFactory(this, BrokerModel);
            OrderTracker  = new OrderTracker(this);
            Subscription  = new DataSubscriptionManager(datafeed, CashManager);
            Results       = new Result(0, _porfolioBenchmark);

            //Portfolio benchmark is not used
            benchmark.OnCalc(x => 0);
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            worldClock = new WorldClock(player.worldClock);
            worldClockLabel.Content = worldClock.clock;
            playerName.Content      = player.name;
            playerHealth.Content    = player.stats.health;
            playerHunger.Content    = player.stats.hunger;

            goldCount.Content  = player.stats.gold;
            foodCount.Content  = player.stats.food;
            woodCount.Content  = player.stats.wood;
            stoneCount.Content = player.stats.stone;

            currentLocationText.Content = player.currentLocation.localeName;
            gatherButton.Content        = player.currentLocation.gatherDesc;

            BitmapImage bi3 = new BitmapImage();

            bi3.BeginInit();
            bi3.UriSource = new Uri(player.currentLocation.img, UriKind.Relative);
            bi3.EndInit();
            currentLocation.Stretch = Stretch.Fill;
            currentLocation.Source  = bi3;

            currentLocationDesc.Text = player.currentLocation.desc;
            SetTimer();
        }
Exemple #5
0
 private void Awake()
 {
     _instance   = this;
     _spawnPoint = GetComponent <WorldSpawnPoint>();
     _dayCycle   = GetComponent <DayCycle>();
     _worldClock = GetComponent <WorldClock>();
 }
Exemple #6
0
        public void OnTriggerTryToStart(Trigger trigger)
        {
            string failureMessage = string.Empty;

            if (State.HasBeenUnlocked)
            {
                return;
            }

            if (State.TimedLock && !WorldClock.IsTimeOfDay(State.TimesLocked))
            {
                return;
            }

            string keyName = string.Empty;

            if (Player.Local.Inventory.HasKey(State.KeyType, State.KeyTag, out keyName))
            {
                if (!State.HasBeenUnlocked)
                {
                    State.HasBeenUnlocked = true;
                    GUI.GUIManager.PostSuccess("Unlocked with " + keyName);
                }
                return;
            }

            failureMessage = "[Target] is locked";
            trigger.TriggerFail(dynamic, failureMessage);
        }
Exemple #7
0
        public void OnRefreshBehavior()
        {
            if (!mInitialized || mDestroyed)
            {
                return;
            }

            if (creature.State.Domestication != DomesticatedState.Wild)
            {
                Finish();
                return;
            }

            if (WorldClock.IsTimeOfDay(creature.State.AggressiveTOD))
            {
                Timid timid = null;
                if (worlditem.Is <Timid>(out timid))
                {
                    timid.Finish();
                }
                worlditem.GetOrAdd <Aggressive>();
                creature.Body.EyeMode = BodyEyeMode.Aggressive;
            }
            else
            {
                //if we're not aggressive, we're timid because we're wild
                Aggressive aggressive = null;
                if (worlditem.Is <Aggressive>(out aggressive))
                {
                    aggressive.Finish();
                }
                worlditem.GetOrAdd <Timid>();
                creature.Body.EyeMode = BodyEyeMode.Timid;
            }
        }
    public void CaptureCharacter()
    {
        WorldClock worldClock = FindObjectOfType <WorldClock>();

        worldClock.GiveTurnTo(Turn.None);
        FindObjectOfType <SessionManager>().ImprisonCharacter();
    }
Exemple #9
0
 /// <summary>
 /// Create form, create game
 /// </summary>
 public GameForm()
 {
     InitializeComponent();
     game = Game.CreateGame(this.ClientSize);
     watch.Start();
     WorldClock.Start();
 }
Exemple #10
0
    void Awake()
    {
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;

            // Must be first time creating this, we need our world clock, sun and moon!
            OurTimeSystem = (GameObject)Instantiate(WorldTime);
            time          = OurTimeSystem.GetComponentInChildren <WorldClock>();

            // Need OVRCam if assigned
            if (OVRCam != null && UseVR)
            {
                OVRCam      = (GameObject)Instantiate(OVRCam);
                OVRCam.name = "MyOVRCameraRig";
                DontDestroyOnLoad(OVRCam);
                GameObject.Find("Main Camera").GetComponent <AudioListener> ().enabled = false;
            }
            else
            {
                VRSettings.enabled = false;
            }
        }
        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);
    }
Exemple #11
0
 /// <summary>
 /// Create form, create game
 /// </summary>
 public GameForm(GameMode mode)
 {
     InitializeComponent();
     game = Game.CreateGame(ClientSize, mode);
     game.InitGame();
     watch.Start();
     WorldClock.Start();
 }
    // Update is called once per frame
    void Update()
    {
        //  clock count!
        WorldClock.CountUp();

        //  scene update!
        SceneController.Instance.SceneUpdate();
    }
 private void BindWorldClock(WorldClock worldClock)
 {
     worldClock.OnYearUp  += HandleYearUp;
     worldClock.OnMonthUp += HandleMonthUp;
     worldClock.OnWeekUp  += HandleWeekUp;
     worldClock.OnDayUp   += HandleDayUp;
     worldClock.OnHourUp  += HandleHourUp;
 }
    void UpdateTurnsAndSteps()
    {
        Character character = FindObjectOfType <Character>();

        stepsTaken += character.stepsTaken;
        WorldClock worldClock = FindObjectOfType <WorldClock>();

        turnsPassed += worldClock.turnsTaken;
    }
    // Use this for initialization
    void Start()
    {
        gm     = FindObjectOfType <GameManager>();
        player = GameObject.Find("Player");
        clock  = FindObjectOfType <WorldClock>();

        bAnimationStarted = false;
        //StartCoroutine(PlayAnimation(5));
    }
Exemple #16
0
 public PlayerInfo(int id, string name, Origin location, string file, WorldClock worldClock)
 {
     this.id              = id;
     this.name            = name;
     this.origin          = location;
     this.stats           = new Stats();
     this.currentLocation = origin.home;
     this.file            = file;
     this.worldClock      = worldClock;
 }
Exemple #17
0
        public override void PushSelectedObjectToViewer()
        {
            //turn this into a string builder
            Color         plantColor = Colors.ColorFromString(mSelectedObject.CommonName, 100);
            List <string> detailText = new List <string>();

            mExamineInfo.Clear();

            Skill            examineSkill      = null;
            GenericWorldItem dopplegangerProps = null;

            if (Skills.Get.SkillByName("Gathering", out examineSkill))
            {
                bool showDetails = false;
                Plants.Examine(mSelectedObject, mExamineInfo);
                detailText.Add("Viewing season " + WorldClock.TimeOfYearToString(SelectedSeasonality));
                if (Flags.Check((uint)mSelectedObject.EncounteredTimesOfYear, (uint)SelectedSeasonality, Flags.CheckType.MatchAny) ||
                    examineSkill.State.NormalizedUsageLevel > Plants.MinimumGatheringSkillToRevealBasicProps)
                {
                    showDetails                   = true;
                    dopplegangerProps             = mPlantDoppleganger;
                    dopplegangerProps.Subcategory = mSelectedObject.Name;
                }
                else
                {
                    detailText.Add("(You don't know what this plant looks like during this time of year.)");
                }
                detailText.Add("_");
                for (int i = 0; i < mExamineInfo.Count; i++)
                {
                    if (examineSkill.State.NormalizedUsageLevel > mExamineInfo[i].RequiredSkillUsageLevel)
                    {
                        detailText.Add(mExamineInfo[i].StaticExamineMessage);
                    }
                    else
                    {
                        detailText.Add(mExamineInfo[i].ExamineMessageOnFail);
                    }
                }
                string finalDetailText = detailText.JoinToString("\n");
                GUIDetailsPage.Get.DisplayDetail(
                    this,
                    mSelectedObject.CommonName,
                    finalDetailText,
                    "PlantIcon",
                    Mats.Get.IconsAtlas,
                    plantColor,
                    Color.white,
                    dopplegangerProps);
                if (showDetails)
                {
                    GUIDetailsPage.Get.DisplayDopplegangerButton("Next Season", "OnClickNextSeason", gameObject);
                }
            }
        }
 /// <summary>
 /// UnRegisters a WorldClock
 /// </summary>
 public void UnRegisterClock(WorldClock clockToRegister)
 {
     if (allClocks.ContainsKey(clockToRegister.ClockID))
     {
         allClocks.Remove(clockToRegister.ClockID);
     }
     else
     {
         Debug.LogWarningFormat("WorldClock {0} was not registered.", clockToRegister.ClockID);
     }
 }
 /// <summary>
 /// Registers a WorldClock for quick lookup
 /// </summary>
 /// <param name="clockToRegister"> The <see cref="WorldClock"/> to track in the library</param>
 public void RegisterClock(WorldClock clockToRegister)
 {
     if (!allClocks.ContainsKey(clockToRegister.ClockID))
     {
         allClocks.Add(clockToRegister.ClockID, clockToRegister);
     }
     else
     {
         Debug.LogWarningFormat("WorldClock {0} has already been registered. Do you have multiple instances of the same clock, or instances with the same id?", clockToRegister.ClockID);
     }
 }
 /// <summary>
 /// Sets an already registered clock active by its ID
 /// </summary>
 /// <param name="clockID">the id of the <see cref="WorldClock"/> to set active</param>
 public void SetActiveClock(string clockID)
 {
     if (!allClocks.ContainsKey(clockID))
     {
         Debug.LogWarningFormat("Please register the clock {0} before attempting to set it active.", clockID);
     }
     else
     {
         ActiveClock = allClocks[clockID];
     }
 }
    IEnumerator <WaitForSeconds> DelayOpenScene()
    {
        WorldClock worldClock = FindObjectOfType <WorldClock>();

        worldClock.GiveTurnTo(Turn.None);
        yield return(new WaitForSeconds(delayOpen));

        speakers.PlayOneShot(openSound);
        anim.SetTrigger("Open");
        worldClock.GiveTurnTo(Turn.Player);
        EnableSurrendering();
    }
Exemple #22
0
 /// <summary>
 /// Create form, create game
 /// </summary>
 public GameForm()
 {
     SongMap.Instance.Load();
     InitializeComponent();
     this.ClientSize = new Size(
         (2 * Screen.PrimaryScreen.Bounds.Width) / 3,
         (2 * Screen.PrimaryScreen.Bounds.Height) / 3
         );
     Game = Game.CreateGame(this.ClientSize);
     Watch.Start();
     WorldClock.Start();
 }
    /// <summary>
    /// Displays the time for the given WorldClock
    /// </summary>
    public void DisplayTime()
    {
        WorldClock clock = ClockLibrary.Instance.ActiveClock;

        if (clock != null)
        {
            displayText.text = clock.GetFormattedMinutesAndHours();
        }
        else
        {
            Debug.Log("No Active Clock");
        }
    }
 /// <summary>
 /// Set the active clock. Registers the clock if it is not already registered
 /// </summary>
 /// <param name="clock">A reference to the <see cref="WorldClock"/> to set active</param>
 public void SetActiveClock(WorldClock clock)
 {
     if (!allClocks.ContainsKey(clock.ClockID))
     {
         allClocks.Add(clock.ClockID, clock);
     }
     if (ActiveClock != null)
     {
         ActiveClock.Tick.RemoveListener(ActiveClockTicked);
     }
     ActiveClock = clock;
     ActiveClock.Tick.AddListener(ActiveClockTicked);
 }
Exemple #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PortfolioManager"/> class for running a backtest.
        /// </summary>
        /// <param name="portfolioimplementations">The portfolioimplementations.</param>
        /// <param name="simulation">The backtest.</param>
        public PortfolioManager(PortfolioImplementations portfolioimplementations, SimulationMessage simulation)
            : this(portfolioimplementations)
        {
            //Set initial message
            _initialMessageInstance = simulation;

            //Since this is a backtest request
            RunMode = RunMode.Backtester;

            //World clock is depended on data received
            var clock = new WorldClock(() => PortfolioImplementations.DataFeed.LastDataReceivedUtc == DateTime.MinValue ?
                                       simulation.StartDateTime :
                                       portfolioimplementations.DataFeed.LastDataReceivedUtc);

            //Get additional information
            if (!Enum.TryParse(simulation.AccountType, out AccountType accounttype))
            {
                throw new Exception($"Cannot initialize backtest account type {simulation.AccountType}");
            }
            if (!Enum.TryParse(simulation.BrokerType, out BrokerType brokertype))
            {
                throw new Exception($"Cannot initialize backtest broker type {simulation.BrokerType}");
            }
            if (!Enum.TryParse(simulation.BaseCurrency, out CurrencyType basecurrency))
            {
                throw new Exception($"Cannot initialize backtest base currency type {simulation.BaseCurrency}");
            }

            //Get latest currency rates, so we are up to date (trough forced reload)
            _log.Debug($"Initializing currency implementation: {PortfolioImplementations.Currency.GetType().FullName}");
            Config.LoadConfigFile <CurrencyRatesConfig[]>(Config.GlobalConfig.CurrencyRatesConfigFile, true);
            PortfolioImplementations.Currency.Initialize(clock, true);

            //Get broker model
            var brokermodel = BrokerModelFactory.GetBroker(accounttype, brokertype);

            //Check if the currency selected matches the currency of this broker (for instance when using crypto currencies)
            decimal allocatedfunds = simulation.QuantFund.AllocatedFunds;
            brokermodel.GetCompatibleInitialCapital(portfolioimplementations.Currency, ref basecurrency, ref allocatedfunds);
            simulation.QuantFund.AllocatedFunds = allocatedfunds;

            //Create portfolio
            _portfolio = CreatePortfolio(simulation.PortfolioId, Guid.NewGuid().ToString(), brokermodel,
                                         simulation.Leverage, basecurrency, basecurrency, clock, simulation.ExtendedMarketHours);

            //Set initial funds
            _portfolio.CashManager.AddCash(basecurrency, allocatedfunds);

            //Set initial fund message
            _initialFundMessage = simulation.QuantFund;
        }
        private void BindWorldClock()
        {
            _worldClock = WorldClock.Instance;

            // instantiate UI element
            var contentHolder  = _display.transform.FindChild("content_holder");
            var displayProduct = Instantiate(_displayTimePrefab);

            displayProduct.transform.SetParent(contentHolder, false);

            // return the text field to be updated every frame
            _clockDisplay      = displayProduct.transform.FindChild("product_value").GetComponent <TextMeshProUGUI>();
            _clockDisplay.text = GenerateCurrentTimeString();
        }
Exemple #27
0
        public void Initialize(Inventory inventory)
        {
            _inventory = inventory;
            if (_worldClock == null)
            {
                _worldClock          = WorldClock.Instance;
                _worldClock.OnDayUp += TickEnergyCosts;
            }

            if (_energyProduct == null)
            {
                _energyProduct = ProductLookup.Instance.GetProduct(ENERGY_PRODUCT_NAME);
            }
        }
Exemple #28
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Debug.Log("Multiple instances of WorldClock in the scene. Destroying duplicates.");
            Destroy(gameObject);
        }

        // Start on day 1, 07:00
        t = 86400 + 7 * 3600;
    }
        static void OnGuildUpdate(int msgID, BinReader data)
        {
            uint        charID = data.ReadUInt32();
            WorldClient client = WorldServer.GetClientByCharacterID(charID);

            client.Player.GuildID        = data.ReadUInt32();
            client.Player.GuildRank      = data.ReadUInt32();
            client.Player.GuildTimeStamp = WorldClock.GetTimeStamp();
            client.Player.Save();
            client.Player.UpdateData();
            client.Player.GuildTimeStamp = WorldClock.GetTimeStamp();
            client.Player.UpdateData();
            //			EventManager.AddEvent(new DelayedUpdateEvent(client.Player));
            return;
        }
Exemple #30
0
        /// <summary>
        /// Load crypto exchangeModel model
        /// </summary>
        /// <param name="clock"></param>
        public CryptoExchangeModel(WorldClock clock)
        {
            //Load config
            string configname = "crypto";
            var    config     = Config.MarketHourConfig.FirstOrDefault(x => x.Exchanges.Select(e => e.ToLower()).Contains(configname.ToLower()));

            if (config == null)
            {
                throw new ArgumentException($"Could not load configuration with name {configname}");
            }

            //Set information
            _worldClock = clock;
            TimeZone    = (TimeZone)Enum.Parse(typeof(TimeZone), config.TimeZone);
        }
Exemple #31
0
        public void AddComponentInstanceAndChildContainers()
        {
            IWindsorContainer parent = new WindsorContainer();
            IWindsorContainer child = new WindsorContainer();
            parent.AddChildContainer(child);

            IClock clock1 = new IsraelClock();
            IClock clock2 = new WorldClock();

            parent.Kernel.AddComponentInstance<IClock>(clock2);
            child.Kernel.AddComponentInstance<IClock>(clock1);

            Assert.AreSame(clock2,parent.Resolve<IClock>());
            Assert.AreSame(clock1, child.Resolve<IClock>());

        }