示例#1
0
        public void SetPosition(BlockPoint point)
        {
            var x = point.X * _sizeCell;
            var y = -point.Y * _sizeCell;

            _block.anchoredPosition = new Vector2(x, y);
        }
示例#2
0
    private void InitSnack()
    {
        NowFace = Face.Face_X_Y_0;//FORCE THIS FACE
        int random = Random.Range(0, 4);

        NowMoveTo = random == 0 ? MoveTo.X : (random == 1 ? MoveTo.X_ : (random == 2 ? MoveTo.Y : MoveTo.Y_));  //excpet Z

        //Reset fruit
        int randX = Random.Range(0, BLOCK_NUM);
        int randY = Random.Range(0, BLOCK_NUM);
        int randZ = Random.Range(1, BLOCK_NUM);

        FruitBlock = new BlockPoint(randX, randY, randZ);
        //Reset snack
        SnackBlock.Clear();
        int randomX = Random.Range(0, BLOCK_NUM);
        int randomY = Random.Range(0, BLOCK_NUM);
        int randomZ = 0;

        SnackBlock.Add(new BlockPoint(randomX, randomY, randomZ));
        //Reset color
        UpdateColor();

        //Debug.Log("Snack begin at:" + randomX + "," + randomY + "," + randomZ + "--Face:" + NowFace + "--Move:" + NowMoveTo);
    }
示例#3
0
        public void Initiation(Side side)
        {
            _side = side;
            switch (side)
            {
            case Side.Down:
                _sidePoint = new BlockPoint(0, 1);
                break;

            case Side.Up:
                _sidePoint = new BlockPoint(0, -1);
                break;

            case Side.Left:
                _sidePoint = new BlockPoint(-1, 0);
                break;

            case Side.Right:
                _sidePoint = new BlockPoint(1, 0);
                break;

            default:
                _sidePoint = new BlockPoint(0, 0);
                break;
            }
        }
示例#4
0
        public void MoveTo(BlockPoint point)
        {
            var x = point.X * _sizeCell;
            var y = -point.Y * _sizeCell;

            MoveAnimator.MoveTo(new Vector2(x, y));
        }
示例#5
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "MoviengPoint")
     {
         target++;
     }
     else if (collision.tag == "Block")
     {
         BlockPoint target = collision.transform.GetComponent <BlockPoint>();
         if (!target.isDead)
         {
             saveSpeed = speed;
             speed     = 0;
             //Тут должна быть смена анимации на атаку барьера
             isBlock = true;
             block   = target;
         }
         else
         {
             speed   = saveSpeed;
             isBlock = false;
             block   = null;
         }
     }
     else if (collision.tag == "Tower")
     {
         Tower target = collision.transform.GetComponent <Tower>();
         if (!target.isDead)
         {
             saveSpeed = speed;
             speed     = 0;
             //Тут должна быть смена анимации на атаку барьера
             isBlock = true;
             tower   = target;
         }
         else
         {
             speed   = saveSpeed;
             isBlock = false;
             tower   = null;
         }
     }
     else if (collision.tag == "Projectile")
     {
         Projectile newP = collision.gameObject.GetComponent <Projectile>();
         if (newP != null)
         {
             UnitHit(newP);
         }
         Destroy(collision.gameObject);
     }
     else if (collision.tag == "Finish")
     {
         LevelManager.instance.finishedUnits.Add(baseUnit);
         LevelManager.instance.UnitList.Remove(this);
         LevelManager.instance.Finished(baseUnit);
         Destroy(gameObject);
     }
 }
