Exemple #1
0
        string GetMoistureContent()
        {
            RaycastHit hit;
            Vector3    forward = transform.TransformVector(Vector3.left);
            Ray        ray     = new Ray(firePoint.position, forward);

            ShootLaserFromTargetPosition(firePoint.position, forward, scanDistance);
            lineRenderer.enabled = true;
            if (Physics.Raycast(ray, out hit, scanDistance))
            {
                Debug.DrawRay(firePoint.position, forward, Color.red, 0.01f, false);
                WaterSource waterSrc = hit.collider.GetComponent <WaterSource> ();
                if (waterSrc != null)
                {
                    float moisture = 1 / Vector3.Distance(hit.point, hit.transform.position);
                    Debug.DrawLine(hit.transform.position, hit.point, Color.blue, 20f, false);
                    if (moisture >= 0)
                    {
                        return(moisture.ToString("F2") + units);
                    }
                    else
                    {
                        return("0" + units);
                    }
                }
                else
                {
                    return("Object Contains No Moisture");
                }
            }
            else
            {
                return("No Soil Found");
            }
        }
Exemple #2
0
        public override string GetLocalizedStats(ushort buildingID, ref Building data)
        {
            StringBuilder sb = new StringBuilder();


            string floatFormat = "F1";

            if (this.m_standingWaterDepth > 0)
            {
                float bottomElevation       = data.m_position.y;
                float waterSurfaceElevation = Singleton <TerrainManager> .instance.WaterLevel(VectorUtils.XZ(data.m_position));

                float           targetElevation = data.m_position.y + this.m_standingWaterDepth;
                TerrainManager  instance        = Singleton <TerrainManager> .instance;
                WaterSimulation waterSimulation = instance.WaterSimulation;
                if (data.m_waterSource != 0)
                {
                    WaterSource sourceData = waterSimulation.LockWaterSource(data.m_waterSource);
                    targetElevation = sourceData.m_target;

                    //sb.AppendLine("Flow Rate: " + sourceData.m_flow.ToString(floatFormat));

                    /*sb.AppendLine("Water: " + sourceData.m_water.ToString(floatFormat));
                     * sb.AppendLine("Target Elevation: " + targetElevation2.ToString(floatFormat));*/

                    waterSimulation.UnlockWaterSource(data.m_waterSource, sourceData);
                }
                sb.AppendLine("Bottom Elevation:" + bottomElevation.ToString(floatFormat));
                sb.AppendLine("Ground Water Elevation: " + targetElevation.ToString(floatFormat));
                sb.AppendLine("Water Surface Elevation: " + waterSurfaceElevation.ToString(floatFormat));
            }

            return(sb.ToString());
        }
 public void AddWaterSource(WaterSource waterSource)
 {
     if (!waterSources.ContainsKey(waterSource.gameObject))
     {
         waterSources.Add(waterSource.gameObject, waterSource);
     }
 }
Exemple #4
0
        void Update()
        {
            GameObject under = getObjectUnder();

            if (under != null)
            {
                if (under.GetComponent <Bath>() != null && under.GetComponent <Bath>().filled == false)
                {
                    if (this.filled)
                    {
                        Bath bath = under.GetComponent <Bath>();
                        bath.fill();
                        this.unFill();
                    }
                }
                if (under.GetComponent <WaterSource>() != null)
                {
                    if (!this.filled)
                    {
                        WaterSource waterSource = under.GetComponent <WaterSource>();
                        this.fill();
                    }
                }
            }
        }
Exemple #5
0
    public float GetTotalAvailableAmount(WaterSource source)
    {
        float availCap   = GetAvailableCapacity(source.capacity);
        float usedAmount = source.GetUsedAmount();

        return(availCap - usedAmount);
    }
    private void OnTriggerEnter2D(Collider2D col)
    {
        // Tree
        if (col.gameObject.tag == "Flower")
        {
            TreeController tree = col.gameObject.GetComponent <TreeController>();
            if (this.tankScript.HasWater(tree.GetLevelCost()) && tree.CanLevelUp())
            {
                this.tankScript.UseWater(tree.GetLevelCost());
                tree.LevelUp();
            }
        }

        // Water
        if (col.gameObject.tag == "Water")
        {
            WaterSource source = col.gameObject.GetComponent <WaterSource>();
            int         empty  = this.tankScript.GetWaterCapacity() - this.tankScript.GetWaterAmount();
            this.tankScript.AddWater(source.GetWater(empty));
            if (empty > 0)
            {
                this.audio.clip = this.splash;
                this.audio.Play();
            }
        }
    }
        public IHttpActionResult PutWaterSource(string id, WaterSource waterSource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != waterSource.FunctionalWaterSource)
            {
                return(BadRequest());
            }

            db.Entry(waterSource).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WaterSourceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #8
