Ejemplo n.º 1
0
    public void Compact()
    {
        int counter = inv.inventory.Count;

        foreach (GameObject obj in inv.inventory)
        {
            BlockProperties blockFacts = obj.GetComponent <BlockProperties> ();
            if (blockFacts != null)
            {
                counter += blockFacts.size;
            }
        }

        if (counter == 0)
        {
            return;
        }
        inv.reset();

        GameObject block = Instantiate(junkBlockPrefab, body.Find("Compactor").position, Quaternion.identity, null);

        block.transform.localScale *= (Mathf.Log(counter) + 1);
        block.GetComponent <BlockProperties> ().size = counter;
        block.GetComponent <Rigidbody2D> ().mass     = counter;
        block.GetComponent <Rigidbody2D> ().AddForce(10 * transform.up, ForceMode2D.Impulse);
    }
Ejemplo n.º 2
0
        private void Canvas1_ShowBlockPoperites(object sender, EventArgs e)
        {
            var temp = (sender as MyBlock);

            if (_properties != null)
            {
                if (_properties.ShouldRefresh(temp))
                {
                    _properties.UpdateProperties();
                    return;
                }
                else
                {
                    splitContainer2.Panel2.Controls.Remove(_properties);
                }
            }

            _properties = new BlockProperties(temp)
            {
                Width    = splitContainer2.Panel2.Width,
                Height   = splitContainer2.Panel2.Height,
                Location = new System.Drawing.Point(0, 0)
            };

            _properties.BlockPropertyChanged += _properties_BlockPropertyChanged;
            splitContainer2.Panel2.Controls.Add(_properties);
        }
Ejemplo n.º 3
0
    private void OnTriggerEnter(Collider other)
    {
        BlockProperties properties = other.gameObject.GetComponent <BlockProperties>();

        if (properties != null && isGameActive)
        {
            isGameActive = false;

            //Win
            if (properties.color == desiredColor)
            {
                monitorText.text = "Good!";

                GetComponentInChildren <ParticleSystem>().Play();

                source.clip = goodClip;
                source.Play();
            }

            //Lose
            else
            {
                monitorText.text = "Incorrect, you placed a " + properties.color.ToString() + " block";

                source.clip = badClip;
                source.Play();
            }

            StartCoroutine(StartNewRoundSoon());
        }
    }
Ejemplo n.º 4
0
 /**draw()
  * Draws the physical representation of a Block in the world.
  */
 public void draw()
 {
     base.draw();
     if (thisBody != null)
     {
         bp = thisBody.GetComponent <BlockProperties> ();
     }
 }
Ejemplo n.º 5
0
    private BlockProperties NewBlock()
    {
        myBlock = Instantiate(blockGO).GetComponent <BlockProperties>();
        blockList.Add(myBlock);
        myBlock.ResetBlock();
        myBlock.transform.SetParent(transform);


        return(myBlock);
    }
Ejemplo n.º 6
0
    string BuildInfoString()
    {
        BlockProperties bp   = this.GetComponent <BlockProperties>();
        string          info = "<b>" + this.name + "</b>\n\n";

        info += "Application name: " + bp.ApplicationName + "\n";
        info += "Business Group: " + bp.BusinessGroup + "\n";
        info += "Business Function: " + bp.BusinessFunction + "\n";
        info += "Desirability: " + bp.Desirability;

        return(info);
    }
Ejemplo n.º 7
0
 void Start()
 {
     rb    = GetComponentInChildren <Rigidbody2D> ();
     block = GetComponentInChildren <BlockProperties> ();
     if (block != null)
     {
         rb.AddForce(force * block.size * transform.right, ForceMode2D.Impulse);
     }
     else
     {
         rb.AddForce(force * transform.right, ForceMode2D.Impulse);
     }
 }
Ejemplo n.º 8
0
    public List <GameObject> GetSameColorTouchingBlocks(GameObject blockToCheck)
    {
        Color             blockToCheckColor         = blockToCheck.GetComponent <SpriteRenderer>().color;
        BlockProperties   blockToCheckProperties    = blockToCheck.GetComponent <BlockProperties>();
        List <GameObject> sameColorWithBlockToCheck = new List <GameObject>();

        for (int i = 0; i < blockToCheckProperties.TouchingBlocks.Count; i++)
        {
            if (blockToCheckProperties.TouchingBlocks[i].GetComponent <SpriteRenderer>().color == blockToCheckColor)
            {
                sameColorWithBlockToCheck.Add(blockToCheckProperties.TouchingBlocks[i]);
            }
        }
        return(sameColorWithBlockToCheck);
    }
