// Use this for initialization void Awake() { setYAxisLevel = transform.position.y; interactions = gameObject.GetComponent<InteractiveObject> (); status = critterStates.free; forthrow = GetComponent<Rigidbody>(); }
void OnTriggerEnter(Collider other) { if(other.tag == "IOEnemy") { if(targetList.Exists(InteractiveObject => InteractiveObject.targetName == other.name)) { } else { InteractiveObject newEnemy = new InteractiveObject(0, other.transform, other.name); targetList.Add(newEnemy); Debug.Log ("Adding new Enemy to Navi-List - Type: " + newEnemy.targetType + " Name: " + newEnemy.targetName); } } if(other.tag == "IONPC") { InteractiveObject newNPC = new InteractiveObject(1, other.transform, other.name); targetList.Add (newNPC); Debug.Log ("Adding new NPC to Navi-List - Type: " + newNPC.targetType + " Name: " + newNPC.targetName); } if(other.tag == "IO") { InteractiveObject newObject = new InteractiveObject(2, other.transform, other.name); targetList.Add (newObject); Debug.Log ("Adding new NPC to Navi-List - Type: " + newObject.targetType + " Name: " + newObject.targetName); } }
public void Awake() { startPivotLocalPosition = this.pickingUpPivotTr.localPosition; currentInteractableObjects = new List<InteractiveObject>(); currentPointedObject = null; heldObject = null; heldObjectIsInHand = false; }
public void OnTriggered(InteractiveObject ByObject = null) { if (triggerOnlyOnce && _triggered) return; //Debug.Log ("showing " + this); Dialog.instance.Show(this, ByObject); _triggered = true; }
void Avake() { cloudCollider = gameObject.GetComponent<Collider>(); alongMove = 0f; direction = 1; cloudInteractions = GetComponent<InteractiveObject>(); Debug.Log (gameObject.GetComponent<InteractiveObject>()); }
void Awake() { playerText = GameObject.Find("Textbox").GetComponent<PlayerText>(); dayController = GameObject.Find("GameManager").GetComponent<DayController>(); task1 = GameObject.Find("AlarmClock").GetComponent<InteractiveObject>(); task2 = GameObject.Find("Microwave").GetComponent<InteractiveObject>(); task3 = GameObject.Find("Dresser").GetComponent<InteractiveObject>(); }
public void OnHitButton(int index) { Hide(); if (!_currentEvent.PerformAction(index)) { Game.instance.OnFinishedInteraction(); _currentObject = null; } }
public bool AddToInventory(InteractiveObject obj) { if (inventory.Count < 10) { inventory.Add(obj); return true; } return false; }
void Awake() { _stateObject = transform.parent.GetComponentInChildren< ToggleStateObject >(); if (!_stateObject) { gameObject.SetActive(false); Debug.Log("Could not find a ToggleStateObject to use! Disabling this object."); } }
public void GenerateRoom(int blocked) { newRoom = true; roomNumber++; int choice; blockedDirection = blocked; obj = null; enemy = null; while (obj == null || enemy == null) { choice = Random.Range (0, allObjects.Length); if (allObjects[choice].ObjectType() == "Enemy") { if (roomNumber <= 10) if (allObjects[choice].GetTier() == 1) enemy = (Enemy)allObjects[choice]; else if (roomNumber <= 20) if (allObjects[choice].GetTier() == (Random.Range (0f, 10f) < 5 ? 1 : 2)) enemy = (Enemy)allObjects[choice]; else if (roomNumber <= 30) if (allObjects[choice].GetTier () == (Random.Range (0f, 10f) < 5 ? 2 : 3)) enemy = (Enemy)allObjects[choice]; else if (roomNumber <= 40) if (allObjects[choice].GetTier () == 3) enemy = (Enemy)allObjects[choice]; } else if (allObjects[choice].ObjectType() == "Object") { if (roomNumber <= 10) if (allObjects[choice].GetTier() == 1) obj = allObjects[choice]; else if (roomNumber <= 20) if (allObjects[choice].GetTier() == (Random.Range (0f, 10f) < 5 ? 1 : 2)) obj = allObjects[choice]; else if (roomNumber <= 30) if (allObjects[choice].GetTier () == (Random.Range (0f, 10f) < 5 ? 2 : 3)) obj = allObjects[choice]; else if (roomNumber <= 40) if (allObjects[choice].GetTier () == 3) obj = allObjects[choice]; } } }
public string Equip(string item) { InteractiveObject temp; if (CheckInventory(item) != null && CheckInventory(item).CanBeEquipped()) { if (equippedItem != null) { temp = equippedItem; equippedItem = CheckInventory(item); RemoveFromInventory(item); AddToInventory(temp); return "You swapped " + temp.ToString () + " with "+ item + "."; } equippedItem = CheckInventory(item); RemoveFromInventory(item); return "You are now wielding " + item.ToLower() +"!"; } return "You can't equip that."; }
public void Show(GameEvent CurrentEvent, InteractiveObject ParentObject=null) { /*while (buttonsContainer.childCount > 0) { Destroy(buttonsContainer.GetChild(0).gameObject); }*/ _currentEvent = CurrentEvent; foreach(DialogButton b in buttons) { b.gameObject.SetActive(false); } if (_currentEvent.actions.Length == 0) { SetButton(buttons[0], "Continue my quest for the truth."); } else { for(int i=0;i<Mathf.Min(_currentEvent.actions.Length,buttons.Length);i++) { SetButton(buttons[i], _currentEvent.actions[i].label); } } ButtonsGroup.alpha = 0; ButtonsGroup.interactable = false; ButtonsGroup.blocksRaycasts = false; if (ParentObject != null) { _currentObject = ParentObject; } if (_currentObject != null) { objectName.text = _currentObject.name; } else { objectName.text = ""; } CameraHandler.instance.targetObject = _currentObject; parent.SetActive(true); dialogText.text = ""; var reveal = dialogText.GetComponent<RevealText>(); reveal.Reveal2(_currentEvent.description, onComplete: () => StartCoroutine(RevealButtons())); }
/// <summary> /// Обработчик под тип входных данных OPTION_SERIES /// </summary> /// <param name="price">цена БА</param> /// <param name="time">время до экспирации в долях года</param> /// <param name="optSer">опционная серия</param> /// <param name="rate">процентная ставка</param> /// <param name="barNum">индекс бара в серии</param> /// <returns>улыбка, восстановленная из цен опционов</returns> public InteractiveSeries Execute(double price, double time, IOptionSeries optSer, double rate, int barNum) { int barsCount = ContextBarsCount; if ((barNum < barsCount - 1) || (optSer == null)) { return(Constants.EmptySeries); } double f = price; double dT = time; if (Double.IsNaN(f)) { //throw new ScriptException("Argument 'price' contains NaN for some strange reason. f:" + f); return(Constants.EmptySeries); } if ((dT < Double.Epsilon) || (Double.IsNaN(dT))) { return(Constants.EmptySeries); } if (Double.IsNaN(rate)) { //throw new ScriptException("Argument 'rate' contains NaN for some strange reason. rate:" + rate); return(Constants.EmptySeries); } IOptionStrikePair[] strikes = (from strike in optSer.GetStrikePairs() //orderby strike.Strike ascending -- уже отсортировано select strike).ToArray(); List <InteractiveObject> controlPoints = new List <InteractiveObject>(); for (int j = 0; j < strikes.Length; j++) { IOptionStrikePair sInfo = strikes[j]; // Сверхдалекие страйки игнорируем if ((sInfo.Strike < m_minStrike) || (m_maxStrike < sInfo.Strike)) { continue; } double putPx, callPx; double putQty, callQty; DateTime putTime, callTime; { putPx = IvSmile.GetOptPrice(m_context, f, sInfo.Put, m_optionPxMode, sInfo.Tick * m_shiftAsk, sInfo.Tick * m_shiftBid, out putQty, out putTime); } { callPx = IvSmile.GetOptPrice(m_context, f, sInfo.Call, m_optionPxMode, sInfo.Tick * m_shiftAsk, sInfo.Tick * m_shiftBid, out callQty, out callTime); } double putSigma = Double.NaN, callSigma = Double.NaN, precision; if (!Double.IsNaN(putPx)) { putSigma = FinMath.GetOptionSigma(f, sInfo.Strike, dT, putPx, rate, false, out precision); putSigma = Math.Min(putSigma, m_maxSigma); if (putSigma <= 0) { putSigma = Double.NaN; } } if (!Double.IsNaN(callPx)) { callSigma = FinMath.GetOptionSigma(f, sInfo.Strike, dT, callPx, rate, true, out precision); callSigma = Math.Min(callSigma, m_maxSigma); if (callSigma <= 0) { callSigma = Double.NaN; } } InteractivePointActive ip = new InteractivePointActive(); { //ip.Color = (m_optionPxMode == OptionPxMode.Ask) ? Colors.DarkOrange : Colors.DarkCyan; //ip.DragableMode = DragableMode.None; //ip.Geometry = Geometries.Rect; // (optionPxMode == OptionPxMode.Ask) ? Geometries.Rect : Geometries.Rect; //ip.IsActive = true; //ip.Value = new Point(d2.V1, d2.V2); //ip.Tooltip = String.Format("K:{0}; IV:{1:#0.00}", d2.V1, d2.V2 * PctMult); } InteractiveObject obj = new InteractiveObject(ip); if (m_optionType == StrikeType.Put) { if (!Double.IsNaN(putSigma)) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false, rate); controlPoints.Add(obj); } } else if (m_optionType == StrikeType.Call) { if (!Double.IsNaN(callSigma)) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false, rate); controlPoints.Add(obj); } } else if (m_optionType == StrikeType.Any) { if ((!Double.IsNaN(putSigma)) && (!Double.IsNaN(callSigma))) { if (m_optionPxMode == OptionPxMode.Ask) { if (putSigma < callSigma) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false, rate); } else { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false, rate); } } else if (m_optionPxMode == OptionPxMode.Bid) { if (putSigma > callSigma) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false, rate); } else { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false, rate); } } controlPoints.Add(obj); } else if ((!Double.IsNaN(putSigma)) && (Double.IsNaN(callSigma))) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false, rate); controlPoints.Add(obj); } else if ((Double.IsNaN(putSigma)) && (!Double.IsNaN(callSigma))) { FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false, rate); controlPoints.Add(obj); } } } // ReSharper disable once UseObjectOrCollectionInitializer InteractiveSeries res = new InteractiveSeries(); // Здесь так надо -- мы делаем новую улыбку res.ControlPoints = new ReadOnlyCollection <InteractiveObject>(controlPoints); SmileInfo info; var baseSec = optSer.UnderlyingAsset; DateTime scriptTime = baseSec.Bars[baseSec.Bars.Count - 1].Date; if (!IvSmile.TryPrepareSmileInfo(m_context, f, dT, rate, optSer.ExpirationDate, scriptTime, baseSec.Symbol, res, out info)) { return(Constants.EmptySeries); } return(res); }
void OnTriggerEnter(Collider other) { if(other.gameObject.tag == INTERACTIVE_TAG) { interactive_object = other.gameObject.GetComponent<InteractiveObject>(); } }
void Start() { interactions = GetComponent<InteractiveObject> (); gameObject.GetComponent<ParticleSystem>().Stop (); lastPosition = transform.position; }
public void Reset() { blockedDirection = 0; roomNumber = 0; obj = null; enemy = null; }
public static void remove_focusOut(InteractiveObject that, Action <FocusEvent> value) { CommonExtensions.RemoveDelegate(that, value, FocusEvent.FOCUS_OUT); }
protected override void Execute(InteractiveObject obj, Command command) { obj.Use(); ResponseManager.Instance.UsedAirlock(WhoAmI.ToString() + '>', command.ReceiverID.ToString()); }
public static void add_keyDown(InteractiveObject that, Action <KeyboardEvent> value) { CommonExtensions.CombineDelegate(that, value, KeyboardEvent.KEY_DOWN); }
void ResetResponseEventListener(Button b, InteractiveObject sender, int response) { b.onClick.RemoveAllListeners (); b.onClick.AddListener(() => onResponsePressed(sender, response)); }
public static void remove_gestureZoom(InteractiveObject that, Action <TransformGestureEvent> value) { CommonExtensions.RemoveDelegate(that, value, TransformGestureEvent.GESTURE_ZOOM); }
public static void remove_imeStartComposition(InteractiveObject that, Action <IMEEvent> value) { CommonExtensions.RemoveDelegate(that, value, IMEEvent.IME_START_COMPOSITION); }
public static void remove_gestureTwoFingerTap(InteractiveObject that, Action <GestureEvent> value) { CommonExtensions.RemoveDelegate(that, value, GestureEvent.GESTURE_TWO_FINGER_TAP); }
public static void add_gestureSwipe(InteractiveObject that, Action <TransformGestureEvent> value) { CommonExtensions.CombineDelegate(that, value, TransformGestureEvent.GESTURE_SWIPE); }
public static void remove_gesturePressAndTap(InteractiveObject that, Action <PressAndTapGestureEvent> value) { CommonExtensions.RemoveDelegate(that, value, PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP); }
/// <summary> /// Метод под флаг TemplateTypes.INTERACTIVESPLINE /// </summary> public InteractiveSeries Execute(InteractiveSeries smile, IOptionSeries optSer, int barNum) { if ((smile == null) || (optSer == null)) { return(Constants.EmptySeries); } int barsCount = m_context.BarsCount; if (!m_context.IsLastBarUsed) { barsCount--; } if (barNum < barsCount - 1) { return(Constants.EmptySeries); } SmileInfo oldInfo = smile.GetTag <SmileInfo>(); if ((oldInfo == null) || (oldInfo.ContinuousFunction == null)) { return(Constants.EmptySeries); } double futPx = oldInfo.F; double dT = oldInfo.dT; if (m_executeCommand) { string msg = String.Format("[{0}.StartButton] Strike: {1}", GetType().Name, m_strike); m_context.Log(msg, MessageType.Info, false); } #region 1. Список страйков HashSet <string> serList = StrikeList; serList.Clear(); IOptionStrikePair[] pairs; if (Double.IsNaN(m_strikeStep) || (m_strikeStep <= Double.Epsilon)) { pairs = optSer.GetStrikePairs().ToArray(); } else { // Выделяем страйки, которые нацело делятся на StrikeStep pairs = (from p in optSer.GetStrikePairs() let test = m_strikeStep * Math.Round(p.Strike / m_strikeStep) where DoubleUtil.AreClose(p.Strike, test) select p).ToArray(); // [2015-12-24] Если шаг страйков по ошибке задан совершенно неправильно, // то в коллекцию ставим все имеющиеся страйки. // Пользователь потом разберется if (pairs.Length <= 0) { pairs = optSer.GetStrikePairs().ToArray(); } } //if (pairs.Length < 2) // return Constants.EmptyListDouble; foreach (IOptionStrikePair pair in pairs) { double k = pair.Strike; serList.Add(k.ToString(StrikeFormat, CultureInfo.InvariantCulture)); } #endregion 1. Список страйков InteractiveSeries res = Constants.EmptySeries; List <InteractiveObject> controlPoints = new List <InteractiveObject>(); #region 2. Формируем улыбку просто для отображения текущего положения потенциальной котировки // При нулевом рабочем объёме не утруждаемся рисованием лишних линий if (!DoubleUtil.IsZero(m_qty)) { for (int j = 0; j < pairs.Length; j++) { var pair = pairs[j]; double sigma = oldInfo.ContinuousFunction.Value(pair.Strike) + m_shiftIv; if (!DoubleUtil.IsPositive(sigma)) { //string msg = String.Format("[DEBUG:{0}] Invalid sigma:{1} for strike:{2}", GetType().Name, sigma, nodeInfo.Strike); //m_context.Log(msg, MessageType.Warning, true); continue; } //bool isCall = (futPx <= pair.Strike); bool isCall; if (m_optionType == StrikeType.Call) { isCall = true; } else if (m_optionType == StrikeType.Put) { isCall = false; } else { isCall = (futPx <= pair.Strike); } StrikeType optionType = isCall ? StrikeType.Call : StrikeType.Put; double theorOptPx = FinMath.GetOptionPrice(futPx, pair.Strike, dT, sigma, oldInfo.RiskFreeRate, isCall); theorOptPx += m_shiftPriceStep * pair.Tick; theorOptPx = Math.Round(theorOptPx / pair.Tick) * pair.Tick; if (!DoubleUtil.IsPositive(theorOptPx)) { //string msg = String.Format("[DEBUG:{0}] Invalid theorOptPx:{1} for strike:{2}", GetType().Name, theorOptPx, nodeInfo.Strike); //m_context.Log(msg, MessageType.Warning, true); continue; } // Пересчитываем сигму обратно, ЕСЛИ мы применили сдвиг цены в абсолютном выражении if (m_shiftPriceStep != 0) { sigma = FinMath.GetOptionSigma(futPx, pair.Strike, dT, theorOptPx, oldInfo.RiskFreeRate, isCall); if (!DoubleUtil.IsPositive(sigma)) { //string msg = String.Format("[DEBUG:{0}] Invalid sigma:{1} for strike:{2}", GetType().Name, sigma, nodeInfo.Strike); //m_context.Log(msg, MessageType.Warning, true); continue; } } // ReSharper disable once UseObjectOrCollectionInitializer SmileNodeInfo nodeInfo = new SmileNodeInfo(); var secDesc = isCall ? pair.CallFinInfo.Security : pair.PutFinInfo.Security; nodeInfo.F = oldInfo.F; nodeInfo.dT = oldInfo.dT; nodeInfo.RiskFreeRate = oldInfo.RiskFreeRate; nodeInfo.Strike = pair.Strike; nodeInfo.Sigma = sigma; nodeInfo.OptPx = theorOptPx; nodeInfo.OptionType = isCall ? StrikeType.Call : StrikeType.Put; nodeInfo.Pair = pair; nodeInfo.Symbol = secDesc.Name; nodeInfo.DSName = secDesc.DSName; nodeInfo.Expired = secDesc.Expired; nodeInfo.FullName = secDesc.FullName; // ReSharper disable once UseObjectOrCollectionInitializer InteractivePointActive tmp = new InteractivePointActive(); tmp.IsActive = true; tmp.ValueX = pair.Strike; tmp.ValueY = sigma; tmp.DragableMode = DragableMode.Yonly; tmp.Tooltip = String.Format(CultureInfo.InvariantCulture, " F: {0}\r\n K: {1}; IV: {2:P2}\r\n {3} px {4}", futPx, pair.Strike, sigma, optionType, theorOptPx); tmp.Tag = nodeInfo; //tmp.Color = Colors.White; if (m_qty > 0) { tmp.Geometry = Geometries.Triangle; } else if (m_qty < 0) { tmp.Geometry = Geometries.TriangleDown; } else { tmp.Geometry = Geometries.None; } InteractiveObject obj = new InteractiveObject(); obj.Anchor = tmp; controlPoints.Add(obj); } // ReSharper disable once UseObjectOrCollectionInitializer res = new InteractiveSeries(); // Здесь так надо -- мы делаем новую улыбку res.ControlPoints = new ReadOnlyCollection <InteractiveObject>(controlPoints); // ReSharper disable once UseObjectOrCollectionInitializer SmileInfo sInfo = new SmileInfo(); sInfo.F = futPx; sInfo.dT = dT; sInfo.Expiry = oldInfo.Expiry; sInfo.ScriptTime = oldInfo.ScriptTime; sInfo.RiskFreeRate = oldInfo.RiskFreeRate; sInfo.BaseTicker = oldInfo.BaseTicker; res.Tag = sInfo; if (controlPoints.Count > 0) { res.ClickEvent -= InteractiveSplineOnQuoteIvEvent; res.ClickEvent += InteractiveSplineOnQuoteIvEvent; m_clickableSeries = res; } } #endregion 2. Формируем улыбку просто для отображения текущего положения потенциальной котировки PositionsManager posMan = PositionsManager.GetManager(m_context); if (m_cancelAllLong) { posMan.DropAllLongIvTargets(m_context); } if (m_cancelAllShort) { posMan.DropAllShortIvTargets(m_context); } #region 4. Котирование { var longTargets = posMan.GetIvTargets(true); var shortTargets = posMan.GetIvTargets(false); var ivTargets = longTargets.Union(shortTargets).ToList(); for (int j = 0; j < ivTargets.Count; j++) { var ivTarget = ivTargets[j]; // PROD-6102 - Требуется точное совпадение опционной серии if (optSer.ExpirationDate.Date != ivTarget.SecInfo.Expiry.Date) { // Вывести предупреждение??? continue; } IOptionStrikePair pair; double k = ivTarget.SecInfo.Strike; if (!optSer.TryGetStrikePair(k, out pair)) { // Вывести предупреждение??? continue; } double sigma; QuoteIvMode quoteMode = ivTarget.QuoteMode; if (quoteMode == QuoteIvMode.Absolute) { sigma = ivTarget.EntryIv; } else { sigma = oldInfo.ContinuousFunction.Value(k) + ivTarget.EntryIv; if (!DoubleUtil.IsPositive(sigma)) { //string msg = String.Format("[DEBUG:{0}] Invalid sigma:{1} for strike:{2}", GetType().Name, sigma, nodeInfo.Strike); //m_context.Log(msg, MessageType.Warning, true); continue; } } //bool isCall = (futPx <= pair.Strike); // Определяю тип опциона на основании информации в Задаче StrikeType taskOptionType = StrikeType.Any; if (ivTarget.SecInfo.StrikeType.HasValue) { taskOptionType = ivTarget.SecInfo.StrikeType.Value; } bool isCall; if (taskOptionType == StrikeType.Call) { isCall = true; } else if (taskOptionType == StrikeType.Put) { isCall = false; } else { isCall = (futPx <= pair.Strike); // Это аварийная ситуация? } StrikeType optionType = isCall ? StrikeType.Call : StrikeType.Put; double theorOptPx = FinMath.GetOptionPrice(futPx, k, dT, sigma, oldInfo.RiskFreeRate, isCall); theorOptPx += ivTarget.EntryShiftPrice * pair.Tick; theorOptPx = Math.Round(theorOptPx / pair.Tick) * pair.Tick; if (!DoubleUtil.IsPositive(theorOptPx)) { //string msg = String.Format("[DEBUG:{0}] Invalid theorOptPx:{1} for strike:{2}", GetType().Name, theorOptPx, nodeInfo.Strike); //m_context.Log(msg, MessageType.Warning, true); continue; } // [07-07-2020] PROD-7879 - После сдвига и округления цены волатильность меняется. Её нужно вычислить заново. double actualSigma = FinMath.GetOptionSigma(futPx, k, dT, theorOptPx, oldInfo.RiskFreeRate, isCall); IOptionStrike optStrike = isCall ? pair.Call : pair.Put; ISecurity sec = optStrike.Security; double totalQty = posMan.GetTotalQty(sec, m_context.BarsCount, TotalProfitAlgo.AllPositions, ivTarget.IsLong); // Поскольку котирование страйка по волатильности -- это вопрос набора нужного количества СТРЕДДЛОВ, // то учитывать надо суммарный объём опционов как в колах, так и в путах. // НО ЗАДАЧУ-ТО Я СТАВЛЮ ДЛЯ КОНКРЕТНОГО ИНСТРУМЕНТА! // Как быть? //double totalQty = posMan.GetTotalQty(pair.Put.Security, m_context.BarsCount, TotalProfitAlgo.AllPositions, ivTarget.IsLong); //totalQty += posMan.GetTotalQty(pair.Call.Security, m_context.BarsCount, TotalProfitAlgo.AllPositions, ivTarget.IsLong); double targetQty = Math.Abs(ivTarget.TargetShares) - totalQty; // Если имеется дробный LotTick (как в Дерибит к примеру), то надо предварительно округлить targetQty = sec.RoundShares(targetQty); if (targetQty > 0) { string note = String.Format(CultureInfo.InvariantCulture, "{0}; ActQty:{1}; Px:{2}; IV:{3:P3}; F:{4}; dT:{5}", ivTarget.EntryNotes, targetQty, theorOptPx, actualSigma, futPx, dT); if (ivTarget.IsLong) { posMan.BuyAtPrice(m_context, sec, targetQty, theorOptPx, ivTarget.EntrySignalName, note); } else { posMan.SellAtPrice(m_context, sec, targetQty, theorOptPx, ivTarget.EntrySignalName, note); } } else { string msg = String.Format(CultureInfo.InvariantCulture, "IvTarget cancelled. SignalName:{0}; Notes:{1}", ivTarget.EntrySignalName, ivTarget.EntryNotes); posMan.CancelVolatility(m_context, ivTarget, msg); // TODO: потом убрать из ГЛ m_context.Log(msg, MessageType.Info, true, new Dictionary <string, object> { { "VOLATILITY_ORDER_CANCELLED", msg } }); } } } #endregion 4. Котирование #region 5. Торговля if (m_executeCommand && (!DoubleUtil.IsZero(m_qty))) { double k; if ((!Double.TryParse(m_strike, out k)) && (!Double.TryParse(m_strike, NumberStyles.Any, CultureInfo.InvariantCulture, out k))) { return(res); } var pair = (from p in pairs where DoubleUtil.AreClose(k, p.Strike) select p).SingleOrDefault(); if (pair == null) { return(res); } InteractiveObject obj = (from o in controlPoints where DoubleUtil.AreClose(k, o.Anchor.ValueX) select o).SingleOrDefault(); if (obj == null) { return(res); } // TODO: для режима котирования в абсолютных числах сделать отдельную ветку //double iv = obj.Anchor.ValueY; const QuoteIvMode QuoteMode = QuoteIvMode.Relative; if (posMan.BlockTrading) { string msg = String.Format(RM.GetString("OptHandlerMsg.PositionsManager.TradingBlocked"), m_context.Runtime.TradeName + ":QuoteIv"); m_context.Log(msg, MessageType.Warning, true); return(res); } // Выбираю тип инструмента пут или колл? bool isCall; if (m_optionType == StrikeType.Call) { isCall = true; } else if (m_optionType == StrikeType.Put) { isCall = false; } else { isCall = (futPx <= k); } double iv = m_shiftIv; int shift = m_shiftPriceStep; var option = isCall ? pair.Call : pair.Put; if (m_qty > 0) { // Пересчитываю целочисленный параметр Qty в фактические лоты конкретного инструмента double actQty = m_qty * option.LotTick; string sigName = String.Format(CultureInfo.InvariantCulture, "Qty:{0}; IV:{1:P2}+{2}; dT:{3}; Mode:{4}", actQty, iv, shift, dT, QuoteMode); posMan.BuyVolatility(m_context, option, Math.Abs(actQty), QuoteMode, iv, shift, "BuyVola", sigName); m_context.Log(sigName, MessageType.Info, false); } else if (m_qty < 0) { // Пересчитываю целочисленный параметр Qty в фактические лоты конкретного инструмента double actQty = m_qty * option.LotTick; string sigName = String.Format(CultureInfo.InvariantCulture, "Qty:{0}; IV:{1:P2}+{2}; dT:{3}; Mode:{4}", actQty, iv, shift, dT, QuoteMode); posMan.SellVolatility(m_context, option, Math.Abs(actQty), QuoteMode, iv, shift, "SellVola", sigName); m_context.Log(sigName, MessageType.Info, false); } } #endregion 5. Торговля return(res); }
public static void remove_keyFocusChange(InteractiveObject that, Action <FocusEvent> value) { CommonExtensions.RemoveDelegate(that, value, FocusEvent.KEY_FOCUS_CHANGE); }
public void onResponsePressed(InteractiveObject sender, int response) { if (response >= curDialog.responses.Count) { return; } clearResponses (); Dialog lastDialog = curDialog; curDialog = curDialog.GetDialogFor (curDialog.responses[response]); if (curDialog == null) { hideText(); sender.actionForResponse(lastDialog, response); } else { // Cache the current dialog so we can continue from it later sender.setCurrentResponse(curDialog); // Set text in dialog box textBox.transform.GetComponentInChildren<Text>().text = Localization.GetDialog (curDialog.contentKey); // Set up buttons for new responses for (int i = 0; i < curDialog.responses.Count; i++) { setButton(sender, i); } } }
public static void remove_clear(InteractiveObject that, Action <Event> value) { CommonExtensions.RemoveDelegate(that, value, Event.CLEAR); }
/** * Add an interactable to the list of tiles * * Arguments * - InteractiveObject toAdd - the interactive object to add */ public void AddInteractable(InteractiveObject toAdd) { InteractiveTiles.Add(toAdd); blockedTiles.Add(toAdd.GetTile()); }
public static void remove_keyUp(InteractiveObject that, Action <KeyboardEvent> value) { CommonExtensions.RemoveDelegate(that, value, KeyboardEvent.KEY_UP); }
public void Reset() { health = 100; tiredness = 105; hunger = 115; equippedItem = null; inventory.Clear(); }
public static void remove_mouseDown(InteractiveObject that, Action <MouseEvent> value) { CommonExtensions.RemoveDelegate(that, value, MouseEvent.MOUSE_DOWN); }
public SetStateInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex) { m_targetObject = Grid.FindInteractiveObject(m_targetSpawnID); m_parent = Grid.FindInteractiveObject(m_parentID); }
public static void add_mouseFocusChange(InteractiveObject that, Action <FocusEvent> value) { CommonExtensions.CombineDelegate(that, value, FocusEvent.MOUSE_FOCUS_CHANGE); }
public IntruderAlertTrapEffect(Int32 p_staticID, InteractiveObject p_parent) : base(p_staticID, p_parent) { }
public IncreaseAttributeInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex) { m_interactiveObject = Grid.FindInteractiveObject(m_targetSpawnID); m_parent = Grid.FindInteractiveObject(m_parentID); }
/// <summary> /// Обработчик под тип входных данных INTERACTIVESPLINE /// </summary> /// <param name="price">цена БА</param> /// <param name="time">время до экспирации в долях года</param> /// <param name="optPrices">опционные цены</param> /// <param name="rate">процентная ставка</param> /// <param name="barNum">индекс бара в серии</param> /// <returns>улыбка, восстановленная из цен опционов</returns> public InteractiveSeries Execute(double price, double time, InteractiveSeries optPrices, double rate, int barNum) { int barsCount = ContextBarsCount; if ((barNum < barsCount - 1) || (optPrices == null) || (optPrices.ControlPoints.Count <= 0)) { return(Constants.EmptySeries); } IReadOnlyList <InteractiveObject> cps = optPrices.ControlPoints; double f = price; double dT = time; if (Double.IsNaN(f)) { //throw new ScriptException("Argument 'price' contains NaN for some strange reason. f:" + f); return(Constants.EmptySeries); } if ((dT < Double.Epsilon) || (Double.IsNaN(dT))) { return(Constants.EmptySeries); } if (Double.IsNaN(rate)) { //throw new ScriptException("Argument 'rate' contains NaN for some strange reason. rate:" + rate); return(Constants.EmptySeries); } List <InteractiveObject> controlPoints = new List <InteractiveObject>(); for (int j = 0; j < cps.Count; j++) { InteractiveObject strikeObj = cps[j]; double strike = strikeObj.Anchor.ValueX; // Сверхдалекие страйки игнорируем if ((strike < m_minStrike) || (m_maxStrike < strike)) { continue; } double optPx; double stradlePx = Double.NaN; double putPx = Double.NaN, callPx = Double.NaN; if (m_optionType == StrikeType.Put) { putPx = strikeObj.Anchor.ValueY; optPx = putPx; } else if (m_optionType == StrikeType.Call) { callPx = strikeObj.Anchor.ValueY; optPx = callPx; } else { stradlePx = strikeObj.Anchor.ValueY; optPx = stradlePx; } double sigma = Double.NaN; double putSigma = Double.NaN, callSigma = Double.NaN, stradleSigma = Double.NaN, precision; if (!Double.IsNaN(putPx)) { putSigma = FinMath.GetOptionSigma(f, strike, dT, putPx, rate, false, out precision); putSigma = Math.Min(putSigma, m_maxSigma); if (putSigma <= 0) { putSigma = Double.NaN; } else { if (m_optionType == StrikeType.Put) { sigma = putSigma; } } } if (!Double.IsNaN(callPx)) { callSigma = FinMath.GetOptionSigma(f, strike, dT, callPx, rate, true, out precision); callSigma = Math.Min(callSigma, m_maxSigma); if (callSigma <= 0) { callSigma = Double.NaN; } else { if (m_optionType == StrikeType.Call) { sigma = callSigma; } } } if (!Double.IsNaN(stradlePx)) { stradleSigma = FinMath.GetStradleSigma(f, strike, dT, stradlePx, rate, out precision); stradleSigma = Math.Min(stradleSigma, m_maxSigma); if (stradleSigma <= 0) { stradleSigma = Double.NaN; } else { if (m_optionType == StrikeType.Any) { sigma = stradleSigma; } } } if (Double.IsNaN(sigma) || (sigma <= 0) || Double.IsNaN(optPx) || (optPx <= 0)) { continue; } InteractivePointActive ip = new InteractivePointActive(); { //ip.Color = (m_optionPxMode == OptionPxMode.Ask) ? Colors.DarkOrange : Colors.DarkCyan; //ip.DragableMode = DragableMode.None; //ip.Geometry = Geometries.Rect; // (optionPxMode == OptionPxMode.Ask) ? Geometries.Rect : Geometries.Rect; //ip.IsActive = true; ip.Value = new Point(strike, sigma); string nowStr = DateTime.Now.ToString(DateTimeFormatWithMs, CultureInfo.InvariantCulture); ip.Tooltip = String.Format(CultureInfo.InvariantCulture, "K:{0}; IV:{1:#0.00}%\r\n{2} {3} @ {4}\r\nDate: {5}", strike, sigma * Constants.PctMult, m_optionType, optPx, 1, nowStr); } InteractiveObject obj = new InteractiveObject(ip); if (m_optionType == StrikeType.Put) { if (!Double.IsNaN(putSigma)) { //FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false); controlPoints.Add(obj); } } else if (m_optionType == StrikeType.Call) { if (!Double.IsNaN(callSigma)) { //FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false); controlPoints.Add(obj); } } else if (m_optionType == StrikeType.Any) { if (!Double.IsNaN(stradleSigma)) { if (m_optionPxMode == OptionPxMode.Ask) { //if (putSigma < callSigma) // FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false); //else // FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false); } else if (m_optionPxMode == OptionPxMode.Bid) { //if (putSigma > callSigma) // FillNodeInfo(ip, f, dT, sInfo, StrikeType.Put, m_optionPxMode, putPx, putQty, putSigma, putTime, false); //else // FillNodeInfo(ip, f, dT, sInfo, StrikeType.Call, m_optionPxMode, callPx, callQty, callSigma, callTime, false); } controlPoints.Add(obj); } } } // ReSharper disable once UseObjectOrCollectionInitializer InteractiveSeries res = new InteractiveSeries(); // Здесь так надо -- мы делаем новую улыбку res.ControlPoints = new ReadOnlyCollection <InteractiveObject>(controlPoints); SmileInfo info; if (!IvSmile.TryPrepareSmileInfo(m_context, f, dT, rate, new DateTime(), new DateTime(), null, res, out info)) { return(Constants.EmptySeries); } return(res); }
/** * Set the currently tracked interactive object * * Arguments * - InteractiveObject i - The new interactive object to track */ public void SetCurrent(InteractiveObject i) { Current = i; }
public Village(Game game, Torch.Object parent, byte[] data) : base(game, data) { Name = "Kakariko Village"; SandbagImage = "Zones/Kakariko/village/sandbag"; Sandbag = Grid.FromBitmap(Game.Services, SandbagImage); ImageLayers = new List <ImageObject> { new ImageObject(Game, parent, "Zones/Kakariko/Village/village") { DrawOrder = -1 }, new ImageObject(Game, parent, "Zones/Kakariko/Village/arch") { X = 2568, Y = 2784, DrawOrder = 2925 }, new ImageObject(Game, parent, "Zones/Kakariko/Village/house_1") { X = 1728, Y = 336, DrawOrder = 587 }, new ImageObject(Game, parent, "Zones/Kakariko/Village/mailbox") { X = 483, Y = 1152, DrawOrder = 1224 }, new ImageObject(Game, parent, "Zones/Kakariko/Village/cave") { X = 534, Y = 565, DrawOrder = 660 }, new ImageObject(Game, parent, "Zones/Kakariko/Village/bombshop") { X = 240, Y = 2544, DrawOrder = 2750 }, }; Objects = new List <InteractiveObject>(); // mailbox var obj = new InteractiveObject { Location = new Rectangle(486, 1200, 36, 24) }; obj.Interact += SimpleDialog("kakariko/town", "mailbox"); Objects.Add(obj); // statue obj = new InteractiveObject { Location = new Rectangle(1512, 1224, 96, 96) }; obj.Interact += SimpleDialog("kakariko/town", "statue"); Objects.Add(obj); // cliff obj = new InteractiveObject { Location = new Rectangle(268, 445, 312 - 268, 5) }; obj.Interact += SimpleDialog("kakariko/town", "cliff"); Objects.Add(obj); // inn obj = new InteractiveObject { Location = new Rectangle(1895, 2009, 48, 7) }; obj.Interact += SimpleDoor("kakariko/inn", "entrance"); Objects.Add(obj); // merchant obj = new InteractiveObject { Location = new Rectangle(1941, 2736, 54, 12) }; obj.Interact += SimpleMerchant("kakariko/town", "merchant"); Objects.Add(obj); Doors = new List <Door> { new Door { Location = new Rectangle(312, 2725, 48, 8), Name = "bombshop", Orientation = Direction.Down, Zone = "kakariko/bombshop", ZoneDoor = "entrance" }, new Door { Location = new Rectangle(2664, 2997, 48, 32), Name = "arch", Orientation = Direction.Up }, new Door { Location = new Rectangle(1895, 2030, 48, 7), Name = "inn", Orientation = Direction.Down } }; }
public SpawnMonsterInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex) { m_spawnTarget = Grid.FindInteractiveObject(m_targetSpawnID); m_parent = Grid.FindInteractiveObject(m_parentID); }
void OnTriggerExit(Collider other) { if(other.gameObject.GetComponent<InteractiveObject>() && other.gameObject.GetComponent<InteractiveObject>() == interactive_object) { interactive_object.active = false; interactive_object = null; } }
/// <summary> /// Check what is the current object with which we can interact from the list of interactable objects /// </summary> private void CheckCurrentInteractableObject() { float minDistanceSqr = Mathf.Infinity; InteractiveObject closestObject = null; foreach (var o in currentInteractableObjects) { float distanceSqr = (o.transform.position - this.transform.position).sqrMagnitude; if (distanceSqr < minDistanceSqr) { minDistanceSqr = distanceSqr; closestObject = o; } } if (this.currentPointedObject != closestObject) { if (this.currentPointedObject != null) this.currentPointedObject.SetPointed(false); if (closestObject != null) closestObject.SetPointed(true); } this.currentPointedObject = closestObject; }
void Update() { Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //Detects whether the mouse is touching an object with a collider on it if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { //References to the created objects necessary for the mouse detection InteractiveObject obj = hit.collider.GetComponent <InteractiveObject>(); DoorProperty door = hit.collider.GetComponent <DoorProperty>(); if (door != null && door.isHot == true) { if (HotCheck == false) { Hot.enabled = true; Debug.Log("This door is hot!"); } HotCheck = true; } else { HotCheck = false; } if (door != null && door.isNoisy == true) { if (NoisyCheck == false) { Noisy.enabled = true; Debug.Log("This door is Noisy!"); } NoisyCheck = true; } else { NoisyCheck = false; } if (Input.GetMouseButtonDown(0)) { if (door != null && door.isSafe == false) { { notSafe.Play(); Debug.Log("This door is unsafe!"); } } } if (Input.GetMouseButtonDown(0)) { if (obj) { obj.TriggerIneraction(); } } } else { Hot.enabled = false; Noisy.enabled = false; } }
/// <summary> /// Adds a new interectable object to this controller's reach /// </summary> /// <param name="o">The object to add</param> public void AddObject(InteractiveObject o) { this.currentInteractableObjects.Add(o); }
/// <summary> /// Shows the text. /// </summary> /// <param name="sender">The InteractiveObject that called this</param> /// <param name="dialogKey">Dialog key.</param> /// <param name="fontSize">Font size.</param> public void showText(InteractiveObject sender, string dialogKey, int fontSize = 12) { curDialog = DialogEditor.GetDialog (dialogKey); if (curDialog == null) { Debug.LogWarning(string.Format("Dialog of key \"{0}\" not found", dialogKey)); return; } // Set text up isTextUp = true; // Reposition the text box based on the sender's position on screen if (Camera.main.WorldToScreenPoint (sender.transform.position).y < Screen.height / 2f) { textBox.transform.localPosition = new Vector3(0f, Screen.height / 4f, 0); } else { textBox.transform.localPosition = new Vector3(0f, -Screen.height / 4f, 0); } textBox.SetActive (true); textBox.transform.GetComponentInChildren<Text>().text = Localization.GetDialog (curDialog.contentKey); textBox.transform.GetComponentInChildren<Text> ().fontSize = fontSize; // Set the talker's name textBox.transform.GetChild (1).GetChild(0).GetComponent<Text> ().text = sender.getName(); textBox.GetComponent<Animator>().Play ("TextBoxAppear"); for (int i = 0; i < curDialog.responses.Count; i++) { setButton(sender, i); } }
private void OnParentChanged(InteractiveObject target, Transform newParent) { NavigationDrawer = newParent == null ? null : newParent.gameObject.GetComponentInParent <NavigationDrawer>(); }
/// <summary> /// Sets the button. /// </summary> /// <param name="btnResponse">Button response.</param> /// <param name="i">The index.</param> private void setButton(InteractiveObject sender, int i) { GameObject btnResponse = buttonsParent.GetChild (i).gameObject; btnResponse.SetActive (true); btnResponse.transform.GetComponentInChildren<Text>().text = curDialog.GetResponse(i); ResetResponseEventListener(btnResponse.GetComponent<Button>(), sender, i); }
/// <summary> /// Clear the currently held object /// </summary> public void ClearHeldObject() { //Debug.Log("CLEAR!"); this.handSwitcher.ShowHand(HandType.NONE); this.heldObject.MaterialController.Remove(this.pickedUpMaterial); this.heldObject = null; this.heldObjectIsInHand = false; }
/** * Remove this interactable from the list of tiles * * Arguments * - InteractiveObject toRemove - The interactive object to remove */ public void RemoveInteractable(InteractiveObject toRemove) { InteractiveTiles.Remove(toRemove); blockedTiles.Remove(toRemove.GetTile()); Debug.Log("int Remove: " + toRemove.GetTile().ToString()); }
// Start is called before the first frame update void Start() { rigidBody = GetComponent <Rigidbody>(); state = GetComponent <InteractiveObject>(); animator = GetComponent <Animator>(); }
// Update is called once per frame void Update() { //Update the distance of each item in the list if(targetMarkerExists && currentTarget == null) { switchTarget(); Destroy(targetMarker); targetMarkerExists = false; } if(targetList.Count > 0) { foreach(InteractiveObject iteratedTarget in targetList) { iteratedTarget.distance = Vector3.Distance(transform.position, iteratedTarget.targetTransform.position); if(iteratedTarget.distance > 5.0f) { switchTarget(); targetList.Remove(iteratedTarget); } } if(currentTargetID > targetList.Count) { switchTarget(); } else { currentTarget = targetList[currentTargetID]; } //Debug.Log ("Current Target: " + currentTarget.targetName + " (ID: " + currentTargetID + "/" + (targetList.Count - 1) + ")"); if(!targetMarkerExists) { targetMarker = Instantiate(Resources.Load ("Graphical/NaviMarker")) as GameObject; targetMarkerExists = true; } else { targetMarker.transform.position = currentTarget.targetTransform.position; targetMarker.transform.position += new Vector3(0.0f, 0.7f, 0.0f); } } else { currentTargetID = 0; //Make sure that next time there is a target in the list, the list starts from the top. currentTarget = null; //Debug.Log ("No Targets"); if(targetMarkerExists) { Destroy(targetMarker); targetMarkerExists = false; } } }
/// <summary> /// Set a object as held in hand (or picked up) /// </summary> /// <param name="o">Object to hold</param> /// <param name="handType">Hands to show</param> /// <param name="inHand">Is it in hand instead of picked up?</param> public void SetHeldObject(InteractiveObject o, HandType handType = HandType.TEST_1, bool inHand = false) { //Debug.Log("Holding object with hands " + handType); this.heldObjectIsInHand = inHand; if (inHand) { this.currentInteractableObjects.Remove(o); // We make sure to remove it from the current interactiable objects, since the trigger won't be triggered now! } else { o.MaterialController.Add(this.pickedUpMaterial, 150); } this.handSwitcher.ShowHand(handType); this.heldObject = o; }
// Use this for initialization void Start() { interactions = GetComponent<InteractiveObject> (); //Debug.Log (interactions); }
public override void PlacementTrigger(InteractiveObject ingredient) { cauldron.AddIngredient(ingredient); StartCoroutine(PlacementAnimation(ingredient)); }