コード例 #1
0
    FloatingBlock[,,] GenerateRunningCalculationFloatingArray(int[,,] blockTypeDistribution, float[,,] massDistribution) // This expands the input array in each axis' positive and negative direction to create a layer of air around the stored Vehicle
    {
        FloatingBlock[,,] output = new FloatingBlock[blockTypeDistribution.GetLength(0) + 2, blockTypeDistribution.GetLength(1) + 2, blockTypeDistribution.GetLength(2) + 2];
        for (int x = 0; x < output.GetLength(0); x++)
        {
            for (int z = 0; z < output.GetLength(1); z++)
            {
                for (int y = 0; y < output.GetLength(2); y++)
                {
                    int   blockType;
                    float blockMass;
                    if ((x == 0 || y == 0 || z == 0) || (x == output.GetLength(0) - 1 || z == output.GetLength(1) - 1 || y == output.GetLength(2) - 1)) // if position is in expanded area, outside of blockDistribution
                    {
                        blockType = 0;
                        blockMass = 0;
                    }
                    else
                    {
                        blockType = blockTypeDistribution[x - 1, z - 1, y - 1];
                        blockMass = massDistribution[x - 1, z - 1, y - 1];
                    }

                    Vector3 relativePosition = new Vector3((float)x - (((float)output.GetLength(0) - 1) * 0.5f), (float)y - (((float)output.GetLength(2) - 1) * 0.5f), (float)z - (((float)output.GetLength(1) - 1) * 0.5f));
                    relativePosition *= FloatingTools.Constants.blockSize;

                    output[x, z, y] = new FloatingBlock(false, relativePosition, blockType, blockMass);
                }
            }
        }

        return(output);
    }
コード例 #2
0
    public void addBlock(float x, float y, Color c)
    {
        GameObject    obj   = new GameObject();
        FloatingBlock block = obj.AddComponent <FloatingBlock>();

        block.init(c, this, blockFolder.transform, Random.Range(-.005F, .005F));
        block.transform.localPosition = new Vector3(x, y, 0F);
        float randy = Random.Range(.5F, 1.5F);

        block.transform.localScale = new Vector3(randy, randy, 0);


        floatingBlocks.Add(block);
    }
コード例 #3
0
        internal void FillUI(Inline targetInline)
        {
            FloatingBlock flaotingBlock = targetInline as FloatingBlock;

            if (flaotingBlock != null)
            {
                this.FillUIFromFloatingBlock(flaotingBlock);
            }
            else
            {
                ImageInline image = targetInline as ImageInline;
                Debug.Assert(image != null, "Unexpected inline type");
                if (image != null)
                {
                    this.FillUIFromImage(image);
                }
            }
        }
コード例 #4
0
    void HandleInitialWaterContact()
    {
        if (WaterContactPoint == null)
        {
            Debug.LogError("WaterContactPoint was null, this should be impossible");
        }
        Vector3 lowestDetectedBlock             = (Vector3)WaterContactPoint;//water contact point can be used as inital because one adjacend block will always be lower
        Vector3 lowestDetectedBlockInWorldspace = vehicleParent.transform.TransformPoint((Vector3)FloatingTools.TransfromDictionaryIndexToRelativePosition((Vector3)WaterContactPoint, allBlocks));

        FloatingBlock lowestDetectedBlockObject = null;

        DetermineLowestAdjacentAirBlock(ref lowestDetectedBlock, ref lowestDetectedBlockInWorldspace, ref lowestDetectedBlockObject);

        //allBlocks[lowestDetectedBlock].isFlooded = true; //this works, but the below method is better
        lowestDetectedBlockObject.isFlooded = true;
        allFloodedBlocks.Add(new KeyValuePair <Vector3, FloatingBlock>(lowestDetectedBlock, lowestDetectedBlockObject));

        //Instantiate(testCube, vehicleParent.transform.TransformPoint(lowestDetectedBlockObject.relativePosition), vehicleParent.transform.rotation); //For testing only
    }
コード例 #5
0
 private void FillUIFromFloatingBlock(FloatingBlock floatingBlock)
 {
     this.SetWrappingStyle(floatingBlock.WrappingStyle);
     this.SetMargin(floatingBlock.Margin);
     this.SetTextWrap(floatingBlock.TextWrap);
 }
コード例 #6
0
    //This block determines which of the blocks touching the water contacting solid block is the lowest, therefore deteriming the start position for the flooding calcs
    void DetermineLowestAdjacentAirBlock(ref Vector3 lowestDetectedBlock, ref Vector3 lowestDetectedBlockInWorldspace, ref FloatingBlock lowestDetectedBlockObject)
    {
        Vector3[] offsetVectors = new Vector3[6] {
            new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1)
        };
        for (int i = 0; i < 6; i++)
        {
            Vector3 blockCurrentlyCheckedPostion = (Vector3)WaterContactPoint + offsetVectors[i];

            FloatingBlock blockCurrentlyCheckedObject;
            if (allBlocks.TryGetValue(blockCurrentlyCheckedPostion, out blockCurrentlyCheckedObject))
            {
                Vector3 blockCurrentlyCheckedPositionInWorldspace = vehicleParent.transform.TransformPoint(blockCurrentlyCheckedObject.relativePosition);

                if (blockCurrentlyCheckedPositionInWorldspace.y < lowestDetectedBlockInWorldspace.y)
                {
                    if (blockCurrentlyCheckedObject.blockType == 0)
                    {
                        lowestDetectedBlock             = blockCurrentlyCheckedPostion;
                        lowestDetectedBlockInWorldspace = blockCurrentlyCheckedPositionInWorldspace;
                        lowestDetectedBlockObject       = blockCurrentlyCheckedObject;
                    }
                }
            }
        }
    }
コード例 #7
0
 private void FillUIFromFloatingBlock(FloatingBlock floatingBlock)
 {
     this.SetWrappingStyle(floatingBlock.WrappingStyle);
     this.SetMargin(floatingBlock.Margin);
     this.SetTextWrap(floatingBlock.TextWrap);
 }
コード例 #8
0
 private void FillUIFromFloatingBlock(FloatingBlock flaotingBlock)
 {
     this.SetVerticalPosition(flaotingBlock.VerticalPosition);
     this.SetHorizontalPosition(flaotingBlock.HorizontalPosition);
     this.SetAllowOverlap(flaotingBlock.AllowOverlap);
 }
コード例 #9
0
 private void FillUIFromFloatingBlock(FloatingBlock flaotingBlock)
 {
     this.SetVerticalPosition(flaotingBlock.VerticalPosition);
     this.SetHorizontalPosition(flaotingBlock.HorizontalPosition);
     this.SetAllowOverlap(flaotingBlock.AllowOverlap);
 }