// Stickfloor control function void RunStickfloors() { if (tempStickfloors.Count > 0) { int sfPos; List <int> arrayList = new List <int>(tempStickfloors.Keys); for (int index = 0; index < arrayList.Count; index++) { StickfloorManage stickfloors = tempStickfloors[arrayList[index]]; switch (stickfloors.movingState) { case StickfloorState.NONE: stickfloors.speedTimeCount = 0; stickfloors.movingState = StickfloorState.MOVING; stickfloors.leftStickfloor = stickfloors.stickfloorSet.floorCount; stickfloors.existingStickfloorCount = 0; stickfloors.stickfloorRoot = new int[modelLengthNumOnScreen]; break; case StickfloorState.MOVING: if (stickfloors.leftStickfloor == 0 && stickfloors.existingStickfloorCount == stickfloors.stickfloorSet.floorCount) { stickfloors.idleTimeCount = 0; stickfloors.movingState = StickfloorState.IDLING; } else { float speedTime = stickfloorSetup.GetTypeTime(stickfloors.stickfloorSet.type); // Ready for stickfloor move if (stickfloors.speedTimeCount >= speedTime) { int nextKey = 0; int prevKey = 0; int maxVal = modelLengthNumOnScreen - 1; int minVal = 0; int calculation = -1; for (int stickFloor = maxVal; stickFloor >= minVal; stickFloor += calculation) { int name = Floor.instance.GetOriginalName(stickFloor, stickfloors.columnNumber); if (stickfloors.stickfloorRoot[stickFloor] == null) { stickfloors.stickfloorRoot[stickFloor] = 0; } // If in the first grid if (stickFloor == minVal && stickfloors.stickfloorRoot[stickFloor] == 0 && stickfloors.existingStickfloorCount == 0) { stickfloors.stickfloorRoot[stickFloor] = 1; stickfloors.existingStickfloorCount++; ChangeFloorToStickfloor(name, StickfloorChangeProgress.HEAD); } else if (stickfloors.stickfloorRoot[stickFloor] == 1) { nextKey = stickFloor + 1; prevKey = stickFloor - 1; // if head is the last if (stickFloor == maxVal && stickfloors.stickfloorRoot[prevKey] == 1) { stickfloors.leftStickfloor--; } else // last stickfloor if (stickFloor == maxVal && stickfloors.stickfloorRoot[prevKey] == 0) { stickfloors.stickfloorRoot[stickFloor] = 0; ChangeFloorToStickfloor(name, StickfloorChangeProgress.TAIL); } else // If head is found and not in the last grid if (nextKey <= maxVal && stickfloors.stickfloorRoot[nextKey] == 0) { name = Floor.instance.GetOriginalName(nextKey, stickfloors.columnNumber); stickfloors.stickfloorRoot[nextKey] = 1; ChangeFloorToStickfloor(name, StickfloorChangeProgress.HEAD); } else // if tail has been found if (prevKey >= minVal && stickfloors.stickfloorRoot[prevKey] == 0 && stickfloors.existingStickfloorCount >= stickfloors.stickfloorSet.floorCount) { stickfloors.stickfloorRoot[stickFloor] = 0; ChangeFloorToStickfloor(name, StickfloorChangeProgress.TAIL); } else // if head has found and block count has not fulfilled yet if (stickfloors.stickfloorRoot[nextKey] == 1 && stickFloor == minVal && stickfloors.existingStickfloorCount < stickfloors.stickfloorSet.floorCount) { stickfloors.existingStickfloorCount++; } else // if tail with block count has fulfilled if (stickfloors.stickfloorRoot[nextKey] == 1 && stickFloor == minVal && stickfloors.existingStickfloorCount >= stickfloors.stickfloorSet.floorCount) { stickfloors.stickfloorRoot[stickFloor] = 0; ChangeFloorToStickfloor(name, StickfloorChangeProgress.TAIL); } } } stickfloors.speedTimeCount = 0; } else { stickfloors.speedTimeCount += Time.deltaTime; } } break; case StickfloorState.IDLING: if (stickfloors.idleTimeCount >= stickfloors.stickfloorSet.idleTime) { stickfloors.movingState = StickfloorState.NONE; } else { stickfloors.idleTimeCount += Time.deltaTime; } break; } } } }
void SetNewDataToCell(int setCount, bool startState) { int collectionId = GetCollectionId(); if (startState == true) { collectionId = defaultFloor.defaultFloorCollection; } int columnNo; int columnCount; for (int width = 0; width < setCount; width++) { columnCount = floorSetup.floorSetCollection[collectionId].floorSetConf.Count; columnNo = GetColumnId(columnCount); if (columnNo == 1) { collectionId = GetCollectionId(); } FloorColumnDef floorColumnDef = floorSetup.floorSetCollection[collectionId].floorSetConf[columnNo]; FloorColumnSet floorList = floorSetup.floorColumnSetList[floorColumnDef.columnIndex]; int floorSetupListCount = floorList.floorSetList.Count; int floorObjectIndex = 0; int obstacleObjectIndex = 0; int index; for (int length = 0; length < modelLengthNumOnScreen; length++) { bool listDataMatchState = false; int name = GetName(length, presentBlockNum); FloorSet tempFloorSet = new FloorSet(); ObstacleTypes obstacleType = ObstacleTypes.NONE; FloorAttributes tempFloorAtt = FloorAttributes.FLOOR; if (floorObjectIndex < floorSetupListCount) { tempFloorSet = floorList.floorSetList[floorObjectIndex]; if (tempFloorSet.index == length) { tempFloorAtt = tempFloorSet.floorAttribute; if (tempFloorSet.obstacleType != ObstacleTypes.NONE && tempFloorSet.obstacleType != null) { obstacleType = tempFloorSet.obstacleType; } listDataMatchState = true; Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt); floorObjectIndex++; } } if (listDataMatchState == false) { tempFloorSet = defaultFloor.initFloor; Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt); listDataMatchState = true; } } int widthSize = GetWidthSize(presentBlockNum); // If ninjastar has existing if (floorColumnDef.ninjastarIndex != null && floorColumnDef.ninjastarIndex > 0) { if (tempStars.ContainsKey(widthSize) == false) { index = floorColumnDef.ninjastarIndex; NinjaStarManage tempNinjastar = new NinjaStarManage(); tempNinjastar.columnNumber = widthSize; tempNinjastar.ninjaStarSet = ninjastarSetup.ninjaStarSetList[index]; tempNinjastar.movingState = NinjastarState.NONE; tempNinjastar.starsCount = 0; tempStars.Add(widthSize, tempNinjastar); if (ninjastarSetup.ninjaStarSetList[index].position == FloorPosition.TOP) { int enemyLocation = GetName(3, presentBlockNum); Floor.instance.SetObstacleType(ObstacleTypes.SOLDIER, enemyLocation); } } } if (floorColumnDef.stickfloorIndex != null && floorColumnDef.stickfloorIndex > 0) { if (tempStickfloors.ContainsKey(widthSize) == false) { index = floorColumnDef.stickfloorIndex; StickfloorManage tempStickfloor = new StickfloorManage(); tempStickfloor.columnNumber = widthSize; tempStickfloor.idleTimeCount = 0f; tempStickfloor.stickfloorSet = stickfloorSetup.stickfloorSetList[index]; tempStickfloor.movingState = StickfloorState.NONE; tempStickfloor.leftStickfloor = 0; tempStickfloor.speedTimeCount = 0; tempStickfloors.Add(widthSize, tempStickfloor); } } if (floorColumnDef.flowingfloorId != null && floorColumnDef.flowingfloorId > 0) { if (tempFlowingfloors.ContainsKey(widthSize) == false) { index = floorColumnDef.flowingfloorId; FlowingfloorManage tempFlowingfloor = new FlowingfloorManage(); tempFlowingfloor.columnNumber = widthSize; tempFlowingfloor.flowingfloorSet = flowingfloorSetup.flowingfloorSetList[index]; tempFlowingfloor.movingState = FlowingfloorState.NONE; tempFlowingfloor.count = 0; tempFlowingfloors.Add(widthSize, tempFlowingfloor); } } if (floorColumnDef.rollingRockId != null && floorColumnDef.rollingRockId > 0) { if (tempRollingRocks.ContainsKey(widthSize) == false) { index = floorColumnDef.rollingRockId; RollingRockManage tempRollingRock = new RollingRockManage(); tempRollingRock.columnNumber = widthSize; tempRollingRock.rollingRockSet = rollingRockSetup.rollingRockSetList[index]; tempRollingRock.movingState = RollingRockState.NONE; tempRollingRock.rollingRockCount = 0; tempRollingRock.rollingRockStartState = true; tempRollingRocks.Add(widthSize, tempRollingRock); } } // Floor local position increase if (presentBlockNum < modelWidthNumOnScreen) { presentBlockNum++; } } }