Преглед изворни кода

🎨 优化乡源树细节

快乐的梦鱼 пре 1 дан
родитељ
комит
f23ef25fd2

+ 2 - 0
src/api/system/ConfigurationApi.ts

@@ -32,6 +32,8 @@ export interface IConfigurationItem {
   tree: {
     fruitImage: string;
     backgroundImage: string;
+    offsetX: number;
+    offsetY: number;
     animWater: string[];
     animWaterAnimProps: VillageTreeAnimProps;
     animFertilize: string[];

+ 2 - 0
src/api/system/DefaultConfiguration.json

@@ -28,6 +28,8 @@
   "tree": {
     "fruitImage": "https://xy.wenlvti.net/app_static/images/home/tree/AnimFruit.png",
     "backgroundImage": "https://xy.wenlvti.net/uploads/20260707/8aa4310ffa61d9519dd8d3af1f323b8b.png",
+    "offsetX": 0,
+    "offsetY": -0.1,
     "animWater": ["https://xy.wenlvti.net/uploads/20260707/bc23f215467a6f9e31bb3290ed1e8f6a.png"],
     "animWaterAnimProps": {
       "framerate": 14,

+ 4 - 2
src/pages/home/village/components/VillageTree.vue

@@ -41,6 +41,8 @@ const props = withDefaults(defineProps<{
   treeImage: string;
   treeAnimProps?: VillageTreeAnimProps;
   treeName?: string;
+  treeOffsetX: number;
+  treeOffsetY: number;
   fruitImage: string;
   backgroundImage: string;
   animWater: string[];
@@ -89,8 +91,8 @@ const render = new MiniRender.Scene(
     });
     treeMain.width = this.precentXToPixel(props.treeAnimProps.width);
     treeMain.height = this.precentYToPixel(props.treeAnimProps.height);
-    treeMain.x = (this.width - treeMain.width) / 2;
-    treeMain.y = (this.height - treeMain.height);
+    treeMain.x = (this.width - treeMain.width) / 2 + this.precentXToPixel(props.treeOffsetX);
+    treeMain.y = (this.height - treeMain.height) + this.precentYToPixel(props.treeOffsetY);
     treeMain.interactive = true;
     treeMain.name = 'treeMain';
     treeMain.play();

+ 4 - 2
src/pages/home/village/introd/tree.vue

@@ -8,6 +8,8 @@
       :treeImage="currentVillage.treeImage"
       :treeName="currentVillage.treeName"
       :treeAnimProps="currentVillage.treeImageAnimProps"
+      :treeOffsetX="appConfiguration.tree.offsetX"
+      :treeOffsetY="appConfiguration.tree.offsetY"
       :fruitImage="appConfiguration.tree.fruitImage"
       :backgroundImage="appConfiguration.tree.backgroundImage"
       :animFertilize="appConfiguration.tree.animFertilize"
@@ -351,7 +353,7 @@ async function handlePickOrWaterOrFertilize(action: 'pick' | 'water' | 'fertiliz
         toast(res, 4000);
         break;
       case 'water': {
-        //await TreeApi.water(villageStore.currentVillage.id);
+        await TreeApi.water(villageStore.currentVillage.id);
         hideLoading();
         villageTreeRef.value?.playStateAnimation('water');
         lastRefreshAction.value = 'water';
@@ -431,7 +433,7 @@ async function refreshVillageTreeInfo() {
     const newVillage = requireNotNull(villageStore.currentVillage);
     const oldLight = oldVillage.lightTotal;
     const oldTreeName = oldVillage.treeName;
-    lastAddLight.value = Math.max(0, oldLight - newVillage.lightTotal);
+    lastAddLight.value = Math.max(0, newVillage.lightTotal - oldLight);
     lastLevelUp.value = oldTreeName !== newVillage.treeName ? newVillage.treeName : '';
   } else {
     lastAddLight.value = 0;