쩝 작은 게임이지만, 게임 룰이 판이하게 변경될 때마다 작업이 참 많다. 

 

case Rock = 0, Paper, Scissors, UBB, Golden

 

 

        case .Rock:

            return "rock"

        case .Paper:

            return "paper"

        case .Scissors:

            return "scissors"

        case .UBB:

            return "ubb"

        case .Golden:

            return "golden"

 

  1. User Action : tab - rotation 제거
  2. 방향 전환 모듈 제거에 따른 승리룰 체크 변경

  func algorithmDrawOrWin(typeUpper: hjhBlocType, directionUpper: hjhDirectionType, typelower: hjhBlocType, directionLower: hjhDirectionType) -> Bool {

        

        var nothingIsNorth : hjhDirectionType = directionUpper

        var nothingIsNorth2 : hjhDirectionType = directionLower

        

        if nothingIsNorth == .Nothing { nothingIsNorth = .North }

        if nothingIsNorth2 == .Nothing { nothingIsNorth2 = .North }

 

  1. Init Rotation 제거 - 처음 나올 때부터 회전.

//hjh_disabled_init random rotation        if GS.s.stage6flag {

//            if Bool.random() { rotateBlocks(orientation: orientation) }

//            if Bool.random() { rotateBlocks(orientation: orientation) }

//            if Bool.random() { rotateBlocks(orientation: orientation) }

//        }

 

 

final func rotateBlocks(orientation: Orientation) {

        guard let blockRowColumnTranslation: Array<(columnDiff: Int, rowDiff: Int)> = blockRowColumnPositions[orientation] else {

            return

        }

        

        if self.blocks.mBlocDirection == .North {

            self.blocks.mBlocDirection = hjhDirectionType.East

        } else if self.blocks.mBlocDirection == .East {

            self.blocks.mBlocDirection = hjhDirectionType.South

        } else if self.blocks.mBlocDirection == .South {

            self.blocks.mBlocDirection = hjhDirectionType.West

        } else if self.blocks.mBlocDirection == .West {

            self.blocks.mBlocDirection = hjhDirectionType.North

        } else if self.blocks.mBlocDirection == .Nothing {

            self.blocks.mBlocDirection = hjhDirectionType.East

        }

        

        let rotateAction = SKAction.rotate(byAngle: radian2degree(-90), duration: 0.5)

        self.blocks.mSprite?.run(SKAction.sequence([SKAction.group([rotateAction

            //            , rotateAction

            ])

            //            , SKAction.removeFromParent()

            ]))

        //TODO: ROTATE

        //        for (idx, diff) in blockRowColumnTranslation.enumerated() {

        //            blocks[idx].mXposition = column + diff.columnDiff

        //            blocks[idx].mYposition = row + diff.rowDiff

        //        }

    }

 

  1. Bloc Type 제거 및 정리

case Rock = 0, Paper, Scissors, UBB, Golden 

var spriteName: String {

        switch self {

        case .Rock:

            return "rock"

        case .Paper:

            return "paper"

        case .Scissors:

            return "scissors"

        case .UBB:

            return "ubb"

        case .Golden:

            return "golden"

//        case .ERROR:

//            return "ERROR"

        }

    }

에서

    var spriteName: String {

        switch self {

        case .Rock:

            return "rock"

        case .Rock1:

            return "rock1"

        case .Rock2:

            return "rock2"

        case .Paper:

            return "paper"

        case .Paper1:

            return "paper1"

        case .Paper2:

            return "paper2"

        case .Scissors:

            return "scissors"

        case .Scissors1:

            return "scissors1"

        case .Scissors2:

            return "scissors2"

.

.

.

  1. Bloc type 변경에 따른 승리룰 변경 적용

   fileprivate func tigRules1(_ bloc: AtomicBloc, _ vX: Int, _ vY: Int, _ effectX: CGFloat, _ effectY: CGFloat) {

        //                Toast.showBlack(message: bloc.mBlocType.description + " and " + prevBloc!.mBlocType.description)

        //                Toast.showBlack(message: bloc.mXposition.description + "," + bloc.mYposition.description + " and " + prevBloc!.mXposition.description + "," + prevBloc!.mYposition.description)

        //TODO: making "nil" type

        if algorithmDrawOrWin(typeUpper: bloc.mBlocType, directionUpper: bloc.mBlocDirection, typelower: GS.s.hjhBlocStorage?[vX, vY + 1]?.mBlocType ?? hjhBlocType.Rock, directionLower: GS.s.hjhBlocStorage?[vX, vY + 1]?.mBlocDirection ?? hjhDirectionType.Nothing) {

            debugPrint("same same bloc type")

            //                    let randomRadius = CGFloat(UInt(arc4random_uniform(400) + 100))

            //                    let goLeft = arc4random_uniform(100) % 2 == 0

            //                    var point = GS.s.gameScene?.spritePositionCalculator_(column: (GS.s.hjhBlocStorage?[vX, vY]!.mXposition)!, row: (GS.s.hjhBlocStorage?[vX, vY]!.mYposition)!)

            //                    point = CGPoint(x: point!.x + (goLeft ? -randomRadius : randomRadius), y: point!.y)

            //

            //                    let randomDuration = TimeInterval(arc4random_uniform(2)) + 0.5

            //                    // #5

            //                    var startAngle = CGFloat(Double.pi)

            //                    var endAngle = startAngle * 2

            //                    if goLeft {

            //                        endAngle = startAngle

            //                        startAngle = 0

            //                    }

            //                    let archPath = UIBezierPath(arcCenter: point!, radius: randomRadius, startAngle: startAngle, endAngle: endAngle, clockwise: goLeft)

            //                    let archAction = SKAction.follow(archPath.cgPath, asOffset: false, orientToPath: true, duration: randomDuration)

            //                    archAction.timingMode = .easeIn

            let atomicSprite = GS.s.hjhBlocStorage?[vX, vY]?.mSprite!

            debugPrint("\n demo1checking " + (GS.s.hjhBlocStorage?[vX, vY + 1]?.mSprite!.description ?? "NONE") ?? "NOTHING")

            

            

            GS.s.hjhBlocStorage?[vX, vY + 1]?.mSprite!.removeFromParent()

            GS.s.hjhBlocStorage?[vX, vY + 1]?.deletingMeFromStorage()

            

            //                    let atomicSprite2 = GS.s.hjhBlocStorage?[vX, vY + 1]?.mSprite!

            atomicSprite!.alpha = 1000

            

            //                let fadeInAction = SKAction.fadeAlpha(to: 0, duration: 0.2)

            //                fadeInAction.timingMode = .easeIn

            

            //                let hjhAction001 = SKAction.moveBy(x: 0, y: 0, duration: 1)

            let hjhAction002 = SKAction.scale(to: 0, duration: 0.5)

            

            atomicSprite!.run(                            SKAction.sequence(

                //                        [SKAction.group([fadeInAction]),

                [SKAction.group([hjhAction002]),

                 SKAction.removeFromParent()])

            )

            

            let yae : Int = vY + 1

            //                    GS.s.hjhBlocStorage?[vX, yae]?.mSprite!.removeFromParent()

            debugPrint("vxvy : ", vX, vY, yae)

            //                    GS.s.hjhBlocStorage?[vX, yae]?.deletingMeFromStorage()

            //                run(SKAction.wait(forDuration: 0.4), completion: completion)

            

            //                    debugPrint("animateCollapsingLines : ", block.mXposition, block.mYposition, block.mSprite!.anchorPoint.x, block.mSprite!.anchorPoint.y)

            // #6

            //                    sprite!.zPosition = 1000

            //

            //                    sprite!.removeFromParent()

            

            GS.s.hjhBlocStorage?[vX, vY]?.deletingMeFromStorage()

            let effect = eff_baamTwoBlocks(x: effectX, y: effectY)

            GS.s.gameScene?.addChild(effect)

            if GS.s.logLevel == .fixing {

                debugPrint("hjhFixingBloc Effect x = ", effect.position.x, ", y = ", effect.position.y) }

            totalScore += 10

            //                    GS.s.hjhBlocStorage?[vX, vY + 1]?.mSprite?.removeFromParent()

            //                    GS.s.hjhBlocStorage?[vX, vY + 1]?.deletingMeFromStorage()

            //

            //TODO: WHY                    Toast.show(message: (GS.s.hjhBlocStorage?[vX, vY]?.mXposition.description)! + " " + (GS.s.hjhBlocStorage?[vX, vY]?.mYposition.description)!)

            //TODO: WHY                    Toast.showBlack(message: GS.s.hjhBlocStorage?[vX, vY]?.mXposition.description ?? "NOTHING")

            //                    GS.s.hjhBlocStorage?[vX, vY + 1]?.mSprite?.removeFromParent()

            //                                        prevBloc!.deletingMeFromStorage()

        }

 

  1. 골든 블락, 제거 안되는 블락 제거에 따른 룰 변경

if typeUpper == hjhBlocType.Golden {

            return true

        }

        

        if nothingIsNorth != nothingIsNorth2 {

            return false

        }

 

구문 제거

'Blog History' 카테고리의 다른 글

330  (0) 2020.05.26
329  (0) 2020.05.26
327  (0) 2020.05.25
326  (0) 2020.05.25
325  (0) 2020.05.25

+ Recent posts