示例#1
0
    void OnSceneGUI()
    {
        VoronoiDemo voronoi = (VoronoiDemo)target;

        if (voronoi.graph)
        {
            foreach (Voronoi.Cell cell in voronoi.graph.cells)
            {
                Handles.color = Color.black;
                Handles.Label(cell.site.ToVector3(), "Site " + cell.site.id);

                if (cell.halfEdges.Count > 0)
                {
                    int i = 0;
                    foreach (HalfEdge halfEdge in cell.halfEdges)
                    {
                        if (halfEdge.edge.va && halfEdge.edge.vb)
                        {
                            if (cell.site.id == 1)
                            {
                                Vector3 posA = halfEdge.edge.va.ToVector3();
                                Vector3 posB = halfEdge.edge.vb.ToVector3();
                                Handles.Label(posA + Vector3.up * i * 10, "Cell " + cell.site.id + " Edge " + i + " Vertex A " + posA);
                                Handles.Label(posB + Vector3.up * i * 10, "Cell " + cell.site.id + " Edge " + i + " Vertex B " + posB);
                                i++;
                            }
                        }
                    }
                }
            }
        }
    }
    public void initializeAgent()
    {
        Vorono = GetComponent <VoronoiDemo>();

        int house_nb = Vorono.list_house.Count;

        choose_house = new int[house_nb, 2];
        int current_choose_house = house_nb;

        for (int j = 0; j < house_nb; j++)
        {
            choose_house[j, 0] = j;
            choose_house[j, 1] = 4;
        }
        for (int i = 0; i < number_inhabitant; i++)
        {
            int   choice     = Random.Range(0, current_choose_house);
            int   choice_sky = Random.Range(0, Vorono.list_skys.Count);
            int[] sky_house  = { choice, choice_sky };
            Vorono.list_position_inhabitant.Add(sky_house);
            Vector3 pos = Vorono.list_house[choice].transform.position;
            pos = new Vector3(pos.x, 0.03039218f, pos.z);
            GameObject PetitBo = Instantiate(PetitBonhomme, pos, Quaternion.identity);
            PetitBo.GetComponent <NavMeshAgent>().Warp(pos);
            //PetitBo.transform.position = new Vector3(PetitBo.transform.position.x, 0.005f, PetitBo.transform.position.z);
            BonhommeBehavior BonhommeScript = PetitBo.GetComponent <BonhommeBehavior>();
            BonhommeScript.home_sweet_home  = Vorono.list_house[choice];
            BonhommeScript.my_taff          = Vorono.list_skys[choice_sky];
            BonhommeScript.home_sweet_home2 = Vorono.list_house2[choice];
            BonhommeScript.my_taff2         = Vorono.list_skys2[choice_sky];
            BonhommeScript.Vorono           = Vorono;
            BonhommeScript.init_position    = pos;
            Vorono.list_inhabitant.Add(PetitBo);
            if (choose_house[choice, 1] == 1)
            {
                current_choose_house--;
                choose_house[choice, 0] = choose_house[current_choose_house, 0];
                choose_house[choice, 1] = choose_house[current_choose_house, 0];
            }
            else
            {
                choose_house[choice, 1]--;
            }
        }
    }
 void Start()
 {
     Vorono = GetComponent <VoronoiDemo>();
     Daying = GetComponent <DayNightCycle>();
 }
示例#4
0
        public HapticHandler(List <GameObject> chunks, Bounds bounds, Vector3 impactPoint, int id, VoronoiDemo voro)
        {
            impactTime = Time.timeSinceLevelLoad;

            this.chunks      = chunks;
            this.bounds      = bounds;
            this.impactPoint = impactPoint;
            this.id          = id;

            foreach (GameObject chunk in chunks)
            {
                Cell  cell   = chunk.GetComponent <FractureChunk>().cell;
                float length = 1.5f * 2.4f / 6.0f;
                //float length = Mathf.Min((Time.timeSinceLevelLoad - impactTime)*2, 2.0f * 2.4f / 6.0f);
                bool s = (cell.site.ToVector3() - bounds.center - impactPoint).magnitude < length;
                if (s)
                {
                    chunk.GetComponent <FractureChunk>().ApplyForce(impactPoint);
                }
            }

            Vector4 impactShader = new Vector4();

            impactShader.x = impactPoint.x;
            impactShader.y = impactPoint.y;
            impactShader.z = impactPoint.z;
            impactShader.w = Time.time;

            voro.bubbleGenerator.Center   = impactPoint;
            voro.bubbleGenerator.dieCount = 3;
        }