示例#6
0
    /// <summary>
    /// Places a block at the given position and orientation.
    /// </summary>
    public int PlaceBlock(Block block, BlockOrientation orientation, Color color, int x, int y, bool initial = false)
    {
        block.Rotate(orientation);

        if (!CanPlaceBlock(block, x, y))
        {
            throw new InvalidOperationException("No block can be placed here! Use CanPlaceBlock() first!");
        }

        int blockId = _idCounter++;

        _blocks.Add(blockId, new BlockPlacement()
        {
            BlockId     = blockId,
            Block       = block,
            Orientation = orientation
        });

        for (int iX = 0; iX < block.Width; iX++)
        {
            for (int iY = 0; iY < block.Height; iY++)
            {
                if (block.IsFieldSet(iX, iY))
                {
                    Debug.Log("Place Block [" + x + ", " + y + "] + [" + iX + ", " + iY + "] @ " + ((y + iY) * Width + (x + iX)));
                    _blockGrid[(y + iY) * Width + (x + iX)] = blockId;
                    if (initial || !scoreHandler)
                    {
                        _blockGridBackground[(y + iY) * Width + (x + iX)] =
                            new BlockPoint()
                        {
                            Valid = true, Color = color
                        };
                    }
                    else
                    {
                        BlockPoint bp = _blockGridBackground[y * Width + x];

                        if (bp.Valid)
                        {
                            if (bp.Color == color)
                            {
                                scoreHandler.BlockScore += 25;
                            }
                            else
                            {
                                scoreHandler.BlockScore += 5;
                            }
                        }
                        else
                        {
                            scoreHandler.BlockScore -= 2;
                        }
                    }
                }
            }
        }
        return(blockId);
    }
示例#7
0
 private bool TryMove(BlockController sender, BlockPoint newPoint)
 {
     if (_blocks[newPoint.X, newPoint.Y] == null)
     {
         _blocks[sender.Position.X, sender.Position.Y] = null;
         _blocks[newPoint.X, newPoint.Y] = sender;
         sender.AcceptMove();
     }
 }
        private void Block_TryMove(BlockController sender, Side side, BlockPoint newPoint)
        {
            var nextBlock = _blocks[newPoint.X, newPoint.Y];

            if (nextBlock != null && nextBlock.IsStarted)
            {
                nextBlock.Reverce();
                sender.AcceptMove();
            }
        }
示例#9
0
 private bool OnClickMove(BlockController sender, BlockPoint newPoint)
 {
     if (_blocks[newPoint.X, newPoint.Y] == null && AllowClickMoved(sender))
     {
         sender.Moved     = true;
         sender.IsStarted = false;
         sender.AcceptMove();
         return(true);
     }
     return(false);
 }
示例#10
0
    private void UpdateCameraPosition()
    {
        if (null != camera)
        {
            BlockPoint snakeHeadPoint = SnackBlock[0];
            Vector3    snakeHeadPos   = new Vector3(snakeHeadPoint.X - BLOCK_NUM / 2, snakeHeadPoint.Y - BLOCK_NUM / 2, snakeHeadPoint.Z - BLOCK_NUM / 2) + ORIGIN_POS;
            Vector3    wantedPos      = ORIGIN_POS + (snakeHeadPos - ORIGIN_POS).normalized * CameraDis;

            CameraTransform.LookAt(ORIGIN_POS);
            CameraTransform.position = Vector3.Lerp(CameraTransform.position, wantedPos, CameraMoveRate);

            //Debug.Log( string.Format("Snake Head:{0}  ORIGIN_POS:{1}  Camera Now:{2}  Wanted:{3}", snakeHeadPos,ORIGIN_POS,CameraTransform.position,wantedPos) );
        }
    }
        private bool ReverceCheck(BlockController sender, BlockPoint newPoint)
        {
            int x = newPoint.X;
            int y = newPoint.Y;

            var nextBlock = _blocks[x, y];

            if (nextBlock != null && nextBlock.IsStarted && nextBlock.Side != sender.Side)
            {
                nextBlock.Reverce();
                _changedBlock.Add(sender, newPoint);
                sender.AcceptMove();
                return(true);
            }
            return(false);
        }
示例#12
0
 public void UpdateMove()
 {
     if (_allowMove)
     {
         _allowMove   = false;
         _oldPosition = _position;
         _position    = GetNewPoint();
         _blockView.MoveTo(_position);
         CallMove();
     }
     else if (_reverceMove)
     {
         _reverceMove = false;
         _oldPosition = _position;
         _position    = GetRevercePoint();
         _blockView.MoveTo(_position);
         CallMove();
     }
 }
