完善更新系统

This commit is contained in:
LingASDJ 2023-04-28 01:30:57 +08:00
parent 6cf586c24c
commit f583f2af62
15 changed files with 222 additions and 121 deletions

View File

@ -188,10 +188,14 @@ scenes.newsscene$newsinfo.enable_news=启用新闻
scenes.gamenewsscene.title=游戏更新
scenes.gamenewsscene$newsinfo.no_internet=正在检查新版本,长时间无响应可能是检查失败,若长时间未成功。请继续游玩,等待下次启动检查游戏
scenes.gamenewsscene$newsinfo.no_internet=正在检查新版本,长时间无响应可能是检查失败,若尚未成功显示更新界面。请点击下方的继续游玩
scenes.gamenewsscene.read_more=继续游玩
scenes.gamenewsscene$articlebutton.btndownload_more=立即下载最新版本
scenes.gamenewsscene$articlebutton.btnfixeddownload=建议安装最新正版
scenes.gamenewsscene$articlebutton.update=最新版本!
scenes.gamenewsscene$articlebutton.desc=你的游戏版本为最新,点击下方继续游戏。
scenes.gamenewsscene$articlebutton.download=Δ更新版本Δ
scenes.gamenewsscene$articlebutton.okay=继续游玩
scenes.rankingsscene.title=最高纪录

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -8,50 +8,49 @@ import com.watabou.utils.Random;
public class Boss extends Mob {
protected static float baseMin;
protected static float baseMax;
protected static float baseAcc;
protected static float baseEva;
protected static float baseHT;
protected static float baseMinDef;
protected static float baseMaxDef;
protected static float baseMin; //最小伤害
protected static float baseMax; //最大伤害
protected static float baseAcc; //命中率
protected static float baseEva; //闪避率
protected static float baseHT; //生命值
protected static float baseMinDef; //最小防御
protected static float baseMaxDef; //最大防御
protected void initProperty() {
properties.add(Property.BOSS);
immunities.add(Grim.class);
immunities.add(ScrollOfPsionicBlast.class);
immunities.add(ScrollOfRetribution.class);
}
protected void initProperty() {
properties.add(Property.BOSS); //添加BOSS属性
immunities.add(Grim.class); //添加Grim类
immunities.add(ScrollOfPsionicBlast.class); //添加ScrollOfPsionicBlast类
immunities.add(ScrollOfRetribution.class); //添加ScrollOfRetribution类
}
protected void initBaseStatus(float min, float max, float acc, float eva, float ht, float mid, float mad) {
baseMin = min;
baseMax = max;
baseAcc = acc;
baseEva = eva;
baseHT = ht;
baseMinDef = mid;
baseMaxDef = mad;
}
protected void initBaseStatus(float min, float max, float acc, float eva, float ht, float mid, float mad) {
baseMin = min; //最小伤害
baseMax = max; //最大伤害
baseAcc = acc; //命中率
baseEva = eva; //闪避率
baseHT = ht; //生命值
baseMinDef = mid; //最小防御
baseMaxDef = mad; //最大防御
}
protected void initStatus(int exp) {
defenseSkill = Math.round(baseEva);
EXP = exp;
HP = HT = Math.round(baseHT);
}
protected void initStatus(int exp) {
defenseSkill = Math.round(baseEva); //闪避率
EXP = exp; //经验值
HP = HT = Math.round(baseHT); //生命值
}
@Override
public int damageRoll() {
return Math.round(Random.NormalFloat( baseMin, baseMax ));
}
@Override
public int damageRoll() {
return Math.round(Random.NormalFloat( baseMin, baseMax )); //随机伤害
}
@Override
public int attackSkill( Char target ) {
return Math.round(baseAcc);
}
@Override
public int attackSkill( Char target ) {
return Math.round(baseAcc); //命中率
}
@Override
public int drRoll() {
return Math.round(Random.NormalFloat(baseMinDef, baseMaxDef));
}
@Override
public int drRoll() {
return Math.round(Random.NormalFloat(baseMinDef, baseMaxDef)); //随机防御
}
}

View File

