Пример #1
0
    // 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);
                }
            }
        }
    }
Пример #2
0
    // assumes that the routes have all been loaded already
    public static DATA_Zone FLOAD_ZONE_BY_NAME(string sName)
    {
        DATA_Zone zone = new DATA_Zone();

        for (int i = 0; i < mZones.Length; i++)
        {
            if (mZones[i].mName == sName)
            {
                zone = mZones[i];
                return(zone);
            }
        }

        Debug.Log("Zone not found");
        return(null);
    }
Пример #3
0
    public static void FLOAD_ZONES()
    {
        string path = Application.dataPath + "/FILE_IO/Plays/Zones/";

        string[] fPathNames = Directory.GetFiles(path, "*.bin");

        mZones = new DATA_Zone[fPathNames.Length];
        for (int i = 0; i < fPathNames.Length; i++)
        {
            BinaryReader br = new BinaryReader(new FileStream(fPathNames[i], FileMode.Open));
            mZones[i]         = new DATA_Zone();
            mZones[i].mName   = br.ReadString();
            mZones[i].mSpot.x = br.ReadSingle();
            mZones[i].mSpot.y = br.ReadSingle();

            br.Close();
        }
    }
Пример #4
0
    // 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;
        }
    }
Пример #5
0
    // Will return false if the write was a failure.
    public static bool FWRITE_ZONE(DATA_Zone zone)
    {
        if (zone.mName == string.Empty)
        {
            Debug.Log("Can't save un-named zone");
            return(false);
        }

        string path = Application.dataPath + "/FILE_IO/Plays/Zones/" + zone.mName + ".bin";

        BinaryWriter bw = new BinaryWriter(new FileStream(path, FileMode.Create));

        bw.Write(zone.mName);
        bw.Write(zone.mSpot.x);
        bw.Write(zone.mSpot.y);

        bw.Close();

        return(true);
    }
Пример #6
0
    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;
        }
    }