Esempio n. 1
0
    /// <summary>
    /// Called when a block takes damage.
    /// </summary>
    /// <param name="block">the block damaged.</param>
    private void EventBlockDamaged(BreakableBlock block)
    {
        // if this isn't our block we dont care.
        if (block.transform.parent != transform)
        {
            return;
        }
        //exit if we can't deal damage.
        if (!CanDamage)
        {
            return;
        }

        // unsubscribe this block since it will have a damaged color.
        OnUpdateColor -= block.ChangeColor;

        var healthPercent = block.Health / block.MaxHealth;

        // Only bother coloring the block if it's not dead.
        if (healthPercent > 0f)
        {
            block.ChangeColor(Color.Lerp(new Color(1f, 1f, 1f, 0f), Color.white, healthPercent));
        }

        // only update colors if we're getting darker.
        if (_lastHealthPercent > healthPercent)
        {
            UpdateBlockColors(healthPercent);
        }

        // store for later.
        _lastHealthPercent = healthPercent;
    }
Esempio n. 2
0
    private IEnumerator CreateExplosions(Vector3 direction)
    {
        // Loop through all range of Explosion
        for (int i = 1; i < 3; i++)
        {
            RaycastHit hit;
            Physics.Raycast(transform.position + new Vector3(0, .5f, 0), direction, out hit, i, levelMask);

            // If there is no collider there
            if (!hit.collider)
            {
                // Spawn the explosion effect
                Instantiate(explosionPrefab, transform.position + (i * direction), explosionPrefab.transform.rotation);
            }
            else
            {
                // It hit something!
                BreakableBlock breakable = hit.collider.GetComponent <BreakableBlock>();
                if (breakable)
                {
                    breakable.TakeDamage(damage);
                }
            }
            yield return(new WaitForSeconds(.05f));
        }
    }
Esempio n. 3
0
    void AddBlock(Vector2Int pos)
    {
        blockLocations.Add(pos);
        BreakableBlock block = Instantiate(blockPrefab);

        block.transform.parent        = entityContainer.transform;
        block.transform.localPosition = new Vector3(pos.x, pos.y);
    }
Esempio n. 4
0
 public AstNodeBuilder(ISequenceReader <Token> reader,
                       BreakableBlock block,
                       string[] interceptChars,
                       OperatorNode node) : base(reader, block)
 {
     _interceptChars = interceptChars;
     _hasParent      = true;
     _currentNode    = node;
 }
Esempio n. 5
0
        public AstNodeBuilder(ISequenceReader <Token> reader,
                              BreakableBlock block,
                              string[] interceptChars,
                              bool hasparent = false) : base(reader, block)

        {
            _interceptChars = interceptChars;
            _hasParent      = hasparent;
        }
Esempio n. 6
0
    /// <summary>
    /// Called when a block attached to this bar dies.
    /// </summary>
    /// <param name="block">the block that is going to be destroyed</param>
    private void EventBlockBreak(BreakableBlock block)
    {
        // if this isn't our block we don't care.
        if (block.transform.parent != transform)
        {
            return;
        }

        UpdateBlockColors(0f);
        CanDamage = false;
        Blocks.ForEach(b => { b.CanDamage = CanDamage; });
    }
Esempio n. 7
0
        private Expression buildReturnExpression(BreakableBlock block)
        {
            var expNode = new AstNodeBuilder(_reader, block, _interceptChars).Build();

            var retNode = OperatorNodeFactory.CreateReturn(block);

            retNode.Operands.Add(expNode);

            var exp = new Expression(block);

            exp.Root = retNode;

            return(exp);
        }
Esempio n. 8
0
    void FixedUpdate()
    {
        var brokenBlock = BreakBlock();

        if (brokenBlock != prevBlock)
        {
            if (prevBlock)
            {
                prevBlock.RevertBreak();
            }

            prevBlock = brokenBlock;
        }
    }
Esempio n. 9
0
 public static ContinueNode CreateContinue(BreakableBlock block)
 {
     return(new ContinueNode(block));
 }
Esempio n. 10
0
 public static BreakNode  CreateBreak(BreakableBlock block)
 {
     return(new BreakNode(block));
 }
Esempio n. 11
0
 public FunctionBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 12
0
 public FunctionDefineExpression(BreakableBlock parent) : base(parent)
 {
 }
Esempio n. 13
0
 public TryCatchFinallyBlockBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 14
0
 public FinallyBlock(BreakableBlock parent) : base(parent)
 {
 }
Esempio n. 15
0
 public ObjectLiteralBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 16
