/* * Shift the water */ public virtual WaterObject OnFlow(WaterObject inflow) { if (inflow == null) { WaterObject myWater = null; if (this.Water != null) { myWater = this.Water.Copy(); } this.Water = null; return(myWater); } if (this.Water == null) { this.Water = inflow.Copy(); return(null); } WaterObject cpy = this.Water.Copy(); this.Water = inflow.Copy(); return(cpy); }
/// <summary> /// Makes time move (tick) forward for the modules. Ticking time forward allows for the water to flow through /// the system. /// </summary> public List <WaterObject> TickModules() { List <WaterObject> waterLeaving = new List <WaterObject>(); // Flow water through the reservoir, to start flow through everything else try { for (int i = 0; i < MapCapacity; i++) { this.Reservoir.Tick(); WaterObject water = this.Reservoir.OnFlow(new WaterObject()); var currentModule = this.Reservoir.NextModule; while (currentModule != null) { currentModule.Tick(); water = currentModule.OnFlow(water); currentModule = currentModule.NextModule; } if (water != null) { waterLeaving.Add(water.Copy()); // Add the water that came from the last module } } } catch (Exception e) { } return(waterLeaving); }
public static Guid AddOrUpdateWaterObject( this RiversECO.DataContext.DataContext dataContext, WaterObject waterObject, bool rewriteWaterObjects) { var existingWaterObject = dataContext.WaterObjects .SingleOrDefault(x => waterObject.CodeSwb == x.CodeSwb); if (existingWaterObject != null) { waterObject.Id = existingWaterObject.Id; if (rewriteWaterObjects) { existingWaterObject.Category = waterObject.Category; existingWaterObject.Description = waterObject.Description; existingWaterObject.ModifiedOn = DateTime.UtcNow; existingWaterObject.Note = waterObject.Note; existingWaterObject.Type = waterObject.Type; existingWaterObject.TypeCode = waterObject.TypeCode; existingWaterObject.TypeName = waterObject.TypeName; } } else { dataContext.Add(waterObject); } return(waterObject.Id); }
public static WaterObject MapToWaterObject(this LakeFeatureProperties feature) { try { var waterObject = new WaterObject() { Id = Guid.NewGuid(), Name = feature.NameUkr, CodeSwb = feature.CodeSwb, CreatedOn = DateTime.UtcNow, Category = feature.Category, TypeName = feature.TypeName, TypeCode = feature.TypeCode, Description = GetLakeDescription(feature), Type = WaterObjectType.Lake }; return(waterObject); } catch (Exception exception) { ConsoleLogger.WriteError($"Exception occured while mapping the lake feature {feature}.", exception); throw exception; } }
/// <summary> /// Pump the Water /// </summary> /// <param name="inflow"></param> /// <returns></returns> public override WaterObject OnFlow(WaterObject inflow) { if (this.PumpBroken) { return(null); // Do not continue the flow of water if pumping is off } return(base.OnFlow(inflow)); }
/// <summary> /// Only called when the pump is on. Brings as much water as it can from the previous module into this one. /// Override for custom functionality in modules! /// </summary> protected virtual void OnFlow() { if (this.PreviousModule && this.Water == null) { this.Water = this.PreviousModule.Water; this.PreviousModule.Water = null; } }
public WaterObject Copy() { WaterObject cpy = new WaterObject(); cpy.Purity1 = this.Purity1; cpy.Purity2 = this.Purity2; cpy.Purity3 = this.Purity3; return(cpy); }
//Инициализация и заполнение формы public ArticleForm(WaterObject river) { InitializeComponent(); NameBox.Text = river.Name; TypeBox.Text = river.Type; RegionBox.Text = river.Region; AreaBox.Text = river.Area.ToString(); DeapthBox.Text = river.Depth.ToString(); EditonalBox.Text = river.EditionalData; PictureBox.Image = river.Image; }
//Коструктор для редактирования public EditArticleForm(WaterObject o2) : this() { Water = new WaterObject(o2); EditionalBox.Text = Water.EditionalData; AreaNumber.Value = Water.Area; WaterImage.Image = Water.Image; NameBox.Text = Water.Name; RegionCbox.Text = Water.Region; DepthNumber.Value = Water.Depth; TypeCbox.Text = Water.Type; }
private void Button1_Click(object sender, EventArgs e) { if (Water == null) { Water = new WaterObject(); } Water.EditionalData = EditionalBox.Text; Water.Area = AreaNumber.Value; Water.Image = (Bitmap)WaterImage.Image; Water.Name = NameBox.Text; Water.Region = RegionCbox.Text; Water.Depth = DepthNumber.Value; Water.Type = TypeCbox.Text; }
// Fill the reservoir public override WaterObject OnFlow(WaterObject inflow) { if (inflow != null) { Water.Enqueue(inflow.Copy()); } if (this.IsEmpty || this.DrainBroken) { return(null); } return(Water.Dequeue()); }
public void AddObject(WaterObject waterObject) { if (waterObject is BubbleSpawnerObject) { PurpleObjects.Add(waterObject); } else if (waterObject is BubbleObject) { BrownObjects.Add(waterObject); } else { throw new ArgumentOutOfRangeException(); } }
void Start() { WaterObject waterObject = gameObject.AddComponent <WaterObject>(); waterObject.SetMaterialDensity(400); waterObject.convexifyMesh = true; waterObject.simplifyMesh = true; waterObject.targetTris = 64; waterObject.GenerateSimMesh(); waterObject.Init(); // Important. Without running Synchronize() WaterObject will not be registered by the WaterObjectManager and // the physics will not work. Just note that running Synchronize() can be WaterObjectManager.Instance.Synchronize(); }
//private void ChangeGunPosition() //{ // Vector3 horizontalOffset = new Vector3(0.5f, 0, 0); // Vector3 verticalOffset = new Vector3(0, 0.75f, 0); // if (Input.GetAxisRaw("Horizontal") != 0) // { // if (Input.GetAxisRaw("Horizontal") == -1) // { // if(Input.GetAxisRaw("Vertical") == 1) // { // transform.position = // playerTransform.position + (horizontalOffset * -1) + (verticalOffset * 0.5f); // } // else // transform.position = playerTransform.position + (horizontalOffset * -1); // } // if (Input.GetAxisRaw("Horizontal") == 1) // { // if (Input.GetAxisRaw("Vertical") == 1) // { // transform.position = // playerTransform.position + horizontalOffset + (verticalOffset * 0.5f); // } // else // transform.position = playerTransform.position + horizontalOffset; // } // } // else if(Input.GetAxisRaw("Vertical") == 1) // { // transform.position = playerTransform.position + verticalOffset; // } //} private void HandleShootingInput() { if (Input.GetButton("Action") && timeSinceLastBullet >= timeBetweenBulletsInSeconds) { timeSinceLastBullet = 0; //Shoot a bullet Vector2 directionToFire = GetDirectionToFire(); //Create new water bullet, then set speed WaterObject newBullet = Instantiate(bullet, transform.position, transform.rotation); //Set the speed of the water bullet Rigidbody2D waterObjectRigidbody = newBullet.GetComponent <Rigidbody2D>(); waterObjectRigidbody.velocity = (directionToFire * bulletSpeed); } timeSinceLastBullet += Time.deltaTime; }
void HandleShooting() { //Get raw input axese float horizontalInput = Input.GetAxisRaw("Horizontal"); float verticalInput = Input.GetAxisRaw("Vertical"); //Get total 8-way input direction Vector2 inputDirection = new Vector2(horizontalInput, verticalInput); Vector2 fireVector = GetDirectionalFireVector(inputDirection); if (inputDirection != Vector2.zero) { //Create new water bullet, then set speed WaterObject newBullet = Instantiate(bullet, transform.position, transform.rotation); Rigidbody2D bulletRigidbody = newBullet.GetComponent <Rigidbody2D>(); //bulletRigidbody.velocity = inputDirection * (bulletSpeed * directionalMagnitudeChange) ; } }
/// <summary> /// Recursive. Water flows. Stops if current systems is blocked (override this depending on type) /// </summary> public virtual void WaterFlow() { //only flows if water is available from previous and not blocked bool blocked = false; //make this public later if (PreviousModule.Water != null && !blocked) { //take water from previous then moved to new modules this.Water = PreviousModule.Water; if (NextModule != null) { foreach (Module next in NextModule) { next.WaterFlow(); } } } }
void ShootGun() { if (Input.GetButton("Shoot") && cooldownTimeRemaining <= 0) { gunPointingDirection = transform.position - transform.parent.position; //Create new water bullet WaterObject newBullet = Instantiate(bullet, transform.position, transform.rotation); //Set the speed of the water bullet Rigidbody2D waterObjectRigidbody = newBullet.GetComponent <Rigidbody2D>(); waterObjectRigidbody.velocity = (gunPointingDirection.normalized * bulletSpeed); //Set cooldown cooldownTimeRemaining = gunCooldownTime; } }
private void ShootInput() { //Cooldown timer goes down cooldownTimeRemaining += Time.deltaTime * -1; if (Input.GetButton("Shoot") && cooldownTimeRemaining <= 0) { //Create new water bullet WaterObject newBullet = Instantiate(bullet, transform.position, transform.rotation); //Set the speed of the water bullet Rigidbody2D waterObjectRigidbody = newBullet.GetComponent <Rigidbody2D>(); waterObjectRigidbody.velocity = (offsetVector.normalized * bulletSpeed); //Set cooldown cooldownTimeRemaining = gunCooldownTime; } }
private void SetUpWater() { //sizeZ = 150; //sizeX = 150; // Mesh for the map var mesh = new Mesh(); // Setting vertices var vertices = new List <Vector3>(Settings.WaterVertices); // Generating indices var indices = new List <int>(); for (int z = 0; z < sizeZ; z++) { for (int x = 0; x < sizeX; x++) { // Fetching indices for the current square int v1 = x + (z * (sizeX + 1)); int v2 = x + 1 + (z * (sizeX + 1)); int v3 = x + ((z + 1) * (sizeX + 1)); int v4 = x + 1 + ((z + 1) * (sizeX + 1)); // Saving them in the right order indices.AddRange(new[] { v3, v2, v1, v3, v4, v2 }); } } // Finilizing mesh mesh.SetVertices(vertices); //Назначаем вершины mesh.SetTriangles(indices, 0); //Назначаем треугольники - индексы вершин mesh.uv = Settings.WaterUVs; mesh.RecalculateBounds(); //Постройка меша mesh.RecalculateNormals(); //Постройка меша // Setting mesh to mesh renderers WaterObject.GetComponent <MeshFilter>().mesh = mesh; // Creating collider WaterObject.gameObject.AddComponent <MeshCollider>(); WaterObject.AddComponent <WaterBasic>(); WaterObject.transform.Translate(Vector3.up * Settings.WaterHeight); }
void Start() { //check if person object exists and fetch collider if (PersonObject != null) { PersonCollider = PersonObject.GetComponent <Collider>(); } //check if water object exists and fetch collider and audio source if (WaterObject != null) { WaterCollider = WaterObject.GetComponent <Collider>(); WaterSource = WaterObject.GetComponent <AudioSource>(); } //check for the existance of a water particle emitter and fetch audio source if (WaterfallObject != null) { WaterFallSource = WaterfallObject.GetComponent <AudioSource>(); } }
private void HandleShootingInput() { //Get horizontal input float horizontalInput = Input.GetAxisRaw("Horizontal"); if (Input.GetButtonDown("Action")) { //Get vert input float verticalInput = Input.GetAxisRaw("Vertical"); //Shoot even when standing still if (horizontalInput == 0 && verticalInput == 0) { horizontalInput = facingDirection; } //Get total 8-way input direction Vector2 inputDirection = new Vector2(horizontalInput, verticalInput); //Get player movement speed Vector2 playerVelocity = GameObject.Find("Player").GetComponent <Rigidbody2D>().velocity; //Create new water bullet WaterObject newWaterObject = Instantiate(waterObject, transform.position, transform.rotation); //Set the speed of the water bullet Rigidbody2D waterObjectRigidbody = newWaterObject.GetComponent <Rigidbody2D>(); waterObjectRigidbody.velocity = (inputDirection * fireSpeed) + new Vector2(playerVelocity.x, 0); //IMPORTANT NOTE: Shots need to be fired w/ different velocities depending // on the direction they are travelling. ???? i think } facingDirection = horizontalInput; }
/// <summary> /// Recursive. Water flows. Stops if current systems is blocked (override this depending on type) /// </summary> public virtual void WaterFlow() { //only flows if water is available from previous and not blocked bool blocked = false; //make this public later for (int i = 0; i < PreviousModule.Count; i++) //loop through all the previous modules { if (PreviousModule[i].Water != null && !blocked) { //take water from previous then moved to new modules this.Water = PreviousModule[i].Water; if (NextModule != null) { foreach (Module next in NextModule) { next.WaterFlow(); } } break; } } }
/// <summary> /// Filters the water, as a filter does /// </summary> /// <param name="water"></param> /// <returns></returns> public WaterObject FilterWater(WaterObject water) { if (water == null) { return(water); } if (this.PurityBroken) { return(water); // Do not filter it if purity is broken } if (this.PurityIndexToControl < 1) { this.PurityIndexToControl = 1; } if (this.PurityIndexToControl > 3) { this.PurityIndexToControl = 3; } water.purity[this.PurityIndexToControl - 1] = true; return(water); }
public virtual void WaterDisable() { Water = null; WaterIndicator.SetActive(false); gameObject.BroadcastMessage("SetWater", false, SendMessageOptions.DontRequireReceiver); }
/// <summary> /// Apply filtration during flow /// </summary> /// <param name="inflow"></param> /// <returns></returns> public override WaterObject OnFlow(WaterObject inflow) { var water = base.OnFlow(inflow); // Returns water that was inside the filter return(FilterWater(water)); // Filter it for the next module }