示例#13
0
    public BlockMapSimulator(int width, int height, BlockRegistry blockRegistry)
    {
        this.Width    = width;
        this.Height   = height;
        this.Registry = blockRegistry;

        _blockGrid           = new int[width * height];
        _blockGridBackground = new BlockPoint[width * height];
        _blocks    = new Dictionary <int, BlockPlacement>();
        _idCounter = 0;

        for (int i = 0; i < _blockGrid.Length; i++)
        {
            _blockGrid[i]           = BLOCK_ID_EMPTY;
            _blockGridBackground[i] = new BlockPoint()
            {
                Valid = false
            };
        }
    }
        private bool ReverceMove(BlockController sender, BlockPoint newPoint)
        {
            int x = newPoint.X;
            int y = newPoint.Y;

            if (x < 0 || x >= _weightGamePole || y < 0 || y >= _heightGamePole)
            {
                _blocksGenerator.SetBlock(sender);
                MoveBall();
                return(false);
            }

            var nextBlock = _blocks[x, y];

            if (nextBlock != null && nextBlock.IsStarted)
            {
                nextBlock.Reverce();
                _changedBlock.Add(sender, newPoint);
                sender.AcceptMove();
                return(true);
            }
            return(false);
        }
示例#15
0
 private void BlockOnClickMove(BlockController sender, Side side, BlockPoint newPoint)
 {
     throw new NotImplementedException();
 }
示例#16
0
 public void SetPosition(BlockPoint position)
 {
     _oldPosition = position;
     _position    = position;
     _blockView.SetPosition(position);
 }
示例#17
0
 public BlockPoint Rem(BlockPoint point)
 {
     return(new BlockPoint(_x - point.X, _y - point.Y));
 }
示例#18
0
 public BlockPoint Add(BlockPoint point)
 {
     return(new BlockPoint(_x + point.X, _y + point.Y));
 }
