Esempio n. 1
0
        public void PerformResourceTransition(BarrierType barrierType, Resource resource, ResourceUsage usageBefore, ResourceUsage usageAfter, uint subresource = AllSubResources)
        {
            Debug.Assert(resource != null, "No resource given to transition.");
            Debug.Assert(usageBefore != usageAfter, "Usage before and afterwards is the same.");

            PerformResourceTransitionImpl(barrierType, resource, usageBefore, usageAfter, subresource);
        }
        private double DiscreteAdjustedBarrier(BarrierType barrierType, Position position, double barrier, double sigma, double dt, double barrierShift)
        {
            double longBarrier  = (barrier + barrierShift) * Math.Exp(0.5826 * sigma * Math.Sqrt(dt));
            double shortBarrier = (barrier + barrierShift) * Math.Exp(-0.5826 * sigma * Math.Sqrt(dt));

            if (position == Position.Sell)
            {
                if (barrierType == BarrierType.DownAndOut || barrierType == BarrierType.UpAndIn)
                {
                    return(longBarrier);
                }
                else
                {
                    return(shortBarrier);
                }
            }
            else
            {
                if (barrierType == BarrierType.DownAndIn || barrierType == BarrierType.UpAndOut)
                {
                    return(longBarrier);
                }
                else
                {
                    return(shortBarrier);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Computes the isovist at the specified depth of view.
        /// </summary>
        /// <param name="depth">The depth of view.</param>
        /// <param name="typeOfBarrier">The type of barrier.</param>
        /// <param name="cellularFloor">The cellularFloor.</param>
        /// <param name="Tolerance">The tolerance.</param>
        public void Compute(double depth, BarrierType typeOfBarrier,
                            CellularFloor cellularFloor, double Tolerance = OSMDocument.AbsoluteTolerance)
        {
            var isovist = CellularIsovistCalculator.GetIsovist(this.VantageCell + new UV(cellularFloor.CellSize / 2, cellularFloor.CellSize / 2),
                                                               depth, typeOfBarrier, cellularFloor, Tolerance);

            this.VisibleCells = isovist.VisibleCells;
        }
Esempio n. 4
0
 //Barrier
 public void Barrier(BarrierType bType)
 {
     Commands.Add(new CommandEntry()
     {
         Type        = CommandType.Barrier,
         BarrierType = bType,
     });
 }
Esempio n. 5
0
    // Start is called before the first frame update
    void Start()
    {
        if (barrierType == null)
        {
            barrierType = BarrierType.DEFAULT;
        }

        MakeInvisible();
    }
Esempio n. 6
0
    private void AddData(EntityType entityType, EnemyType enemyType, BarrierType barrierType, float percent)
    {
        var newData = new RoadEntityData();

        newData.entityType    = entityType;
        newData.enemyType     = enemyType;
        newData.barrierType   = barrierType;
        newData.percentAtRoad = percent;
        data.Add(newData);
    }
Esempio n. 7
0
        public float GetCoefficient(BarrierType barrierType)
        {
            var result = _barriers.SingleOrDefault(x => x.BarrierType == barrierType);

            if (result == null)
            {
                throw new ArgumentException($"Нет данных для препятствия: {barrierType}");
            }
            return(result.Coefficient);
        }
Esempio n. 8
0
 public override Element factory(BarrierType type,int x,int y)
 {
     switch(type)
     {
         case BarrierType.RockBarrier: return new RockBarrier(x, y);
         case BarrierType.BrickBarrier: return new BrickBarrier(x, y);
         case BarrierType.GrassBarrier: return new GrassBarrier(x, y);
     }
     return null;
 }
 public RoadEntityData(EntityType entityType, EnemyType enemyType, BarrierType barrierType, float percentAtRoad, float height, float offset, int roadCount, int desiredRoad)
 {
     this.entityType    = entityType;
     this.enemyType     = enemyType;
     this.barrierType   = barrierType;
     this.percentAtRoad = percentAtRoad;
     this.height        = height;
     this.offset        = offset;
     this.roadCount     = roadCount;
     this.desiredRoad   = desiredRoad;
 }
Esempio n. 10
0
        public DoubleNoTouch(string assetName, DateTime obsStart, DateTime obsEnd, double barrierDown, double barrierUp, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierType barrierType, Currency simulationCcy)
            : base(assetName, discountCurve, ccy, payDate, notional, simulationCcy)
        {
            _obsStart    = obsStart;
            _obsEnd      = obsEnd;
            _barrierType = barrierType;

            _notional       = new Vector <double>(notional);
            _barrierUpVec   = new Vector <double>(barrierUp);
            _barrierDownVec = new Vector <double>(barrierDown);
        }
 private ConstantContinuousSingleBarrierKnockoutFunction(double strike, double timeToExpiry, double sign, int numberOfSteps, BarrierType barrierType, double barrierLevel, DoubleArray rebate)
 {
     JodaBeanUtils.notNull(barrierType, "barrierType");
     JodaBeanUtils.notNull(rebate, "rebate");
     this.strike        = strike;
     this.timeToExpiry  = timeToExpiry;
     this.sign          = sign;
     this.numberOfSteps = numberOfSteps;
     this.barrierType   = barrierType;
     this.barrierLevel  = barrierLevel;
     this.rebate        = rebate;
 }
Esempio n. 12
0
        public OneTouch(string assetName, DateTime obsStart, DateTime obsEnd, double barrier, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierSide barrierSide, BarrierType barrierType, Currency simulationCcy)
            : base(assetName, discountCurve, ccy, payDate, notional, simulationCcy)
        {
            _obsStart = obsStart;
            _obsEnd   = obsEnd;
            _barrier  = barrier;

            _barrierType = barrierType;
            _barrierSide = barrierSide;

            _notional   = new Vector <double>(notional);
            _barrierVec = new Vector <double>(barrier);
        }
Esempio n. 13
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="startDate">开始日</param>
 /// <param name="maturityDate">到期日</param>
 /// <param name="exercise">行权方式</param>
 /// <param name="optionType">看涨看跌</param>
 /// <param name="strike">行权价</param>
 /// <param name="rebate">敲出补偿收益</param>
 /// <param name="coupon">敲出额外收益</param>
 /// <param name="participationRate">名义本金有效比例</param>
 /// <param name="barrierType">障碍类型</param>
 /// <param name="lowerBarrier">障碍价格下限</param>
 /// <param name="upperBarrier">障碍价格上限</param>
 /// <param name="isDiscreteMonitored">是否离散观察</param>
 /// <param name="underlyingType">标的资产类型</param>
 /// <param name="calendar">交易日历</param>
 /// <param name="dayCount">日期规则</param>
 /// <param name="payoffCcy">收益计算币种</param>
 /// <param name="settlementCcy">结算币种</param>
 /// <param name="exerciseDates">行权日</param>
 /// <param name="observationDates">观察日</param>
 /// <param name="fixings">观察价格序列</param>
 /// <param name="notional">名义本金</param>
 /// <param name="settlementGap">结算日规则</param>
 /// <param name="optionPremiumPaymentDate">权利金支付日</param>
 /// <param name="optionPremium">权利金</param>
 /// <param name="isMoneynessOption">是否为相对行权价期权</param>
 /// <param name="initialSpotPrice">标的资产期初价格</param>
 /// <param name="dividends">标的资产分红</param>
 /// <param name="position">持仓方向</param>
 /// <param name="barrierShift">障碍价格偏移</param>
 /// <param name="barrierStatus">敲入敲出状态</param>
 /// <param name="hasNightMarket">标的资产是否有夜盘交易</param>
 /// <param name="commodityFuturesPreciseTimeMode">是否启用精确时间模式</param>
 public BarrierOption(Date startDate,
                      Date maturityDate,
                      OptionExercise exercise,
                      OptionType optionType,
                      double strike,
                      double rebate,
                      double coupon,
                      double participationRate,
                      BarrierType barrierType,
                      double lowerBarrier,
                      double upperBarrier,
                      bool isDiscreteMonitored,
                      InstrumentType underlyingType,
                      ICalendar calendar,
                      IDayCount dayCount,
                      CurrencyCode payoffCcy,
                      CurrencyCode settlementCcy,
                      Date[] exerciseDates,
                      Date[] observationDates,
                      Dictionary <Date, double> fixings,
                      double notional                      = 1,
                      DayGap settlementGap                 = null,
                      Date optionPremiumPaymentDate        = null,
                      double optionPremium                 = 0,
                      bool isMoneynessOption               = false,
                      double initialSpotPrice              = 0.0,
                      Dictionary <Date, double> dividends  = null,
                      Position position                    = Position.Buy,
                      double barrierShift                  = 0.0,
                      BarrierStatus barrierStatus          = BarrierStatus.Monitoring,
                      bool hasNightMarket                  = false,
                      bool commodityFuturesPreciseTimeMode = false
                      )
     : base(startDate, maturityDate, exercise, optionType, new double[] { strike }, underlyingType, calendar, dayCount,
            payoffCcy, settlementCcy, exerciseDates, observationDates, notional, settlementGap,
            optionPremiumPaymentDate, optionPremium,
            isMoneynessOption: isMoneynessOption, initialSpotPrice: initialSpotPrice, dividends: dividends, hasNightMarket: hasNightMarket,
            commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode)
 {
     Rebate              = rebate;
     Coupon              = coupon;
     ParticipationRate   = participationRate;
     BarrierType         = barrierType;
     Barrier             = lowerBarrier;
     IsDiscreteMonitored = isDiscreteMonitored;
     UpperBarrier        = upperBarrier;
     Fixings             = fixings;
     Position            = position;
     BarrierShift        = barrierShift;
     BarrierStatus       = barrierStatus;
 }
Esempio n. 14
0
        /// <summary>
        /// Return a repulsion line from the closest barrier
        /// </summary>
        /// <param name="point">A point in the field</param>
        /// <param name="barrierType">The type of barrier</param>
        /// <returns>A line</returns>
        public UVLine GetRepulsionLine(UV point, BarrierType barrierType)
        {
            var collision = CollisionAnalyzer.GetCollidingEdge(point, this, barrierType);

            if (collision == null)
            {
                return(null);
            }
            if (collision.ClosestPointOnBarrier == null)
            {
                return(null);
            }
            return(new UVLine(point, collision.ClosestPointOnBarrier));
        }
Esempio n. 15
0
        public EuropeanBarrierOption(string assetName, DateTime obsStart, DateTime obsEnd, DateTime expiry, OptionType callPut, double strike, double barrier, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierSide barrierSide, BarrierType barrierType, Currency simulationCcy)
            : base(assetName, discountCurve, ccy, payDate, notional, simulationCcy)
        {
            _obsStart = obsStart;
            _obsEnd   = obsEnd;
            _expiry   = expiry;
            _callPut  = callPut;

            _barrierType = barrierType;
            _barrierSide = barrierSide;

            _notional   = new Vector <double>(notional);
            _barrierVec = new Vector <double>(barrier);
            _strikeVec  = new Vector <double>(strike);
        }
Esempio n. 16
0
        public OneTouch(string assetName, DateTime obsStart, DateTime obsEnd, double barrier, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierSide barrierSide, BarrierType barrierType)
        {
            _obsStart      = obsStart;
            _obsEnd        = obsEnd;
            _barrier       = barrier;
            _discountCurve = discountCurve;
            _ccy           = ccy;
            _payDate       = payDate;

            _barrierType = barrierType;
            _barrierSide = barrierSide;

            _assetName  = assetName;
            _notional   = new Vector <double>(notional);
            _barrierVec = new Vector <double>(barrier);
        }
Esempio n. 17
0
        public Barrier(Way w, List <BarrierConfigurations> config)
        {
            id            = w.id;
            type          = getBarrierType(w.tags);
            barrierConfig = getBarrierConfiguration(config, type);

            height          = barrierConfig.height;
            thickness       = barrierConfig.width;
            barrierMaterial = (Material)Resources.Load(barrierConfig.Path);

            BarrierContainer = new GameObject("Barrier" + w.id);
            BarrierContainer.transform.position = new Vector3(0, 0, 0);
            BarrierElements = new List <GameObject>();
            barrierWay      = w;
            generateBarrier(w);
        }
Esempio n. 18
0
        public Barrier(Way w, List<BarrierConfigurations> config)
        {
            id = w.id;
            type = getBarrierType(w.tags);
            barrierConfig = getBarrierConfiguration(config,type);

            height = barrierConfig.height;
            thickness = barrierConfig.width;
            barrierMaterial = (Material)Resources.Load(barrierConfig.Path);

            BarrierContainer = new GameObject("Barrier" + w.id);
            BarrierContainer.transform.position = new Vector3(0, 0, 0);
            BarrierElements = new List<GameObject>();
            barrierWay = w;
            generateBarrier(w);
        }
Esempio n. 19
0
        public DoubleNoTouch(string assetName, DateTime obsStart, DateTime obsEnd, double barrierDown, double barrierUp, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierType barrierType)
        {
            _obsStart      = obsStart;
            _obsEnd        = obsEnd;
            _barrierDown   = barrierDown;
            _barrierUp     = barrierUp;
            _discountCurve = discountCurve;
            _ccy           = ccy;
            _payDate       = payDate;

            _barrierType = barrierType;

            _assetName      = assetName;
            _notional       = new Vector <double>(notional);
            _barrierUpVec   = new Vector <double>(barrierUp);
            _barrierDownVec = new Vector <double>(barrierDown);
        }
Esempio n. 20
0
        public List <UV> GetEdgeEndPoint(BarrierType barrierType)
        {
            switch (barrierType)
            {
            case BarrierType.Visual:
                return(this.VisualBarrierEndPoints);

            case BarrierType.Physical:
                return(this.PhysicalBarrierEndPoints);

            case BarrierType.Field:
                return(this.FieldBarrierEndPoints);

            case BarrierType.BarrierBuffer:
                return(this.BufferBarrierEndPoints);
            }
            return(null);
        }
Esempio n. 21
0
        public static Barrier BarrierFromType(BarrierType type, GameState state)
        {
            string modelName = string.Empty;
            switch (type)
            {
                case BarrierType.Cube:
                    modelName = GameConstants.MdlCube;
                    break;
                case BarrierType.Cylinder:
                    modelName = GameConstants.MdlCylinder;
                    break;
                case BarrierType.Pryamid:
                    modelName = GameConstants.MdlPryamid;
                    break;
                default:
                    break;
            }

            return new Barrier(modelName, state, type);
        }
Esempio n. 22
0
        public EuropeanBarrierOption(string assetName, DateTime obsStart, DateTime obsEnd, DateTime expiry, OptionType callPut, double strike, double barrier, string discountCurve, Currency ccy, DateTime payDate, double notional, BarrierSide barrierSide, BarrierType barrierType)
        {
            _obsStart      = obsStart;
            _obsEnd        = obsEnd;
            _expiry        = expiry;
            _callPut       = callPut;
            _strike        = strike;
            _barrier       = barrier;
            _discountCurve = discountCurve;
            _ccy           = ccy;
            _payDate       = payDate;

            _barrierType = barrierType;
            _barrierSide = barrierSide;

            _assetName  = assetName;
            _notional   = new Vector <double>(notional);
            _barrierVec = new Vector <double>(barrier);
            _strikeVec  = new Vector <double>(strike);
        }
Esempio n. 23
0
 public Barrier(string modelName, GameState state, BarrierType type)
     : base(modelName, state)
 {
     BarrierType = type;
     double rateOfFire = 0;
     switch (BarrierType)
     {
         case BarrierType.Cube:
             rateOfFire = 650;
             break;
         case BarrierType.Cylinder:
             rateOfFire = 100;
             break;
         case BarrierType.Pryamid:
             rateOfFire = 650;
             break;
         default:
             break;
     }
     Cannon = new MountedGun(state, rateOfFire);
 }
Esempio n. 24
0
        public Barier(BarrierType type, Point p)
        {
            switch (type)
            {
            case BarrierType.Stone:
                // Name = BarrierType.Stone.ToString();
                break;

            case BarrierType.Ravine:
                // Name = BarrierType.Ravine.ToString();
                break;

            case BarrierType.Tree:
                // Name = BarrierType.Tree.ToString();
                break;

            case BarrierType.Fence:
                // Name = BarrierType.Fence.ToString();
                break;
            }
            // P = p;
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -891985998:         // strike
                    this.strike = (double?)newValue.Value;
                    break;

                case -1831499397:         // timeToExpiry
                    this.timeToExpiry = (double?)newValue.Value;
                    break;

                case 3530173:         // sign
                    this.sign = (double?)newValue.Value;
                    break;

                case -1323103225:         // numberOfSteps
                    this.numberOfSteps = (int?)newValue.Value;
                    break;

                case 1029043089:         // barrierType
                    this.barrierType = (BarrierType)newValue;
                    break;

                case 1827586573:         // barrierLevel
                    this.barrierLevel = (double?)newValue.Value;
                    break;

                case -934952029:         // rebate
                    this.rebate = (DoubleArray)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Esempio n. 26
0
        private BarrierConfigurations getBarrierConfiguration(List<BarrierConfigurations> configs, BarrierType type)
        {
            switch(type)
            {
                case BarrierType.fence:
                    return configs[0];
                case BarrierType.wall:
                    return configs[1];
                case BarrierType.cityWall:
                    return configs[2];
                case BarrierType.retaining_wall:
                    return configs[3];
                case BarrierType.none:
                    return configs[4];

            }
            return new BarrierConfigurations();
        }
Esempio n. 27
0
        public static double BarrierOptionPV(double forward, double strike, double riskFreeRate, double expTime, double volatility, OptionType CP, double barrier, BarrierType barrierType, BarrierSide barrierSide)
        {
            var blackPV        = BlackPV(forward, strike, riskFreeRate, expTime, volatility, CP);
            var barrierHitProb = BarrierProbability(forward, forward, barrier, volatility, expTime, barrierSide);

            return(barrierType == BarrierType.KI ? barrierHitProb * blackPV : (1.0 - barrierHitProb) * blackPV);
        }
Esempio n. 28
0
 public override void PerformResourceTransitionImpl(BarrierType barrierType, Resource resource, ResourceUsage usageBefore, ResourceUsage usageAfter, uint subresource)
 {
     SharpDX.Direct3D12.ResourceStates before = InternalUtils.GetResourceStateDX(usageBefore);
     SharpDX.Direct3D12.ResourceStates after  = InternalUtils.GetResourceStateDX(usageAfter);
     CommandListD3D12.ResourceBarrierTransition(((ResourceDX)resource).ResourceD3D12, (int)subresource, before, after);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BarrierOptionCalculator"/> class.
        /// </summary>
        /// <param name="optionType">Type of the option, Call or Put.</param>
        /// <param name="barrierType">UpAndIn, DownAndOut etc.</param>
        /// <param name="payoff">Option payoff, coupon/rebate/paticipationrate included.</param>
        /// <param name="barrier">Barrier level</param>
        /// <param name="secondarybarrier">Secondary barrier, only effective for double barrier options</param>
        /// <param name="strike">The strike.</param>
        /// <param name="spotPrice">The spot price.</param>
        /// <param name="exerciseInYears">The maturity in years.</param>
        /// <param name="standardDeviation">Volatility, measured by the standard deviation of the underlying.</param>
        /// <param name="riskFreeRate">Risk free rate</param>
        /// <param name="dividendRate">Continuous dividend rate</param>
        public BarrierOptionCalculator(OptionType optionType,
                                       BarrierType barrierType,
                                       double rebate,
                                       double barrier,
                                       double secondarybarrier,
                                       double strike,
                                       double spotPrice,
                                       double exerciseInYears,
                                       double standardDeviation,
                                       double riskFreeRate,
                                       double dividendRate,
                                       Date valuationDate,
                                       Date exerciseDate,
                                       Date underlyingMaturityDate,
                                       IDayCount dayCount,
                                       InstrumentType underlyingInstrumentType,
                                       double notional)
        {
            _isOptionOnFutures = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType);
            _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType);

            _optionType  = optionType;
            _barrierType = barrierType;
            _rebate      = rebate;
            _H           = barrier;
            _H2          = secondarybarrier;
            _X           = strike;
            _S           = spotPrice;
            _T           = exerciseInYears;
            _K           = rebate;
            _sigma       = standardDeviation;
            _r           = riskFreeRate;
            _dividend    = dividendRate;
            _b           = AnalyticalOptionPricerUtil.costOfCarry(_isOptionOnFutures || _isOptionOnForward, dividendRate, riskFreeRate);
            _dayCount    = dayCount;
            _notional    = notional;

            var riskfreeDfAtMaturity = CalcDfFromZeroRate(riskFreeRate, underlyingMaturityDate, valuationDate);
            var riskfreeDfAtExercise = CalcDfFromZeroRate(riskFreeRate, exerciseDate, valuationDate);

            _dfExerciseToMaturity = (_isOptionOnForward) ? riskfreeDfAtMaturity / riskfreeDfAtExercise : 1.0;

            // factors calculation
            switch (barrierType)
            {
            case BarrierType.DownAndIn:
            case BarrierType.DownAndOut:
                _yita = 1.0;
                break;

            case BarrierType.UpAndIn:
            case BarrierType.UpAndOut:
                _yita = -1.0;
                break;

            case BarrierType.DoubleTouchOut:
            case BarrierType.DoubleTouchIn:
                throw new PricingLibraryException("Double barrier shall use AnalyticalDoubleBarrierOptionEngine to calculate!");
            }

            _phi = optionType.Equals(OptionType.Call) ? 1.0 : -1.0;
        }
Esempio n. 30
0
 public override void PerformResourceTransitionImpl(BarrierType barrierType, Resource resource, ResourceUsage usageBefore, ResourceUsage usageAfter, uint subresource)
 {
     SharpDX.Direct3D12.ResourceStates before = InternalUtils.GetResourceStateDX(usageBefore);
     SharpDX.Direct3D12.ResourceStates after = InternalUtils.GetResourceStateDX(usageAfter);
     CommandListD3D12.ResourceBarrierTransition(((ResourceDX)resource).ResourceD3D12, (int) subresource, before, after);
 }
Esempio n. 31
0
 private ExceptionBarrierManager()
 {
     Type = BarrierType.None;
 }
Esempio n. 32
0
        public async Task <BarrierAddResult> Register(string userNumber, string barrierNumber, BarrierType type)
        {
            userNumber    = userNumber.FormatToNumber();
            barrierNumber = barrierNumber.FormatToNumber();
            var analog = await _db.Barriers.FirstOrDefaultAsync(b => b.BarrierType == type && b.UserNumber.Equals(userNumber));

            var barrier = new Barrier()
            {
                BarrierNumber = barrierNumber,
                BarrierType   = type,
                UserNumber    = userNumber,
            };

            if (analog != null)
            {
                barrier.Token = analog.Token;
            }
            else
            {
                var facade = _barrierFactory.Create(barrier);
                await facade.Register(userNumber);
            }
            _db.Add(barrier);
            await _db.SaveChangesAsync();

            return(new BarrierAddResult()
            {
                Id = barrier.Id,
                Status = (analog == null) ? BarrierAddStatus.WaitForConfirmation : BarrierAddStatus.Confirmed
            });
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Obtains an instance.
        /// </summary>
        /// <param name="strike">  the strike </param>
        /// <param name="timeToExpiry">  the time to expiry </param>
        /// <param name="putCall">  put or call </param>
        /// <param name="numberOfSteps">  number of steps </param>
        /// <param name="barrierType">  the barrier type </param>
        /// <param name="barrierLevel">  the barrier level </param>
        /// <param name="rebate">  the rebate </param>
        /// <returns> the instance </returns>
        public static ConstantContinuousSingleBarrierKnockoutFunction of(double strike, double timeToExpiry, PutCall putCall, int numberOfSteps, BarrierType barrierType, double barrierLevel, DoubleArray rebate)
        {
            ArgChecker.isTrue(numberOfSteps > 0, "the number of steps should be positive");
            ArgChecker.isTrue(numberOfSteps + 1 == rebate.size(), "the size of rebate should be numberOfSteps + 1");
            double sign = putCall.Call ? 1d : -1d;

            return(new ConstantContinuousSingleBarrierKnockoutFunction(strike, timeToExpiry, sign, numberOfSteps, barrierType, barrierLevel, rebate));
        }
Esempio n. 34
0
    public static void HandleCollision(GameObject hitObject, Ball ball)
    {
        GameManager gameManager = hitObject.GetComponentInParent <GameManager>();
        Barrier     barrierHit  = hitObject.GetComponent <Barrier>();

        if (!barrierHit)
        {
            barrierHit = hitObject.GetComponentInParent <Barrier>();
        }
        BarrierType typeHit = barrierHit.getBarrierType();

        // handling for Targets
        if (typeHit == BarrierType.Target)
        {
            //gameManager.soundManager.playBallBounceBarrier();
            Target hitTarget = barrierHit as Target;
            hitTarget.deductResources(ball.getBallResources());
            if (hitTarget.breakResources.allResourceSum() < 1)
            {
                GameObject.Destroy(hitObject.GetComponentInParent <Target>().gameObject);
                gameManager.soundManager.playTargetDestroyed();

                if (gameManager.getPowerLevel() >= gameManager.powerMax) // split the ball
                {
                    GameObject splitBall = GameObject.Instantiate(ball.gameObject);
                    splitBall.gameObject.transform.parent = gameManager.gameObject.transform;
                    Ball newBall = splitBall.GetComponent <Ball>();
                    newBall.isLaunchBall = false;

                    int powerLevel = gameManager.getPowerLevel();
                    newBall.setResources(powerLevel, powerLevel, powerLevel, powerLevel);
                    newBall.setComponents();
                    // make the split ball smaller than the original
                    newBall.setHalfBallSize();
                    if (newBall.reflectedY)
                    {
                        newBall.yDir = !newBall.yDir;
                    }
                    else
                    {
                        newBall.xDir = !newBall.xDir;
                    }
                    newBall.setComponents();
                    newBall.setCircleCollider(false);
                    newBall.launch();
                    // clear all circle colliders once we start splitting
                    gameManager.clearCircleColliders();
                }
            }
        }

        ShotLine shotLine = barrierHit as ShotLine;

        if (typeHit == BarrierType.ShotLine)
        {
            // see if this is the first ball back
            if (!shotLine.isLaunchPointSet())
            {
                ball.setLock(true);
                //ball.transform.position = new Vector2(ball.transform.position.x, -4.61f);
                shotLine.updateLaunchPoint(ball.transform.position, ball.gameObject);
            }
            else
            {
                // destroy this extra ball
                GameObject.Destroy(ball.gameObject);
            }
        }

        // handling for simple Barriers
        if (typeHit == BarrierType.Barrier)
        {
            // gameManager.soundManager.playBallBounceBarrier();
        }
    }
Esempio n. 35
0
 public async Task <BarrierAddResult> AddBarrier(string userNumber, string barrierNumber, BarrierType type)
 {
     return(await _barrierService.Register(userNumber, barrierNumber, type));
 }
Esempio n. 36
0
 public async Task <BarrierAddResult> ManualAdd(string userNumber, string barrierNumber, BarrierType type, string token)
 {
     return(await _barrierService.AddManual(userNumber, barrierNumber, type, token));
 }
Esempio n. 37
0
 public virtual Element factory(BarrierType type, int x, int y)
 {
     return null;
 }