Example #1
0
        private void SetTileMaterial()
        {
            this.blockMaterials = this.blockRenderer.sharedMaterials;

#if UNITY_EDITOR
            this._materialID      = Random.Range(1, 6);
            this.tileUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Empty/Standard/Up/", "Empty" + this._materialID.ToString().PadLeft(2, '0') + "-Up");
            this.tileDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Empty/Standard/Down/", "Empty" + this._materialID.ToString().PadLeft(2, '0') + "-Down");
#endif

            if (this._blockState == BlockInfo.BlockState.UP)
            {
                this.blockMaterials[0] = this.tileUpMaterial;
            }
            else
            {
                if (this.isUp)
                {
                    this.blockMaterials[0] = this.tileUpMaterial;
                }
                else
                {
                    this.blockMaterials[0] = this.tileDownMaterial;
                }
            }

            this.blockRenderer.sharedMaterials = this.blockMaterials;
        }
Example #2
0
        /// <summary>
        /// Static constructor. Created when Unity first loads.
        /// </summary>
        static EntryPoint()
        {
            // Retrieve the saved name of the current global text asset
            var textAssetName = EditorPrefs.GetString(StringLibrary.GLOBAL_FONT_KEY, StringLibrary.ARIAL);

            // Load the saved global text asset
            var globalTextAsset = AssetProcessor.LoadTextAsset(textAssetName);

            // If, for some reason, there is no text asset, create a default Arial text asset
            if (globalTextAsset == null)
            {
                AssetProcessor.CreateDefaultTextAsset();
                globalTextAsset = AssetProcessor.LoadTextAsset(textAssetName);
            }

            // Create the listener for notifications of newly create Text objects
            var hierarchyListener = new HierarchyListener();

            // Grab all, if any, Text objects in the scene
            var allTextObjects = Resources.FindObjectsOfTypeAll(typeof(Text));

            if (allTextObjects == null)
            {
                allTextObjects = Resources.FindObjectsOfTypeAll(typeof(Text));
            }

            // Create and initialize the GlobalFontSettings
            new GlobalTextSettings(globalTextAsset, allTextObjects);

            // Initialize the listener for the font settings window
            GlobalTextSettingsWindow.hierarchyListener = hierarchyListener;

            // Start listening for the creation of text objects
            hierarchyListener.Listen();
        }
Example #3
0
        private void SetMiscMaterial()
        {
            this.warpUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Warp/Standard/Up/", "Up-Up");
            this.warpDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Warp/Standard/Down/", "Up-Down");

            // OLD WARP DIRECTION CODE.

            /*switch(this.FirstDirection){
             *  case BlockInfo.BlockDirection.UP:
             *      this.warpUpMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Up/", "Up-Up");
             *      this.warpDownMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Down/", "Up-Down");
             *      break;
             *
             *  case BlockInfo.BlockDirection.RIGHT:
             *      this.warpUpMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Up/", "Right-Up");
             *      this.warpDownMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Down/", "Right-Down");
             *      break;
             *
             *  case BlockInfo.BlockDirection.DOWN:
             *      this.warpUpMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Up/", "Down-Up");
             *      this.warpDownMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Down/", "Down-Down");
             *      break;
             *
             *  case BlockInfo.BlockDirection.LEFT:
             *      this.warpUpMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Up/", "Left-Up");
             *      this.warpDownMaterial = AssetProcessor.FindAsset<Material>("Assets/Models/Block/Material/Warp/Standard/Down/", "Left-Down");
             *      break;
             * }*/
        }
Example #4
0
        public static void Reset()
        {
            LogUtils.Verbose("Context.Reset");

            ClearAssetsCache();
            _init           = false;
            _roots          = null;
            _groups         = null;
            Attributes      = null;
            _assetProcessor = null;
            _assemblies     = null;
        }
Example #5
0
        public static void FindOrCreate()
        {
            GameObject temp = GameObject.FindWithTag("TileManager");

            if (temp == null)
            {
#if UNITY_EDITOR
                temp = AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefab + "Resources/", "TileManager");
#else
                temp = ResourceManager.instance.tileManager;
#endif
                Instantiate(temp).name = "TileManager";
            }
        }
