【PC遊戲】殺戮尖塔basemod百科翻譯(2)


3樓貓 發佈時間:2023-03-09 23:38:39 作者:區區一個呆唯__ Language

本文內容包括:

自定義顏色

自定義角色


正文如下:

-----------------------------------

自定義顏色

說明

在嘗試為遊戲創建一個新角色的過程中,不可避免的是,你會想給角色創建一個新的顏色。正如鐵甲戰士是紅色的,靜默獵手是綠色的,你的自定義角色也需要一個顏色,可能是青色,橙色或者黃色。

枚舉

殺戮尖塔遊戲本體使用AbstractCard.CardColor枚舉表示顏色,所以為了給遊戲添加新顏色,你應該使用ModTheSpire的枚舉補丁特性,除此之外,還有要把它註冊到BaseMod中。

你還需要定義一個卡牌顏色和卡牌庫類型值,並且它們必須有完全相同的名字。

下面是一個例子,展示瞭如何做到這一點:

-----------------------------------

import com.evacipated.cardcrawl.modthespire.lib.SpireEnum;

import com.megacrit.cardcrawl.cards.AbstractCard;


public class AbstractCardEnum {


 @SpireEnum

 public static AbstractCard.CardColor MOD_NAME_COLOR;

}

-----------------------------------

import com.evacipated.cardcrawl.modthespire.lib.SpireEnum;

import com.megacrit.cardcrawl.helpers.CardLibrary;


public class LibraryTypeEnum {


 @SpireEnum

 public static CardLibrary.LibraryType MOD_NAME_COLOR;

}

-----------------------------------

如何使用

除了為CardColor枚舉定義補丁外,你還需要向BaseMod註冊自定義顏色,以便它能夠正確地實現與該顏色相關的其餘功能。例如,你需要指定到能量球和卡片背景的路徑。為此,你會需要調用本百科頁面API部分中詳細介紹的addColor方法。然而,在@SpireInitializer中調用addColor方法是非常重要的。不要在postInitialize或任何其他hook中調用它。一般來說,你想把你的模組名稱作為顏色的前綴,這樣即使你和別人使用相同的顏色,也不會遇到意想不到的兼容性問題。

API(應用程序接口)

color - 這應該是自定義顏色

bgColor - 背景顏色

backColor - 背景色

frameColor - 框架顏色

frameOutlineColor - 框架輪廓顏色

descBoxColor - 說明框顏色

trailVfx - 視覺效果尾色

glowColor - 微光顏色

attackBg - 攻擊背景圖像的路徑 (路徑從jar的根目錄開始)

skillBg - 技能背景圖像的路徑 (路徑從jar的根目錄開始)

powerBg - 能力背景圖像的路徑 (路徑從jar的根目錄開始)

(注:這裡指的應該是攻擊,技能,能力牌不同形狀的貼圖框吧)

energyOrb - 能量球圖像路徑 (路徑從jar的根目錄開始)

attackBgPortrait - 卡牌查看視圖的攻擊背景圖像的路徑 (路徑從jar的根目錄開始)

skillBgPortrait - 卡牌查看視圖的技能背景圖像路徑(路徑從jar的根目錄開始)

powerBgPortrait - 卡牌查看視圖的能力背景圖像的路徑 (路徑從jar的根路徑開始)

energyOrbPortrait - 卡片牌查看視圖的能量球圖像路徑 (路徑從jar的根目錄開始)

cardEnergyOrb - 你的卡牌小能量球圖像描述的路徑

-----------------------------------

addColor(AbstractCard.CardColor color, Color everythingColor, String attackBg, String skillBg, String powerBg, String energyOrb, String attackBgPortrait, String skillBgPortrait, String powerBgPortrait, String energyOrbPortrait, String cardEnergyOrb)

-----------------------------------

everythingColor - 對先前版本的所有顏色參數使用相同的顏色

自定義角色

遊戲本體使用AbstractPlayer.PlayerClass枚舉表示角色選項,所以為了添加一個新角色到遊戲中,除了註冊它到BaseMod,你還需要使用ModTheSpire的enum補丁功能。下面是一個例子,展示瞭如何做到這一點:

-----------------------------------

import com.evacipated.cardcrawl.modthespire.lib.SpireEnum;

import com.megacrit.cardcrawl.characters.AbstractPlayer;


public class MyPlayerClassEnum {


 @SpireEnum

 public static AbstractPlayer.PlayerClass MY_PLAYER_CLASS;

}

-----------------------------------

要求

1.(前置條件)用BaseMod為玩家註冊一個新的自定義顏色-看看這裡是怎麼做的https://github.com/daviscook477/BaseMod/wiki/Custom-Colors

2.定義一個具有public class CharSelectInfo getLoadout()方法的自定義角色類

3.將自定義角色註冊到BaseMod

API

注意,addCharacter只能在EditCharactersSubscriber的receiveEditCharacters回調中調用

addCharacter(Class characterClass, String titleString, String classString, String color, String selectText, String selectButton, String portrait, String characterID)

character - 你的角色的一個實例

color - 這個角色的自定義顏色的名稱,例如:MY_CUSTOM_COLOR.toString() 

其中MY_CUSTOM_COLOR是該字符顏色的枚舉值


selectButtonPath - 選擇按鈕貼圖的路徑(從jar的根目錄開始)

portraitPath - 你的角色選擇描述貼圖路徑(從你的jar的根目錄開始)(尺寸: 1920px x 1200px)

characterID - 應該是MY_PLAYER_CLASS, MY_PLAYER_CLASS是這個角色的類的枚舉值

例子

要添加自定義角色,必須執行以下兩個步驟——定義自定義角色並將其註冊到BaseMod。

