Ejemplo n.º 1
0
    public void initialize(int _overSampling, int _vecHeight, int _wallRadius, Texture2D _levelImage)
    {
        overSampling = _overSampling;
        vecHeight    = _vecHeight;
        wallRadius   = _wallRadius;
        levelImage   = _levelImage;
        Debug.Log("Starting to Initialize?");
        //first we create the actual vecot field class;
        myVectorField = new vectorField(_levelImage.width, _levelImage.height, _overSampling, _vecHeight, _wallRadius);
        //now we need to add the walls

        vectorFHelper newVFHelper = new vectorFHelper(myVectorField, _wallRadius, _vecHeight, _overSampling, levelImage.width * _overSampling, levelImage.height * _overSampling);

        for (int x = 0; x < levelImage.width; x++)
        {
            for (int z = 0; z < levelImage.height; z++)
            {
                if (levelImage.GetPixel(x, z) == Color.black)
                {
                    myVectorField.addWIC(x, z, newVFHelper);
                }
            }
        }
        newVFHelper.start();
        while (newVFHelper.getInCommingWallCount() > 0)
        {
            ;
        }
        myVectorField.storeValues();
        newVFHelper.stop();
        Debug.Log("During runtime wall Count" + myVectorField.wallMem.Count);
    }
Ejemplo n.º 2
0
    public void addWIC(int x, int z, vectorFHelper myHelper)
    {
        int startx = (x * overSampling);
        int endx   = (x * overSampling) + overSampling;
        int startz = (z * overSampling);
        int endz   = (z * overSampling) + overSampling;

        for (int i = startx; i < endx; i++)
        {
            for (int j = startz; j < endz; j++)
            {
                addWall(i, j, false, myHelper);
            }
        }

        recalcVecField = true;
    }
Ejemplo n.º 3
0
    void addWall(int x, int z, bool instansiateWall, vectorFHelper myHelper)
    {
        if (validValues(x, z) && (!(tiles[x, z].type == fType.wall)))           //if (validValues(x, z) && (!(tiles[x, z].type == fType.wall))) {

        {
            wallMem.Add(new Vector2(x, z));
            myHelper.addWall(new Vector2(x, z));

            tiles[x, z].type = fType.wall;
            tiles[x, z].vec  = Vector3.zero;
            if (instansiateWall)
            {
                // we need to add code here that adds just one wall.

                ///This is old code
                //GameObject wall = GameObject.Instantiate(wallPrefab, arraySpaceToWorld(new Vector3(x, 1, z)), Quaternion.identity) as GameObject;
                //wall.transform.localScale=new Vector3((1.0f / overSampling), 1,(1.0f / overSampling));
                //wall.transform.parent = this.transform;
            }
        }
    }