Example #6
0
        static AssetDatabase InitializeDatabase()
        {
            if (AssetDirectory == null)
            {
                throw new Exception("Assets directory was null");
            }

            if (AssetManifest == null)
            {
                throw new Exception("Assets manifest was null");
            }

            return(AssetProcessor.buildDatabase(Manifest, AssetDirectory, AssetOverrideDirectory));
        }
Example #7
0
        /// <summary>
        /// Reset to Unity's standard font, "Arial".
        /// </summary>
        private void ResetFontButton()
        {
            EditorGUILayout.Space();

            if (GUILayout.Button("Reset Font"))
            {
                var selctedFont = StringLibrary.ARIAL;

                AssetProcessor.CreateDefaultTextAsset();
                GlobalTextSettings.TextSettings = AssetProcessor.LoadTextAsset(selctedFont);

                hierarchyListener.Listen();

                fontDisplayName = selctedFont;
                RepaintAll();
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="processor"></param>
        /// <param name="fileName"></param>
        void BuildAsset(AssetProcessor processor, string[] args, AssetSource assetFile, ref BuildResult buildResult)
        {
            try {
                //	Is up-to-date?
                if (!context.Options.ForceRebuild)
                {
                    if (!Wildcard.Match(assetFile.KeyPath, context.Options.CleanPattern, true))
                    {
                        if (!context.Options.Files.Contains(assetFile.KeyPath))
                        {
                            if (assetFile.IsUpToDate)
                            {
                                buildResult.UpToDate++;
                                return;
                            }
                        }
                    }
                }


                var keyPath = assetFile.KeyPath;

                if (keyPath.Length > 40)
                {
                    keyPath = "..." + keyPath.Substring(keyPath.Length - 40 + 3);
                }

                Log.Message("{0,-40} {1,-5}   {3}", keyPath, Path.GetExtension(keyPath), string.Join(" ", args), assetFile.Hash);

                // Apply attribute :
                var parser = new CommandLineParser(processor.GetType());
                parser.OptionLeadingChar = '/';

                parser.ParseCommandLine(processor, args);

                //
                //	Build :
                //
                processor.Process(assetFile, context);

                buildResult.Succeded++;
            } catch (Exception e) {
                Log.Error("{0} : {1}", assetFile.KeyPath, e.Message);
                buildResult.Failed++;
            }
        }
Example #9
0
    public static void FindOrCreate()
    {
        GameObject tempController = GameObject.FindGameObjectWithTag("GameController");

        if (tempController == null)
        {
#if UNITY_EDITOR
            tempController = AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefabMisc, AssetPaths.GameControllerName);
#else
            tempController = ResourceManager.instance.gameController;
#endif
            Instantiate(tempController).name = AssetPaths.GameControllerName;
            return;
        }
        else
        {
            return;
        }
    }
        private void SetupLevelBlocks()
        {
            GameObject block = null;

            for (int i = 0; i < 3; i++)
            {
                GameObject temp = Instantiate(ResourceManager.instance.mainMenuPlane) as GameObject;
                temp.transform.parent   = this.transform;
                temp.transform.position = new Vector3(thisObject.transform.position.x + (i * this.distanceBetweenPage) + 2.5f, thisObject.gameObject.transform.position.y - 1.0f, thisObject.transform.position.z + 0.5f);
                for (int r = 0; r < this._row; r++)
                {
                    for (int c = 0; c < this._col; c++)
                    {
#if UNITY_EDITOR
                        block = (GameObject)Instantiate(AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefabMainMenu + "Blocks/", AssetPaths.LevelNumberBlockName));
#else
                        block = (GameObject)Instantiate(ResourceManager.instance.levelNumberBlock);
#endif
                        block.GetComponent <LevelBlockButton>().SetID(this._count + 1);
                        if (i >= 1)
                        {
                            block.transform.position = new Vector3(thisObject.transform.position.x + (this.distanceBetweenPage * i) + c * 1, thisObject.gameObject.transform.position.y - r, thisObject.transform.position.z);
                        }
                        else
                        {
                            block.transform.position = new Vector3(thisObject.transform.position.x + c * 1, thisObject.gameObject.transform.position.y - r, thisObject.transform.position.z);
                        }

                        block.transform.parent          = thisObject.transform;
                        this._aLevelBlocks[this._count] = block;
                        this._levelBlocks.Add(block);

                        this._count++;

                        if (this._count >= MazeInfo.MaxMazeLength)
                        {
                            break;
                        }
                    }
                }
            }
        }
