Ejemplo n.º 1
0
    public TempleWallBlock GetBlockAtPosition(WallBlockPosition wallPos)
    {
        switch (wallPos)
        {
        case WallBlockPosition.TopLeft:
            return(topLeft);

        case WallBlockPosition.TopCenter:
            return(topCenter);

        case WallBlockPosition.TopRight:
            return(topRight);

        case WallBlockPosition.MiddleLeft:
            return(middleLeft);

        case WallBlockPosition.MiddleCenter:
            return(middleCenter);

        case WallBlockPosition.MiddleRight:
            return(middleRight);

        case WallBlockPosition.BottomLeft:
            return(bottomLeft);

        case WallBlockPosition.BottomCenter:
            return(bottomCenter);

        case WallBlockPosition.BottomRight:
            return(bottomRight);
        }

        return(null);
    }
Ejemplo n.º 2
0
    public void IntegrateNewBlock(TempleWallBlock newBlock, WallBlockType blockType, WallBlockPosition wallPos)
    {
        Transform oldBlockTransform = GetBlockTransform(wallPos);

        CodeTools.CopyTransform(oldBlockTransform, newBlock.transform, true, true, false);

        DisableBlock(wallPos);

        AssignBlockToPosition(newBlock, wallPos);
    }
Ejemplo n.º 3
0
 public bool DoesItFit(WallBlockType blockType, TempleWall wall, WallBlockPosition blockPos)
 {
     if (wall.GetBlockAtPosition(blockPos).blockType == WallBlockType.Block)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
    private GameObject WallBlockGO(WallBlockType b, TempleWall wall, WallBlockPosition pos)
    {
        switch (b)
        {
        case WallBlockType.Alcove:
            if (TempleWall.PositionIsTop(pos))
            {
                return(alcovePrefab_top);
            }
            else if (TempleWall.PositionIsMiddle(pos))
            {
                return(alcovePrefab_middle);
            }
            else if (TempleWall.PositionIsBottom(pos))
            {
                return(alcovePrefab_bottom);
            }
            else
            {
                Debug.LogError("Invalid wall position, apparently.");
                return(null);
            }


        case WallBlockType.ArrowTrap:
            if (TempleWall.PositionIsTop(pos))
            {
                if (gameplayManager.DEBUG_angledTopArrow)
                {
                    return(arrowTrapPrefab_topAngled);
                }
                else
                {
                    return(arrowTrapPrefab_top);
                }
            }
            else if (TempleWall.PositionIsMiddle(pos))
            {
                return(arrowTrapPrefab_middle);
            }
            else if (TempleWall.PositionIsBottom(pos))
            {
                return(arrowTrapPrefab_bottom);
            }
            else
            {
                Debug.LogError("Invalid wall position, apparently.");
                return(null);
            }
        }

        return(null);
    }
Ejemplo n.º 5
0
    private void AssignBlockToPosition(TempleWallBlock newBlock, WallBlockPosition wallPos)
    {
        switch (wallPos)
        {
        case WallBlockPosition.TopLeft:
            topLeft = newBlock;
            break;

        case WallBlockPosition.TopCenter:
            topCenter = newBlock;
            break;

        case WallBlockPosition.TopRight:
            topRight = newBlock;
            break;

        case WallBlockPosition.MiddleLeft:
            middleLeft = newBlock;
            break;

        case WallBlockPosition.MiddleCenter:
            middleCenter = newBlock;
            break;

        case WallBlockPosition.MiddleRight:
            middleRight = newBlock;
            break;

        case WallBlockPosition.BottomLeft:
            bottomLeft = newBlock;
            break;

        case WallBlockPosition.BottomCenter:
            bottomCenter = newBlock;
            break;

        case WallBlockPosition.BottomRight:
            bottomRight = newBlock;
            break;
        }

        return;
    }
Ejemplo n.º 6
0
    public void SpawnBlock(WallBlockType blockType, TempleWall wall, WallBlockPosition wallPos)
    {
        // fetch the GO prefab using the enum
        GameObject toSpawn = WallBlockGO(blockType, wall, wallPos);

        GameObject newBlockGO = (GameObject)Instantiate(toSpawn) as GameObject;

        newBlockGO.transform.parent = wall.transform;
        TempleWallBlock newBlock = newBlockGO.GetComponent <TempleWallBlock>();

        newBlock.blockPosition = wallPos;

        // this happens automatically assuming the new block gets parented under "Environment" so, not necessary
//        if (transform.localScale != Vector3.one)
//           newBlock.ScaleSelf(transform.localScale);

        newBlockGO.transform.localScale = Vector3.Scale(newBlockGO.transform.localScale, transform.localScale);


        wall.IntegrateNewBlock(newBlock, blockType, wallPos);
    }
Ejemplo n.º 7
0
 public static bool PositionIsBottom(WallBlockPosition wallPos)
 {
     return((wallPos == WallBlockPosition.BottomCenter) || (wallPos == WallBlockPosition.BottomLeft) || (wallPos == WallBlockPosition.BottomRight));
 }
Ejemplo n.º 8
0
 public static bool PositionIsMiddle(WallBlockPosition wallPos)
 {
     return((wallPos == WallBlockPosition.MiddleCenter) || (wallPos == WallBlockPosition.MiddleLeft) || (wallPos == WallBlockPosition.MiddleRight));
 }
Ejemplo n.º 9
0
 public static bool PositionIsTop(WallBlockPosition wallPos)
 {
     return((wallPos == WallBlockPosition.TopCenter) || (wallPos == WallBlockPosition.TopLeft) || (wallPos == WallBlockPosition.TopRight));
 }
Ejemplo n.º 10
0
    public Transform GetBlockTransform(WallBlockPosition wallPos)
    {
        TempleWallBlock block = GetBlockAtPosition(wallPos);

        return(block.gameObject.transform);
    }
Ejemplo n.º 11
0
    private void DisableBlock(WallBlockPosition wallPos)
    {
        TempleWallBlock block = GetBlockAtPosition(wallPos);

        Destroy(block.gameObject);
    }
Ejemplo n.º 12
0
    void Update()
    {
        if (Time.time < timeNextBlock)
        {
            return;
        }

        timeNextBlock = Time.time + timeBetweenBlocks;

        WallBlockType nextBlockType;

        if (DEBUG_blockType1 != WallBlockType.NONE)
        {
            if (Random.Range(0, 2) == 0)
            {
                nextBlockType = DEBUG_blockType1;
            }
            else
            {
                nextBlockType = DEBUG_blockType2;
            }
        }
        else
        {
            if (Random.Range(1, (trapCount + alcoveCount + 3)) < (trapCount + 1))
            {
                nextBlockType = WallBlockType.Alcove;
            }
            else
            {
                nextBlockType = WallBlockType.ArrowTrap;
            }
        }


        bool weirdTrapThisTime = (Random.Range(0f, 1f) < 0.8f) ? true : false;

        DEBUG_angledTopArrow = weirdTrapThisTime;

        RelativeDirection wallDir  = EnvironmentManager.RandomRelativeDirection();
        WallBlockPosition blockPos = EnvironmentManager.RandomWallBlockPosition();

        if ((!weirdTrapThisTime) && (nextBlockType == WallBlockType.ArrowTrap) && (TempleWall.PositionIsBottom(blockPos)))
        {
            while (TempleWall.PositionIsBottom(blockPos))
            {
                blockPos = EnvironmentManager.RandomWallBlockPosition();
            }
        }

        int tries = 0;

        while ((!environmentManager.DoesItFit(nextBlockType, wallDir, blockPos)) && (tries < 100))
        {
            wallDir  = EnvironmentManager.RandomRelativeDirection();
            blockPos = EnvironmentManager.RandomWallBlockPosition();
            if ((!weirdTrapThisTime) && (nextBlockType == WallBlockType.ArrowTrap) && (TempleWall.PositionIsBottom(blockPos)))
            {
                while (TempleWall.PositionIsBottom(blockPos))
                {
                    blockPos = EnvironmentManager.RandomWallBlockPosition();
                }
            }

            tries++;
        }

        if (tries == 100)
        {
            return;
        }

        // decide whether to impose any prop spawns
        // this is super TMP chance for now
        float percentChance = ((Time.time - timeOfLastGoalObject) / (timeOfLastGoalObject + maxTimeTilGoalObject));

        if ((nextBlockType == WallBlockType.Alcove) && (Random.Range(0f, 1f) < percentChance))
        {
            if (!NothingInLimbo())
            {
                readyForInsertion    = RandomAvailableGoalPiece();
                timeOfLastGoalObject = Time.time;
            }
//            else
//               Debug.Log("Can't impose goal spawns because nothing is in limbo.");
        }

        environmentManager.SpawnBlock(nextBlockType, wallDir, blockPos);

        trapCount   = environmentManager.BlockCount(WallBlockType.ArrowTrap);
        alcoveCount = environmentManager.BlockCount(WallBlockType.Alcove);
    }
Ejemplo n.º 13
0
 public bool DoesItFit(WallBlockType blockType, RelativeDirection wallDir, WallBlockPosition blockPos)
 {
     return(DoesItFit(blockType, GetWallAtDirection(wallDir), blockPos));
 }
Ejemplo n.º 14
0
 public void SpawnBlock(WallBlockType blockType, RelativeDirection wallDir, WallBlockPosition wallPos)
 {
     SpawnBlock(blockType, GetWallAtDirection(wallDir), wallPos);
 }