public ActionResult DeleteConfirmed(int id) { Paratrooper paratrooper = db.Paratroopers.Find(id); db.Paratroopers.Remove(paratrooper); db.SaveChanges(); return(RedirectToAction("Index")); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Projectile") { Paratrooper paratrooper = gameObject.GetComponentInParent <Paratrooper>(); paratrooper.ParachuteHit(); } }
void OnCollisionEnter2D(Collision2D c) { if (c == null || hasLanded) { return; } if (c.gameObject.name == "Ground") { if (parachute.activeSelf) { hasLanded = true; parachute.SetActive(false); print("Paratrooper has landed"); } else { animator.SetTrigger("Death"); Destroy(gameObject, 0.5f); print("Paratrooper killed when landing without parachute"); GameObject.Find("GameManager").BroadcastMessage("ModifyScore", 5); } return; } Paratrooper otherParatrooper = c.gameObject.GetComponent <Paratrooper>(); if (otherParatrooper) { hasLanded = true; paratrooperBelow = otherParatrooper; if (parachute.activeSelf) { parachute.SetActive(false); print("Paratrooper has landed safely on top of another paratrooper"); } else { KillAndDieByFalling(); } return; } Projectile projectile = c.gameObject.GetComponent <Projectile>(); if (projectile) { GameObject ps = (GameObject)Instantiate(deathAnimation); ps.transform.position = transform.position; Destroy(gameObject); Destroy(c.gameObject); print("Paratrooper hit and destroyed"); GameObject.Find("GameManager").BroadcastMessage("ModifyScore", 5); } }
public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,CurrentStatus,OrganizationID,QualificationID")] Paratrooper paratrooper) { if (ModelState.IsValid) { db.Entry(paratrooper).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrganizationID = new SelectList(db.Organizations, "ID", "Unit", paratrooper.OrganizationID); ViewBag.QualificationID = new SelectList(db.Qualifications, "ID", "ID", paratrooper.QualificationID); return(View(paratrooper)); }
// GET: Paratroopers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Paratrooper paratrooper = db.Paratroopers.Find(id); if (paratrooper == null) { return(HttpNotFound()); } return(View(paratrooper)); }
// GET: Paratroopers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Paratrooper paratrooper = db.Paratroopers.Find(id); if (paratrooper == null) { return(HttpNotFound()); } ViewBag.OrganizationID = new SelectList(db.Organizations, "ID", "Unit", paratrooper.OrganizationID); ViewBag.QualificationID = new SelectList(db.Qualifications, "ID", "ID", paratrooper.QualificationID); return(View(paratrooper)); }
void Update() { if (attackers != null) { attackers = attackers.FindAll(UpdateAttacker); if (attackers.Count == 0) { gameObject.SetActive(false); } } if (gameOver) { return; } List <Paratrooper> left = new List <Paratrooper>(); List <Paratrooper> right = new List <Paratrooper>(); GameObject[] paratroopers = GameObject.FindGameObjectsWithTag("Paratrooper"); for (int i = 0; i < paratroopers.Length; i++) { Paratrooper para = paratroopers[i].GetComponent <Paratrooper>(); if (para && para.HasLandedOnLeft()) { left.Add(para); continue; } if (para && para.HasLandedOnRight()) { right.Add(para); continue; } } if (left.Count >= 4) { gameOver = true; attackers = SetupAttackers(left, 1); } if (right.Count >= 4) { gameOver = true; attackers = SetupAttackers(right, -1); } }
bool UpdateAttacker(Paratrooper attacker) { // This is a superhack. I know. float x = Mathf.Abs(attacker.transform.position.x); float y = attacker.transform.position.y; if (x < 1.6f) { // Attacker has hit the turret GunControl gun = GameObject.Find("Gun").GetComponent <GunControl>(); gun.ExplodeAndDie(); attacker.gameObject.GetComponent <Rigidbody2D>().gravityScale = 5; attacker.gameObject.GetComponent <Rigidbody2D>().drag = 0; attacker.gameObject.GetComponent <Rigidbody2D>().fixedAngle = false; attacker.gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector3(-attacker.move.x * 30, 30), ForceMode2D.Impulse); attacker.gameObject.GetComponent <Rigidbody2D>().AddTorque(200 * attacker.move.x); attacker.move.x = 0; return(false); } else if (x >= 4.6f && y < 0.1f) { // Move towards turret on ground attacker.gameObject.GetComponent <Rigidbody2D>().gravityScale = 0; MoveAttacker(attacker, attacker.move.x, 0); } else if (x < 4.6f && y <= 6) { // Move up next to turret attacker.gameObject.GetComponent <Rigidbody2D>().gravityScale = 0; MoveAttacker(attacker, 0, 1); } else if (y > 6) { // Move towards turret on the turret MoveAttacker(attacker, attacker.move.x, 0); } return(true); }
void MoveAttacker(Paratrooper attacker, float x, float y) { attacker.transform.position += new Vector3(x, y) * Time.deltaTime * 10; }