Ejemplo n.º 9
0
    IEnumerator StartNewSurfaces()
    {
        if (From == "" || From == "RIGHT")
        {
            yield return(StartCoroutine("MovePlayerToCenterFromRight"));
        }
        else
        {
            yield return(StartCoroutine("MovePlayerToCenterFromLeft"));
        }
        yield return(new WaitForSeconds(5.0f));

        BlockProperties bp  = Block.GetComponent <BlockProperties> ();
        InfiniteLevel   ifl = gameObject.GetComponent <InfiniteLevel> ();

        foreach (GameObject value in ifl.SurfaceList)
        {
            value.SetActive(false);
        }
        ifl.SurfaceList.Clear();
        //Debug.Log (ifl.SurfaceList.Count);
        PlayerController pc = gameObject.GetComponent <PlayerController>();
        PlayerPhysics    pp = gameObject.GetComponent <PlayerPhysics>();

        if (bp.ToContinue == "CONTINUE")
        {
            if (bp.NextLevelDirection == "LEFT")
            {
                StartCoroutine(ifl.InfiniteLevelLeft(Block.transform.position.x, Block.transform.position.y - 10.0f));
                if (Mathf.Sign(pc.Speed) > 0)
                {
                    pc.Speed *= -1.0f;
                }
            }
            else
            {
                StartCoroutine(ifl.InfiniteLevelRight(Block.transform.position.x, Block.transform.position.y - 10.0f));
                if (Mathf.Sign(pc.Speed) < 0)
                {
                    pc.Speed *= -1.0f;
                }
            }
            From            = bp.NextLevelDirection;
            pp.enabled      = true;
            pc.CurrentSpeed = 0.0f;
            pc.enabled      = true;
        }
    }
Ejemplo n.º 10
0
 public Block(int requestedBlockID, string blockName, List <Obj> objs, Icon icon, BlockProperties properties,
              List <ColliderComposite> compoundCollider, List <NeededResource> neededResources, bool showCollider,
              float mass, Type[] scripts, List <AddingPoint> addingPoints)
 {
     this.id               = requestedBlockID;
     this.objs             = objs;
     this.name             = blockName;
     this.icon             = icon;
     this.properties       = properties;
     this.compoundCollider = compoundCollider;
     this.neededResources  = neededResources;
     this.showCollider     = showCollider;
     this.mass             = mass;
     this.components       = scripts;
     this.addingPoints     = addingPoints;
 }
Ejemplo n.º 11
0
    public IEnumerator InfiniteLevelRight(float currentXPos, float currentYPos)
    {
        InfiniteGo = false;
        int counter = 2;

        XPosition  = currentXPos;
        surfacepos = new Vector3(XPosition, currentYPos, 0.0f);
        s          = (GameObject)Instantiate(TheSurfaceObject, surfacepos, Quaternion.identity);
        SurfaceList.Enqueue(s);
        s.transform.parent = organizeSurface.transform;
        surfacepos        += new Vector3(SpawnPositionOffset, 0.0f, 0.0f);
        s = (GameObject)Instantiate(TheSurfaceObject, surfacepos, Quaternion.identity);
        SurfaceList.Enqueue(s);
        s.transform.parent = organizeSurface.transform;
        XPositionPlus      = XPosition + 30.0f;
        while (!InfiniteGo)
        {
            if (transform.position.x >= XPosition)
            {
                XPosition  += SpawnPositionOffset;
                surfacepos += new Vector3(SpawnPositionOffset, 0.0f, 0.0f);
                s           = (GameObject)Instantiate(TheSurfaceObject, surfacepos, Quaternion.identity);
                SurfaceList.Enqueue(s);
                s.transform.parent = organizeSurface.transform;
                counter++;
            }
            if (transform.position.x >= XPositionPlus)
            {
                XPositionPlus += SpawnPositionOffset;
                GameObject deact = SurfaceList.Dequeue();
                deact.SetActive(false);
            }
            InfiniteGo = counter > 100;
            yield return(0);
        }

        surfacepos += new Vector3(SpawnPositionOffset, 0.0f, 0.0f);
        GameObject      tb = (GameObject)Instantiate(TransitionBlock, surfacepos, Quaternion.identity);
        BlockProperties bp = tb.GetComponent <BlockProperties> ();

        bp.ToContinue         = "CONTINUE";
        bp.NextLevelDirection = "LEFT";
    }