0
        protected override void ProduceGoods(ushort buildingID, ref Building buildingData, ref Building.Frame frameData, int productionRate, int finalProductionRate, ref Citizen.BehaviourData behaviour, int aliveWorkerCount, int totalWorkerCount, int workPlaceCount, int aliveVisitorCount, int totalVisitorCount, int visitPlaceCount)
        {
            productionRate = 0;
            TerrainManager  instance        = Singleton <TerrainManager> .instance;
            WaterSimulation waterSimulation = instance.WaterSimulation;

            if (this.m_standingWaterDepth > 0 && buildingData.m_waterSource == 0)
            {
                HandleWaterSource(buildingID, ref buildingData, true, (int)this.m_standingWaterDepth * 10, 1000, 1);
            }
            else if (this.m_standingWaterDepth > 0)
            {
                WaterSource watersourceData = waterSimulation.LockWaterSource(buildingData.m_waterSource);

                float waterSurfaceElevation = Singleton <TerrainManager> .instance.WaterLevel(VectorUtils.XZ(buildingData.m_position));

                if (waterSurfaceElevation > watersourceData.m_target)
                {
                    watersourceData.m_outputRate = 0u;
                }
                else if (watersourceData.m_outputRate == 0u)
                {
                    watersourceData.m_outputRate = ((50u * watersourceData.m_water) / 1000u) - ((50u * watersourceData.m_water) / 1000u) % 50 + 50;
                }
                if (watersourceData.m_water < 50u)
                {
                    watersourceData.m_outputRate += 50u;
                    watersourceData.m_water       = 1000u * (watersourceData.m_outputRate / 50);
                }
                waterSimulation.UnlockWaterSource(buildingData.m_waterSource, watersourceData);
            }
            base.ProduceGoods(buildingID, ref buildingData, ref frameData, productionRate, finalProductionRate, ref behaviour, aliveWorkerCount, totalWorkerCount, workPlaceCount, aliveVisitorCount, totalVisitorCount, visitPlaceCount);
        }
        public IHttpActionResult PostWaterSource(WaterSource waterSource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.WaterSources.Add(waterSource);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (WaterSourceExists(waterSource.FunctionalWaterSource))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = waterSource.FunctionalWaterSource }, waterSource));
        }
Exemple #10
0
        void Update()
        {
            GameObject under = getObjectUnder();

            if (under != null)
            {
                if (under.GetComponent <Bath>() != null && under.GetComponent <Bath>().filled == false)
                {
                    if (this.filled)
                    {
                        Debug.Log("emptying bucket");
                        Bath bath = under.GetComponent <Bath>();
                        bath.fill();
                        this.unFill();
                    }
                }
                if (under.GetComponent <WaterSource>() != null)
                {
                    if (!this.filled)
                    {
                        Debug.Log("filling bucket");
                        WaterSource waterSource = under.GetComponent <WaterSource>();
                        this.fill();
                    }
                }
            }
        }
