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


3樓貓 發佈時間:2023-03-10 00:31:00 作者:區區一個呆唯__ Language

前言:出於開發mod的需要,筆者打算翻譯一下殺戮尖塔basemod的使用教程。希望各位盒友能督促我儘快完成翻譯工作。對開發殺戮尖塔mod有興趣或者有相關經驗的盒友可以在評論區評論或者私信我。筆者能力尚且不足,如有錯誤請指正。


本文包含:

basemod wiki介紹

自定義卡牌

正文如下:

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

介紹

歡迎訪問Basemod 百科!

這個百科是為方便使用模組的玩家查找安裝步驟/指南和幫助模組製作者熟知一些basemod模組API並查看一些如何添加內容到遊戲中一些代碼實例而設計的。

什麼是BaseMod?

BaseMod是一個殺戮尖塔的模組API。

它允許模組製作者更加簡單地接入基本遊戲功能,而不是必須通過單調的過程來創建大量的字節碼補丁。

它支持以下內容:

1.添加自定義遺物

2.添加自定義卡牌(包括新的卡牌顏色)

3.添加自定義角色類

4.添加自定義藥水

5.添加自定義事件

6.添加自定義怪物

我們未來的計劃是擴展這個API,使它能包含遊戲的更多部分。

目前還有一些插件接口問題要解決:

1.抽牌

2.消耗牌

3.遊戲執行中很多不同的部分,例如:戰鬥結束時,遊戲開始前,等等…

瀏覽這篇百科以瞭解BaseMod提供的具體細節。

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

自定義卡牌

自定義卡牌構造函數

CustomCard(String id, String name, String img, int cost, String rawDescription, CardType type, CardColor color, CardRarity rarity, CardTarget target)

  • id - 卡牌編號
  • name - 卡牌名稱
  • img - 卡牌圖片路徑 (圖片路徑在你的根目錄) (250px x 190px); 你的大版本(應該指的就是右鍵卡牌時看到的大圖)圖片路徑 (500 x 380p) 應該是 img + "_p" 因此如果圖片命名為 "my_card.png" 然後大圖查看版本應該命名為"my_card_p.png". 在測試版畫風中, 文件應該命名為 "my_card_b.png" 以及大圖查看版應該命名為"my_card_b_p.png".
  • cost - 卡牌的能量消耗
  • rawDescription - 卡牌的描述文字
  • type - 卡牌的類型, 例如ATTACK(攻擊), SKILL(技能), POWER(能力)
  • color - 卡牌顏色; 遊戲基本顏色設定是 RED, GREEN, COLORLESS, CURSE, STATUS 不過你也能使用自定義顏色
  • rarity - 卡牌稀有度, 例如COMMON(普通), UNCOMMON(罕見), RARE(稀有)
  • target - 卡牌的目標類型, 例如 does it target ENEMY(是否瞄準敵人), ALL_ENEMIES(所有敵人), SELF(自身), 等等…

自定義卡牌貼圖

下面的方法可以在構造函數中調用,然而,以後如果你想改變紋理,可以在任何時候調用這些方法。

卡牌背景

setBackgroundTexture(String smallTexturePath, String largeTexturePath)

  • smallTexturePath - 貼圖路徑 (512 x 512p).
  • largeTexturePath - 查看視圖貼圖路徑 (1024 x 1024p).

卡牌能量球

setOrbTexture(String smallTexturePath, String largeTexturePath)

  • smallTexturePath - 能量球貼圖路徑 (512 x 512p).
  • largeTexturePath - 能量球查看視圖貼圖路徑(164 x 164p).

卡牌稀有度橫幅

setBannerTexture(String smallTexturePath, String largeTexturePath)

  • smallTexturePath - 貼圖路徑 (512 x 512p).
  • largeTexturePath - 查看視圖貼圖路徑 (1024 x 1024p).

註冊(卡牌)

為了使用下面的方法來添加和刪除卡牌,你必須在你的主模組文件裡實現EditCardsSubscriber方法,然後重載receiveEditCards方法。

在該方法中,你需要添加或刪除卡牌。

  • BaseMod.addCard(AbstractCard card)(注:CustomCard 繼承AbstractCard)
  • BaseMod.removeCard(AbstractCard card) 從遊戲中刪除一張卡(注:刪除一張事件中使用的卡牌是目前未測試/未定義的行為)

自定義卡牌的例子

