Esempio n. 1
0
    void Explode()
    {
        Collider[] collidersFracturing = Physics.OverlapSphere(transform.position, blastradius);

        foreach (Collider objectInRange in collidersFracturing)
        {
            Fracture fracture = objectInRange.GetComponent <Fracture>();
            if (fracture != null)
            {
                fracture.Destroy();
            }
        }

        Collider[] collidersMove = Physics.OverlapSphere(transform.position, blastradius);

        foreach (Collider objectInRange in collidersMove)
        {
            Rigidbody rb = objectInRange.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.AddExplosionForce(explosionForce, transform.position, blastradius);
            }
        }

        Destroy(gameObject);
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (br == null)
        {
            fire.SetActive(true);
            RaycastHit hit;
            if (Physics.Raycast(fire.transform.position, fire.transform.forward, out hit, 1.5f))
            {
                //Debug.DrawLine (fire.transform.position,fire.transform.position + (-fire.transform.up * 1.5f));
                Fracture  fract  = hit.collider.gameObject.GetComponent <Fracture> ();
                Breakable breaka = hit.collider.gameObject.GetComponent <Breakable> ();
                if (fract != null)
                {
                    fract.Break(0);
                }
                else if (breaka != null)
                {
                    breaka.Break(0);
                }
            }
        }

        if (!dm.beingHeld && br == null)
        {
            rb.AddExplosionForce(18f, fire.transform.position, 2f);
        }
    }
Esempio n. 3
0
        protected override void Seed(DbContext context)
        {
            var patient = new Patient()
            {
                FirstName      = "Bubba",
                LastName       = "Ho-Tep",
                Age            = 1234,
                PersonalNumber = "1101991231234"
            };

            context.Patients.Add(patient);
            context.SaveChanges();

            var incident = new Incident()
            {
                InjuryDate     = "2010-03-04",
                InjuryHour     = 9,
                PersonalNumber = patient.PersonalNumber
            };

            context.Incidents.Add(incident);

            var fracture = new Fracture()
            {
                IncidentID = incident.ID,
                AOCode     = "33A2"
            };

            context.Fractures.Add(fracture);

            patient = new Patient()
            {
                FirstName      = "Joe",
                LastName       = "Schmoe",
                Age            = 35,
                PersonalNumber = "1212121231234"
            };
            context.Patients.Add(patient);
            context.SaveChanges();

            incident = new Incident()
            {
                InjuryDate     = "2002-08-05",
                InjuryHour     = 23,
                PersonalNumber = patient.PersonalNumber
            };
            context.Incidents.Add(incident);

            fracture = new Fracture()
            {
                IncidentID = incident.ID,
                AOCode     = "22B1"
            };
            context.Fractures.Add(fracture);
        }
    public void Break(Fracture fracture, Vector3 world)
    {
        //var local = fracture.transform.InverseTransformPoint(world);
        Profiler.BeginSample("Do fracture call");

        //fracture.DoFracture(local);
        fracture.DoFracture();

        Profiler.EndSample();

        StartCoroutine(Explode(world));
    }
Esempio n. 5
0
        public HttpStatusCode Index(Guid id)
        {
            var fracture = new Fracture(id);

            db.Fractures.Attach(fracture);
            db.Fractures.Remove(fracture);
            try {
                db.SaveChanges();
            } catch (System.Data.DataException) {
                return(HttpStatusCode.NotFound);
            }

            return(HttpStatusCode.OK);
        }