Ejemplo n.º 12
0
        public IEnumerable <BlockProperties> GetBlockTypes()
        {
            var materialType = new Dictionary <ushort, MaterialType>
            {
                { 0, MaterialType.Grassland },
                { 1, MaterialType.MarbleFloor }
            };

            var properties = new BlockProperties();

            properties.SetBlockId(1);
            properties.SetMaterial((short)MaterialType.Grassland);

            yield return(properties);

            properties = new BlockProperties();
            properties.SetBlockId(2);
            properties.SetMaterial((short)MaterialType.MarbleFloor);

            yield return(properties);
        }
Ejemplo n.º 13
0
 private void Canvas1_HideBlockPoperites(object sender, EventArgs e)
 {
     splitContainer2.Panel2.Controls.Remove(_properties);
     _properties = null;
 }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        if (itemsHaveChanged)
        {
            _loadItemsFromEquippedList();
            itemsHaveChanged = false;
        }


        bool raycastHit = false;

        RaycastHit hit;

        // only collide raycast with Blocks layer
        int layerMaskBlocksOnly = LayerMask.GetMask("Blocks");

        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, m_maxBlockPlacingRange, layerMaskBlocksOnly))
        {
            raycastHit = true;
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
        }
        else
        {
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 10, Color.white);
        }


        // Input Function
        if (Input.anyKeyDown)
        {
            int numberKey = 0;
            if (int.TryParse(Input.inputString, out numberKey))
            {
                if ((numberKey > 0) && (numberKey < 8))
                {
                    // remap from 1234567890 to 0123456789 (because of keyboard layout)
                    toolbarSlotSelection = (numberKey + 9) % 10;

                    if (activeItems[toolbarSlotSelection].transform.childCount > 0)
                    {
                        string itemName     = activeItems[toolbarSlotSelection].transform.GetChild(0).gameObject.name;
                        int    bracketIndex = itemName.IndexOf("(");
                        itemName           = itemName.Substring(0, bracketIndex);
                        blockTypeSelection = (BLOCK_ID)System.Enum.Parse(typeof(BLOCK_ID), itemName.ToUpper());
                        _hideSelectors();
                        selectors[toolbarSlotSelection].SetActive(true);
                    }
                }
            }
        }


        currentlySelectedBlockUI.text = blockDatabase.GetProperties((BLOCK_ID)blockTypeSelection).m_description;


        // if selection within range
        if (raycastHit)
        {
            // determine if block place position is too close to the player
            Vector3 blockPlacePosition   = new IntPos((hit.point) + (hit.normal * 0.5f) + new Vector3(0.5f, 0.5f, 0.5f)).Vec3();//(new IntPos(((hit.point) + (hit.normal * 0.1f))).Vec3() + new Vector3(0.5f, 0.5f, 0.5f));
            IntPos  integerPlacePosition = new IntPos(blockPlacePosition);

            // position of the block the raycast hit
            IntPos hitBlockPosition = new IntPos((hit.point) + (hit.normal * -0.5f) + new Vector3(0.5f, 0.5f, 0.5f));

            byte hitBlockType = world.GetBlockID(hitBlockPosition);

            // get all properties of the block the raycast hit
            BlockProperties hitBlockProperties = blockDatabase.GetProperties((BLOCK_ID)hitBlockType);

            // show description text for block
            blockDescriptionUI.text = hitBlockProperties.m_description;

            // put visible ghost block there and make it visible
            ghostBlock.transform.position = blockPlacePosition;
            ghostBlock.gameObject.SetActive(true);

            { // Debug block selection
                Debug.DrawRay(blockPlacePosition, new Vector3(0.5f, 0.0f, 0.0f), Color.red);
                Debug.DrawRay(blockPlacePosition, new Vector3(0.0f, 0.5f, 0.0f), Color.green);
                Debug.DrawRay(blockPlacePosition, new Vector3(0.0f, 0.0f, 0.5f), Color.blue);

                Debug.DrawRay(blockPlacePosition, new Vector3(0.0f, -0.5f, 0.0f), Color.yellow);
            }

            // Place Block
            if ((Input.GetButtonDown("PlaceBlock")))
            {
                // determine if block place position is too close to the player
                if (!ghostBlock.IsColliding() && hitBlockProperties.m_canBePlacedUpon)
                {
                    Debug.Log("Placing block!");
                    Command cmd = new AddBlockCommand((byte)blockTypeSelection, integerPlacePosition);

                    if (Execute(ref cmd))
                    {
                        // send notification that a Block was placed
                        NotifyAll(gameObject, OBSERVER_EVENT.PLACED_BLOCK);
                    }
                }   // endif ghostBlock colliding
                else
                {
                    Debug.Log("Cannot place block--Entity is in the way!");
                }
            }

            // Remove Block
            if (Input.GetButtonDown("RemoveBlock"))
            {
                Debug.Log("Removing block!");
                Command cmd = new RemoveBlockCommand(hitBlockType, hitBlockPosition);
                Execute(ref cmd);
            }
        }
        else // endif raycast hit
        {
            ghostBlock.gameObject.SetActive(false);
            blockDescriptionUI.text = "";
        }

        // Undo Last
        if (Input.GetButtonDown("Cancel") || Input.GetKeyDown(KeyCode.Backspace))
        {
            if (commandList.Count > 0)
            {
                var lastAction = commandList.Last;

                if (lastAction.Value.IsCompleted())
                {
                    lastAction.Value.Undo();
                }
                else
                {
                    Debug.Log("Could not Undo! Action not completed! Removing uncompleted action");
                }

                commandList.RemoveLast();
            }
            else
            {
                Debug.Log("Could not Undo! Nothing to Undo!");
            }
        }
    }
Ejemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        var rocksObjects = GameObject.FindGameObjectsWithTag("BedRock");

        for (int f = 0; f < rocksObjects.Length; f++)
        {
            rocksObjects[f].transform.parent = underGroundRock_Object.gameObject.transform;
        }


        //spawn cell
        if (!cellSpawned)
        {
            for (i = 0; (i < maxBlocksPerCell) && (currentRow != maxRows); i++)
            {
                if (SelectNewBiome)
                {
                    float y = Random.Range(0.0f, 10.0f);

                    currentRandomNumber = y;
                    {
                        if (y < 3.0f)
                        {
                            Grassland      = true;
                            MudLand        = false;
                            Forest         = false;
                            SelectNewBiome = false;
                        }

                        else if (y > 5.0f && y < 7.0f)
                        {
                            MudLand        = true;
                            Grassland      = false;
                            Forest         = false;
                            SelectNewBiome = false;
                        }

                        else if (y > 7.0f)
                        {
                            MudLand        = false;
                            Grassland      = false;
                            Forest         = true;
                            SelectNewBiome = false;
                        }
                    }
                }


                float x = Random.Range(0.0f, 10.0f);
                {
                    if (Grassland)
                    {
                        if (x < 1)
                        {
                            CurrentBlock[i] = Grassland_block1;
                        }

                        else if (x < 2)
                        {
                            CurrentBlock[i] = Grassland_block3;
                        }

                        else if (x < 3)
                        {
                            CurrentBlock[i] = Grassland_block4;
                        }

                        else if (x < 4)
                        {
                            CurrentBlock[i] = Grassland_block5;
                        }

                        else
                        {
                            CurrentBlock[i] = Grassland_block2;
                        }
                    }

                    else if (MudLand)
                    {
                        if (x < 1)
                        {
                            CurrentBlock[i] = MudLand_block1;
                        }

                        else if (x < 2)
                        {
                            CurrentBlock[i] = MudLand_block2;
                        }

                        else if (x < 3)
                        {
                            CurrentBlock[i] = MudLand_block3;
                        }

                        else if (x < 4)
                        {
                            CurrentBlock[i] = MudLand_block4;
                        }

                        else
                        {
                            CurrentBlock[i] = MudLand_block5;
                        }
                    }

                    else if (Forest)
                    {
                        if (x < 1)
                        {
                            CurrentBlock[i] = Forest_block1;
                        }

                        else if (x < 2)
                        {
                            CurrentBlock[i] = Forest_block2;
                        }

                        else if (x < 3)
                        {
                            CurrentBlock[i] = Forest_block3;
                        }

                        else if (x < 4)
                        {
                            CurrentBlock[i] = Forest_block4;
                        }

                        else
                        {
                            CurrentBlock[i] = Forest_block5;
                        }
                    }
                }

                currentBlockproperties = CurrentBlock[i].gameObject.GetComponent <BlockProperties>();
                currentBlockproperties.blockCellLocation = BlockCell;

                if (i % 10 == 0)
                {
                    depthPos++;
                    widthPos = defaultWidthPos;
                }

                float heightToUse = Random.Range(0, maxHeightOffset);

                GameObject test = Instantiate(CurrentBlock[i], new Vector3(widthPos + (currentRow * 10), heightToUse, depthPos), Quaternion.identity);
                currentHeight = -1;

                test.transform.parent = Cell.transform;

                //Saving.blocksToSave[i] = CurrentBlock[i];

                meshFilters = CurrentBlock[i].gameObject.GetComponentsInChildren <MeshFilter>();



                for (int y = 0; y < MaxHeight; y++)
                {
                    float j = Random.Range(0.0f, 10.0f);
                    {
                        if (j < 1)
                        {
                            CurrentBlock[i] = UnderGround_Rock_block1;
                        }

                        else if (j < 2)
                        {
                            CurrentBlock[i] = UnderGround_Rock_block2;
                        }

                        else if (j < 3)
                        {
                            CurrentBlock[i] = UnderGround_Rock_block3;
                        }

                        else
                        {
                            CurrentBlock[i] = UnderGround_Rock_block4;
                            CurrentBlock[i].gameObject.tag = "BedRock";
                        }
                    }


                    test = Instantiate(CurrentBlock[i], new Vector3(widthPos + (currentRow * 10), heightToUse + currentHeight--, depthPos), Quaternion.identity);
                    test.transform.parent = Cell.transform;

                    y++;
                }

                test.name = total.ToString();
                total++;
                widthPos++;
            }


            if (currentRow == maxRows)
            {
                cellSpawned = true;
                underGroundRock_Combine.CombineMeshes(Cell);
            }

            if (i == maxBlocksPerCell)
            {
                BlockCell++;
                currentCell++;
                SelectNewBiome = true;
                i = 0;
                //total = 10 * currentCell;

                if (currentCell == maxCells)
                {
                    widthPos    = defaultWidthPos;
                    depthPos    = defaultDepthPos;
                    currentCell = 0;
                    currentRow++;
                    i = -1;
                }

                Cell      = new GameObject();
                Cell.name = "Cell Number :";
            }
        }
    }
 public BlockRenderData(BlockProperties properties)
 {
     Properties = properties;
     Textures   = new List <TexCoord>();
 }
 private static bool checkBlockName(BlockProperties blockProperties)
 {
     if (isBuildable(blockProperties)
         && !availableBlockTypes.Contains(blockProperties)
         && !usedBlockNames.Contains(blockProperties.getName()))
     {
         usedBlockNames.Add(blockProperties.getName());
         return true;
     }
     else return false;
 }
