//Done on seperate thread private void UpdateCreatingWorld(Object stateInfo) { Tile[,] tileGrid = new Tile[worldWidth, worldHeight]; List <Intersection> intersectionList = new List <Intersection>(); List <Town> townList = new List <Town>(); //Creating Mass LandMass landMass = new LandMass(tileGrid, waterMap, loadingInfo); //Creating Mass LandSmoothing landSmoothing = new LandSmoothing(tileGrid, loadingInfo); //Creating Roads TownsAndRoads townsAndRoads = new TownsAndRoads(tileGrid, intersectionList, townList, loadingInfo); AddingTrees addingTrees = new AddingTrees(tileGrid, treeMap, loadingInfo); //Setting the world WorldController.world = new World(worldWidth, worldHeight, tileGrid, intersectionList, townList); WorldController.world.AddVehicle(); //Faster GC Collection Array.Clear(waterMap, 0, waterMap.Length); Array.Clear(treeMap, 0, treeMap.Length); GC.Collect(); creationState = CreationState.InitMiniMap; }
public async Task <CreationState> AddUserAsnc(AddUserDto addUserDto) { var creationState = new CreationState { IsCreatedSuccessfully = false, CreatedObjectId = null }; var checkUsersAddedBefore = await _unitOfWork.UserRepository.FindElementAsync(x => x.Email == addUserDto.Email || x.PhoneNumber == addUserDto.PhoneNumber); if (checkUsersAddedBefore == null) { var newUser = _mapper.Map <AddUserDto, UsersProfile>(addUserDto); await _unitOfWork.UserRepository.CreateAsync(newUser); creationState.IsCreatedSuccessfully = await _unitOfWork.SaveAsync() > 0; creationState.CreatedObjectId = newUser.Id; string extention = Path.GetExtension(addUserDto.File.FileName); string path = _hostEnvironment.WebRootPath + "/Uploads/" + newUser.Id + extention; using (var stream = new FileStream(path, FileMode.Create)) { await addUserDto.File.CopyToAsync(stream); } } else { creationState.ErrorMessages.Add("This user added before"); } return(creationState); }
private void BuildGameFieldAnimated() { this.state = CreationState.Creating; var board = Game.Instance.GameBoard; if (board == null) { return; } if (fieldVisuals.Capacity < board.Cells.Length) { fieldVisuals.Capacity = board.Cells.Length; } var w = board.Width; var h = board.Height; var d = board.Depth; var fieldMarginSize = FieldSize + Margin; var worldSize = new Vector3(w * fieldMarginSize.x, h * fieldMarginSize.y, d * fieldMarginSize.z); var startPoint = (-worldSize + fieldMarginSize) / 2f; BoardEffectOrchestrator.PlayEffect(board.Cells, new SphericalGrowthTimeline(new Vector3(0, -worldSize.y, 0), 30f), item => BoardVisuals.BoardToWorldPosition((BoardCell)item), item => { var cell = (BoardCell)item; var instance = Instantiate(Prefab); instance.BoardCell = cell; instance.transform.position = startPoint + new Vector3(cell.PosX * fieldMarginSize.x, cell.PosY * fieldMarginSize.y, cell.PosZ * fieldMarginSize.z); instance.UpdateHullColor(); fieldVisuals.Add(instance); }, this.OnVisualsCreated); }
private void UpdateCreatingMiniMap() { if (WorldController.worldMini.Create(loadingInfo)) { creationState = CreationState.Done; } }
protected void HandleWrites(SocketState ss) { ArrayList socks = ss.WriteSocks; for (int i = 0; i < socks.Count; i++) { Socket s = (Socket)socks[i]; CreationState cs = ss.TakeCreationState(s); if (cs != null) { cs.HandleWritability(s); } else { //Let's try to flush the buffer: try { ss.FlushSocket(s); } catch { /* * We should close this edge */ TcpEdge tcpe = ss.GetEdge(s); TEL.RequestClose(tcpe); //Go ahead and forget about this socket. CloseAction ca = new CloseAction(tcpe, null); ca.Start(ss); } } } }
public override void Update(Input input) { base.Update(input); if (creationState == CreationState.WaitingForPerlin) { UpdateWaitPerlin(); } else if (creationState == CreationState.StartCreatingWorld) { ThreadPool.QueueUserWorkItem(UpdateCreatingWorld); creationState = CreationState.CreatingWorld; } else if (creationState == CreationState.InitMiniMap) { UpdateInitMiniMap(); } else if (creationState == CreationState.CreatingMiniMap) { UpdateCreatingMiniMap(); } else if (creationState == CreationState.Done) { ScreenController.ChangeScreen(new GameScreen()); } }
public PlantUmlFile CreateFile() { _state = new CreationState(); Skin?.WriteTo(_state.File.Top); if (!Scale.IsEmpty) { _state.File.Top.Writeln("scale " + Scale); } var hm = HideMembers.GetPumlCommands("hide"); foreach (var i in hm) { _state.File.Top.Writeln(i); } if (!string.IsNullOrEmpty(Title)) { _state.File.Top.Writeln("title"); _state.File.Top.Writeln(' ' + Title); _state.File.Top.Writeln("end title"); } // sprites foreach (var i in Sprites.OrderBy(a => a.Key)) { i.Value.Save(_state.File, i.Key); } var types = _entities.OrderBy(a => a.Value.OrderIndex) .Select(a => a.Key) .ToList(); if (IgnorePackages) { ProcessList(types, UmlPackageName.Empty); } else { var pcks = _entities.Values.Select(GetPackageName) .Distinct() .OrderBy(a => a).ToArray(); foreach (var i in pcks) { ProcessList(types, i); } } PackageClose(); _state.File.Relations.AddRange(Relations); Legend.WriteTo(_state.File.Classes); var result = _state.File; _state = null; return(result); }
/* ////////////////////////////// * * Here are all the normal methods of TcpEdgeListener * * ////////////////////////////// */ public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb) { try { if (!IsStarted) { throw new EdgeException("TcpEdgeListener is not started"); } else if (ta.TransportAddressType != TransportAddress.TAType.Tcp) { throw new EdgeException(ta.TransportAddressType.ToString() + " is not my type: Tcp"); } else if (_ta_auth.Authorize(ta) == TAAuthorizer.Decision.Deny) { //Too bad. Can't make this edge: throw new EdgeException(ta.ToString() + " is not authorized"); } else { //Everything looks good: ArrayList tmp_ips = new ArrayList(); tmp_ips.Add(((IPTransportAddress)ta).GetIPAddress()); CreationState cs = new CreationState(ecb, new Queue(tmp_ips), ((IPTransportAddress)ta).Port, this); ActionQueue.Enqueue(cs); } } catch (Exception e) { ecb(false, null, e); } }
public async Task <CreationState> AddUserAsync(AddUserDto addUserDto) { var creationState = new CreationState { IsCreatedSuccessfully = false, CreatedObjectId = null }; try { //Identity User Mapping var newUserIdentity = _mapper.Map <AddUserDto, IdentityUser>(addUserDto); var checkUsersAddedBefore = await _unitOfWork.UserRepository.FindElementAsync(x => x.Email == addUserDto.Email || x.PhoneNumber == addUserDto.PhoneNumber); if (checkUsersAddedBefore == null) { //Adding User var result = await _userManager.CreateAsync(newUserIdentity, addUserDto.Password); //Check If User Added if (result.Succeeded) { var userId = Guid.Parse(await _userManager.GetUserIdAsync(newUserIdentity)); var newUser = _mapper.Map <AddUserDto, UsersProfile>(addUserDto); newUser.Id = userId; await _unitOfWork.UserRepository.CreateAsync(newUser); creationState.IsCreatedSuccessfully = await _unitOfWork.SaveAsync() > 0; creationState.CreatedObjectId = newUser.Id; creationState.CreatedObjectId = userId; if (addUserDto.File != null) { string extention = Path.GetExtension(addUserDto.File.FileName); string path = _hostEnvironment.WebRootPath + "/Uploads/" + newUser.Id + extention; using (var stream = new FileStream(path, FileMode.Create)) { await addUserDto.File.CopyToAsync(stream); } } } else { foreach (IdentityError item in result.Errors) { creationState.ErrorMessages.Add(item.Description); } } } else { creationState.ErrorMessages.Add("This user added before"); } } catch (Exception ex) { creationState.ErrorMessages.Add(ex.Message); } return(creationState); }
//Remove and return the CreationState public CreationState TakeCreationState(Socket s) { CreationState cs = (CreationState)_sock_to_constate[s]; _sock_to_constate.Remove(s); _con_socks.Remove(s); return(cs); }
private void UpdateWaitPerlin() { if (perlinOneCompleted) { if (perlinTwoCompleted) { creationState = CreationState.StartCreatingWorld; } } }
private void OnVisualsDeleted() { this.fieldVisuals.Clear(); this.state = CreationState.Deleted; if (this.needsCreation) { this.needsCreation = false; this.BuildGameFieldAnimated(); } }
//public Ec2Instance(AmazonEC2Client client, string instanceId) //{ // this.Client = client; // this.InstanceId = instanceId; // // TODO: Get name from tag (and other specification stuff) // this.Name = "TODO"; // this.state = CreationState.CreatedNotSetup; // this.Logger = new StubLogger(); //} public Ec2Instance(AmazonEC2Client client, Config config, Instance runningInstance) { this.Client = client; this.config = config; this.InstanceId = runningInstance.InstanceId; this.Reconnect(runningInstance); this.state = CreationState.IsSetup; this.Logger = new StubLogger(); }
public Ec2Instance(AmazonEC2Client client, Config config, string name, InstanceSpecification specification) { this.Client = client; this.config = config; this.Name = name; this.Specification = specification; this.uniqueKey = Guid.NewGuid().ToString(); this.state = CreationState.DoesntExist; this.Logger = new StubLogger(); }
// Start is called before the first frame update void Start() { if (!Application.isPlaying) { return; } this.state = CreationState.Deleted; Game.Instance.NewGameStarting += OnNewGameStarting; Game.Instance.NewGameStarted += OnNewGameStarted; Game.Instance.GameLoaded += this.OnGameLoaded; Game.Instance.StartNewGame(); }
protected void HandleErrors(SocketState ss) { ArrayList socks = ss.ErrorSocks; for (int i = 0; i < socks.Count; i++) { Socket s = (Socket)socks[i]; CreationState cs = ss.TakeCreationState(s); if (cs != null) { cs.HandleError(s); } } }
private AbstractState CreateAbstractState(Shipping m_Parent) { AbstractState _ret = null; switch (m_Parent.ShippingState2.GetValueOrDefault(GetDefaultValue(m_Parent))) { case ShippingState2.Cancelation: _ret = new CancelationState(this); break; case ShippingState2.Canceled: _ret = new CanceledState(this); break; case ShippingState2.Completed: _ret = new CompletedState(this); break; case ShippingState2.Confirmed: _ret = new ConfirmedState(this); break; case ShippingState2.Creation: _ret = new CreationState(this); break; case ShippingState2.Delayed: _ret = new DelayedState(this); break; case ShippingState2.LackOfData: _ret = new LackOfDataState(this); break; case ShippingState2.Left: _ret = new LeftState(this); break; case ShippingState2.Started: _ret = new StartedState(this); break; case ShippingState2.Waiting: _ret = new WaitingState(this); break; } return(_ret); }
public async Task SetupAsync(CancellationToken?cancellationToken = null) { if (this.state == CreationState.DoesntExist) { await this.CreateAsync(cancellationToken); this.state = CreationState.IsSetup; } else if (this.state == CreationState.ExistsNotSetup) { var runningInstance = await this.DescribeInstanceAsync(); this.Reconnect(runningInstance); this.state = CreationState.IsSetup; } }
public async Task<CreationState> AddProductAsnc(AddProductDto addProductDto) { var creationState = new CreationState { IsCreatedSuccessfully = false, CreatedObjectId = null }; var newProduct = _mapper.Map<AddProductDto, Products>(addProductDto); await _unitOfWork.ProductRepository.CreateAsync(newProduct); creationState.IsCreatedSuccessfully = await _unitOfWork.SaveAsync() > 0; creationState.CreatedObjectId = newProduct.Id; string extention = Path.GetExtension(addProductDto.File.FileName); string path = _hostEnvironment.WebRootPath + "/Uploads/" + newProduct.Id + extention; using (var stream = new FileStream(path, FileMode.Create)) { await addProductDto.File.CopyToAsync(stream); } return creationState; }
private void DestroyGameFieldAnimated() { this.state = CreationState.Deleting; if (this.fieldVisuals.Count == 0) { this.OnVisualsDeleted(); return; } var startPoint = this.fieldVisuals[0] != null ? this.fieldVisuals[0].transform.position : Vector3.zero; BoardEffectOrchestrator.PlayEffect(this.fieldVisuals, new SphericalGrowthTimeline(startPoint, 30f), item => ((FieldVisual)item).transform.position, item => Destroy(((FieldVisual)item).gameObject), this.OnVisualsDeleted); }
public async Task <CreationState> AddOrder(AddOrderDto orderDto) { var creationState = new CreationState { IsCreatedSuccessfully = false, CreatedObjectId = null }; var product = await _unitOfWork.ProductRepository.FindByIdAsync(orderDto.ProductId); if (orderDto.OrderQuantity <= product.ProductQuantity) { var newOrder = _mapper.Map <AddOrderDto, Orders>(orderDto); // if user choose chicken if (product.ProductCategory == ProductCategory.Chicken && product.KiloOfProduct >= orderDto.KiloOfOrder) { newOrder.OrderPrice = (float)(newOrder.KiloOfOrder * product.ProductPrice); } else { creationState.ErrorMessages.Add("Dismatch Kilo of order in kilo in product"); } // if user choose Chick if (product.ProductCategory == ProductCategory.Chick && product.ProductQuantity >= newOrder.OrderQuantity) { newOrder.OrderPrice = (float)(newOrder.OrderQuantity * product.ProductPrice); } else { creationState.ErrorMessages.Add("Dismatch quantity of order in quantity in product"); } await _unitOfWork.OrderRepository.CreateAsync(newOrder); creationState.IsCreatedSuccessfully = await _unitOfWork.SaveAsync() > 0; creationState.CreatedObjectId = newOrder.Id; } else { creationState.ErrorMessages.Add("Invaled quantity of order"); } return(creationState); }
public CreationManager(ServerDirector serverDirector, CreationState initialState) { currentCreationState = initialState; director = serverDirector; }
public void Start() { m_currentCreationState = CreationState.VISUALIZATION; m_dropdownCreationState = GameObject.Find ("dropdown_creation_states").GetComponent<Dropdown>(); m_currentCameraProjection = CameraProjection.PERSPECTIVE; m_cameraPerspObject = GameObject.Find ("camera_persp"); m_cameraPersp = m_cameraPerspObject.GetComponent<Camera> (); m_cameraOrthoObject = GameObject.Find ("camera_ortho"); m_cameraOrtho = m_cameraOrthoObject.GetComponent<Camera> (); m_cameraOrthoObject.SetActive (false); m_currentCamera = m_cameraPersp; m_currentCameraObject = m_cameraPerspObject; m_isTranslating = false; m_isRotating = false; m_xyTranslationSpeed = 1; m_zTranslationSpeed = 30; m_rotatingSpeed = 5; m_creationPanel = GameObject.Find ("panel_building_creation"); m_canSelectObject = false; Shader.EnableKeyword ("_EMISSION"); m_selectedMaterial = Resources.Load("stripes_mat", typeof(Material)) as Material; m_defaultWallMaterial = Resources.Load ("Default-Material", typeof(Material)) as Material; m_levelDisplayText = GameObject.Find ("label_level_display").GetComponent<Text>(); m_buildingContainer = GameObject.Find ("building"); m_building = new Dictionary<string, LinkedList<GameObject>> (); /*LinkedList<GameObject> list = new LinkedList<GameObject> (); GetAllChildrenWithTag (list, m_buildingContainer, "Construction"); m_building.Add ("*", list); m_levelDisplayText.text = "*";*/ }
public void OnChangeCreationState() { /* chooses the opposite camera projection and change it afterward. */ switch (m_dropdownCreationState.value) { case 0: onChangeCameraProjection (); m_currentCreationState = CreationState.BASE; m_currentCameraProjection = CameraProjection.PERSPECTIVE; break; case 1 : m_currentCreationState = CreationState.OBJECT_CREATION; m_currentCameraProjection = CameraProjection.ORTHOGRAPHIC; break; case 2 : m_currentCreationState = CreationState.CUSTOMIZATION; m_currentCameraProjection = CameraProjection.ORTHOGRAPHIC; break; case 3 : m_currentCreationState = CreationState.VISUALIZATION; m_currentCameraProjection = CameraProjection.ORTHOGRAPHIC; break; default: break; } onChangeCameraProjection (); }
public void AddCreationState(Socket s, CreationState cs) { _sock_to_constate[s] = cs; _con_socks.Add(s); }
public virtual void StartCharacterCreation() { ShowCreationUI(); if (createCaracterName != null) { createCaracterName.text = ""; } if (TMPCreateCaracterName != null) { TMPCreateCaracterName.text = ""; } if (enterUI != null) { enterUI.SetActive(false); } if (races[0] != null) { race = races[0].raceData; } foreach (UGUICharacterRaceSlot raceSlot in races) { raceSlot.RaceSelected(race); } UpdateRaceDetails(); aspect = classes[0].classData; foreach (UGUICharacterClassSlot classSlot in classes) { classSlot.ClassSelected(aspect); } if (character != null) { Destroy(character); } characterName = ""; int randomResult = UnityEngine.Random.Range(0, 2); if (randomResult == 0) { gender = "Male"; } else { gender = "Female"; } if (avatarList != null) { avatarList.PreparSlots(race.raceName, gender, aspect.className); } // Do this after gender so the icons can be updated UpdateClassDetails(); ResetModel(); /*if (classes.Count > 0) * aspect = classes [0]; * SetCharacter ();*/ loginState = LoginState.CharacterCreate; creationState = CreationState.Body; }
public void Go(Object stateInfo) { creationState = CreationState.WaitingForPerlin; ThreadPool.QueueUserWorkItem(CreateWaterMap); ThreadPool.QueueUserWorkItem(CreateRiverMap); }
private void OnVisualsCreated() { this.state = CreationState.Created; }
//Done on main thread with pauses as we need to access the graphics device private void UpdateInitMiniMap() { WorldController.worldMini = new WorldMini(); creationState = CreationState.CreatingMiniMap; }
public async Task SetupAsync(CancellationToken? cancellationToken = null) { if (this.state == CreationState.DoesntExist) { await this.CreateAsync(cancellationToken); this.state = CreationState.IsSetup; } else if (this.state == CreationState.ExistsNotSetup) { var runningInstance = await this.DescribeInstanceAsync(); this.Reconnect(runningInstance); this.state = CreationState.IsSetup; } }
void StartCharacterCreation() { if (character != null) Destroy(character); characterName = ""; int randomResult = Random.Range(0, 2); if(randomResult == 0) { gender = "Male"; }else{ gender = "Female"; } //SetCharacter(npcAppearance.GenerateRandomUMA(race + gender)); SetCharacter(characterPrefabs[selectedPrefab]); loginState = LoginState.CharacterCreate; creationState = CreationState.Body; }
public void AddCreationState(Socket s, CreationState cs) { _sock_to_constate[ s ] = cs; _con_socks.Add(s); }
/* ////////////////////////////// * * Here are all the normal methods of TcpEdgeListener * * ////////////////////////////// */ public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb) { try { if( !IsStarted ) { throw new EdgeException("TcpEdgeListener is not started"); } else if( ta.TransportAddressType != TransportAddress.TAType.Tcp ) { throw new EdgeException(ta.TransportAddressType.ToString() + " is not my type: Tcp"); } else if( _ta_auth.Authorize(ta) == TAAuthorizer.Decision.Deny ) { //Too bad. Can't make this edge: throw new EdgeException( ta.ToString() + " is not authorized"); } else { //Everything looks good: ArrayList tmp_ips = new ArrayList(); tmp_ips.Add(((IPTransportAddress)ta).GetIPAddress()); CreationState cs = new CreationState(ecb, new Queue( tmp_ips ), ((IPTransportAddress) ta).Port, this); ActionQueue.Enqueue(cs); } } catch(Exception e) { ecb(false, null, e); } }