//--------------------------------------------------------------------- public override void create(Dictionary <string, object> param) { mMapParam = param; mScene = mMapParam["LogicScene"] as CLogicScene; mPos = (EbVector3)mMapParam["SourcePosition"]; int score = 0; List <CLogicFish> all_fish = mScene.getLevel().getAllFish(); if (all_fish != null && all_fish.Count > 0) { foreach (var f in all_fish) { score += EbDataMgr.Instance.getData <TbDataFish>(f.FishVibId).FishScore; f.signDestroy(); } } mReturnValue = new List <object>(); ReturnValue.Add("FullScreenBomb"); ReturnValue.Add(score); mDelayTime = 8; mScene.getLevel().setPauseCreateFishCrowd(true); }
//------------------------------------------------------------------------- public override void create(Dictionary <string, object> param) { mMapParam = param; mScene = mMapParam["LogicScene"] as CLogicScene; mPos = (EbVector3)mMapParam["SourcePosition"]; uint et_player_rpcid = (uint)mMapParam["PlayerID"]; int bullet_rate = (int)mMapParam["BulletRate"]; TbDataEffectAOE effect_data = EbDataMgr.Instance.getData <TbDataEffectAOE>(mEffectId); int total_score = 0; int fish_score = 0; int effect_fish_vib_id = -1; bool fish_die = false; List <CLogicFish> fish_list = getFishByPositionAndRadius(mPos, (float)effect_data.Radius); List <string> custom_param_list = new List <string>(); // 遍历aoe范围内的活鱼 foreach (var fish in fish_list) { // 检查是否在鱼的销毁列表,如果在则跳过,防止重复计算。 if (fish.IsDie) { continue; } // 击中鱼测试,击中则把分数包括特效分数计下来,一起计算到aoe特效分数里面去。 fish_score = 0; effect_fish_vib_id = -1; fish_die = fish.hit(et_player_rpcid, bullet_rate, ref fish_score, ref effect_fish_vib_id); if (fish_die) { custom_param_list.Add(fish.FishObjId.ToString()); total_score += fish_score; } } // 服务端广播创建特效 int current_die_fish_id = (int)mMapParam["DieFishObjId"];//触发这个效果的鱼 mScene.getProtocol().s2allcCreateClientEffect( et_player_rpcid, bullet_rate, mPos, current_die_fish_id, mEffectId, mEffectName, (int)mEffectType, mDelayTime, custom_param_list); mReturnValue = new List <object>(); ReturnValue.Add("EffectAOE"); ReturnValue.Add(total_score); }
private static void CopyOrAdd(List <Dynamo> ReturnValue, IProperty IDProperty, Dynamo Item) { Contract.Requires <ArgumentNullException>(IDProperty != null); if (Item == null) { return; } if (ReturnValue == null) { ReturnValue = new List <Dynamo>(); } var IDValue = IDProperty.GetValue(Item); var Value = ReturnValue.FirstOrDefault(x => IDProperty.GetValue(x).Equals(IDValue)); if (Value == null) { ReturnValue.Add(Item); } else { Item.CopyTo(Value); } }
//------------------------------------------------------------------------- public override void create(Dictionary <string, object> param) { mMapParam = param; mScene = mMapParam["LogicScene"] as CLogicScene; mPos = (EbVector3)mMapParam["SourcePosition"]; uint et_player_rpcid = (uint)mMapParam["PlayerID"]; int bullet_rate = (int)mMapParam["BulletRate"]; int die_fish_id = (int)mMapParam["DieFishObjId"]; int score = 0; TbDataEffectRadiationLighting effect_data = EbDataMgr.Instance.getData <TbDataEffectRadiationLighting>(mEffectId); List <CLogicFish> fish_list = mScene.getLevel().getListFishById(effect_data.NormalFish.Id); int each_fish_score = EbDataMgr.Instance.getData <TbDataFish>(effect_data.NormalFish.Id).FishScore; foreach (var n in fish_list) { score += each_fish_score; n.signDestroy(); } // 服务端广播创建特效 List <string> custom_param_list = new List <string>(); custom_param_list.Add(effect_data.NormalFish.Id.ToString()); mScene.getProtocol().s2allcCreateClientEffect( et_player_rpcid, bullet_rate, mPos, die_fish_id, mEffectId, mEffectName, (int)mEffectType, mDelayTime, custom_param_list); mReturnValue = new List <object>(); ReturnValue.Add("Lighting"); ReturnValue.Add(score); ReturnValue.Add(effect_data.NormalFish.Id); }
public override bool Execute(out ResultTuple ret, ResultTuple[] parameters, Plan.ParameterChooser[] parameterMap, TextWriter executionLog, TextWriter debugLog, out bool preconditionViolated, out Exception exceptionThrown, out bool contractViolated, bool forbidNull, bool useRandoopContracts, out ContractState contractStates) { long startTime = 0; Timer.QueryPerformanceCounter(ref startTime); object[] objects = new object[method.GetParameters().Length]; // Get the actual objects from the results using parameterIndices; object receiver = parameters[parameterMap[0].planIndex].tuple[parameterMap[0].resultIndex]; for (int i = 0; i < method.GetParameters().Length; i++) { Plan.ParameterChooser pair = parameterMap[i + 1]; objects[i] = parameters[pair.planIndex].tuple[pair.resultIndex]; } contractStates = new ContractState(); preconditionViolated = false; if (useRandoopContracts) { try { preconditionViolated = new RandoopContractsManager().PreconditionViolated(method, objects); } catch (InvalidRandoopContractException) { } //precondition is invalid, ignore it and proceed with execution if (preconditionViolated) { ret = null; exceptionThrown = null; contractViolated = false; return(false); } } if (forbidNull) { foreach (object o in objects) { Util.Assert(o != null); } } CodeExecutor.CodeToExecute call; object returnValue = null; contractViolated = false; //default value of contract violation call = delegate() { returnValue = method.Invoke(receiver, objects); }; bool retval = true; executionLog.WriteLine("execute method " + method.Name + "[" + (timesExecuted - 1).ToString() + "]"); //[email protected] changes Logger.Debug("execute method " + method.Name //[email protected] adds + "[" + (timesExecuted - 1).ToString() + "]"); executionLog.Flush(); //if (timesExecuted != ReturnValue.Count + 1) //[email protected] adds for debug //{ // Logger.Debug("timeExecute = " + timesExecuted.ToString() + // " but ReturnValue is " + ReturnValue.Count.ToString()); //} timesExecuted++; if (!CodeExecutor.ExecuteReflectionCall(call, debugLog, out exceptionThrown)) { //for exns we can ony add the class to faulty classes when its a guideline violation if (Util.GuidelineViolation(exceptionThrown.GetType())) { PlanManager.numDistinctContractViolPlans++; KeyValuePair <MethodBase, Type> k = new KeyValuePair <MethodBase, Type>(method, exceptionThrown.GetType()); if (!exnViolatingMethods.ContainsKey(k)) { PlanManager.numContractViolatingPlans++; exnViolatingMethods[k] = true; } //add this class to the faulty classes contractExnViolatingClasses[method.DeclaringType] = true; contractExnViolatingMethods[method] = true; } ret = null; executionLog.WriteLine("return value [" + (timesExecuted - 1).ToString() + "]: invocationOk is false.");//[email protected] adds //string temp = "RANDOOPFAIL"; //[email protected] adds for capture current status ReturnValue.Add(null); //[email protected] adds for capture current status return(false); } else { ret = new ResultTuple(method, receiver, returnValue, objects); #region caputre latest execution return value ////[email protected] adds to capture return value -- start//// if (returnValue != null) { if ((returnValue.GetType() == typeof(string)) || (returnValue.GetType() == typeof(bool)) || (returnValue.GetType() == typeof(byte)) || (returnValue.GetType() == typeof(short)) || (returnValue.GetType() == typeof(int)) || (returnValue.GetType() == typeof(long)) || (returnValue.GetType() == typeof(float)) || (returnValue.GetType() == typeof(double)) || (returnValue.GetType() == typeof(char))) { executionLog.WriteLine("return value [" + (timesExecuted - 1).ToString() + "]: " + returnValue.ToString().Replace("\n", "\\n").Replace("\r", "\\r")); } else { executionLog.WriteLine("return value [" + (timesExecuted - 1).ToString() + "]: not string or primitive"); } //doulbe check to make sure there is no non-deterministic exeuction -- we don't want to regression assertion with that //This is not a sufficient approach because the difference may be inherited from previous constructors or method calls //What was done in Randoop(java): after generating an "entire" test suite, Randoop runs it before outputting it. //If any test fails, Randoop disables each failing assertions. //let the VS plug-in do this functionality if (Execute2(returnValue, objects, receiver, executionLog, debugLog)) { ReturnValue.Add(returnValue); } else { ReturnValue.Add(null); } } else { executionLog.WriteLine("return value [" + (timesExecuted - 1).ToString() + "]: no return value"); ReturnValue.Add(null); } ////[email protected] adds to capture return value -- end//// #endregion caputre latest execution return value } //check if the objects in the output tuple violated basic contracts if (ret != null) { CheckContracts(ret, ref contractViolated, ref retval); contractStates = new RandoopContractsManager().ValidateAssertionContracts(method, receiver, returnValue); } if (contractViolated) //[email protected] adds { executionLog.WriteLine("contract violation."); //[email protected] adds } long endTime = 0; Timer.QueryPerformanceCounter(ref endTime); executionTimeAccum += endTime - startTime / (double)Timer.PerfTimerFrequency; return(retval); }