// I guess for now we just start with zones. public void FDisplayPlay() { DPC_ZoneGFX[] zGX = FindObjectsOfType <DPC_ZoneGFX>(); foreach (DPC_ZoneGFX gfx in zGX) { Destroy(gfx.gameObject); } // Now, iterate through all players, and spawn in a node representing their zone. PE_Role[] athletes = FindObjectsOfType <PE_Role>(); foreach (PE_Role role in athletes) { if (role.mRole == "Zone") { // get the zone details from the IO DATA_Zone zone = IO_ZoneList.FLOAD_ZONE_BY_NAME(role.mDetails); if (zone != null) { Vector2 vPos = rSnapSpot.transform.position; vPos += zone.mSpot / 10f; Instantiate(PF_ZoneGFX, vPos, transform.rotation); } } } }
// Maybe have this as a function that we call. void Start() { cRigid = GetComponent <Rigidbody>(); cAth = GetComponent <PRAC_Ath>(); cAcc = GetComponent <PRAC_AI_Acc>(); cCatchLog = GetComponent <RP_CatchLog>(); if (cAth.mJob.mRole == "Zone") { mZoneSpot = IO_ZoneList.FLOAD_ZONE_BY_NAME(cAth.mJob.mDetail).mSpot; mZoneSpot.z = mZoneSpot.y; mZoneSpot.y = 0f; PLY_SnapSpot snap = FindObjectOfType <PLY_SnapSpot>(); mZoneSpot += snap.transform.position; } mState = STATE.S_GETTING_TO_SPOT; }
// The play editor calls us. public void FRun_Update() { // // Basically, every time that we click, spawn a point, and destroy any exising points. // if(Input.GetMouseButtonDown(0)){ // // first, we raycast to make sure we're over the field. Because we can't spawn a player randomly off the field. // RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); // if(hit.collider != null) // { // if(hit.collider.GetComponent<PE_Field>() != null){ // Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); // pos.z = 90; // SpawnPointDestroyOld(pos); // } // } // } // // Also, do the conversion and shove the zone details into the zone. // DPC_ZoneSpot spot = FindObjectOfType<DPC_ZoneSpot>(); // if(spot != null) // { // // now "shove" the detail about it into itself. // // do a conversion to find the pixels -> yards. // Vector2 vYards = spot.transform.position - rSnapSpot.transform.position; // vYards /= 50f/rField.GetComponent<RectTransform>().rect.width; // vYards.x = (float)System.Math.Round(vYards.x, 0); // vYards.y = (float)System.Math.Round(vYards.y, 0); // spot.mZone.mSpot = vYards; // rZonePos.text = "("+vYards.x+", "+vYards.y+")"; // // Now find out what the name of the zone is. // spot.mZone.mName = rZoneName.text; // } if (Input.GetMouseButtonDown(1)) { // // Now we just load in all the zones, then display them. DATA_Zone zone = IO_ZoneList.FLOAD_ZONE_BY_NAME(mZoneToSpawn); Vector2 vZoneSpot = zone.mSpot; vZoneSpot /= 10f; vZoneSpot += (Vector2)rSnapSpot.transform.position; var clone = Instantiate(PF_ZoneSpot, vZoneSpot, transform.rotation); clone.mZone = zone; } }
private void RenderZone(DT_PlayerRole role, PLY_SnapSpot snapSpot) { // get the zone details. DATA_Zone zn = IO_ZoneList.FLOAD_ZONE_BY_NAME(role.mDetail); GFX_Zone zoneGFX; if (zn.mSpot.y > 19f) { // render using the "deep zone" version. zoneGFX = GFX_DeepZone; } else if (zn.mSpot.y > 9f) { // render using mid zone version zoneGFX = GFX_MidZone; } else { // render using shallow zone version. zoneGFX = GFX_ShallowZone; } Vector3 vZonePos = snapSpot.transform.position; vZonePos.z += zn.mSpot.y; vZonePos.x += zn.mSpot.x; Instantiate(zoneGFX, vZonePos, transform.rotation); Vector3 vStartPos = UT_VecConversion.ConvertVec2(role.mStart); vStartPos += snapSpot.transform.position; Vector3 vIterPos = vStartPos; Vector3 vDir = Vector3.Normalize(vZonePos - vStartPos); while (Vector3.Dot(vDir, vZonePos - vIterPos) > 0f) { Instantiate(GFX_ZoneTrail, vIterPos, transform.rotation); vIterPos += vDir * 0.5f; } }