假設你想要創建一張卡牌,叫做Flare,它未升級的時候能對一名敵人造成3點傷害,給予1層易傷(不如閃電霹靂),升級後,對一名敵人造成6點傷害,給予2層易傷。(小痛擊)。

如果這張卡是紅色的,並且把圖片放在你的jar文件的img/my_card_img.png路徑下,下面的代碼將創建這張卡:

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

import com.megacrit.cardcrawl.actions.AbstractGameAction;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;

import com.megacrit.cardcrawl.cards.AbstractCard;

import com.megacrit.cardcrawl.cards.DamageInfo;

import com.megacrit.cardcrawl.characters.AbstractPlayer;

import com.megacrit.cardcrawl.dungeons.AbstractDungeon;

import com.megacrit.cardcrawl.monsters.AbstractMonster;

import com.megacrit.cardcrawl.powers.VulnerablePower;


import basemod.abstracts.CustomCard;

//創建Flare的對象,繼承CustomCard抽象類

public class Flare

extends CustomCard {

    public static final String ID = "myModID:Flare";

    private static CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);

    // 獲取包含在遊戲中顯示的字符串的對象。

    public static final String NAME = cardStrings.NAME;

    public static final String DESCRIPTION = cardStrings.DESCRIPTION;

    public static final String IMG_PATH = "img/my_card_img.png";

//卡牌費用

    private static final int COST = 0;

//卡牌基礎傷害

    private static final int ATTACK_DMG = 3;

//升級後增加的傷害

    private static final int UPGRADE_PLUS_DMG = 3;

//易傷層數

    private static final int VULNERABLE_AMT = 1;

//升級後增加的易傷層數

    private static final int UPGRADE_PLUS_VULNERABLE = 1;

//調用父類的有參構造,傳遞參數,之前有介紹過

    public Flare() {

        super(ID, NAME, IMG_PATH, COST, DESCRIPTION,

          AbstractCard.CardType.ATTACK, AbstractCard.CardColor.RED,

          AbstractCard.CardRarity.UNCOMMON, AbstractCard.CardTarget.ENEMY);

        this.magicNumber = this.baseMagicNumber = VULNERABLE_AMT;

        this.damage=this.baseDamage = ATTACK_DMG;

        

//添加背景圖片        this.setBackgroundTexture("img/custom_background_small.png", "img/custom_background_large.png");


//添加能量球圖片        this.setOrbTexture("img/custom_orb_small.png", "img/custom_orb_large.png");


//添加稀有度橫幅圖片        this.setBannerTexture("img/custom_banner_large.png", "img/custom_banner_large.png");

    }

//使用卡牌時觸發的動作,包括傷害邏輯,而且造成傷害的代碼一般是寫在方法末尾的,所以有“動作優先於傷害”的說法

    @Override

    public void use(AbstractPlayer p, AbstractMonster m) {

     AbstractDungeon.actionManager.addToBottom(new com.megacrit.cardcrawl.actions.common.DamageAction(m,

    new DamageInfo(p, this.damage, this.damageTypeForTurn),

    AbstractGameAction.AttackEffect.SLASH_DIAGONAL));

     AbstractDungeon.actionManager.addToBottom(new ApplyPowerAction(m, p, new VulnerablePower(m, this.magicNumber, false), this.magicNumber, true, AbstractGameAction.AttackEffect.NONE));

    }

//複製卡牌後獲得一張新的卡牌,舉個例子,初始卡牌就是通過makeCopy方法被複制進牌庫的

    @Override

    public AbstractCard makeCopy() {

        return new Flare();

    }

//升級卡牌的名稱修改,假設敲一張“打擊”,就會變成“打擊+”

    @Override

    public void upgrade() {

        if (!this.upgraded) {

            this.upgradeName();

 //升級傷害增加值           this.upgradeDamage(UPGRADE_PLUS_DMG);

 //升級其他屬性增加值           this.upgradeMagicNumber(UPGRADE_PLUS_VULNERABLE);

        }

    }

}

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

查看視圖注意事項

在百科大全的卡牌總覽界面上有一個查看視圖,它會顯示你的卡的更大版本。通過在名稱中添加_p,能根據原始圖像位置自動找到它。這張貼圖的大小應該是500px x 380px。更改名稱的一個例子是img/my_card.png變成img/my_card_p.png。

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

參考鏈接:

https://github.com/daviscook477/BaseMod

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


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