Example #11
0
        private void SetMiscMaterial()
        {
            switch (this.FirstDirection)
            {
            case BlockInfo.BlockDirection.UP:
                this._arrowUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Up/", "Up-Up");
                this._arrowDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Down/", "Up-Down");
                break;

            case BlockInfo.BlockDirection.RIGHT:
                this._arrowUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Up/", "Right-Up");
                this._arrowDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Down/", "Right-Down");
                break;

            case BlockInfo.BlockDirection.DOWN:
                this._arrowUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Up/", "Down-Up");
                this._arrowDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Down/", "Down-Down");
                break;

            case BlockInfo.BlockDirection.LEFT:
                this._arrowUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Up/", "Left-Up");
                this._arrowDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Normal/Standard/Down/", "Left-Down");
                break;
            }

            if (this.BlockState == BlockInfo.BlockState.UP)
            {
                this.blockMaterials[1] = this._arrowUpMaterial;
            }
            else
            {
                if (this.isUp)
                {
                    this.blockMaterials[1] = this._arrowUpMaterial;
                }
                else
                {
                    this.blockMaterials[1] = this._arrowDownMaterial;
                }
            }
        }
Example #12
0
        private void SetMiscMaterial()
        {
            Material glassMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Glass/", "Glass");

            if (this.glassBlock != null)
            {
                this.glassBlock.GetComponent <GlassCollider>().blockRenderer = this.glassBlock.GetComponent <MeshRenderer>();
                this.glassBlock.GetComponent <GlassCollider>().blockRenderer.sharedMaterial = glassMaterial;
            }
            else
            {
                this.glassBlock = this.transform.GetChild(0).gameObject;
                if (this.glassBlock != null)
                {
                    this.glassBlock.GetComponent <GlassCollider>().blockRenderer = this.glassBlock.GetComponent <MeshRenderer>();
                    this.glassBlock.GetComponent <GlassCollider>().blockRenderer.sharedMaterial = glassMaterial;
                }
                else
                {
                    throw new System.ArgumentNullException("Can Not Find The Glass Block.");
                }
            }
        }
Example #13
0
        public static void FindOrCreate()
        {
            GameObject tempController = GameObject.FindGameObjectWithTag("SoundController");

            if (tempController == null)
            {
#if UNITY_EDITOR
                tempController = AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefabMisc, AssetPaths.SoundControllerName);
#else
                tempController = ResourceManager.instance.soundController;
#endif
                var audio = tempController.GetComponent <AudioSource>() as AudioSource;
                audio.rolloffMode   = AudioRolloffMode.Linear;
                audio.minDistance   = 50.0f;
                audio.volume        = 0.2f;
                tempController      = Instantiate(tempController) as GameObject;
                tempController.name = AssetPaths.SoundControllerName;
                if (GameController.instance.gameState == GlobalInfo.GameState.MENU)
                {
                    tempController.transform.parent = Camera.main.transform;
                }
            }
        }