示例#19
0
    private void Move(MoveTo towards)
    {
        //move except head
        int count = SnackBlock.Count;

        for (int i = 1; i < SnackBlock.Count; i++)
        {
            SnackBlock[count - i] = SnackBlock[count - i - 1];
        }

        //move head
        BlockPoint oldPoint = SnackBlock[0];
        int        oldX     = oldPoint.X;
        int        oldY     = oldPoint.Y;
        int        oldZ     = oldPoint.Z;

        BlockPoint newPoint = new BlockPoint(oldX, oldY, oldZ);

        switch (towards)
        {
        case MoveTo.X:

            if (NowFace == Face.Face_X_Y_0)
            {
                if (oldX == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_1_Y_Z;
                    NowMoveTo = MoveTo.Z;

                    newPoint.Z += 1;
                }
                else
                {
                    newPoint.X += 1;
                }
            }
            else if (NowFace == Face.Face_X_Y_1)
            {
                if (oldX == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_1_Y_Z;
                    NowMoveTo = MoveTo.Z_;

                    newPoint.Z -= 1;
                }
                else
                {
                    newPoint.X += 1;
                }
            }
            else if (NowFace == Face.Face_X_0_Z)
            {
                if (oldX == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_1_Y_Z;
                    NowMoveTo = MoveTo.Y;

                    newPoint.Y += 1;
                }
                else
                {
                    newPoint.X += 1;
                }
            }
            else if (NowFace == Face.Face_X_1_Z)
            {
                if (oldX == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_1_Y_Z;
                    NowMoveTo = MoveTo.Y_;

                    newPoint.Y -= 1;
                }
                else
                {
                    newPoint.X += 1;
                }
            }
            break;

        case MoveTo.X_:
            if (NowFace == Face.Face_X_Y_0)
            {
                if (oldX == 0)
                {
                    NowFace   = Face.Face_0_Y_Z;
                    NowMoveTo = MoveTo.Z;

                    newPoint.Z += 1;
                }
                else
                {
                    newPoint.X -= 1;
                }
            }
            else if (NowFace == Face.Face_X_Y_1)
            {
                if (oldX == 0)
                {
                    NowFace   = Face.Face_0_Y_Z;
                    NowMoveTo = MoveTo.Z_;

                    newPoint.Z -= 1;
                }
                else
                {
                    newPoint.X -= 1;
                }
            }
            else if (NowFace == Face.Face_X_0_Z)
            {
                if (oldX == 0)
                {
                    NowFace   = Face.Face_0_Y_Z;
                    NowMoveTo = MoveTo.Y;

                    newPoint.Y += 1;
                }
                else
                {
                    newPoint.X -= 1;
                }
            }
            else if (NowFace == Face.Face_X_1_Z)
            {
                if (oldX == 0)
                {
                    NowFace   = Face.Face_0_Y_Z;
                    NowMoveTo = MoveTo.Y_;

                    newPoint.Y -= 1;
                }
                else
                {
                    newPoint.X -= 1;
                }
            }
            break;

        case MoveTo.Y:
            if (NowFace == Face.Face_X_Y_0)
            {
                if (oldY == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_1_Z;
                    NowMoveTo = MoveTo.Z;

                    newPoint.Z += 1;
                }
                else
                {
                    newPoint.Y += 1;
                }
            }
            else if (NowFace == Face.Face_X_Y_1)
            {
                if (oldY == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_1_Z;
                    NowMoveTo = MoveTo.Z_;

                    newPoint.Z -= 1;
                }
                else
                {
                    newPoint.Y += 1;
                }
            }
            else if (NowFace == Face.Face_0_Y_Z)
            {
                if (oldY == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_1_Z;
                    NowMoveTo = MoveTo.X;

                    newPoint.X += 1;
                }
                else
                {
                    newPoint.Y += 1;
                }
            }
            else if (NowFace == Face.Face_1_Y_Z)
            {
                if (oldY == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_1_Z;
                    NowMoveTo = MoveTo.X_;

                    newPoint.X -= 1;
                }
                else
                {
                    newPoint.Y += 1;
                }
            }
            break;

        case MoveTo.Y_:
            if (NowFace == Face.Face_X_Y_0)
            {
                if (oldY == 0)
                {
                    NowFace   = Face.Face_X_0_Z;
                    NowMoveTo = MoveTo.Z;

                    newPoint.Z += 1;
                }
                else
                {
                    newPoint.Y -= 1;
                }
            }
            else if (NowFace == Face.Face_X_Y_1)
            {
                if (oldY == 0)
                {
                    NowFace   = Face.Face_X_0_Z;
                    NowMoveTo = MoveTo.Z_;

                    newPoint.Z -= 1;
                }
                else
                {
                    newPoint.Y -= 1;
                }
            }
            else if (NowFace == Face.Face_0_Y_Z)
            {
                if (oldY == 0)
                {
                    NowFace   = Face.Face_X_0_Z;
                    NowMoveTo = MoveTo.X;

                    newPoint.X += 1;
                }
                else
                {
                    newPoint.Y -= 1;
                }
            }
            else if (NowFace == Face.Face_1_Y_Z)
            {
                if (oldY == 0)
                {
                    NowFace   = Face.Face_X_0_Z;
                    NowMoveTo = MoveTo.X_;

                    newPoint.X -= 1;
                }
                else
                {
                    newPoint.Y -= 1;
                }
            }
            break;

        case MoveTo.Z:
            if (NowFace == Face.Face_X_0_Z)
            {
                if (oldZ == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_Y_1;
                    NowMoveTo = MoveTo.Y;

                    newPoint.Y += 1;
                }
                else
                {
                    newPoint.Z += 1;
                }
            }
            else if (NowFace == Face.Face_X_1_Z)
            {
                if (oldZ == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_Y_1;
                    NowMoveTo = MoveTo.Y_;

                    newPoint.Y -= 1;
                }
                else
                {
                    newPoint.Z += 1;
                }
            }
            else if (NowFace == Face.Face_0_Y_Z)
            {
                if (oldZ == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_Y_1;
                    NowMoveTo = MoveTo.X;

                    newPoint.X += 1;
                }
                else
                {
                    newPoint.Z += 1;
                }
            }
            else if (NowFace == Face.Face_1_Y_Z)
            {
                if (oldZ == BLOCK_NUM - 1)
                {
                    NowFace   = Face.Face_X_Y_1;
                    NowMoveTo = MoveTo.X_;

                    newPoint.X -= 1;
                }
                else
                {
                    newPoint.Z += 1;
                }
            }
            break;

        case MoveTo.Z_:
            if (NowFace == Face.Face_X_0_Z)
            {
                if (oldZ == 0)
                {
                    NowFace   = Face.Face_X_Y_0;
                    NowMoveTo = MoveTo.Y;

                    newPoint.Y += 1;
                }
                else
                {
                    newPoint.Z -= 1;
                }
            }
            else if (NowFace == Face.Face_X_1_Z)
            {
                if (oldZ == 0)
                {
                    NowFace   = Face.Face_X_Y_0;
                    NowMoveTo = MoveTo.Y_;

                    newPoint.Y -= 1;
                }
                else
                {
                    newPoint.Z -= 1;
                }
            }
            else if (NowFace == Face.Face_0_Y_Z)
            {
                if (oldZ == 0)
                {
                    NowFace   = Face.Face_X_Y_0;
                    NowMoveTo = MoveTo.X;

                    newPoint.X += 1;
                }
                else
                {
                    newPoint.Z -= 1;
                }
            }
            else if (NowFace == Face.Face_1_Y_Z)
            {
                if (oldZ == 0)
                {
                    NowFace   = Face.Face_X_Y_0;
                    NowMoveTo = MoveTo.X_;

                    newPoint.X -= 1;
                }
                else
                {
                    newPoint.Z -= 1;
                }
            }
            break;
        }

        SnackBlock[0] = newPoint;

        //Debug.Log(string.Format("Move:{0}  Head:{1}  Face:{2}", towards, newPoint.ToString(), NowFace));
    }