Ejemplo n.º 18
0
 public Block Properties(BlockProperties blockProp)
 {
     this.properties = blockProp;
     return(this);
 }
        public override void OnUpdate()
        {
            if (isScrollOverride && !isScrolling)
            {
                isScrollOverride = false;
            }

            if (Time.timeSinceLevelLoad > 12f && doApplyPreferences)
            {
                doApplyPreferences = false;

                foreach (ALivingEntity entity in worldManager.PlayerFaction.units)
                {
                    applyPlayerPreferences(entity);
                }
            }

            if (doSaveGame || doSaveBackup)
            {
                doSaveGame = false;

                if (Time.timeSinceLevelLoad > 12f)
                {
                    worldManager.SaveGame();

                    if (doSaveBackup)
                    {
                        doSaveBackup = false;

                        if (!modSettings.isAutoBackupsEnabled)
                        {
                            GameSaveService.SaveGameInfo saveGameInfo = gameSaveService.getSaveGameInfoFromSettlementName(worldManager.settlementName);
                            gameSaveService.createBackup(saveGameInfo);
                            log("Backup saved for: " + saveGameInfo.Name);
                        }
                    }
                }
                else log("Unable to save. Press play until save button is visible then try again.");
            }

            if (modSettings.isCreativeEnabled)
            {
                if (doCreateBlocks || doReplaceBlocks)
                {
                    selectedBlockType = controlPlayer.buildingMaterial;

                    if (selectedBlockType.getVariations() != null)
                    {
                        selectedBlockData = selectedBlockType.getVariations()[controlPlayer.buildingVariationIndex][0];
                    }
                    else
                    {
                        BlockDataTextureVariant textureData = new BlockDataTextureVariant(TextureVariant.None);
                        textureData.setVariant(TextureVariant.Pillar, controlPlayer.buildingPillarless);
                        textureData.setVariant(TextureVariant.Trimless, controlPlayer.buildingTrimless);

                        selectedBlockData = textureData;
                    }
                }

                if (doBuildStructures)
                {
                    doBuildStructures = false;
                    controlPlayer.structures.Where(s => !s.isBuilt).ToList()
                        .ForEach(s => buildingService.buildStructure(ref s, worldManager.PlayerFaction));
                }
                else if (doReplaceBlocks)
                {
                    doReplaceBlocks = false;
                    buildingService.replaceBlocksInSelection(selectedBlockType, selectedBlockData);
                }
                else if (doSmoothTerrain)
                {
                    doSmoothTerrain = false;
                    buildingService.smoothBlocksInSelection();
                }
                else if (doCreateBlocks)
                {
                    doCreateBlocks = false;
                    buildingService.buildBlocksInSelection(selectedBlockType, selectedBlockData);
                }
                else if (doRemoveBlocks)
                {
                    doRemoveBlocks = false;
                    buildingService.removeBlocksInSelection();
                }
                else if (doRemoveTrees)
                {
                    doRemoveTrees = false;
                    buildingService.removeSelectedTrees();
                    buildingService.removeSelectedShrubs();
                }
                else if (doRemoveAllTrees)
                {
                    doRemoveAllTrees = false;
                    buildingService.removeAllTreeItems();
                    controlPlayer.CancelDesigning(true);
                }
                else if (doPlaceHuman)
                {
                    doPlaceHuman = false;
                    if (isMouseInWorld(out mouseWorldPosition))
                    {
                        unitService.addHuman(selectedUnitType, mouseWorldPosition, autoAccept: true);
                    }
                }
                else if (doPlaceEnemy)
                {
                    doPlaceEnemy = false;
                    if (isMouseInWorld(out mouseWorldPosition))
                    {
                        unitService.addEnemy(selectedEnemyType, mouseWorldPosition);
                    }
                }
                else if (doPlaceAnimal)
                {
                    doPlaceAnimal = false;
                    if (isMouseInWorld(out mouseWorldPosition))
                    {
                        unitService.addAnimal(selectedAnimalType, mouseWorldPosition);
                    }
                }
                else if (doRemoveEntity)
                {
                    doRemoveEntity = false;
                    if (UnitService.isFriendly(selectedEntity) && playerFactionUnitCount <= 1)
                    {
                        log("Unable to remove player unit. There must be at least one unit in the player faction.");
                        return;
                    }
                    selectedEntity.Destroy();
                }
                else if (doSetPlayerUnitSettings)
                {
                    doSetPlayerUnitSettings = false;
                    if (isPlayableUnitSelected)
                    {
                        PlayerUnitSettings.setPlayerUnitSettings(playerUnitTraitSettings, selectedUnit, UnitTrait.List);
                    }
                }
                else if (isPlayableUnitSelected)
                {
                    PlayerUnitSettings.updatePlayerUnitSettings(ref playerUnitTraitSettings, selectedUnit, UnitTrait.List);
                }
            }
        }
        private void updateControlPlayerBlockProperties(BlockProperties properties, IBlock block = null)
        {
            controlPlayer.buildingMaterial = properties;
            controlPlayer.buildTile = properties.getID();
            controlPlayer.buildingVariations = properties.getVariations();
            controlPlayer.buildingVariationIndex = ModUtils.getVariationIndex(block);

            if (block != null && (tempBlockDataTextureVariant = block.getMeta<BlockDataTextureVariant>()) != null)
            {
                controlPlayer.buildingPillarless = tempBlockDataTextureVariant.checkVariant(TextureVariant.Pillar);
                controlPlayer.buildingTrimless = tempBlockDataTextureVariant.checkVariant(TextureVariant.Trimless);
            }
            else
            {
                controlPlayer.buildingPillarless = false;
                controlPlayer.buildingTrimless = false;
            }
        }