Example #14
0
        /// <summary>
        /// Finds the Spawn Blocks To Genereate The Player And AI Objects.
        /// </summary>
        public void GeneratePlayers()
        {
            var humanSpawnPoint = this.humanSpawnPoint;
            var aiSpawnPoint    = this.aiSpawnPoint;

            if (humanSpawnPoint == aiSpawnPoint)
            {
                humanSpawnPoint = new Vector3(0 + BlockInfo.BlockWidth * 0.5f, 2.5f, 0 + BlockInfo.BlockBreadth * 0.5f);
                aiSpawnPoint    = new Vector3((this.columns * BlockInfo.BlockWidth) - (BlockInfo.BlockWidth * 0.5f), 2.5f, (this.rows * BlockInfo.BlockBreadth) - (BlockInfo.BlockBreadth * 0.5f));
            }
            else
            {
                humanSpawnPoint = new Vector3(humanSpawnPoint.x + (BlockInfo.BlockWidth * 0.5f), 2.5f, humanSpawnPoint.z + (BlockInfo.BlockBreadth * 0.5f));
                aiSpawnPoint    = new Vector3(aiSpawnPoint.x + (BlockInfo.BlockWidth * 0.5f), 2.5f, aiSpawnPoint.z + (BlockInfo.BlockBreadth * 0.5f));
            }
#if UNITY_EDITOR
            Instantiate((GameObject)AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefabPlayer, AssetPaths.PlayerName), humanSpawnPoint, Quaternion.identity);
            Instantiate((GameObject)AssetProcessor.FindAsset <GameObject>(AssetPaths.PathPrefabPlayer, AssetPaths.AIName), aiSpawnPoint, Quaternion.identity);
#else
            Instantiate((GameObject)ResourceManager.instance.playerObject, humanSpawnPoint, Quaternion.identity);
            Instantiate((GameObject)ResourceManager.instance.aiObject, aiSpawnPoint, Quaternion.identity);
#endif
        }
Example #15
0
        private void init()
        {
            overrideDirectory = ProgramSettings.get("ASSETS_OVERRIDE_DIR");
            assetsDirectory   = ProgramSettings.get("ASSETS_DIR");
            if (assetsDirectory == null)
            {
                throw new Exception("Assets directory was null");
            }
            assetsManifest = ProgramSettings.get("ASSETS_MANIFEST");
            if (assetsManifest == null)
            {
                throw new Exception("Assets manifest was null");
            }


            if (overrideDirectory != null)
            {
                Debug.Log("Detected override directory, checking for validity");
                // check the override directory for a manifest
                string manifestName       = Path.GetFileName(assetsManifest);
                string overriddenManifest = overrideDirectory + Path.DirectorySeparatorChar + manifestName;
                Debug.Log("checking for overriden manifest:" + overriddenManifest);
                if (File.Exists(overriddenManifest))
                {
                    assetsManifest = overriddenManifest;
                    Debug.Log("Found overriden manifest");
                }
                else
                {
                    Debug.Log("No valid overide manifest found");
                }
            }

            manifest = new Manifest(assetsManifest);
            db       = AssetProcessor.buildDatabase(manifest, assetsDirectory, overrideDirectory);
        }
Example #16
0
 private void SetMiscMaterial()
 {
     this.switchUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Switch/Standard/", "Up");
     this.switchDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Switch/Standard/", "Down");
 }
Example #17
0
 private void SetMiscMaterial()
 {
     this.stunUpMaterial   = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Stun/Standard/", "Stun-Up");
     this.stunDownMaterial = AssetProcessor.FindAsset <Material>("Assets/Models/Block/Material/Stun/Standard/", "Stun-Down");
 }
 public AssetsController(AssetProcessor assetProcessor)
 {
     _assetProcessor = assetProcessor;
 }
        public static void InitialiseTileSets()
        {
            LoadedTileSets = new Dictionary <int, TerrainTileSet>();

            AssetProcessor.LoadTerrainTileSets();
        }
Example #20
0
 /// <summary>
 /// Checks if a TextData assets is created, else it creates one.
 /// </summary>
 private void SetGlobalFontData(Font selectedFont)
 {
     GlobalTextSettings.TextSettings = AssetProcessor.SetGlobalFont(selectedFont);
     GlobalTextSettings.UpdateProperties();
     RepaintAll();
 }