示例#20
0
        protected virtual void dataResivedForSTLINE(DataSet pDataSet)
        {
            //IPagedSource pagedSource;
            DataTable tab = pDataSet.Tables[TableSTLINE.TABLE];

            cellBindingLines = new ImplCellReltions(tab);



            tab.ColumnChanged += new DataColumnChangeEventHandler(tableSTLINEColumnChanged);
            tab.RowChanged    += new DataRowChangeEventHandler(tableSTLINERowChanged);
            tab.RowDeleted    += new DataRowChangeEventHandler(tableSTLINERowDeleted);
            /////CURRENCY///////////////////////////////////////////////////////////////////////
            ToolColumn.add(tab, TableSTLINE.E_DUMMY__TOTAL, typeof(double));
            ToolColumn.add(tab, TableSTLINE.E_DUMMY__PRICE, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__RATE, typeof(double));

            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPTOTAL, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPPRICE, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPRATE, typeof(double));

            ////////////BIND AND INHERIT/////////////////////////////////////////

            new TablesColumnsBinding(
                pDataSet.Tables[TableINVOICE.TABLE],
                pDataSet.Tables[TableSTLINE.TABLE],
                new string[] {
                TableINVOICE.CANCELLED,
                TableINVOICE.CLIENTREF,
                TableINVOICE.DATE_,
                TableINVOICE.SOURCEINDEX,
                //TableINVOICE.E_DUMMY__REPRATE,
                TableINVOICE.PRCLIST
            }
                , new string[] {
                TableSTLINE.CANCELLED,
                TableSTLINE.CLIENTREF,
                TableSTLINE.DATE_,
                TableSTLINE.SOURCEINDEX,
                //TableSTLINE.E_DUMMY__REPRATE,
                TableSTLINE.PRCLIST
            }, true);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //MAIN//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 0; i < count; ++i) //Now 1
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] },
                    new IEvaluator[] { new CalcDoubleDiv(2, 1), new CalcDoubleDiv(2, 0), new CalcDoubleMult(0, 1) },
                    // new string[] { "IIF({1}<>0,{2}/{1},0)", "IIF({0}<>0,{2}/{0},0)", "{0}*{1}" },
                    new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] }, cellExpes, bpArrMain[i] = new BlockPoint(), new ImplValidRowStockPriced());
            }
            //PRICE FROM LOC//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 1; i < count; ++i)
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { arrPriceCols[i] },
                    new IEvaluator[] { new CalcDoubleMult(0, 1) },
                    // new string[] { "{0}*{1}" },
                    new string[] { TableSTLINE.PRICE, arrRateCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.PRICE, arrRateCols[i] }, cellExpes, bpArrPriceXFromLoc[i] = new BlockPoint(), null);
            }
            //TOTAL FROM LOC//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 1; i < count; ++i)
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { arrTotalCols[i] },
                    new IEvaluator[] { new CalcDoubleMult(0, 1) },
                    // new string[] { "{0}*{1}" },
                    new string[] { TableSTLINE.TOTAL, arrRateCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.TOTAL, arrRateCols[i] }, cellExpes, bpArrTotalXFromLoc[i] = new BlockPoint(), null);
            }
            ////////////////////////////////////////////////////////////////////////////////////
            setUsedCurrency(ConstUsedCur.national);


            ////////////////////////////////////////////////////////////////////////////////////
            CellAutomationDB dbAutomation;

            dbAutomation = new CellAutomationDB(tab, new PagedSourceMaterial(environment),
                                                new string[] { TableSTLINE.STOCKREF },
                                                new string[] { TableITEMS.LOGICALREF },
                                                new string[] { },
                                                new string[] { TableITEMS.CODE, TableITEMS.NAME },
                                                UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull,
                                                validatorLineMatOrPromo);

            cellBindingLines.addRelation(dbAutomation.getTriggerColumns(), dbAutomation, validatorLineMatOrPromo);
            dbAutomation = new CellAutomationDB(tab, new PagedSourceMaterial(environment),
                                                new string[] { TableSTLINE.STOCKREF },
                                                new string[] { TableITEMS.LOGICALREF },
                                                new string[] { /* TableSTLINE.DISCPER, */ TableSTLINE.UINFO1, TableSTLINE.UINFO2, TableSTLINE.UNIT, TableSTLINE.UNITREF },
                                                new string[] { /* TableITEMS.DISCPER,*/ TableITEMS.UNITCF1, TableITEMS.UNITCF1, TableITEMS.UNIT1, TableITEMS.UNITREF1 },
                                                UpdateTypeFlags.activeOnRelColumn | UpdateTypeFlags.disableEditCancel | UpdateTypeFlags.setTypeDefaultToDrivedChild,
                                                validatorLineMatOrPromo);

            cellBindingLines.addRelation(dbAutomation.getTriggerColumns(), dbAutomation, validatorLineMatOrPromo);



            //
            //



            new RowDeleteWatcher(tab, null, new string[] { TableSTLINE.TOTAL }, new object[] { 0.0 });



            bindForLineType(tab);
            bindForDistributeSums(tab);
            bindForPromo(tab);
        }