Ejemplo n.º 21
0
    public List <GameObject> SetBlock(Vector3 Pnt, BlockClass B)
    {
        var Affected = new List <GameObject>();
        var PS       = BlockProperties.GetPosition(Pnt);
        var BlockPos = PS.BlockInChunk;

        //Test that block is contained in Block
        if ((BlockPos.x >= 0) & (BlockPos.y >= 0) & (BlockPos.z >= 0) & (BlockPos.x < BlockProperties.ChunkSize) &
            (BlockPos.y < BlockProperties.ChunkSize) &
            (BlockPos.z < BlockProperties.ChunkSize))
        {
            GameObject tempChunk;
            if (Chunks.TryGetValue(PS.ChunkInWorld, out tempChunk))
            {
                tempChunk.GetComponent <ChunkObject>().Blocks[BlockPos.x + 1][BlockPos.y + 1][BlockPos.z + 1] = B;
                Affected.Add(tempChunk);
                var ChunkOffset = new Vector3Int();
                if (BlockPos.x == 0)
                {
                    ChunkOffset.x--;
                }
                if (BlockPos.y == 0)
                {
                    ChunkOffset.y--;
                }
                if (BlockPos.z == 0)
                {
                    ChunkOffset.z--;
                }
                if (BlockPos.x == BlockProperties.ChunkSize - 1)
                {
                    ChunkOffset.x++;
                }
                if (BlockPos.y == BlockProperties.ChunkSize - 1)
                {
                    ChunkOffset.y++;
                }
                if (BlockPos.z == BlockProperties.ChunkSize - 1)
                {
                    ChunkOffset.z++;
                }
                if (ChunkOffset.x != 0)
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(ChunkOffset.x * 16, 0, 0), out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>()
                        .Blocks[BlockPos.x + 1 - ChunkOffset.x * BlockProperties.ChunkSize][
                            BlockPos.y + 1][BlockPos.z + 1] = B;
                        Affected.Add(tempChunk);
                    }
                }

                if (ChunkOffset.y != 0)
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(0, ChunkOffset.y * 16, 0), out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>().Blocks[BlockPos.x + 1][
                            BlockPos.y + 1 - ChunkOffset.y * BlockProperties.ChunkSize][BlockPos.z + 1] = B;
                        Affected.Add(tempChunk);
                    }
                }

                if (ChunkOffset.z != 0)
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(0, 0, ChunkOffset.z * 16), out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>().Blocks[BlockPos.x + 1][BlockPos.y + 1][
                            BlockPos.z + 1 - ChunkOffset.z * BlockProperties.ChunkSize] = B;
                        Affected.Add(tempChunk);
                    }
                }

                if ((ChunkOffset.x != 0) & (ChunkOffset.y != 0))
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(ChunkOffset.x * 16, ChunkOffset.y * 16, 0),
                                           out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>()
                        .Blocks[BlockPos.x + 1 - ChunkOffset.x * BlockProperties.ChunkSize][
                            BlockPos.y + 1 - ChunkOffset.y * BlockProperties.ChunkSize][BlockPos.z + 1] = B;
                        Affected.Add(tempChunk);
                    }
                }

                if ((ChunkOffset.x != 0) & (ChunkOffset.z != 0))
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(ChunkOffset.x * 16, 0, ChunkOffset.z * 16),
                                           out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>()
                        .Blocks[BlockPos.x + 1 - ChunkOffset.x * BlockProperties.ChunkSize]
                        [BlockPos.y + 1][BlockPos.z + 1 - ChunkOffset.z * BlockProperties.ChunkSize] = B;
                        Affected.Add(tempChunk);
                    }
                }

                if ((ChunkOffset.y != 0) & (ChunkOffset.z != 0))
                {
                    if (Chunks.TryGetValue(PS.ChunkInWorld + new Vector3Int(0, ChunkOffset.y * 16, ChunkOffset.z * 16),
                                           out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>().Blocks[BlockPos.x + 1][
                            BlockPos.y + 1 - ChunkOffset.y * BlockProperties.ChunkSize][
                            BlockPos.z + 1 - ChunkOffset.z * BlockProperties.ChunkSize]
                            = B;
                        Affected.Add(tempChunk);
                    }
                }

                if ((ChunkOffset.x != 0) & (ChunkOffset.y != 0) & (ChunkOffset.z != 0))
                {
                    if (Chunks.TryGetValue(
                            PS.ChunkInWorld + new Vector3Int(ChunkOffset.x * 16, ChunkOffset.y * 16, ChunkOffset.z * 16),
                            out tempChunk))
                    {
                        tempChunk.GetComponent <ChunkObject>()
                        .Blocks[BlockPos.x + 1 - ChunkOffset.x * BlockProperties.ChunkSize][
                            BlockPos.y + 1 - ChunkOffset.y * BlockProperties.ChunkSize][
                            BlockPos.z + 1 - ChunkOffset.z * BlockProperties.ChunkSize]
                            = B;
                        Affected.Add(tempChunk);
                    }
                }
            }
        }

        return(Affected);
    }
