Exemplo n.º 1
0
        /// <summary>
        /// 生成下一个格子
        /// </summary>
        void generateNextGrids()
        {
            currentGrids = nextGrids ?? generateGrids();
            nextGrids    = generateGrids();

            fallingY = currentMap.mapY - 1;

            changeState(State.Placing);
        }
Exemplo n.º 2
0
        }                                                       // 清除速度 s/个

        /// <summary>
        /// 更新敌人
        /// </summary>
        void updateEnemy()
        {
            if (enemyGrids == null)
            {
                enemyGrids = generateGrids(Grid.Belong.Enemy);
                fallingY2  = 0;
            }

            aiTime      += Time.deltaTime;
            freezeTime2 += Time.deltaTime;

            if (aiTime >= aiSpeed)
            {
                var targetX = findTargetX();
                var dist    = targetX - fallingX2;

                if (dist > 0)
                {
                    fallingX2++;
                }
                else
                {
                    fallingX2--;
                }

                var w = currentMap.mapX;
                fallingX2 = (w + fallingX2) % w;

                aiTime = 0;


                if (fallingX2 == targetX && freezeTime2 >= freezeDuration / 2)
                {
                    placeGrids(enemyGrids, fallingX2);
                    freezeTime2 = 0;
                }
            }

            if (enemyGrids == null)
            {
                return;
            }
            //var down = InputUtils.getKeyDown(KeyCode.DownArrow, KeyCode.S);
            //if (down) placeGrids(enemyGrids, fallingX2);
            if (!currentMap.isPlacePointValid(enemyGrids, fallingX2, fallingY2 + 1))
            {
                placeGrids(enemyGrids, fallingX2, fallingY2);
            }
            else
            {
                placeGrids(enemyGrids, fallingX2, fallingY2, true);
            }
        }
Exemplo n.º 3
0
        public void placeGrids(RuntimeGrids grids, int x, int y, bool preview = false)
        {
            currentMap.placeGrids(grids, x, y, preview);

            if (!preview)
            {
                _isPlaced = true;
            }

            if (grids.isPlayer && !preview)
            {
                changeState(State.Placed);
            }
            if (grids.isEnemy && !preview)
            {
                enemyGrids = null;
            }
        }