public void Collect(CollectValue value) { m_Score += value.m_Value; if (value.m_NextLevel != -1) { Application.LoadLevel(value.m_NextLevel); } }
public CircuitCollectViewModel GetMultiRateViewModel(string buildId, string energyCode, string[] circuitIDs, string startDate, string endDate) { CircuitCollectViewModel viewModel = new CircuitCollectViewModel(); DateTime startTime = Util.ConvertString2DateTime(startDate, "yyyy-MM-dd HH:mm:ss"); DateTime endTime = Util.ConvertString2DateTime(endDate, "yyyy-MM-dd HH:mm:ss"); List <CircuitMeterInfo> circuitMeterInfos = context.GetMultiRateMeterInfoList(buildId, circuitIDs); string[] meterIDs = GetMeterIDs(circuitMeterInfos); string[] meterParamIDs = GetMeterParamIDs(circuitMeterInfos); List <HistoryValue> startValue = context.GetHistoryValues(meterIDs, meterParamIDs, startTime); List <HistoryValue> endValue = context.GetHistoryValues(meterIDs, meterParamIDs, endTime); List <CollectValue> data = new List <CollectValue>(); foreach (var meterID in startValue) { CollectValue collect = new CollectValue(); collect.Name = circuitMeterInfos.Find(x => x.MeterID.Equals(meterID.MeterID)).CircuitName; collect.ParamName = circuitMeterInfos.Find(x => x.MeterID.Equals(meterID.MeterID) && x.MeterParamID.Equals(meterID.MeterParamID)).MeterParamName; collect.StartValue = meterID.Value; collect.EndValue = endValue.Find(x => x.MeterID.Equals(meterID.MeterID) && x.MeterParamID.Equals(meterID.MeterParamID)).Value; collect.DiffValue = collect.EndValue - collect.StartValue; data.Add(collect); } viewModel.Data = data; return(viewModel); }
/// <summary> /// Wraps <see cref="CollectValue"/> in an anonymous method that can be passed /// to unmaged code. /// </summary> /// <param name="method">The managed method to wrap.</param> /// <param name="freeUserData">Frees the <see cref="GCHandle"/> for any user /// data closure parameters in the unmanged function</param> /// <returns>The callback method for passing to unmanged code.</returns> /// <remarks> /// This function is used to marshal managed callbacks to unmanged code. If this /// callback is only called once, <paramref name="freeUserData"/> should be /// set to <c>true</c>. If it can be called multiple times, it should be set to /// <c>false</c> and the user data must be freed elsewhere. If the callback does /// not have closure user data, then the <paramref name="freeUserData"/> /// parameter has no effect. /// </remarks> public static UnmanagedCollectValue Create(CollectValue method, bool freeUserData) { UnmanagedCollectValue nativeCallback = ( /* <type name="Value" type="GValue*" managed-name="Value" /> */ /* transfer-ownership:none */ ref Value value, /* <type name="guint" type="guint" managed-name="Guint" /> */ /* transfer-ownership:none */ uint nCollectValues_, /* <type name="TypeCValue" type="GTypeCValue*" managed-name="TypeCValue" /> */ /* transfer-ownership:none */ IntPtr collectValues_, /* <type name="guint" type="guint" managed-name="Guint" /> */ /* transfer-ownership:none */ uint collectFlags_) => { var collectValues = GMarshal.PtrToCArray <TypeCValue> (collectValues_, (int)nCollectValues_); var ret = method.Invoke(ref value, collectValues, collectFlags_); var ret_ = GMarshal.StringToUtf8Ptr(ret); return(ret_); }; return(nativeCallback); }