示例#21
0
 void Update()
 {
     if (wayPoints != null && !IsDead)
     {
         navigationTime += Time.deltaTime * speed;
         if (navigationTime > navigation)
         {
             if (target < wayPoints.Length)
             {
                 unit.position = Vector2.MoveTowards(unit.position, wayPoints[target].position, navigationTime);
             }
             else if (!IsDead)
             {
                 unit.position = Vector2.MoveTowards(unit.position, finish.position, navigationTime);
             }
             navigationTime = 0;
         }
     }
     if (block != null)
     {
         if (isBlock && !block.isDead)
         {
             if (attackCouter <= 0)
             {
                 attackCouter     = attackDelay;
                 block.currentHp -= damage;
                 hpCurrent       -= block.damage;
                 Debug.Log("Хрышь " + hpCurrent + " хп, Забор " + block.currentHp + " хп");
             }
             else
             {
                 attackCouter -= Time.deltaTime;
             }
         }
         else
         {
             speed   = saveSpeed;
             isBlock = false;
             block   = null;
         }
     }
     if (tower != null)
     {
         if (isBlock && !tower.isDead)
         {
             if (attackCouter <= 0)
             {
                 attackCouter = attackDelay;
                 tower.hp    -= baseUnit.PARAMS[UNIT_DAMAGE];
             }
             else
             {
                 attackCouter -= Time.deltaTime;
             }
         }
         else
         {
             speed   = saveSpeed;
             isBlock = false;
             tower   = null;
         }
     }
 }
示例#22
0
 private void OnBlockMove(BlockController sender, Side side, BlockPoint newPoint)
 {
 }
示例#23
0
 private void Block_Move(BlockController sender, Side side, BlockPoint newPoint)
 {
     _changedBlock.Add(sender);
 }