BuildTown.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div
  3. class="build-town"
  4. >
  5. <div class="left">
  6. <div
  7. v-for="(item, idx) in sceneList"
  8. :key="idx"
  9. class="scene"
  10. :class="gameProgress.jagsawProgress[item.idxInConfig].isJagsawDone ? 'unlock' : 'lock'"
  11. :style="{
  12. width: `calc(${item.width} / ${windowSizeWhenDesign} * ${unit})`,
  13. height: `calc(${item.height} / ${windowSizeWhenDesign} * ${unit})`,
  14. top: `calc(${item.top} / ${windowSizeWhenDesign} * ${unit})`,
  15. left: `calc(${item.left} / ${windowSizeWhenDesign} * ${unit})`,
  16. }"
  17. @click="$router.push({
  18. name: 'JagsawGame',
  19. query: {
  20. sceneL2Idx: item.idxInConfig,
  21. }
  22. })"
  23. >
  24. <img
  25. class=""
  26. :src="require(`@/assets/images/bg-${item.idxInConfig + 1}.jpg`)"
  27. alt=""
  28. draggable="false"
  29. >
  30. <div class="text-wrap">
  31. <span>{{ gameProgress.jagsawProgress[item.idxInConfig].name }}</span>
  32. <img
  33. v-if="!gameProgress.jagsawProgress[item.idxInConfig].isJagsawDone"
  34. class="lock"
  35. src="@/assets/images/lock.png"
  36. alt=""
  37. draggable="false"
  38. >
  39. </div>
  40. </div>
  41. <img
  42. class="build-tip"
  43. src="@/assets/images/build-tip.png"
  44. alt=""
  45. draggable="false"
  46. >
  47. </div>
  48. <div class="right">
  49. <div class="bottom-wrap">
  50. <div
  51. v-for="(item, idx) in buildList"
  52. :key="idx"
  53. class="step"
  54. >
  55. <button
  56. :class="{
  57. done: gameProgress.buildProgress >= idx
  58. }"
  59. @click="recordBuildProgress(idx)"
  60. >
  61. <div>{{ item.name }}</div>
  62. </button>
  63. <div
  64. v-if="idx !== buildList.length - 1"
  65. class="line"
  66. />
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. import { onMounted, reactive, toRefs, ref } from 'vue'
  74. import useWindowSizeAdaptor from '@/useFunctions/useWindowSizeAdaptor.js'
  75. export default {
  76. name: 'BuildTown',
  77. setup () {
  78. const { windowSizeWhenDesign, unit } = useWindowSizeAdaptor()
  79. return {
  80. windowSizeWhenDesign,
  81. unit
  82. }
  83. },
  84. data() {
  85. return {
  86. sceneList: [
  87. {
  88. idxInConfig: 0,
  89. width: 476,
  90. height: 294,
  91. top: 0,
  92. left: 0,
  93. },
  94. {
  95. idxInConfig: 4,
  96. width: 262,
  97. height: 294,
  98. top: 0,
  99. left: 484,
  100. },
  101. {
  102. idxInConfig: 5,
  103. width: 378,
  104. height: 166,
  105. top: 302,
  106. left: 0,
  107. },
  108. {
  109. idxInConfig: 3,
  110. width: 190,
  111. height: 152,
  112. top: 476,
  113. left: 0,
  114. },
  115. {
  116. idxInConfig: 1,
  117. width: 179,
  118. height: 152,
  119. top: 476,
  120. left: 199,
  121. },
  122. {
  123. idxInConfig: 2,
  124. width: 360,
  125. height: 326,
  126. top: 302,
  127. left: 386,
  128. },
  129. ],
  130. buildList: [
  131. {
  132. name: '建民居',
  133. },
  134. {
  135. name: '布祠堂',
  136. },
  137. {
  138. name: '立牌坊',
  139. },
  140. {
  141. name: '过程名',
  142. },
  143. {
  144. name: '过程名',
  145. },
  146. {
  147. name: '过程名',
  148. },
  149. ],
  150. }
  151. },
  152. computed: {
  153. ...mapState([
  154. 'gameProgress',
  155. ]),
  156. sceneTree() {
  157. return config.sceneTree
  158. },
  159. },
  160. mounted() {
  161. },
  162. unmounted() {
  163. },
  164. methods: {
  165. ...mapMutations([
  166. 'recordBuildProgress',
  167. ]),
  168. },
  169. }
  170. </script>
  171. <style lang="less" scoped>
  172. .build-town {
  173. position: absolute;
  174. left: 0;
  175. top: 0;
  176. width: 100%;
  177. height: 100%;
  178. background-image: url(@/assets/images/bg-game.jpg);
  179. background-size: cover;
  180. background-repeat: no-repeat;
  181. background-position: center center;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. padding-bottom: calc(50 / v-bind('windowSizeWhenDesign') * v-bind('unit'));;
  186. >.left {
  187. position: relative;
  188. width: calc(746 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  189. height: calc(628 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  190. margin-right: calc(83 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  191. >.scene {
  192. position: absolute;
  193. cursor: pointer;
  194. >img {
  195. position: absolute;
  196. left: 0;
  197. top: 0;
  198. width: 100%;
  199. height: 100%;
  200. object-fit: cover;
  201. }
  202. >.text-wrap {
  203. position: absolute;
  204. left: 0;
  205. background: rgba(255,255,255,0.7);
  206. bottom: 0;
  207. width: 100%;
  208. height: calc(32 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  209. padding-left: calc(10 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  210. padding-right: calc(10 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  211. display: flex;
  212. align-items: center;
  213. font-size: calc(16 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  214. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  215. font-weight: bold;
  216. >span {
  217. padding-top: 0.4em;
  218. }
  219. >img.lock {
  220. margin-left: 0.5em;
  221. width: calc(15 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  222. height: calc(21 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  223. }
  224. }
  225. }
  226. .scene.unlock {
  227. >.text-wrap {
  228. color: #30B07A;
  229. }
  230. }
  231. .scene.lock {
  232. >.text-wrap {
  233. color: #C26827;
  234. }
  235. }
  236. >img.build-tip {
  237. position: absolute;
  238. left: 50%;
  239. bottom: calc(-38 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  240. transform: translate(-50%, 100%);
  241. width: calc(506 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  242. height: calc(110 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  243. }
  244. }
  245. >.right {
  246. position: relative;
  247. width: calc(950 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  248. height: calc(628 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  249. background: red;
  250. background-image: url(@/assets/images/bg-jagsaw-game-page-frame.jpg);
  251. background-size: cover;
  252. background-repeat: no-repeat;
  253. background-position: center center;
  254. >div.bottom-wrap {
  255. position: absolute;
  256. left: 50%;
  257. bottom: calc(-70 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  258. transform: translate(-50%, 100%);
  259. width: 100%;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. >.step {
  264. display: flex;
  265. align-items: center;
  266. >button {
  267. width: calc(14 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  268. height: calc(14 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  269. border-radius: 50%;
  270. border: 2px solid #C26827;
  271. position: relative;
  272. >div {
  273. position: absolute;
  274. left: 50%;
  275. bottom: calc(-11 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  276. transform: translate(-50%, 100%);
  277. font-size: calc(24 / v-bind('windowSizeWhenDesign') * v-bind('unit'));;
  278. font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  279. font-weight: bold;
  280. color: #C26827;
  281. }
  282. &.done {
  283. background-color: #30B07A;
  284. border: 2px solid #30B07A;
  285. >div {
  286. color: #30B07A;
  287. }
  288. }
  289. }
  290. >.line {
  291. display: inline-block;
  292. width: calc(120 / v-bind('windowSizeWhenDesign') * v-bind('unit'));;;
  293. height: 1px;
  294. border-top: 1px dashed #C26827;
  295. margin: 0 calc(8 / v-bind('windowSizeWhenDesign') * v-bind('unit'));;;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. </style>