Exemple #11
0
        private bool HandleWaterSource(ushort buildingID, ref Building data, bool output, int rate, int max, float radius)
        {
            TerrainManager  instance        = Singleton <TerrainManager> .instance;
            WaterSimulation waterSimulation = instance.WaterSimulation;

            if (data.m_waterSource != 0)
            {
                return(false);
            }
            else
            {
                Vector3     vector2     = data.CalculatePosition(this.m_waterLocationOffset);
                WaterSource sourceData2 = default(WaterSource);
                sourceData2.m_type           = 2;
                sourceData2.m_inputPosition  = vector2;
                sourceData2.m_outputPosition = vector2;
                sourceData2.m_outputRate     = 50u;
                sourceData2.m_inputRate      = 1u;
                sourceData2.m_water          = 1000u;
                Debug.Log("[RF]NDai.HWS vector2 = " + vector2.ToString());

                sourceData2.m_target = (ushort)(vector2.y + this.m_standingWaterDepth);
                Debug.Log("[RF]NDai.HWS target = " + sourceData2.m_target.ToString());
                if (!waterSimulation.CreateWaterSource(out data.m_waterSource, sourceData2))
                {
                    return(false);
                }
            }
            return(true);
        }
 void Update()
 {
     //if person collider enters water collider play sound from both emitters
     if (PersonCollider.bounds.Intersects(WaterCollider.bounds) && PlayerInWater != true)
     {
         PlayerInWater = true;
         WaterFallSource.PlayOneShot(WaterfallSound, 0.7F);
         WaterSource.PlayOneShot(WaterSound, 0.5F);
     }
     if (PlayerInWater == true && (!WaterFallSource.isPlaying || !WaterSource.isPlaying))
     {
         if (!WaterFallSource.isPlaying)
         {
             WaterFallSource.PlayOneShot(WaterfallSound, 0.7F);
         }
         if (!WaterSource.isPlaying)
         {
             WaterSource.PlayOneShot(WaterSound, 0.5F);
         }
     }
     else if (!PersonCollider.bounds.Intersects(WaterCollider.bounds))
     {
         PlayerInWater = false;
         WaterFallSource.Stop();
         WaterSource.Stop();
     }
 }
 private void WaterShipmentListener(WaterSource w, int spent)
 {
     if (data.DepleteFund(spent) == true)
     {
         w.IncSource(spent);
         data.CalculateWaterDistributionRate();
     }
 }
 private void ResourceInvestmentListener(WaterSource w, int spent)
 {
     if (data.DepleteFund(spent) == true)
     {
         w.Investment(spent);
         data.CalculateWaterDistributionRate();
     }
 }
        public ActionResult DeleteConfirmed(Guid id)
        {
            WaterSource waterSource = db.WaterSources.Find(id);

            db.WaterSources.Remove(waterSource);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 internal void SetWaterSource(WaterSource waterSource)
 {
     this.waterSource          = waterSource;
     this.m_VolumeInLiters     = waterSource.GetVolumeLiters();
     this.m_WaterQuality       = waterSource.GetQuality();
     this.m_DrinkingAudio      = "Play_Slurping1";
     this.m_TimeToDrinkSeconds = 4;
 }
Exemple #17
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        WaterSource waterSource = (WaterSource)target;

        waterSource.falloff = EditorGUILayout.CurveField("Falloff Curve ", waterSource.falloff);
    }
 public ActionResult Edit([Bind(Include = "Id,Name,Description,IsOwned,Capacity,FireStationId")] WaterSource waterSource)
 {
     if (ModelState.IsValid)
     {
         db.Entry(waterSource).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("id") + ""), "Id", "Name", waterSource.FireStationId);
     return(View(waterSource));
 }
        public IHttpActionResult GetWaterSource(string id)
        {
            WaterSource waterSource = db.WaterSources.Find(id);

            if (waterSource == null)
            {
                return(NotFound());
            }

            return(Ok(waterSource));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,IsOwned,Capacity,FireStationId")] WaterSource waterSource)
        {
            if (ModelState.IsValid)
            {
                waterSource.Id = Guid.NewGuid();
                db.WaterSources.Add(waterSource);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("id") + ""), "Id", "Name", waterSource.FireStationId);
            return(View(waterSource));
        }
Exemple #21
0
        internal static void ClampAmount(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("Could not find WaterSupply to transfer to");
                return;
            }

            float limit = Water.GetRemainingCapacity(waterSource.GetQuality()) + Water.GetRemainingCapacityEmpty();

            panel.m_numLiters = Mathf.Min(panel.m_numLiters, limit);
        }
Exemple #22
0
        internal static void UpdateButtons(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("Could not find WaterSource");
                return;
            }

            float limit = Water.GetRemainingCapacity(waterSource.GetQuality()) + Water.GetRemainingCapacityEmpty();

            panel.m_ButtonIncrease.SetActive(panel.m_numLiters < limit);
        }
        public IHttpActionResult DeleteWaterSource(string id)
        {
            WaterSource waterSource = db.WaterSources.Find(id);

            if (waterSource == null)
            {
                return(NotFound());
            }

            db.WaterSources.Remove(waterSource);
            db.SaveChanges();

            return(Ok(waterSource));
        }
        // GET: WaterSources/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WaterSource waterSource = db.WaterSources.Find(id);

            if (waterSource == null)
            {
                return(HttpNotFound());
            }
            return(View(waterSource));
        }
