//---------------------------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------------------------

    #region 2) BUILD GRID AND SET TERRAIN
    void BuildMapGrid(int length, int width, GameObject cellObject, GameObject parentContainer)
    {
        //int cellRadius = displace / 2;

        groundNodeGrid = new MapNode[length, width];   // note that length and width here refer to a number of map tiles.
        Transform parentTransform = parentContainer.transform;

        for (int z = 0; z < width; z++)
        {
            for (int x = 0; x < length; x++)
            {
                Vector3    position = new Vector3((x + 0.5f) * displace, 0, (z + 0.5f) * displace);
                GameObject gridTile = GameObject.Instantiate(cellObject, position, Quaternion.identity, parentTransform);

                GroundTileScript tileComponent = gridTile.AddComponent <GroundTileScript>();

                int moveMentModPF = 0;

                // need to then cast ray to set layer of tile in setLevelTerrain function. 0 is default.

                tileComponent.nodeReference = new MapNode(true, position, x, z, moveMentModPF);  // Creating corresponding node point.
                groundNodeGrid[x, z]        = tileComponent.nodeReference;

                groundCells.Add(tileComponent);

                //gridTile.name = "Tile zx: " + z + ", " + x+ " || ID: "+ tileComponent.tileReference.tileID;
                gridTile.name = "Tile zx: " + z + ", " + x + " || ID: " + groundCells.Count;
            }
        }
        //Debug.Log("List of cells count: " + groundCells.Count);  // Should be the same as "pixelList.Count" and "pix.Length"
        gridCentrePos = transform.position + ((Vector3.right * (displace / 2) * (mapLengthColumnsX)) + (Vector3.forward * (displace / 2) * (mapWidthRowsZ)));
        mapSize       = new Vector2(displace * mapLengthColumnsX, displace * mapWidthRowsZ);

        //Debug.Log((gridCentrePos) +" "+ mapSize);
    }
    void SetupStartingArea()
    {
        cameraHolderPrefab = CameraReferenceSingleton.Instance.gameplayCamHolderPrefab_01;
        GroundTileScript centreBaseTile     = baseTilesList[4];
        Vector3          positionOfBase     = centreBaseTile.nodeReference.worldPosition;
        Vector3          centreCameraToBase = positionOfBase + cameraOffset;

        GameObject baseBuilding = GameObject.Instantiate(mainBaseBuildingPrefab, positionOfBase, Quaternion.identity);

        baseBuilding.name = "MainBase";

        baseBuilding.GetComponent <UI_ActionsButtons>().UIButtonPack = ui_ButtonPackAssociatorLocal.UIButtonPack[0];   // Make sure the first element in the list is the base button pack !!!!

        // Instantiates camera holder prefab in the world and centres it on the base building.

        GameObject mainCameraHolder = GameObject.Instantiate(cameraHolderPrefab, centreCameraToBase, Quaternion.identity);

        mainCameraHolder.name = "Main Camera Holder";

        CameraControl cameraController = cameraControl.GetComponent <CameraControl>();

        cameraController.FetchCameraprefab(mainCameraHolder);
        UnitComponent.FetchCameraprefab(mainCameraHolder);  // if "FetchCameraprefab()" is not static, this line needs to be placed in BaseSpawner script instead, and the reference set upon unit instantiation.
        UnitSelectionManager uSM = gameObject.GetComponent <UnitSelectionManager>();

        uSM.FetchCameraPrefab(mainCameraHolder);
        BaseSpawner_a01.FetchCameraPrefab(mainCameraHolder);
        MinimapClickToGoThere.FetchCameraprefabs(minimapCam, mainCameraHolder, cameraOffset, mapSize);


        gameObject.GetComponent <UI_SetCamsOrder>().SetCams(mainCameraHolder);
    }
    //----------------------------------------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------------------------------------

    #region PATH MANAGEMENT

    public void SendPathRequestForUnit(RaycastHit hit, int listCount)
    {
        Debug.Log("RMB clicked, Move order received for: " + gameObject.name);

        whereAmI = gameObject.transform.position;
        goThere  = hit.collider.transform;
        Vector3 goThereModif = new Vector3(goThere.position.x, 0, goThere.position.z);
        //Debug.Log(goThere.position +"| original goThereModif: "+ goThereModif);

        GroundTileScript gts = hit.collider.GetComponent <GroundTileScript>();  // retrieve from map node note ground tile script

        if (!(gts.transform.position == whereAmI) && unitReference.isSelected == true)
        {
            goThereModif = ScanDestination(hit, listCount, 0);

            //destinationIndicator.transform.position = goThereModif + new Vector3(0, 0.2f, 0);
            //destinationIndicator.SetActive(true);

            //Debug.Log(goThere.position + "| POSTSCAN Modif: " + goThereModif);
            //Debug.Log("Unit " + gameObject.name + " is at: " + gameObject.transform.position.x + "; " + gameObject.transform.position.z + " and wants to head to: " + goThereModif.x + "; " + goThereModif.z);

            PathFinderRequestManager.RequestPath(new PathRequest(whereAmI, goThereModif, OnPathFound)); // changed in accordance with new pf manager version.
        }
    }
Beispiel #4
0
 public BasicBlock(GroundTileScript _underlyingTile, bool interractable)
 {
     dbType           = DataBlockType.BASIC;
     dBUnderlyingTile = _underlyingTile;
 }
Beispiel #5
0
 public CorruptBlock(GroundTileScript _underlyingTile, bool interractable)
 {
     dbType           = DataBlockType.CORRUPT;
     dBUnderlyingTile = _underlyingTile;
 }
Beispiel #6
0
 public UnbreakableBlock(GroundTileScript _underlyingTile, bool interractable)
 {
     dbType           = DataBlockType.UNBREAKABLE;
     dBUnderlyingTile = _underlyingTile;
 }
Beispiel #7
0
 public ToughBlock(GroundTileScript _underlyingTile, bool interractable)
 {
     dbType           = DataBlockType.TOUGH;
     dBUnderlyingTile = _underlyingTile;
 }