Esempio n. 1
0
    public void DefineDisks()
    {
        disks[0] = new SurroundingDisk(firstDisk, 3);
        disks[1] = new SurroundingDisk(secondDisk, 5);
        disks[2] = new SurroundingDisk(thirdDisk, 7);

        SetStartSetup();
    }
Esempio n. 2
0
    // First disk is number 0
    public GameObject FindClosestDiskBuildingSlot(Vector3 pos, int diskNb)
    {
        //Debug.Log("FindClosestDiskBuildingSlot.");
        float      minDist     = Mathf.Infinity;
        GameObject closestSlot = null;

        SurroundingDisk disk = disks[diskNb];

        foreach (GameObject buildingSlot in disk.diskBuildingSlots)
        {
            float dist_squared = (pos - buildingSlot.transform.position).sqrMagnitude;

            if (dist_squared < minDist && !buildingSlot.GetComponent <BuildingSlot>().hasBuilding)
            {
                minDist     = dist_squared;
                closestSlot = buildingSlot;
            }
        }

        //Debug.Log("Closest slot found: " + closestSlot + " | Pos: (x=" + closestSlot.transform.position.x + ",y=" + closestSlot.transform.position.y + ")");
        return(closestSlot);
    }