Pathfinding.GridGraph.SetUpOffsetsAndCosts C# (CSharp) Method

SetUpOffsetsAndCosts() public method

public SetUpOffsetsAndCosts ( ) : void
return void
        public virtual void SetUpOffsetsAndCosts()
        {
            neighbourOffsets = new int[8] {
                -width, 1 , width , -1,
                -width+1, width+1 , width-1, -width-1
            };

            int straightCost = Mathf.RoundToInt (nodeSize*Int3.Precision);
            int diagonalCost = Mathf.RoundToInt (nodeSize*Mathf.Sqrt (2F)*Int3.Precision);

            neighbourCosts = new int[8] {
                straightCost,straightCost,straightCost,straightCost,
                diagonalCost,diagonalCost,diagonalCost,diagonalCost
            };

            //Not for diagonal nodes, first 4 is for the four cross neighbours the last 4 is for the diagonals
            neighbourXOffsets = new int[8] {
                0, 1, 0, -1,
                1, 1, -1, -1
            };

            neighbourZOffsets = new int[8] {
                -1, 0, 1, 0,
                -1, 1, 1, -1
            };
        }