public void Should_contain_risk_one_percent() { var moneyManagement = new MoneyManagement(1, 10000); double lot = moneyManagement.CalculateLotSize(400); Assert.AreEqual(0.25, lot); }
/// <summary>Spawns harvesters on completed build process</summary> public void InitializeBuilt() { this.moneyManager = GameObject.Find("/Main/Canvas/BackgroundTopStripRessources/TextDollar").GetComponent <MoneyManagement>(); this.floatUpSpawner = GameObject.Find("/Main/Canvas/UXElemente").GetComponent <FloatUpSpawner>(); this.mine = transform.parent.transform.gameObject.GetComponentInChildren <BuildBuilding>().BuiltBuildings[2]; // .transform.GetChild(0).gameObject; this.AddHarvester(ref this.attachedHarvesters, ref this.moneyManager, this, this.mine); }
// Use this for initialization void Start() { inv = GameObject.Find("Player").GetComponent <InventoryManagement>(); moneyMng = GameObject.Find("Player").GetComponent <MoneyManagement>(); }
void Start() { playerFlames = GameObject.FindGameObjectWithTag(TagManager.PLAYER_FLAMES).GetComponent<ParticleSystem>(); moneyManagment = GameObject.FindGameObjectWithTag(TagManager.PLAYER).GetComponent<MoneyManagement>(); beforeBurningMoney = moneyManagment.getCurrentMoney(); }
public void Should_contain_risk_one_percent_smaller() { var moneyManagement = new MoneyManagement(1, 2000); double lot = moneyManagement.CalculateLotSize(new MagicBoxOrder { StopLoss = 200 }); Assert.AreEqual(0.1, lot); }
/// <summary>Use this for initialization</summary> private void Start() { var buildingManager = this.AttachedBuilding.GetComponentInChildren<BuildingManager>(); this.costBuilding = buildingManager.BuildCost; this.costEnergy = buildingManager.CostEnergy; this.Cost.text = MoneyManagement.FormatMoney(this.costBuilding); //SetAvailability(false); }
/// <summary> /// Gives the harvester all important values /// </summary> /// <param name="attachedOreRefinery">Ore Refinery to drive to</param> /// <param name="attachedMine">Mine to drive to</param> /// <param name="moneyManagement">Reference to the money pool</param> /// <param name="floatUpSpawner">Reference to the FloatUpSpawner</param> public void Initialize(OreRefinery attachedOreRefinery, GameObject attachedMine, ref MoneyManagement moneyManagement, FloatUpSpawner floatUpSpawner) { this.attachedOreRefinery = attachedOreRefinery; this.attachedMine = attachedMine; this.moneyManagement = moneyManagement; this.floatUpSpawner = floatUpSpawner; AppPauseHandler.Harvesters.Add(this); }
/// <summary> /// Adds a harvester to the refinery /// </summary> /// <param name="attachedHarvesters">Reference to the list the new harvester should be inserted into</param> /// <param name="moneyManager">Reference to the MoneyManagement to add money when harvester is working</param> /// <param name="oreRefinery">The attached refinery</param> /// <param name="oreMine">The attached mine</param> private void AddHarvester(ref List <GameObject> attachedHarvesters, ref MoneyManagement moneyManager, OreRefinery oreRefinery, GameObject oreMine) { var go = UnityEngine.Object.Instantiate(this.HarvesterPrefab, transform.parent); var harvester = go.GetComponentInChildren <Harvester>(); harvester.Initialize(oreRefinery, oreMine, ref moneyManager, this.floatUpSpawner); attachedHarvesters.Add(go); }
public void SetItem(Field field) { try { if (isBuying && MoneyManagement.GetMoney() >= 0 && MoneyManagement.GetMoney() >= cost) { if (!field.isOccupied) { Vector3 itempos = field.gameObject.transform.position; if (prefab.name.Contains("Tower")) { if (Tower.allowedFieldID == field.fieldid) { GameObject newItem = Instantiate(prefab, new Vector3(itempos.x, itempos.y + 5f, itempos.z), new Quaternion(), parent.transform); newItem.AddComponent <Tower>(); newItem.GetComponent <Tower>().posInGrid = field.position; MoneyManagement.BuyItems(cost); PhaseManager.consoletext.text = itemName + " gekauft für " + cost.ToString() + " Gold."; field.isOccupied = true; } else { PhaseManager.consoletext.text = "Not a valid field!"; } } if (prefab.name.Contains("Hero")) { if (Hero.allowedFieldIDs.Contains(field.fieldid)) { GameObject newItem = Instantiate(prefab, new Vector3(itempos.x, itempos.y + 5f, itempos.z), new Quaternion(), parent.transform); newItem.AddComponent <Hero>(); newItem.GetComponent <Hero>().posInGrid = field.position; MoneyManagement.BuyItems(cost); PhaseManager.consoletext.text = itemName + " gekauft für " + cost.ToString() + " Gold."; field.isOccupied = true; } else { PhaseManager.consoletext.text = "Not a valid field!"; } } } else { PhaseManager.consoletext.text = "Field is occupied!"; } } else { PhaseManager.consoletext.text = "Not enough Money!"; } } catch (Exception) { PhaseManager.consoletext.text = "Not implemented Item"; } }
/// <summary> /// This method tries to order a specific unit. If the player has enough money the queue is started. /// </summary> /// <param name="moneyManager">The reference to the players money pool</param> public void Order(ref MoneyManagement moneyManager) { if (!moneyManager.SubMoney(this.CreateAndOrderButton.Cost)) { return; } this.baseSwitch.GetProductionQueue().AddToQueue(this, this.CreateAndOrderButton); this.CreateAndOrderButton.AddSingleUnitBuilding(); }
internal Order CreatePendingSellOrder() { double slPoints = (High[1] - Low[1]) / Point + 2 * Range; double tpPoints = 2 * slPoints * Point; var moneyManagement = new MoneyManagement(2, Balance); double lotSize = moneyManagement.CalculateLotSize(slPoints); Order order = PendingSell(Symbol, lotSize, Low[1] - Range * Point, High[1] + Range * Point, Low[1] - tpPoints); this.ObjectsDeleteAll(); return(order); }
void Awake() { respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>(); dying = false; respawning = false; currentColor = Color.black; screenRect = new Rect(0f, 0f, Screen.width, Screen.height); player = GameObject.FindGameObjectWithTag(TagManager.PLAYER); money = player.GetComponent<MoneyManagement>(); loadGame = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<LoadGameSettings>(); }
/// <summary> /// Triggered by a button click. Builds the wanted building if the money in the attached MoneyManager is enough to cover the costs. /// </summary> /// <param name="i">The index of the building that should be built (Indexes defined in BuildBuilding class)</param> public void ClickBuildBuilding(int i) { if (!available) { return; } if (MoneyManagement.HasMoney(this.costBuilding)) { this.BaseSwitch.GetBuilder().BuildABuilding(i, this.costBuilding, this.costEnergy); } else { SoundControll.StartSound(SoundController.Sounds.FUNDS_REQUIRED); } }
private void OnTriggerStay(Collider other) { if (other != null) { if (other.name.Contains("Hero")) { isInFight = true; if (actHP <= 0) { other.gameObject.GetComponent <Hero>().isInFight = false; MoneyManagement.DropMoney(moneydropped); Destroy(this.gameObject); } } } }
// Update is called once per frame void Update() { // All das hier muss im Update stehen #region Set Color if (isInFightWithTower || isInFight) { this.gameObject.GetComponent <Renderer>().material.color = Color.red; } else { this.gameObject.GetComponent <Renderer>().material.color = standard_color; } #endregion #region Set Stop in Fight if (isInFight) { movementstep = 0; } else { movementstep = speed * Time.deltaTime * 2; } #endregion if (GameManager.isDead) { Destroy(this.gameObject); } #region Check for Next Waypoint and Move // MoneyDrop and die if (targetWaypoint != null || this != null) { float dist = Vector3.Distance(this.transform.position, targetWaypoint.position); CheckDistance(dist); } this.transform.position = Vector3.MoveTowards(this.transform.position, targetWaypoint.position, movementstep); if (actHP <= 0) { MoneyManagement.DropMoney(moneydropped); Destroy(this.gameObject); } #endregion }
internal void CreatedMagicBoxFromPreviousCandle() { double asianSessionHigh = AsianSessionHigh; double asianSessionLow = AsianSessionLow; double slPoints = (asianSessionHigh - asianSessionLow) / Point + 2 * range; var moneyManagement = new MoneyManagement(2, Balance); double lotSize = moneyManagement.CalculateLotSize(slPoints); double tpPoints = Math.Max(1000 * Point, 2 * slPoints * Point); //var tpPoints = 200 * Point; // risk reward ratio = 2 * slPoints _buyOrder = PendingBuy(Symbol, lotSize, asianSessionHigh + range * Point, asianSessionLow - range * Point, asianSessionHigh + tpPoints); _sellOrder = PendingSell(Symbol, lotSize, asianSessionLow - range * Point, asianSessionHigh + range * Point, asianSessionLow - tpPoints); this.ObjectsDeleteAll(); }
private void CreateOrderBox(MagicBoxOrder magicBox) { /// need to refactor this messs into another class double range = magicBox.Range; double takeProfit = magicBox.TakeProfit; // nullify take profit double stopLoss = magicBox.StopLoss; // nullify stop loss, should set after enter the trade. double expiredTime = magicBox.MinuteExpiracy; var moneyManagement = new MoneyManagement(1, Balance); double lotSize = moneyManagement.CalculateLotSize(magicBox.StopLoss); foreach (string currencyPairs in currencyRepository.GetRelatedCurrencyPairs(this, magicBox.Symbol)) { // check if the order has been created for this pair if (orderPool.ContainsOrderForSymbol(currencyPairs)) continue; // refactor to next class and cache the traded value ...(don't let it duplicated like tonight usdcad pairs) // the logic should be in orderPool Order buyOrder = PendingBuy(currencyPairs, lotSize, BuyOpenPriceFor(currencyPairs) + range*PointFor(currencyPairs)); buyOrder.ChangeStopLossInPoints(magicBox.StopLoss); buyOrder.ChangeTakeProfitInPoints(magicBox.TakeProfit); Order sellOrder = PendingSell(currencyPairs, lotSize, SellOpenPriceFor(currencyPairs) - range*PointFor(currencyPairs)); sellOrder.ChangeStopLossInPoints(magicBox.StopLoss); sellOrder.ChangeTakeProfitInPoints(magicBox.TakeProfit); //var buyOrder = PendingBuy(magicBox.Symbol, lotSize, // BuyOpenPriceFor(magicBox.Symbol) + range * PointFor(magicBox.Symbol), // BuyClosePriceFor(magicBox.Symbol) + ((range - stopLoss) * PointFor(magicBox.Symbol)), // BuyClosePriceFor(magicBox.Symbol) + ((range + takeProfit) * PointFor(magicBox.Symbol))); //var sellOrder = PendingSell(magicBox.Symbol, lotSize, // SellOpenPriceFor(magicBox.Symbol) - range * PointFor(magicBox.Symbol), // SellClosePriceFor(magicBox.Symbol) - ((range - stopLoss) * PointFor(magicBox.Symbol)), // SellClosePriceFor(magicBox.Symbol) - ((range + takeProfit) * PointFor(magicBox.Symbol))); orderPool.Add(new OrderWatcher(buyOrder, sellOrder, expiredTime, magicBox.Config)); } }
void Awake() { money = GameObject.FindGameObjectWithTag(TagManager.PLAYER).GetComponent<MoneyManagement>(); beforeMoney = money.getCurrentMoney(); sneaking = true; }
// Use this for initialization void Start() { butRect = new Rect ((Screen.width - width) / 2, 0, width, height); moneyManagement = GameObject.FindGameObjectWithTag(TagManager.PLAYER).GetComponent<MoneyManagement>(); player = GameObject.FindGameObjectWithTag(TagManager.PLAYER); control = player.GetComponent<PlayerControl>(); drinkLogic = player.GetComponent<DrinkLogic>(); }
// Use this for initialization void Start() { inv = GameObject.Find("Player").GetComponent<InventoryManagement>(); moneyMng = GameObject.Find("Player").GetComponent<MoneyManagement>(); }