0
 public ElseBlockBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 17
0
 public ArrayIndexBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 18
0
 public CatchBlock(BreakableBlock parent) : base(parent)
 {
 }
Esempio n. 19
0
 public BreakNode(BreakableBlock block)
 {
     Block = block;
 }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        totalSpaces = rows * columns;

        if (testing)
        {
            Random.InitState(seed);
        }

        levelGrid = new BlockType[rows, columns];

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                rand = Random.Range(0.0f, 20.0f);
                if (rand <= 9.0f)
                {
                    levelGrid[i, j] = BlockType.breakable;
                }
                if (rand <= 13.5f && rand > 9.0f)
                {
                    levelGrid[i, j] = BlockType.unbreakable;
                }
                if (rand <= 20 && rand > 13.5f)
                {
                    levelGrid[i, j] = BlockType.empty;
                }
            }
        }



        levelGrid[0, columns - 2] = BlockType.empty;
        levelGrid[0, columns - 1] = BlockType.player;
        levelGrid[1, columns - 1] = BlockType.empty;

        levelGrid[rows - 2, 0] = BlockType.empty;
        levelGrid[rows - 1, 0] = BlockType.player2;
        levelGrid[rows - 1, 1] = BlockType.empty;



        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                if (levelGrid[i, j] == BlockType.breakable)
                {
                    Vector3        breakPos = new Vector3(startPos.x + blockSize.x * i, startPos.y + blockSize.y, startPos.z - blockSize.z * j);
                    BreakableBlock block    = Instantiate(Breakable, breakPos, Quaternion.identity) as BreakableBlock;
                    if (block != null)
                    {
                        block.bm    = this;
                        block.sm    = this.sm;
                        block.range = this.range;
                        block.limit = this.limit;
                        block.speed = this.speed;
                        block.row   = i;
                        block.col   = j;
                    }
                }

                if (levelGrid[i, j] == BlockType.unbreakable)
                {
                    Vector3 unBreakPos = new Vector3(startPos.x + blockSize.x * i, startPos.y + blockSize.y, startPos.z - blockSize.z * j);
                    Instantiate(UnBreakable, unBreakPos, Quaternion.identity);
                }

                if (levelGrid[i, j] == BlockType.player)
                {
                    Vector3           playerPos = new Vector3(startPos.x + blockSize.x * i, startPos.y + blockSize.y, startPos.z - blockSize.z * j);
                    Player_Controller player    = Instantiate(playerPrefab, playerPos, Quaternion.identity) as Player_Controller;
                    if (player != null)
                    {
                        player.name       = "Player1";
                        player.bm         = this;
                        player.sm         = this.sm;
                        player.bombPrefab = this.bombPrefab;
                        player.amIPlayer1 = true;
                    }
                }
                if (levelGrid [i, j] == BlockType.player2)
                {
                    Vector3           playerPos = new Vector3(startPos.x + blockSize.x * i, startPos.y + blockSize.y, startPos.z - blockSize.z * j);
                    Player_Controller player    = Instantiate(playerPrefab, playerPos, Quaternion.identity) as Player_Controller;
                    if (player != null)
                    {
                        player.name       = "Player2";
                        player.bm         = this;
                        player.sm         = this.sm;
                        player.bombPrefab = this.bombPrefab;
                        player.amIPlayer1 = false;
                    }
                }
            }
        }
    }
Esempio n. 21
0
 public DeclareExpression(BreakableBlock parent) : base(parent)
 {
 }
Esempio n. 22
0
 public DeclareExpressionBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 23
0
 public ExpressionBuilder(ISequenceReader <Token> reader, bool doCheck, BreakableBlock block) : base(reader, block)
 {
     _doCheck = doCheck;
 }
Esempio n. 24
0
 public DoWhileScopeBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
Esempio n. 25
0
 public ElseBlock(BreakableBlock parent) : base(parent)
 {
 }
Esempio n. 26
0
 public ContinueNode(BreakableBlock block) : base(block)
 {
 }
Esempio n. 27
0
 public ParenthesisBuilder(ISequenceReader <Token> reader, BreakableBlock block) : base(reader, block)
 {
 }
 private void OnBlockDied(BreakableBlock block)
 {
     // save our next aiming x.
     _attackController.NextAimLocationX = block.transform.position.x;
 }
Esempio n. 29
0
 private void EventBlockBreak(BreakableBlock block)
 {
     NextAimLocationX = block.transform.position.x;
 }
Esempio n. 30
0
 public TryBlock(BreakableBlock parent) : base(parent)
 {
 }