Ejemplo n.º 22
0
    void DrawApps()
    {
        TextAsset textMatrix = Resources.Load("BusinessArchitectureMatrix") as TextAsset;
        Transform matrixTransform;

        string[] matrixRows = textMatrix.text.Split("\n"[0]);

        foreach (string row in matrixRows)
        {
            if (row != "")
            {
                string[] rowAttributes = row.Split("|"[0]);
                //Debug.Log(nodeRow.ToString().TrimStart().Substring(0, 2));
                //Debug.Log(nodecount.ToString());

                int    year       = int.Parse(rowAttributes[2]);
                string appName    = rowAttributes[4].Trim();
                string colour     = rowAttributes[5].Trim();
                float  x          = float.Parse(rowAttributes[7]) * (xscale + xpad);
                float  appcount   = float.Parse(rowAttributes[8]);
                float  apprank    = float.Parse(rowAttributes[9]);
                float  y          = (float.Parse(rowAttributes[6]) + 0.5f - (apprank - 0.5f) / appcount) * (yscale + ypad); // y = ([y number] - 1 + [app rank] / [app count]) * (scale + pad)
                float  z          = 0;
                bool   leftMatch  = (rowAttributes[10] == "TRUE");
                int    contiguous = int.Parse(rowAttributes[11]);

                matrixTransform = matrixParentTransform.Find("Matrix" + year.ToString());

                if (!leftMatch || appcount > 1)
                {
                    Transform blockInstance = AddBlock(x, y, z, contiguous, Quaternion.identity, appName, prefabAppBlock, matrixTransform);
                    blockInstance.localScale = new Vector3(blockInstance.localScale.x * contiguous, blockInstance.localScale.y / appcount, blockInstance.localScale.z);

                    // fix text panel size
                    Transform objPanal1 = blockInstance.Find("Canvas/Panel1/Text1");
                    objPanal1.localScale = new Vector3(objPanal1.localScale.x / contiguous, objPanal1.localScale.y * appcount, objPanal1.localScale.z);
                    Transform objPanal2 = blockInstance.Find("Canvas/Panel2/Text2");
                    objPanal2.localScale = new Vector3(objPanal2.localScale.x / contiguous, objPanal2.localScale.y * appcount, objPanal2.localScale.z);

                    switch (colour)
                    {
                    case "Amber":
                        blockInstance.GetComponent <Renderer>().material.SetColor("_Color", Color.yellow);
                        objPanal1.GetComponent <Text>().color = Color.black;
                        objPanal2.GetComponent <Text>().color = Color.black;
                        break;

                    case "White":
                        blockInstance.GetComponent <Renderer>().material.SetColor("_Color", Color.grey);
                        objPanal1.GetComponent <Text>().color = Color.black;
                        objPanal2.GetComponent <Text>().color = Color.black;
                        break;
                    }

                    // add property
                    BlockProperties blockProperties = blockInstance.gameObject.GetComponent <BlockProperties>();
                    blockProperties.ApplicationName  = appName;
                    blockProperties.BusinessGroup    = rowAttributes[3].Trim();
                    blockProperties.BusinessFunction = rowAttributes[0].Trim();
                    blockProperties.Desirability     = colour;
                }
            }
        }
    }
Ejemplo n.º 23
0
 public Block(string block)
 {
     this.BlockType = BlockProperties.ByName(block);
 }
        public static bool isBuildable(BlockProperties blockProperties, bool includeAlternates = false)
        {
            if (!excludeNames.IsMatch(blockProperties.getName())
                || (includeAlternates && alternateBlockIds.Contains(blockProperties.getID())))
            {
                return true;
            }

            return false;
        }