Exemplo n.º 1
0
    private void ClearSelection()
    {
        bool canAdd = false;

        if (selectedObjects.Count > 0)
        {
            foreach (GameObject obj in selectedObjects)
            {
                obj.GetComponent <ClickOn>().currentlySelected = false;
                obj.GetComponent <ClickOn>().OnClick();
            }
            selectedObjects.Clear();
            foreach (GameObject obj in selectedMoveObjects)
            {
                OperatingUnit unit = obj.GetComponent <OperatingUnit>();
                if (!unit.isOnPlace)
                {
                    collection.Add(new UnitCollection());
                    canAdd = true;
                    index++;
                    break;
                }
            }

            foreach (GameObject addObj in selectedMoveObjects)
            {
                if (canAdd)
                {
                    collection[index].units.Add(addObj);
                }
            }
            points.Add(rayh.point);
            selectedMoveObjects.Clear();
        }
    }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            OperatingUnit operatingUnit = db.OperatingUnit.Find(id);

            db.OperatingUnit.Remove(operatingUnit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "id,name,address,location,region,unit_type,unit_subtype,city_id,legalEntity_id")] OperatingUnit operatingUnit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(operatingUnit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.city_id        = new SelectList(db.Cities, "id", "name", operatingUnit.city_id);
     ViewBag.legalEntity_id = new SelectList(db.LegalEntity, "id", "name", operatingUnit.legalEntity_id);
     return(View(operatingUnit));
 }
Exemplo n.º 4
0
        // GET: Admin/OperatingUnits/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OperatingUnit operatingUnit = db.OperatingUnit.Find(id);

            if (operatingUnit == null)
            {
                return(HttpNotFound());
            }
            return(View(operatingUnit));
        }
Exemplo n.º 5
0
        // GET: Admin/OperatingUnits/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OperatingUnit operatingUnit = db.OperatingUnit.Find(id);

            if (operatingUnit == null)
            {
                return(HttpNotFound());
            }
            ViewBag.city_id        = new SelectList(db.Cities, "id", "name", operatingUnit.city_id);
            ViewBag.legalEntity_id = new SelectList(db.LegalEntity, "id", "name", operatingUnit.legalEntity_id);
            return(View(operatingUnit));
        }
Exemplo n.º 6
0
    void Move()
    {
        foreach (GameObject obj in selectedMoveObjects)
        {
            OperatingUnit unit = obj.GetComponent <OperatingUnit>();
            rb           = obj.GetComponent <Rigidbody>();
            elapsedTime += Time.deltaTime;

            float velocity = (obj.transform.position - unit.lastPos).magnitude / elapsedTime;
            float distance = Vector3.Distance(obj.transform.position, rayh.point);
            unit.lastPos = obj.transform.position;
            if (!unit.isOnPlace)
            {
                obj.transform.position = Vector3.MoveTowards(obj.transform.position, rayh.point, Time.deltaTime);
            }

            if (velocity * 1000 <= 0.25 && elapsedTime > 5f || distance < 1f)
            {
                unit.isOnPlace = true;
            }
        }
        foreach (UnitCollection coll in collection)
        {
            if (coll.units.Count > 0)
            {
                bool areOnPlace = true;
                int  i          = collection.IndexOf(coll);
                foreach (GameObject objct in coll.units)
                {
                    OperatingUnit unit = objct.GetComponent <OperatingUnit>();
                    rb           = objct.GetComponent <Rigidbody>();
                    elapsedTime += Time.deltaTime;
                    float distance = Vector3.Distance(objct.transform.position, points[i]);
                    unit.lastPos = objct.transform.position;
                    if (!unit.isOnPlace)
                    {
                        objct.transform.position = Vector3.MoveTowards(objct.transform.position, points[i], Time.deltaTime);
                    }

                    if (distance < 1f)
                    {
                        unit.isOnPlace = true;
                    }
                    if (!unit.isOnPlace)
                    {
                        areOnPlace = false;
                    }
                }
                if (areOnPlace)
                {
                    deleteObjects.Add(coll);
                }
            }
        }
        foreach (UnitCollection col in deleteObjects)
        {
            collection.Remove(col);
            index--;
        }
        deleteObjects.Clear();
    }