Example #21
0
        /// <summary>
        /// Draw a block at the pre-calculated mouse hit position.
        /// </summary>
        private void Draw()
        {
            // gets the reference to the grid map component/gameobject the script is connected to (GridController).
            var map = (GridMap)this.target;

            // calculates the position of the mouse over the grid layer.
            var gridPosition = this.GetGridPositionFromMouseLocation();

            // given the grid position check to see if a block has already been created at that location.
            var block = GameObject.Find(string.Format(_blockName, gridPosition.x, gridPosition.z));

            if (map.blockToPlace == BlockInfo.BlockTypes.NONE)
            {
                return;
            }

            // if there is already a block present at the location and is a child of the grid map component we can just leave it and exit this function.
            if (block != null && block.transform.parent == map.transform)
            {
                var tempSwitch = block.GetComponent <SwitchBlock>();
                if (tempSwitch != null)
                {
                    tempSwitch.RemoveAllBlocks(ref map.blockList);
                }

                var tempSwitchBlock = block.GetComponent <SwitchEmptyBlock>();
                if (tempSwitchBlock != null)
                {
                    tempSwitchBlock.RemoveFromParent();
                }

                var tempWarpBlock = block.GetComponent <WarpBlock>();
                if (tempWarpBlock != null)
                {
                    tempWarpBlock.RemoveWarpNode(ref map.blockList);
                }

                map.blockList.Remove(block);
                UnityEngine.Object.DestroyImmediate(block);
                block = null;
            }

            // if no game object was found we will create one.
            if (block == null)
            {
                if (map.blockToPlace == BlockInfo.BlockTypes.NORMAL)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.NormalBlockName);
                    block.GetComponent <NormalBlock>().blockRenderer = block.GetComponent <MeshRenderer>() as MeshRenderer;
                    block.GetComponent <NormalBlock>().SetupBlock(map.blockToPlace, map.blockOneDirection, map.blockState);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.MULTI)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.MultiBlockName);
                    block.GetComponent <MultiBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <MultiBlock>().SetupBlock(map.blockToPlace, map.blockOneDirection, map.blockTwoDirection, map.blockState);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.NUMBER)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.NumberBlockName);
                    block.GetComponent <NumberBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <NumberBlock>().SetupBlock(map.blockToPlace, map.blockState, map.blockNumber);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.STUN)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.StunBlockName);
                    block.GetComponent <StunBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <StunBlock>().SetupBlock(map.blockToPlace, map.blockState, map.blockNumber);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.SWITCH)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.SwitchBlockName);
                    block.GetComponent <SwitchBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <SwitchBlock>().SetupBlock(map.blockToPlace, map.blockState);
                    map.blockList.Add(block);
                    this._switchParentNode    = block;
                    this._switchPointSet      = true;
                    this._switchBlockCount    = 0;
                    this._target.blockToPlace = BlockInfo.BlockTypes.SWTICH_EMPTY;
                    if (this.blockWindow != null)
                    {
                        this.blockWindow.Focus();
                    }
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.SWTICH_EMPTY)
                {
                    this._switchBlockCount++;

                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.SwitchEmptyBlockName);
                    block.GetComponent <SwitchEmptyBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <SwitchEmptyBlock>().SetupBlock(map.blockToPlace, map.blockState);
                    block.GetComponent <SwitchEmptyBlock>().SetParentNode(this._switchParentNode);
                    map.blockList.Add(block);
                    this._switchParentNode.GetComponent <SwitchBlock>().AddEmptyBlock(block);

                    if (this.blockWindow != null)
                    {
                        this.blockWindow.Focus();
                    }

                    if (this._switchBlockCount == map.switchBlockCount)
                    {
                        this._switchParentNode = null;
                        this._switchPointSet   = false;
                        this._switchBlockCount = 0;
                        map.blockToPlace       = BlockInfo.BlockTypes.SWITCH;
                        if (this.blockWindow != null)
                        {
                            this.blockWindow.Focus();
                        }
                    }
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.EMPTY)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.EmptyBlockName);
                    block.GetComponent <EmptyBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <EmptyBlock>().SetupBlock(map.blockToPlace, map.blockState);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.EMPTY_TALL)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.EmptyTallBlockName);
                    block.GetComponent <EmptyBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <EmptyBlock>().SetupBlock(map.blockToPlace);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.INVISIBLE)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.InvisibleBlock);
                    map.blockList.Add(block);
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.WARP)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.WarpBlockName);
                    block.GetComponent <WarpBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <WarpBlock>().SetupBlock(map.blockToPlace, map.blockOneDirection, map.blockState);
                    map.blockList.Add(block);
                    this._warpParentNode = block;
                    map.blockToPlace     = BlockInfo.BlockTypes.WARP_NODE;
                    if (this.blockWindow != null)
                    {
                        this.blockWindow.Focus();
                    }
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.WARP_NODE)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.WarpBlockName);
                    block.GetComponent <WarpBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <WarpBlock>().SetupBlock(BlockInfo.BlockTypes.WARP, map.blockOneDirection, map.blockState);
                    block.GetComponent <WarpBlock>().AddWarpNode(this._warpParentNode);
                    this._warpParentNode.GetComponent <WarpBlock>().AddWarpNode(block);
                    map.blockList.Add(block);

                    this._warpParentNode = null;
                    map.blockToPlace     = BlockInfo.BlockTypes.WARP;
                    if (this.blockWindow != null)
                    {
                        this.blockWindow.Focus();
                    }
                }
                else if (map.blockToPlace == BlockInfo.BlockTypes.GLASS)
                {
                    block = AssetProcessor.InstantiatePrefab <GameObject>(AssetPaths.PathPrefabBlocks, AssetPaths.GlassBlockName);
                    block.GetComponent <GlassBlock>().blockRenderer = block.GetComponent <MeshRenderer>();
                    block.GetComponent <GlassBlock>().SetupBlock(BlockInfo.BlockTypes.GLASS, map.blockState, map.blockNumber);
                    map.blockList.Add(block);
                }
                else
                {
                    Debug.LogError("NOTHING TO CREATE.");
                }
            }

            Vector3 blockPositionInLocalSpace = new Vector3();

            // set the block position on the grid map.
            if (map.blockToPlace == BlockInfo.BlockTypes.EMPTY_TALL)
            {
                blockPositionInLocalSpace = new Vector3((gridPosition.x * map.BlockWidth) + (map.BlockWidth * 0.5f), 1.0f, (gridPosition.z * map.BlockBreadth));
            }
            else if (map.blockToPlace == BlockInfo.BlockTypes.INVISIBLE)
            {
                blockPositionInLocalSpace = new Vector3((gridPosition.x * map.BlockWidth) + (map.BlockWidth * 0.5f), 1.5f, (gridPosition.z * map.BlockBreadth));
            }
            else
            {
                if (map.blockState == BlockInfo.BlockState.UP)
                {
                    blockPositionInLocalSpace = new Vector3((gridPosition.x * map.BlockWidth) + (map.BlockWidth * 0.5f), 1.0f, (gridPosition.z * map.BlockBreadth));
                }
                else
                {
                    blockPositionInLocalSpace = new Vector3((gridPosition.x * map.BlockWidth) + (map.BlockWidth * 0.5f), 0.0f, (gridPosition.z * map.BlockBreadth));
                }
            }
            block.transform.position = map.transform.position + blockPositionInLocalSpace;

            // we scale the block to the grid sizes defined by the BlockWidth and BlockHeight fields.
            if (map.blockToPlace == BlockInfo.BlockTypes.EMPTY_TALL)                              // NEED TO GET RID OF LATER.
            {
                block.transform.localScale = new Vector3(map.BlockWidth, 3.0f, map.BlockBreadth); // NEED TO GET RID OF LATER.
            }
            else // NEED TO GET RID OF LATER.
            {
                block.transform.localScale = new Vector3(map.BlockWidth, map.BlockHeight, map.BlockBreadth);
            }

            // we set the block as a child to the parent.
            block.transform.parent = map.transform;

            // give the block a name that will represent its location on the grid.
            block.name = string.Format(_blockName, gridPosition.x, gridPosition.z);
        }
 public PairsController(PairConfigProcessor pairConfigProcessor, AssetProcessor assetProcessor)
 {
     _pairConfigProcessor = pairConfigProcessor;
     _assetProcessor      = assetProcessor;
 }
Example #23
0
 /// <summary>
 /// Initializes the asset's load function.
 /// </summary>
 /// <param name="processor">Function called whenever the asset is reloaded.</param>
 /// <returns>Asset builder.</returns>
 public AssetBuilder <T> Create(AssetProcessor processor)
 {
     this.processor = processor;
     return(this);
 }