定義一個自定義角色(比較長)

-----------------------------------

import java.util.ArrayList;


import com.badlogic.gdx.math.MathUtils;

import com.esotericsoftware.spine.AnimationState;

import com.megacrit.cardcrawl.actions.utility.ExhaustAllEtherealAction;

import com.megacrit.cardcrawl.characters.AbstractPlayer;

import com.megacrit.cardcrawl.core.EnergyManager;

import com.megacrit.cardcrawl.core.Settings;

import com.megacrit.cardcrawl.dungeons.AbstractDungeon;

import com.megacrit.cardcrawl.powers.AbstractPower;

import com.megacrit.cardcrawl.screens.CharSelectInfo;

import com.megacrit.cardcrawl.unlock.UnlockTracker;

//創建角色類,繼承自定義角色

public class MyCharacter extends CustomPlayer {

 public static final int ENERGY_PER_TURN = 3; // 你每回合的能量是多少

 public static final String MY_CHARACTER_SHOULDER_2 = "img/char/shoulder2.png"; // 火堆姿勢

        public static final String MY_CHARACTER_SHOULDER_1 = "img/char/shoulder1.png"; // 另一個火堆姿勢

 public static final String MY_CHARACTER_CORPSE = "img/char/corpse.png"; // 角色死亡時的屍體

        public static final String MY_CHARACTER_SKELETON_ATLAS = "img/char/skeleton.atlas"; // spine animation atlas(指的是骨架?)

        public static final String MY_CHARACTER_SKELETON_JSON = "img/char/skeleton.json"; // spine animation json(骨架json)

//繼承父類構造方法,傳遞參數name, MyPlayerClassEnum.MY_PLAYER_CLASS

 public MyCharacter (String name) {

  super(name, MyPlayerClassEnum.MY_PLAYER_CLASS);

  

  this.dialogX = (this.drawX + 0.0F * Settings.scale); // 設置文本氣泡的位置

  this.dialogY = (this.drawY + 220.0F * Settings.scale); // 你可以複製這些值

  

  initializeClass(null, MY_CHARACTER_SHOULDER_2, // 需要調用加載貼圖和設置能量/加載

    MY_CHARACTER_SHOULDER_1,

    MY_CHARACTER_CORPSE, 

    getLoadout(), 20.0F, -10.0F, 220.0F, 290.0F, new EnergyManager(ENERGY_PER_TURN));

  

  loadAnimation(MY_CHARACTER_SKELETON_ATLAS, MY_CHARACTER_SKELETON_JSON, 1.0F); // 如果你使用的是基礎遊戲動畫的修改版本,或者在(骨架?)中製作動畫,請確保包括這一點和以下幾行

  

  AnimationState.TrackEntry e = this.state.setAnimation(0, "animation", true);

  e.setTime(e.getEndTime() * MathUtils.random());

 }


 public static ArrayList<String> getStartingDeck() { // 初始牌組,沒什麼好說的

  //將初始卡牌添加到集合

  ArrayList<String> retVal = new ArrayList<>();

  retVal.add("MyCard0");

  retVal.add("MyCard0");

  retVal.add("MyCard0");

  retVal.add("MyCard0");

  retVal.add("MyCard1");

  retVal.add("MyCard1");

  retVal.add("MyCard1");

  retVal.add("MyCard1");

  retVal.add("MyCard2");

  return retVal;

 }

 public static ArrayList<String> getStartingRelics() { // 添加初始遺物 - 也挺簡單

  ArrayList<String> retVal = new ArrayList<>();

  retVal.add("MyRelic");

  UnlockTracker.markRelicAsSeen("MyRelic");

  return retVal;

 }

//初始血量

        public static final int STARTING_HP = 75;

//初始血上限

        public static final int MAX_HP = 75;

//初始金幣數

        public static final int STARTING_GOLD = 99;

        public static final int HAND_SIZE = 5;


 public static CharSelectInfo getLoadout() { // 其餘的角色面板內容,包括你的角色選擇頁面信息加上HP和初始金幣

  return new CharSelectInfo("My Character", "My character is a person from the outer worlds. He makes magic stuff happen.",

    STARTING_HP, MAX_HP, ORB_SLOTS, STARTING_GOLD, HAND_SIZE,

   this, getStartingRelics(), getStartingDeck(), false);

 }

}

-----------------------------------

添加到BaseMod

注意,如果要做到這一點,你的mod必須為角色添加必要的自定義顏色,就像之前的百科頁面上的自定義顏色所說的那樣。

-----------------------------------

@SpireInitializer

//創建MyMod類實現EditCharactersSubscriber接口

public class MyMod implements EditCharactersSubscriber {

//構造函數,調用BaseMod裡的subscribeToEditCharacters方法

public MyMod() {

BaseMod.subscribeToEditCharacters(this);

}

public static void initialize() {

MyMod mod = new MyMod();

}

//對receiveEditCharacters()方法進行重載

@Override

public void receiveEditCharacters() {

logger.info("begin editing characters");

logger.info("add " + MyPlayerClassEnum.MY_PLAYER_CLASS.toString());

BaseMod.addCharacter(new MyCharcter(CardCrawlGame.playerName),

MY_CHARACTER_BUTTON,

MY_CHARACTER_PORTRAIT,

MyPlayerClassEnum.MY_PLAYER_CLASS);

logger.info("done editing characters");

}

}

-----------------------------------#殺戮尖塔#   #翻譯#  #mod# 

參考鏈接:https://github.com/daviscook477/BaseMod/wiki/Custom-Colors

https://github.com/daviscook477/BaseMod/wiki/Custom-Characters


© 2022 3樓貓 下載APP 站點地圖 廣告合作:asmrly666@gmail.com