Exemple #25
0
        public void Executive(ConsoleKeyInfo key)
        {
            if (key.Key == ConsoleKey.S)
            {
                bool @is = false;

                foreach (WaterSource source in sources)
                {
                    if (cursor.Y == source.Height && source.Width == cursor.X)
                    {
                        @is = true;
                        break;
                    }
                }

                Console.SetCursorPosition(cursor.X, cursor.Y);

                if (!@is)
                {
                    for (int i = 0; i < pipes.Count - 1; i++)
                    {
                        if (pipes[i] != null)
                        {
                            if (cursor.Y == pipes[i].Height && pipes[i].Width == cursor.X)
                            {
                                pipes.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    WaterSource waterSource = new WaterSource(cursor.X, cursor.Y);
                    sources.Add(waterSource);
                }
                else
                {
                    for (int i = 0; i < sources.Count - 1; i++)
                    {
                        if (cursor.Y == sources[i].Height && sources[i].Width == cursor.X)
                        {
                            WaterSource waterSource = new WaterSource(cursor.X, cursor.Y);
                            sources.RemoveAt(i);
                            waterSource.Print();
                            sources.Add(waterSource);
                            break;
                        }
                    }
                }
            }
        }
        // GET: WaterSources/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WaterSource waterSource = db.WaterSources.Find(id);

            if (waterSource == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FireStationId = new SelectList(DataFilter.GetFireStations(TempData.Peek("id") + ""), "Id", "Name", waterSource.FireStationId);
            return(View(waterSource));
        }
Exemple #27
0
        internal static void UpdateCapacityInfo(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("UpdateCapacityInfo: Could not find WaterSource");
                return;
            }

            labelCapacityInfo.text = GetWaterInfo(LiquidQuality.Potable) + "    " +
                                     GetWaterInfo(LiquidQuality.NonPotable) + "    " +
                                     Localization.Get("GAMEPLAY_Empty") + ": " + WaterUtils.FormatWaterAmount(0) + "/" + WaterUtils.FormatWaterAmount(Water.GetRemainingCapacityEmpty());

            labelNoCapacityWarning.gameObject.SetActive(Water.GetRemainingCapacityEmpty() == 0 && Water.GetRemainingCapacity(waterSource.GetQuality()) == 0);
        }
        string isLife()
        {
            GetComponent <AudioSource>().Play();
            Vector3    fwd = selfieCamera.TransformDirection(Vector3.forward);
            RaycastHit hit;
            Ray        r = new Ray(selfieCamera.position, fwd);

            if (Physics.Raycast(r, out hit, scanDistance))
            {
                Debug.DrawRay(selfieCamera.position, fwd, Color.yellow, 1, false);
                WaterSource waterSrc = hit.collider.GetComponent <WaterSource> ();

                if (waterSrc != null)
                {
                    float moisture = 1 / Vector3.Distance(hit.point, hit.transform.position);

                    if (moisture >= waterSrc.minWaterForLife)
                    {
                        StartCoroutine(loadOnScreen(LifeImages [Random.Range(0, LifeImages.Length)], true));
                        Debug.DrawLine(hit.transform.position, hit.point, Color.green, 20, false);
                        return("Life found");
                    }
                    else
                    {
                        StartCoroutine(loadOnScreen(noLifeImages [Random.Range(0, noLifeImages.Length)], false));
                        Debug.DrawLine(hit.transform.position, hit.point, Color.red, 20, false);
                        return("You are close");
                    }
                }
                else
                {
                    StartCoroutine(loadOnScreen(noLifeImages [Random.Range(0, noLifeImages.Length)], false));
                    Debug.DrawLine(hit.transform.position, hit.point, Color.red, 20, false);
                    return("No life here");
                }
            }
            else
            {
                Debug.DrawLine(hit.transform.position, hit.point, Color.red, 20, false);
                return("Use on soil");
            }
        }
Exemple #29
0
        public WaterSource NewWaterSource(Vector2 point, uint flow, uint inrate, uint outrate)
        {
            ushort      sourceNum;
            WaterSource defaultSource = default(WaterSource);
            var         z             = Singleton <TerrainManager> .instance.SampleRawHeightSmoothWithWater(new Vector3(point.x, 0, point.y), false, 0f);

            var pos = new Vector3(point.x, z, point.y);

            // water source settings
            defaultSource.m_flow           = flow;
            defaultSource.m_inputRate      = inrate;
            defaultSource.m_outputRate     = outrate;
            defaultSource.m_outputPosition = pos;
            defaultSource.m_inputPosition  = pos;
            defaultSource.m_type           = 2;
            defaultSource.m_water          = 8000000u;
            _waterSimulation.CreateWaterSource(out sourceNum, defaultSource);
            _waterSourceIDs.Add(sourceNum);
            Temp++;
            return(defaultSource);
        }
    private void Awake()
    {
        waveData      = new WaveData(waterMat);
        waterSource   = new WaterSource();
        mappedSources = new MeshObjectMap <WaterSource>();

        mappedSources.NewObject(waterSource, Vector3.zero);
        waterSource.GenerateRange(Vector3.zero, 1024f, 64, waterMat);
        mappedSources.UpdateAllMeshes();
        // Create wave data based on water material
        GameObject baseobject = mappedSources.GetMapped(waterSource);

        for (int i = -3; i < 4; i++)
        {
            for (int j = -3; j < 4; j++)
            {
                if (!(i == 0 && j == 0))
                {
                    GameObject.Instantiate(baseobject, new Vector3(1024f * i, 0f, 1024f * j), Quaternion.identity);
                }
            }
        }
    }