private static State CastState(tState linqState) { return(linqState == null ? null : new State { Id = linqState.StateId, Text = linqState.Text }); }
private static State CastState(tState linqState) { return linqState == null ? null : new State { Id = linqState.StateId, Text = linqState.Text }; }
public MinigameKingTomato(string level) : base(level) { currentWave = 1; spawnTomatoTimer = 0.0f; spawnTomatoKingTomatoState = 0.0f; restTime = 3.0f; state = tState.Rest; }
public IHttpActionResult GettState(int id) { tState tState = db.tStates.Find(id); if (tState == null) { return(NotFound()); } return(Ok(tState)); }
/// <summary> /// 注入远程线程 /// </summary> /// <param name="DescProcess">进程句柄</param> /// <param name="DllPath">DLL文件路径</param> /// <param name="flags">运行状态</param> /// <param name="UserFun">指定回调函数,该函数应无返回并值接受一个bool型参数</param> /// <returns>返回一个布尔型,表示成功和失败</returns> public IntPtr RemoteThread(int DescProcess, string DllPath, tState flags, CallBack UserCall) { //根据PID取得进程句柄 IntPtr ProcessHandle; try { ProcessHandle = Process.GetProcessById(DescProcess).Handle; } catch (Exception) { return(IntPtr.Zero); throw; } //计算所需要的内存 int oldDllLength = DllPath.Length; DllPath = string.Format("{0}\0", DllPath); byte[] buffer = Encoding.Default.GetBytes(DllPath.ToArray()); int DllLength = buffer.Length; //申请内存空间 IntPtr Baseaddress = VirtualAllocEx(ProcessHandle, 0, DllLength, 4096, 4); if (Baseaddress == IntPtr.Zero) { return(IntPtr.Zero); } //写入内存 int WriteOk = WriteProcessMemory(ProcessHandle, Baseaddress, DllPath, DllLength, 0); if (WriteOk == 0) { return(IntPtr.Zero); } //获取模块句柄/函数入口 IntPtr mHandle = GetModuleHandle("kernel32"); if (mHandle == IntPtr.Zero) { return(IntPtr.Zero); } IntPtr hack = GetProcAddress(mHandle, "LoadLibraryA"); if (hack == IntPtr.Zero) { return(IntPtr.Zero); } //创建远程线程 IntPtr handle = CreateRemoteThread(ProcessHandle, 0, 0, hack, Baseaddress, flags, 0); if (handle == IntPtr.Zero) { return(IntPtr.Zero); } //保存参数 UserFun = UserCall; ProcessPid = DescProcess; hProcess = ProcessHandle; Memory = Baseaddress; hThread = handle; fFullName = DllPath.Replace("\0", ""); //新建线程,用于等待注入线程结束 Thread tWait = new Thread(ColseThread); tWait.Start(); return(handle); }
private static extern IntPtr CreateRemoteThread(IntPtr hThread, int attrib, int size, IntPtr address, IntPtr par, tState flags, int threadid);
public override void update() { base.update(); switch (state) { case tState.Commanding: if (life < 50.0f) { playAction("afraid"); state = tState.S******g; } break; case tState.S******g: // TODO super ugly that state is changed in minigame king tomate break; case tState.Recovering: if (life < LIFE_RETURNS) { life += SB.dt * RECOVERING_LIFE_SPEED; } else { if(CinematicManager.Instance.cinematicToPlay == null) state = tState.Commanding2; } break; case tState.Commanding2: Vector3 directionTo = (GamerManager.getSessionOwner().Player.position - position); directionTo.Normalize(); position += directionTo * SPEED * SB.dt; if (life <= 0.0f) { state = tState.Dying; } break; case tState.Dying: lastOrb -= SB.dt; if (lastOrb < 0.0f && orbsToSpawn > 0) { OrbManager.Instance.addOrbs(position2D, 5, 0, 0, 0, true); lastOrb = SPAWN_ORB_TIME; orbsToSpawn -= 5; } if (orbsToSpawn <= 0) { ParticleManager.Instance.addParticles("kingTomatoExplode", position, Vector3.Zero, Color.White); state = tState.Delete; } break; case tState.Delete: break; } }
/// <summary> /// Обработка объекта /// </summary> /// <param name="obj">объект, который пришел</param> /// <param name="state">тип изменения, входящего объекта</param> /// <param name="type">тип объекта, в который преобразуем</param> /// <param name="mapper">маппер для преобразования</param> /// <param name="attrs">список изменяемых свойств</param> /// <param name="source">Источник изменений</param> /// <param name="arrToUpd">Список обновляемых объектов данных</param> /// <param name="arrConformity">Список обновляемых объектов синхронизации</param> private void ProcessObject(SyncXMLDataObject obj, tState state, Type type, IPropertyMapperWithChangedAttrs mapper, List <string> attrs, Source source, ref List <DataObject> arrToUpd, ref Dictionary <string, List <DataObject> > arrConformity) { if (obj == null) { return; } var view = mapper.GetView(); var nameType = type.FullName; var otype = arrConformity[sObjectType].Cast <ObjectType>().FirstOrDefault(x => x.name == nameType) ?? _syncDS.Query <ObjectType>(ObjectType.Views.ObjectTypeE) .FirstOrDefault(x => x.name == nameType) ?? new ObjectType { name = nameType, id = type.Name }; if (otype.GetStatus() == ObjectStatus.Created) { arrConformity[sObjectType].Add(otype); } Conformity conformity = null; if (otype.GetStatus() != ObjectStatus.Created && source.GetStatus() != ObjectStatus.Created) { conformity = _syncDS.Query <Conformity>(Conformity.Views.ConformityE).FirstOrDefault(x => x.Source.__PrimaryKey.Equals(source.__PrimaryKey) && x.Type.__PrimaryKey.Equals(otype.__PrimaryKey) && x.pkSource.Equals(obj.Guid)); } if (state != tState.deleted) //создание/изменение { DataObject dest = null; if (conformity != null) //ищем по pk { dest = GetDataObject(type, view, conformity.pkDest); } else { dest = GetDataObject(type, view, obj.Guid); } if (dest == null) //ищем по альтернативному ключу { var queryAlt = mapper.GetAltKey(obj, _defDS, _syncDS, source, ref arrToUpd, ref arrConformity); dest = queryAlt?.FirstOrDefault(); if (queryAlt != null && dest != null) { LogService.LogInfo($"BusMessageHandlerService: Удалось найти объект(pk-{obj.Guid}) по альтернативному ключу для типа {nameType}. Сопоставленный объект объект(pk-{dest.__PrimaryKey})"); } } if (dest == null) { dest = (DataObject)Activator.CreateInstance(type); } dest.GetStatus(); dest = mapper.Map(obj, dest, attrs); // Проверяем было ли помещено создание объекта на апдейт. Если да, то такой объект уже считается существующим и статус нового объекта с таким же ключом меняется на Altered. var alreadyExistsCreatedObj = arrToUpd.Exists(x => PKHelper.EQPK(x, dest) && x.GetStatus(false) == ObjectStatus.Created); if (alreadyExistsCreatedObj) { dest.SetLoadingState(LoadingState.Loaded); dest.SetStatus(ObjectStatus.Altered); } arrToUpd.Add(dest); //заполнение мастеров/////////////////////////////////////////////////////////////////////////////// mapper.SetMasters(obj, dest, attrs, _defDS, _syncDS, source, ref arrToUpd, ref arrConformity); if (conformity == null) { conformity = new Conformity { Source = source, Type = otype, pkSource = obj.Guid, pkDest = new Guid(dest.__PrimaryKey.ToString()) }; arrConformity[sConformity].Add(conformity); } } else //удаление { if (conformity != null) { var count = _syncDS.Query <Conformity>(Conformity.Views.ConformityE).Count(x => x.Type.__PrimaryKey.Equals(otype.__PrimaryKey) && x.pkDest.Equals(conformity.pkDest)); if (count >= 1) { conformity.SetStatus(ObjectStatus.Deleted); arrConformity[sConformity].Add(conformity); } if (count == 1) { var dest = GetDataObject(type, view, conformity.pkDest); if (dest != null) { dest.SetStatus(ObjectStatus.Deleted); arrToUpd.Add(dest); } } } } }
public override void update() { base.update(); onionElder.update(); if (CinematicManager.Instance.cinematicToPlay != null) return; switch (state) { case tState.Rest: restTime -= SB.dt; if (restTime < 0.0f) { if (startNewWave()) { state = tState.Combat; } } break; case tState.Combat: if (!updateTomatoes() && getTomatoesLeft() == 0) { ++currentWave; if (currentWave > 3) { restTime = Calc.randomScalar(REST_TIME * 2, REST_TIME * 3); state = tState.KingTomato; kingTomato.playAction("shouting"); } else { state = tState.Rest; } } break; case tState.KingTomato: if (kingTomato.state == KingTomato.tState.Commanding) { restTime -= SB.dt; updateTomatoes(); if (restTime < 2.0f && !kingTomatoStartedWave) { kingTomatoStartedWave = true; kingTomato.playAction("shouting"); } if (restTime < 0.0f) { ++currentWave; spawnTomatoTimer -= SB.dt; spawnTomatoTime = 0.02f; tomatoesToSpawn = Calc.randomNatural(25, 35) + 5 * currentWave; restTime = tomatoesToSpawn * 0.25f; kingTomatoStartedWave = false; } spawnTomatoKingTomatoState -= SB.dt; if (spawnTomatoKingTomatoState < 0.0f) { spawnTomatoKingTomatoState = Calc.randomScalar(SPAWN_TOMATO_KINGTOMATO_STATE_MIN_TIME, SPAWN_TOMATO_KINGTOMATO_STATE_MAX_TIME); spawnTomato(); } } else if (kingTomato.state == KingTomato.tState.S******g) { if (!shitSpawnDone) { shitSpawnDone = true; for (int i = 0; i < SHITTING_TOMATOES; ++i) { spawnTomato(); } } fleeTimer -= SB.dt; if (!fleeDone && fleeTimer < 0.0f) { fleeDone = true; List<Entity2D> enemies = EnemyManager.Instance.getActiveEnemies(); for (int i = 0; i < enemies.Count; ++i) { if (enemies[i] is TomatoFollower) { ((TomatoFollower)enemies[i]).fleeing = true; } } CinematicManager.Instance.playCinematic("kingTomatoReturns"); kingTomato.state = KingTomato.tState.Recovering; } } else if (kingTomato.state == KingTomato.tState.Delete) { afterDieTime += SB.dt; if (afterDieTime > 2.0f) { kingTomato.requestDelete(true); GamerManager.getSessionOwner().data.levelsPassed["onionVillage"] = true; StateManager.addState(StateManager.tGameState.EndStage); } } break; } }