@ -97,6 +97,11 @@ public class DiamondKnight extends Boss {
return attack;
}
/**
* 无敌判定
* @param effect 无敌效果
* @return true:无敌
*/
// @Override
// public boolean isInvulnerable(Class effect) {
// return this.HP==360;
@ -117,6 +122,11 @@ public class DiamondKnight extends Boss {
return super.act();
}
/**
* 判定是否可以攻击
* @param enemy 目标
* @return true:可以攻击
*/
@Override
protected boolean canAttack( Char enemy ) {
if (pumpedUp > 0){
@ -152,6 +162,7 @@ public class DiamondKnight extends Boss {
return result;
}
@Override
protected boolean getCloser( int target ) {
if (pumpedUp != 0) {
@ -161,6 +172,7 @@ public class DiamondKnight extends Boss {
return super.getCloser( target );
}
@Override
public void damage(int dmg, Object src) {
if (!BossHealthBar.isAssigned()){
@ -174,6 +186,7 @@ public class DiamondKnight extends Boss {
ColdChestBossLevel.State level = ((ColdChestBossLevel)Dungeon.level).pro();
//血量低于360后追加phase并加载楼层的进度方法,加载迷宫
if (level == ColdChestBossLevel.State.START && this.HP <= 360 && phase == 0) {
GLog.n(Messages.get(DiamondKnight.class,"now_go"));
GameScene.flash(0x808080);
@ -211,6 +224,8 @@ public class DiamondKnight extends Boss {
}
}
// 当boos血量低于360时加载第二场景
@Override
public void die( Object cause ) {

View File

@ -245,6 +245,7 @@ public class ColdChestBossLevel extends Level {
//GLog.n(String.valueOf(hero.pos));
}
public void progress(){
switch (pro) {
case GO_START:

View File

@ -8,23 +8,22 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.services.news.GameUpdateNewsArticles;
import com.shatteredpixel.shatteredpixeldungeon.services.news.UpdateNews;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.windows.IconTitle;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.ui.Component;
import com.watabou.utils.DeviceCompat;
import java.util.ArrayList;
import java.util.Calendar;
public class GameNewsScene extends PixelScene {
@ -32,7 +31,7 @@ public class GameNewsScene extends PixelScene {
private static final int BTN_HEIGHT = 22;
private static final int BTN_WIDTH = 100;
RenderedTextBlock title = PixelScene.renderTextBlock(Messages.get(this, "title"), 9);
@Override
public void create() {
super.create();
@ -49,14 +48,14 @@ public class GameNewsScene extends PixelScene {
archs.setSize(w, h);
add(archs);
RenderedTextBlock title = PixelScene.renderTextBlock(Messages.get(this, "title"), 9);
title.hardlight(Window.TITLE_COLOR);
title.setPos(
(w - title.width()) / 2f,
(20 - title.height()) / 2f
);
align(title);
add(title);
// title.hardlight(Window.TITLE_COLOR);
// title.setPos(
// (w - title.width()) / 2f,
// (20 - title.height()) / 2f
// );
// align(title);
// add(title);
float top = 18;
@ -71,6 +70,18 @@ public class GameNewsScene extends PixelScene {
}
StyledButton btnSite = new StyledButton(Chrome.Type.GREY_BUTTON_TR, Messages.get(this, "read_more")){
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
}
};
btnSite.icon(Icons.get(Icons.NEWS));
btnSite.textColor(Window.TITLE_COLOR);
btnSite.setRect(left, 190, fullWidth, BTN_HEIGHT);
add(btnSite);
if (!displayingNoArticles) {
ArrayList<GameUpdateNewsArticles> articles = UpdateNews.articles();
@ -111,26 +122,39 @@ public class GameNewsScene extends PixelScene {
}
rightCol = !rightCol;
}
btnSite.visible= false;
btnSite.active= false;
if(article.ling > Game.versionCode || article.ling < Game.versionCode) {
RenderedTextBlock title = PixelScene.renderTextBlock("你的版本需要更新!", 9);
title.hardlight(Window.RED_COLOR);
title.setPos(
(w - title.width()) / 2f,
(20 - title.height()) / 2f
);
align(title);
add(title);
} else {
RenderedTextBlock title = PixelScene.renderTextBlock("已是最新版本!", 9);
title.hardlight(Window.TITLE_COLOR);
title.setPos(
(w - title.width()) / 2f,
(20 - title.height()) / 2f
);
align(title);
add(title);
}
}
top += gap;
} else {
top += 18;
}
StyledButton btnSite = new StyledButton(Chrome.Type.GREY_BUTTON_TR, Messages.get(this, "read_more")){
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
}
};
btnSite.icon(Icons.get(Icons.NEWS));
btnSite.textColor(Window.TITLE_COLOR);
btnSite.setRect(left, 190, fullWidth, BTN_HEIGHT);
add(btnSite);
}
@Override
public void update() {
if (displayingNoArticles && UpdateNews.articlesAvailable()){
@ -151,11 +175,7 @@ public class GameNewsScene extends PixelScene {
bg = Chrome.get(Chrome.Type.GREY_BUTTON_TR);
add(bg);
String message = "";
if (Messages.lang() != Languages.CHINESE){
message += Messages.get(this, "english_warn");
}
String message = Game.version+"---"+Game.versionCode;
SPDSettings.WiFi(false);
UpdateNews.checkForNews();
@ -228,6 +248,11 @@ public class GameNewsScene extends PixelScene {
}
private static class ArticleButton extends StyledButton {
public static void message(String message) {
Game.runOnRenderThread(() -> ShatteredPixelDungeon.scene().add(new WndMessage(message)));
}
GameUpdateNewsArticles article;
BitmapText date;
@ -235,52 +260,52 @@ public class GameNewsScene extends PixelScene {
super(Chrome.Type.GREY_BUTTON_TR, article.title, 6);
this.article = article;
icon(UpdateNews.parseArticleIcon(article));
Calendar cal = Calendar.getInstance();
cal.setTime(article.date);
date = new BitmapText( UpdateNews.parseArticleDate(article), pixelFont);
date.scale.set(PixelScene.align(0.5f));
date.hardlight( 0x888888 );
date.measure();
//add(date);
IconTitle title = new IconTitle(new ItemSprite( ItemSpriteSheet.MAGICGIRLBOOKS ),article.title);
title.setRect( 30, 20, 100, 0 );
title.setPos( title.centerX(), title.bottom() + 4 );
add(title);
int w = Camera.main.width;
String message = article.summary;
message += "\n\n你现在的游戏版本代码"+ Game.versionCode;
message += "\n\n网络上的游戏版本代码"+ article.ling;
message += "\n\n"+(
article.ling > Game.versionCode ? "✦你的版本是旧版本,请及时更新✦":
article.ling == Game.versionCode ? "Δ版本一致,你已是最新版本。Δ": "Γ版本号大于服务器数据,可能是修改版,请谨慎游玩。Γ");
int fullWidth = PixelScene.landscape() ? 202 : 100;
int left = (w - fullWidth)/2;
if(article.ling > Game.versionCode || article.ling < Game.versionCode){
StyledButton btnDownload = new StyledButton(Chrome.Type.SCROLL,
//这里读取的是外面的数据,Condition 'article.ling < Game.versionCode' is always 'true'
//AS不会判定这种外网数据它实际可以运行请勿通过AS优化此代码
article.ling > Game.versionCode ? Messages.get(this, "btnDownload_more") :
article.ling < Game.versionCode ? Messages.get(this, "btnFixedDownload") : ""){
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.platform.openURI(article.URL);
}
};
btnDownload.icon(Icons.get(article.ling > Game.versionCode?Icons.STATS :
article.ling < Game.versionCode ? Icons.WARNING: Icons.STATS));
btnDownload.textColor(Window.TITLE_COLOR);
btnDownload.setRect(left, 160, fullWidth, BTN_HEIGHT);
add(btnDownload);
}
icon(UpdateNews.parseArticleIcon(article));
RenderedTextBlock text = PixelScene.renderTextBlock( 6 );
text.text( message, 100 );
text.setPos( title.left(), title.bottom() + 4 );
add( text );
ShatteredPixelDungeon.scene().add(new WndOptions(Icons.get(Icons.CHANGES),
article.title,
article.summary,
Messages.get(this, "download"),Messages.get(this, "okay")) {
@Override
protected void onSelect(int index) {
if (index == 0) {
//q:书写下面的代码效果注释
//a:如果是桌面版就打开桌面版的下载链接
//a:如果是安卓版就打开安卓版的下载链接
if(DeviceCompat.isDesktop()){
ShatteredPixelDungeon.platform.openURI(article.DesktopURL);
} else {
ShatteredPixelDungeon.platform.openURI(article.URL);
}
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
} else {
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
}
}
@Override
public void onBackPressed() {
//
}
});
} else {
icon(UpdateNews.parseArticleIcon(article));
ShatteredPixelDungeon.scene().add(new WndOptions(Icons.get(Icons.CHANGES),
Messages.get(this, "update"),
Messages.get(this, "desc"),
Messages.get(this, "okay")) {
@Override
protected void onSelect(int index) {
if (index == 0) {
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
}
}
public void onBackPressed() {
//
}
});
}
}
@Override

View File

@ -15,6 +15,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.EndButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ReloadButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndSettings;
@ -139,6 +140,10 @@ public class TitleScene extends PixelScene {
archs.setSize( w, h );
addToBack( archs );
ReloadButton btnReload = new ReloadButton();
btnReload.setRect(0, 0, 16, 20);
add( btnReload );
Image signs = new Image( BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON_SIGNS ) ) {
private float time = 0;
@Override
@ -224,6 +229,7 @@ public class TitleScene extends PixelScene {
StyledButton btnNews = new NewsButton(GREY_TR, Messages.get(this, "news"));
btnNews.icon(new ItemSprite(ItemSpriteSheet.YELLOWBOOKS, null));
btnNews.icon(new ItemSprite(ItemSpriteSheet.YELLOWBOOKS, null));
add(btnNews);
final int BTN_HEIGHT = 20;

View File

@ -71,7 +71,7 @@ public class WelcomeScene extends PixelScene {
}
if (ShatteredPixelDungeon.versionCode == previousVersion && !SPDSettings.intro()) {
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
ShatteredPixelDungeon.switchNoFade(GameNewsScene.class);
return;
}

View File

@ -2,7 +2,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameNewsScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.FeedBackScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
import com.watabou.input.GameAction;
@ -18,7 +18,7 @@ public class EndButton extends IconButton {
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.switchNoFade(GameNewsScene.class);
ShatteredPixelDungeon.switchNoFade(FeedBackScene.class);
}
@Override

View File

@ -0,0 +1,26 @@
package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameNewsScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
public class ReloadButton extends IconButton{
public ReloadButton() {
super(Icons.CHANGES.get());
width = 20;
height = 20;
}
@Override
protected void onClick() {
super.onClick();
ShatteredPixelDungeon.switchNoFade(GameNewsScene.class);
}
@Override
protected String hoverText() {
return Messages.titleCase(Messages.get(WndKeyBindings.class, "update"));
}
}

View File

@ -15,6 +15,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.ColorBlock;
import com.watabou.noosa.Game;
import com.watabou.utils.DeviceCompat;
public class WndFeedback extends Window {
@ -53,7 +54,12 @@ public class WndFeedback extends Window {
@Override
protected void onClick() {
super.onClick();
Gdx.app.exit();
if(DeviceCompat.isAndroid()){
//由于安卓架构对于下方的LibGDX退出并非完全退出仍然可能有进程在后台运行为此强制抛出错误以达到游戏进程完全停止的目的
throw new IllegalStateException("Died");
} else {
Gdx.app.exit();
}
}
};
btnSponsor.icon(Icons.get(Icons.COMPASS));

View File

@ -73,12 +73,20 @@ public class WndInfoItem extends Window {
layoutFields(item, iconTitle, PixelScene.renderTextBlock(item.info(), 6));
}
/**
* 布局字段
* @param item 物品
* @param iconTitle 物品图标
* @param renderedTextBlock 物品信息
*/
private void layoutFields(Item item, IconTitle iconTitle, RenderedTextBlock renderedTextBlock) {
int i = 120;
renderedTextBlock.maxWidth(120);
while (PixelScene.landscape() && renderedTextBlock.height() > 100.0f && i < 220) {
i += 20;
renderedTextBlock.maxWidth(i);
// q:为什么这里要用while循环
// a因为在横屏的时候如果文字太多会导致窗口的高度超过屏幕的高度所以要不断的增加窗口的宽度直到文字的高度小于窗口的高度
}
if (!Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_1) || !(this instanceof WndUseItem) || (!(item instanceof EquipableItem) && !(item instanceof Wand))) {
iconTitle.setRect(0.0f, 0.0f, (float) i, 0.0f);

View File

@ -73,6 +73,8 @@ public class WndOptions extends Window {
layoutBody(pos, message, options);
}
private void layoutBody(float pos, String message, String... options){
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;

View File

@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GameUpdateNews extends GameUpdateNewsService {
@Override
@ -49,11 +48,17 @@ public class GameUpdateNews extends GameUpdateNewsService {
}
article.summary = xmlArticle.get("summary");
article.ling = xmlArticle.getInt("ling");
article.URL = xmlArticle.getChildByName("link").getAttribute("href");
if (!preferHTTPS) {
article.URL= article.URL.replace("https://", "http://");
}
article.DesktopURL = xmlArticle.getChildByName("kinl").getAttribute("href");
if (!preferHTTPS) {
article.DesktopURL= article.DesktopURL.replace("https://", "http://");
}
Pattern versionCodeMatcher = Pattern.compile("v[0-9]+");
try {
Array<XmlReader.Element> properties = xmlArticle.getChildrenByName("category");
@ -92,3 +97,5 @@ public class GameUpdateNews extends GameUpdateNewsService {
}

View File

@ -11,6 +11,8 @@ public class GameUpdateNewsArticles {
public int ling;
public String URL;
public String DesktopURL;
//the icon is stored as a string here so it can be decoded to an image later
//See News.java for supported formats
public String icon;