Esempio n. 6
0
        public ActionResult Index(Fracture fracture)
        {
            if (ModelState.IsValid)
            {
                db.Fractures.Add(fracture);
                db.SaveChanges();

                return(Json(fracture));
            }

            // TODO: Is this the right thing to return?
            return(new HttpStatusCodeResult(
                       HttpStatusCode.InternalServerError));
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Directory.GetCurrentDirectory());

            var db = new DbContext();

            addPatients(db);
            db.SaveChanges();

            foreach (var patient in db.Patients)
            {
                Console.WriteLine(string.Format("patient: {0} {1} {2}",
                                                patient.PersonalNumber, patient.FirstName, patient.LastName));

                foreach (var incident in patient.Incidents)
                {
                    System.Console.WriteLine("    incident: {0} {1} {2} {3}",
                                             incident.InjuryDate, incident.InjuryHour, incident.ID, incident.PersonalNumber);

                    foreach (var fracture in incident.Fractures)
                    {
                        System.Console.WriteLine("        fracture: {0} {1} {2}",
                                                 fracture.AOCode, fracture.ID, fracture.IncidentID);

                        foreach (var procedure in fracture.Procedures)
                        {
                            Console.WriteLine("            procedure: {0}",
                                              procedure.ID
                                              // procedure.Consultation.ID
                                              );
                        }
                    }

                    var frac = new Fracture()
                    {
                        AOCode     = "33A3",
                        IncidentID = incident.ID
                    };
                    db.Fractures.Add(frac);
                    Console.WriteLine(frac.Incident);
                }
            }

            System.Console.ReadLine();
        }
Esempio n. 8
0
    IEnumerator FireFractureProjectile()
    {
        yield return(new WaitForSeconds(0.1f));

        Vector3    instantiationPosition = transform.position + transform.forward + (transform.up * 2f);
        GameObject newFractureProjectile = GameObject.Instantiate(FractureProjectile, instantiationPosition, transform.rotation);

        newFractureProjectile.GetComponent <Rigidbody>().velocity = transform.forward * 30.0f;

        Fracture fractureController = newFractureProjectile.GetComponent <Fracture>();

        fractureController.PassReferenceToHardware(this);
        fractureController.TimeToStop    = TravelTime;
        fractureController.TimeToDestroy = TravelTime + LingerTime;

        GameManager.JoltScreen(-transform.forward, 0.8f);
        StartCoroutine(GoOnCooldown());
    }
Esempio n. 9
0
    void OnCollisionEnter(Collision coll)
    {
        if (rb.velocity.magnitude > 1f)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, explosiveRadius);
            foreach (Collider hit in colliders)
            {
                Rigidbody rb = hit.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    rb.AddExplosionForce(explosiveForce, transform.position, explosiveRadius, 3.0F);
                }

                Fracture fr = hit.GetComponent <Fracture> ();
                if (fr != null)
                {
                    fr.Break(1);
                }

                Breakable br = hit.GetComponent <Breakable> ();
                if (br != null)
                {
                    br.Break(1);
                }
            }
            //Spawn sound
            if (DestructionSounds.Capacity > 0)
            {
                AudioSource.PlayClipAtPoint(DestructionSounds[(int)Mathf.Round(Random.Range(0, DestructionSounds.Capacity - 1))], transform.position, 0.125f);
            }


            //Spawn the particles
            Instantiate(particles, transform.position, Quaternion.identity);
            Destroy(this.gameObject);
        }
    }
Esempio n. 10
0
        public ActionResult Create(Guid parentID, FormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var fracture = new Fracture()
                    {
                        AOCode     = collection["AOCode"],
                        IncidentID = parentID
                    };
                    db.Fractures.Add(fracture);
                    db.SaveChanges();

                    db.Entry(fracture).Reference(f => f.Incident).Load();
                    return(RedirectToAction("Details", "Patients", new { id = fracture.Incident.PersonalNumber }));
                }
            }
            catch
            { }

            // TODO: This should actually report some useful error to the user (or developer...maybe breakpoint?)
            return(View());
        }
