示例#1
0
    void Start()
    {
        inst = FindObjectOfType <Instanciator>();

        shakeCamera = FindObjectOfType <ShakeCamera>();

        player = FindObjectOfType <Player>();
    }
示例#2
0
 private void Start()
 {
     if (mainMenuUI == true)
     {
         Time.timeScale = 0f;
     }
     inst   = FindObjectOfType <Instanciator>();
     player = FindObjectOfType <Player>();
     canvas = FindObjectOfType <Canvas>();
 }
示例#3
0
 /// <summary>
 /// It initializes the pool instantiating as many clones of "generator" as indicated in "initCapacity", under the
 /// gameObject "folder".
 /// </summary>
 /// <param name="initCapacity">Initial number of clones.</param>
 /// <param name="generator">Original GameObject from which clones will be generated.</param>
 /// <param name="folder">GameObject folder where the clones will be located.</param>
 public void InitPool(int initCapacity, GameObject generator, GameObject folder)
 {
     _enemyPool = new List <GameObject>(initCapacity);
     for (int i = 0; i < initCapacity; ++i)
     {
         GameObject newEnemy = Instanciator.InstantiateGameObject(generator, Vector3.zero, Quaternion.Euler(0, 0, 0));
         newEnemy.transform.parent = folder.transform;
         newEnemy.name             = "Enemy" + folder.transform.childCount;
         _enemyPool.Add(newEnemy);
     }
 }
示例#4
0
    void Start()
    {
        inst = FindObjectOfType <Instanciator>();

        //shakeCamera = GetComponent<ShakeCamera>();
        shakeCamera = FindObjectOfType <ShakeCamera>();

        player = FindObjectOfType <Player>();
        if (heart != null)
        {
            heart.SetInteger("life", -1);
        }
    }
示例#5
0
        /// <summary>
        /// It also is in charge of instantiating the corresponding Sprite in the world position corresponding to the position
        /// in the matrix.
        /// After instantiating a block Sprite, it calls its Block component to assign its required shadows.
        /// <seealso cref="BlockType"/>
        /// <seealso cref="Tuple{T1, T2}"/>
        /// </summary>
        /// <param name="blockPosition">World position base which will be used as reference to instantiate block Sprite.</param>
        /// <param name="matrixCoord">Position of the current tile in the matrix, used only to naming the instantiated block Sprite.</param>
        /// <param name="altitude">Number of blocks to storage in the current tile and the type of the top one. From 0 to 2</param>
        /// <param name="mapBlocks">Dictionary with the actual block Sprite to instantiate corresponding to each type of block.</param>
        /// <param name="mapFolder">GameObject folder under which instantiate the block Sprite.</param>
        /// <param name="waterBlock">Block Sprite with water.</param>
        /// <param name="shapeMap">Matrix with all altitudes, used by storage's top Block Component to assign shadows.</param>
        public MapTile(Vector3 blockPosition, Vector2 matrixCoord, Tuple <int, BlockType> altitude,
                       Dictionary <BlockType, GameObject> mapBlocks, GameObject mapFolder, GameObject waterBlock, Tuple <int, BlockType>[][] shapeMap)
        {
            //First we create a base of two sprites representing the ground level.

            GameObject newBlock = Instanciator.InstantiateGameObject(mapBlocks[BlockType.Base], blockPosition, mapBlocks[BlockType.Base].transform.rotation);

            //First base sprite
            newBlock.name             = matrixCoord.x + "-" + matrixCoord.y + "-0";
            newBlock.transform.parent = mapFolder.transform;
            newBlock.SetActive(true);

            // VERTICAL_DIST_TILE is used to locate following block Sprites in higher positions in order to simulate
            // block storage.
            blockPosition.y += VERTICAL_DIST_TILE;

            // Z world position must be also closer to the camera for the higher blocks to conceal partially the lower ones.
            blockPosition.z -= 0.1f;

            //For the second base sprite, the type of the altitude's top block is checked. In case that it is water,
            // a water Sprite is instantiated
            if (altitude.Second == BlockType.Water)
            {
                newBlock = Instanciator.InstantiateGameObject(waterBlock, blockPosition, waterBlock.transform.rotation);
            }
            else
            {
                newBlock = Instanciator.InstantiateGameObject(mapBlocks[BlockType.Base], blockPosition, mapBlocks[BlockType.Base].transform.rotation);
            }

            newBlock.name             = matrixCoord.x + "-" + matrixCoord.y + "-1";
            newBlock.transform.parent = mapFolder.transform;
            newBlock.SetActive(true);

            //Finally, the class instantiates block Sprites until reaching the top one, whose type is defined by altitude.Second
            for (int i = 0; i < altitude.First; ++i)
            {
                blockPosition.y += VERTICAL_DIST_TILE;
                blockPosition.z -= 0.1f;

                //Between the ground and the top there must be always blocks of Floor type.
                if (i < altitude.First - 1)
                {
                    newBlock = Instanciator.InstantiateGameObject(mapBlocks[BlockType.Floor], blockPosition, mapBlocks[BlockType.Floor].transform.rotation);
                }
                else
                {
                    newBlock = Instanciator.InstantiateGameObject(mapBlocks[altitude.Second], blockPosition, mapBlocks[altitude.Second].transform.rotation);
                }

                newBlock.transform.parent = mapFolder.transform;
                newBlock.name             = matrixCoord.x + "-" + matrixCoord.y + "-" + (2 + i);
                newBlock.SetActive(true);
            }

            //The method GenerateShadows is called to assign every needed shadow Sprite.
            newBlock.GetComponent <Block>().GenerateShadows(shapeMap, shapeMap.Length, shapeMap[(int)matrixCoord.x].Length, (int)matrixCoord.x, (int)matrixCoord.y);

            //The position of the top block is storage for future uses.
            _topBlockPosition = newBlock.transform.position;
        }