void HitTarget() { if (impactEffect != null) { GameObject effect = Instantiate(impactEffect, transform.position, transform.rotation) as GameObject; Destroy(effect, 5f); } if (target == null) { return; } Protester protester = target.GetComponent <Protester>(); if (protester != null) { if (damage > 0) { protester.Damage(damage + additionalDamage); } if (fear > 0) { protester.Scare(fear + additionalFear, parentTurret); } } Destroy(gameObject); }
public ActionResult DeleteConfirmed(long id) { Protester protester = db.Protesters.Find(id); db.Protesters.Remove(protester); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ProtesterId,ProtesterCpf,ProtesterName,ProtesterGenre")] Protester protester) { if (ModelState.IsValid) { db.Entry(protester).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(protester)); }
public static float Eval(LevelGenerator level) { CrowdManager crowdMgr = GameObject.FindObjectOfType <CrowdManager> (); List <Protester> protesters = new List <Protester>(); foreach (Protester p in crowdMgr.protesters) { protesters.Add(p); } List <int> groupSizes = new List <int> (); while (protesters.Count > 0) { // Pick a random protester int randomIdx = Random.Range(0, protesters.Count); Protester randomProtester = protesters [randomIdx]; protesters.RemoveAt(randomIdx); /* For every close enough protestor, count it in the group if : * Protestor is closer than a specified range * Raycasting from randomProtestor to it doesn't collide with cops */ float maxDistance = (level.levelShape == Shape.Circle) ? level.radius : Mathf.Min(level.width, level.height); maxDistance /= 5f; int count = 1; List <int> removeIndices = new List <int> (); for (int i = 0; i < protesters.Count; ++i) { Protester p = protesters [i]; if (Vector3.Distance(randomProtester.transform.position, p.transform.position) <= maxDistance) { Ray r = new Ray(randomProtester.transform.position, p.transform.position - randomProtester.transform.position); RaycastHit hit; Physics.Raycast(r, out hit); if (hit.collider.tag == "Protester") { // Protester is in group count += 1; Debug.Log("Found a grouped protester : " + i); removeIndices.Add(i); } } } // Finally, remove grouped protestors from the list for (int j = removeIndices.Count - 1; j >= 0; --j) { protesters.RemoveAt(removeIndices[j]); } groupSizes.Add(count); } float avgGrpSize = (float)(crowdMgr.protesters.Length) / groupSizes.Count; return(100f / avgGrpSize); }
public void TryInteractionMatch(InteractionType interactionType, Vector2 interactionPosition) { Police police = Interactor.GetFreeInteractor(FindObjectsOfType <Police>()); Protester protester = Interactor.GetFreeInteractor(FindObjectsOfType <Protester>()); if (police == null || protester == null) { return; } _interactions.Add(new InteractionProcess(interactionType, protester, police, interactionPosition)); }
public ActionResult Create([Bind(Include = "ProtesterId,ProtesterCpf,ProtesterName,ProtesterGenre")] Protester protester) { if (ModelState.IsValid) { db.Protesters.Add(protester); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(protester)); }
private void SpawnProtestor() { Protester p = GameObject.Instantiate <Protester>(Resources.Load <Protester>("Protester")); p.transform.SetParent(_protestorSpawnRoot.transform, false); _currentlySpawnedProtesters.Add(p); Vector2 pos = new Vector2(_protestorsGatherArea.anchoredPosition.x - _gatherAreaSize.x * 50, _protestorsGatherArea.anchoredPosition.y - _gatherAreaSize.y * 50); pos.x += _gatherAreaSize.x * (100 * UnityEngine.Random.value); pos.y += _gatherAreaSize.y * (100 * UnityEngine.Random.value); p.WalkTo(pos, 15); }
// Return true if it is possible to spawn a Protester at the given coordinates bool CheckSpawnCoords(Vector2 pos) { Vector3 pos3D = Protester.TopVec2ToVec3(pos); for (int i = 0; i != population; ++i) { if (Vector3.Distance(pos3D, protesters[i].transform.position) < 1f) { return(false); } } return(true); }
// GET: Protesters/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Protester protester = db.Protesters.Find(id); if (protester == null) { return(HttpNotFound()); } return(View(protester)); }
public InteractionProcess(InteractionType type, Protester protester, Police police, Vector2 interactionPosition) { InteractionType = type; _protester = protester; _police = police; _interactionPosition = interactionPosition; _policePos = _interactionPosition; _protesterPos = _interactionPosition; _policePos.x += ((RectTransform)police.transform).rect.width / 2 + 5; _protesterPos.x -= ((RectTransform)protester.transform).rect.width / 2 + 5; FaceOneAnother(); }
void HitTarget(float damage, float fear) { Protester protester = target.GetComponent <Protester>(); if (protester != null) { if (damage > 0) { protester.Damage(damage); } if (fear > 0) { protester.Scare(fear, transform); } } }
// The [ReadOnly] attribute tells the job scheduler that this job will not write to rotSpeed public void Execute(ref Translation translation, [ReadOnly] ref ProtesterData data) { //return;//**-- //Debug.Log(translation.Value); translation.Value += new float3(1.005f, 1.005f, .005f); return;//**-- // Rotate something about its up vector at the speed given by RotationSpeed. //**--rotation.Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), rotSpeed.RadiansPerSecond * DeltaTime)); Vector3 vec3 = translation.Value; Protester.UpdateAux(ref vec3, ref data.Destination, data.Speed, DeltaTime); translation.Value = vec3; //Debug.Log("tr:"+translation.Value); }
private void buttonCadastrar_Click(object sender, EventArgs e) { //Validações de preenchimento do cadastro string dataValidacao = DateTime.Now.AddYears(-16).ToShortDateString(); DateTime dataValida = Convert.ToDateTime(DateTime.Now.AddYears(-16).ToShortDateString()); if (textBoxNome.TextLength <= 0 || textBoxNomeMae.TextLength <= 0 || maskedTextBoxCpf.TextLength <= 0 || maskedTextBoxCelular.TextLength <= 0 || comboBoxConvenio.Text == "" || textBoxRua.TextLength <= 0 || textBoxBairro.TextLength <= 0 || textBoxNumero.TextLength <= 0 || textBoxCidade.TextLength <= 0 || comboBoxUf.Text == "") { MessageBox.Show("Todos os campos marcados com '*' devem ser preenchidos!", "Erro ao cadastrar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Aqui será utilizado o metodo CadastrarManifestante da classe Protester else if (Convert.ToDateTime(dateTimePickerDataNasc.Text) >= Convert.ToDateTime(dataValidacao)) { MessageBox.Show("Idade do manifestante deve ser superior a 16 anos.", "Erro ao cadastrar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //Inserindo os valores aos atributos da classe Manifestante (Protester) Protester protester = new Protester(); protester.cod_manifestante = cod_manifestante; protester.nome_manifestante = textBoxNome.Text; protester.nome_mae = textBoxNomeMae.Text; protester.email_manifestante = textBoxEmail.Text; protester.data_nasc_manifestante = dateTimePickerDataNasc.Value; protester.cpf_manifestante = maskedTextBoxCpf.Text; protester.celular_manifestante = maskedTextBoxCelular.Text; protester.telefone_manifestante = maskedTextBoxTelefone.Text; protester.telefone_manifestante = maskedTextBoxTelefone.Text; protester.rua_manifestante = textBoxRua.Text; protester.bairro_manifestante = textBoxBairro.Text; protester.numero_manifestante = textBoxNumero.Text; protester.cidade_manifestante = textBoxCidade.Text; protester.cep_manifestante = maskedTextBoxCep.Text; protester.uf_manifestante = comboBoxUf.Text; protester.observacoes_manifestante = textBoxObs.Text; protester.convenio_manifestante = comboBoxConvenio.Text; //Chamando o metodo CadastrarManifestante protester.EditarManifestante(); MessageBox.Show("Cadastro efetuado com sucesso!", "Cadastro Efetuado", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
// Spawn a Protester and store it in the internal array at index idx void SpawnProtester(int idx) { Vector2 pos = new Vector2(); int attempt = 0; do { // Check that the generation isn't stuck float t = Time.time; if (attempt > maxGenAttempts) { Debug.LogError("Crowd generation taking too long, aborting"); settingsAreShit = true; return; } // Generate spawn coordinates switch (parameters.crowdShape) { case Shape.Circle: pos = Random.insideUnitCircle * parameters.circle.radius; break; case Shape.Rectangle: pos = new Vector2(Random.Range(parameters.rectangle.topLeft.x, parameters.rectangle.bottomRight.x), Random.Range(parameters.rectangle.bottomRight.y, parameters.rectangle.topLeft.y)); break; } ++attempt; } while (!CheckSpawnCoords(pos)); // Actually spawn the Protester Protester newProt = GameObject.Instantiate(protesterPrefab, crowdRoot.transform) as Protester; newProt.transform.GetChild(1).GetComponent <Renderer>().material = parameters.SwapColor[Random.Range(0, 3)]; newProt.transform.position = Protester.TopVec2ToVec3(pos) + new Vector3(0, 0.5f, 0); protesters [idx] = newProt; population += 1; }
// Update is called once per frame void Update() { if (Application.isEditor && Input.GetKeyDown(KeyCode.Space)) { Support = -1; } if (Support > 0 && state == GameState.Running) { //var _score = (int)Time.time; var _score = (int)(Time.time - gameStartTime); if (_score != Score) { Score = _score; if (Score % 2 == 0) { UpdateSupport(); } //Summon(getRandPos);//**--//**-- } } else if (state == GameState.Running) { //state = GameState.Over; EndGame(); } if (state == GameState.Over) { return; } //if (Input.GetButtonDown("Fire1") && !MouseOnObject) if (Input.GetMouseButtonDown(0)) { var pos = camera.ScreenToWorldPoint(Input.mousePosition); pos.z = 0; Debug.Log("jop @ " + pos); var min = float.MaxValue; Protester hit = null; foreach (var p in protesters) { var dist = (p.transform.position - pos).sqrMagnitude; if (dist < min) { min = dist; hit = p; } if (dist < 1) { p.Disperse(); } } Cursor.SetCursor(this.batonDown, Vector2.zero, CursorMode.Auto); StartCoroutine(RevertCursor()); /* * Debug.Log(min); * Debug.Log(hit.transform.position); * Debug.Log(pos);*/ } }