Esempio n. 11
0
        static void addPatients(DbContext db)
        {
            var patient = new Patient()
            {
                FirstName = "Bubba", LastName = "Ho-Tep", Age = 1234, PersonalNumber = "1111111231234"
            };

            db.Patients.Add(patient);
            db.SaveChanges();

            var incident = new Incident()
            {
                InjuryDate     = "2010-03-04",
                InjuryHour     = 9,
                PersonalNumber = patient.PersonalNumber
            };

            db.Incidents.Add(incident);

            var frac1 = new Fracture()
            {
                AOCode     = "33C2",
                IncidentID = incident.ID
            };

            db.Fractures.Add(frac1);

            var frac2 = new Fracture()
            {
                AOCode     = "22B1",
                IncidentID = incident.ID
            };

            db.Fractures.Add(frac2);

            var consultation = new Consultation();

            db.Consultations.Add(consultation);

            var procedure = new Procedure()
            {
                // ConsultationID = consultation.ID,
                FractureID = frac1.ID
            };

            db.Procedures.Add(procedure);

            procedure = new Procedure()
            {
                // ConsultationID = consultation.ID,
                FractureID = frac2.ID
            };
            db.Procedures.Add(procedure);

            //patient = new Patient () {
            //    FirstName = "Joe", LastName = "Schmoe", Age = 35
            //};
            //db.Patients.Add (patient);
            //db.SaveChanges ();

            //injury = new Injury () {
            //    AOCode = "31B2",
            //    InjuryDate = new DateTime (2002, 8, 5),
            //    InjuryHour = 23,
            //    PatientID=patient.ID
            //};
            //db.Injuries.Add (injury);
        }
	void OnTriggerStay(Collider MyTrigger) {
		
		
		if (MyTrigger.gameObject.name.Equals ("VirusFinal(Clone)")||
		    MyTrigger.gameObject.name.Equals("VirusFinalCelula(Clone)")) {
			
			if (llevarBase == false) {
			
				enColision = true;
				speed=6f;
			}
			else{

				vida-=0.1f;
				if(vida==0){

					ControladorRecursos.defensas--;
					Destroy(this.gameObject);
				}
					
			}

			
		}
		if (MyTrigger.gameObject.name.Equals ("virusFinalFracture(Clone)")) {
			
			virus = MyTrigger.GetComponent < Fracture>();
            Destroy(virus.GetComponent<Collider>());
            llevarBase = true;
            MyTrigger.gameObject.transform.parent = this.transform;
            

        }


		if (MyTrigger.gameObject.name.Equals ("NaturalKiller(Clone)")) {
			
			vida -= 2f;
			if (vida <= 0) {
				ControladorRecursos.defensas--;
				Destroy (this.gameObject);
				
				
			}
		
		}
	
	}
    private void DoFracture(List <Vector3> clusters)
    {
        _disableAtFixedUpdate = true;

        var velocity = GetComponent <Rigidbody>().velocity;

        var assignedClusters = new int[points.Count];

        var clouds = new List <Vector3> [ClusterCount];

        Parallel.For(0, points.Count, i => {
            var closestCluster            = -1;
            var closestClusterDistanceSqr = float.PositiveInfinity;

            for (int j = 0; j < ClusterCount; j++)
            {
                var distSqr = (points[i] - clusters[j]).sqrMagnitude;

                if (distSqr < closestClusterDistanceSqr)
                {
                    closestCluster            = j;
                    closestClusterDistanceSqr = distSqr;
                }
            }

            assignedClusters[i] = closestCluster;
        });

        Parallel.For(0, ClusterCount, i => {
            var cloud = new List <Vector3>();

            for (int j = 0; j < points.Count; j++)
            {
                if (assignedClusters[j] == i)
                {
                    cloud.Add(points[j]);
                }
            }

            if (cloud.Count >= 4)
            {
                clouds[i] = cloud;
            }
        });

        var children = new Fracture[ClusterCount];

        for (int i = 0; i < ClusterCount; i++)
        {
            var child = Instantiate(Prefab, transform.parent);

            child.transform.localPosition = transform.localPosition;
            child.transform.localRotation = transform.localRotation;
            child.transform.localScale    = transform.localScale;

            var frac = child.GetComponent <Fracture>();

            frac.Prefab = Prefab;
            //frac.ClusterCount = ClusterCount;
            frac.InitialMesh = false;

            children[i] = frac;
        }

        for (int i = 0; i < ClusterCount; i++)
        {
            if (clouds[i] == null)
            {
                children[i].gameObject.SetActive(false);
                Destroy(children[i].gameObject);
            }
            else
            {
                children[i].points = clouds[i];
                children[i].StartGeneratingMesh();
                children[i].GetComponent <Rigidbody>().velocity = velocity;
            }
        }
    }