示例#1
0
        void GameTick()
        {
            HexTile nextTile = CurrentTile.Neighbour(Dir);

            if (!nextTile || nextTile.Terrain == TerrainType.rock || IsColliding(nextTile))
            {
                Debug.Log("GAME OVER!");
                OnGameOver();
                return;
            }

            for (int i = tail.Count - 1; i >= 0; i--)
            {
                Worm w  = tail[i];
                Worm wn = (i == 0) ? this : tail[i - 1];
                w.Dir         = wn.Dir;
                w.CurrentTile = wn.CurrentTile;
            }


            CurrentTile = nextTile;
            if (IsTarget(CurrentTile))
            {
                ConsumeTarget();
                SetTarget();
            }
            tickCount++;
        }
示例#2
0
        protected override Direction GetNextDirection()
        {
            var desiredDirection = Game.Navigator.GetDirections(CurrentTile);

            return(!CurrentTile.Neighbour(desiredDirection).Info.IsPassable
                ? Direction.Unknown
                : desiredDirection);
        }