DOF/sqr/User/UI/Window/2_Create_Character.nut

718 lines
22 KiB
Plaintext
Raw Normal View History

2024-12-15 21:37:00 +08:00
/*
文件名:2_create_Character.nut
路径:User/UI/Window/2_create_Character.nut
创建日期:2024-12-15 17:40
文件用途: 创建角色
*/
2024-12-18 07:02:27 +08:00
// 底部光动画类型
enum BottomLightAniType {
light
firedust
dust
aura
}
// 获取职业信息
function getJobInfo( job ) {
local T = {};
switch (job) {
case CHARACTERJOB.SWORDMAN: // 男鬼剑士 d
T = {
index = 0, // 索引
nameIndex = 0, // 名称索引
ani = BottomLightAniType.dust,
name = "鬼剑士",
info = "借助凝聚在左手上鬼神之力压制敌人的鬼剑士。", // 介绍
changJob = "剑魂 / 鬼泣 / 狂战士 / 阿修罗" // 转职
};
break;
case CHARACTERJOB.FIGHTER: // 女格斗家 d
T = {
index = 1, // 索引
nameIndex = 1, // 名称索引
ani = BottomLightAniType.dust,
name = "格斗家",
info = "注重身体各不为的锻炼,并熟练运用它们攻击敌人的武道家。", // 介绍
changJob = "气功师 / 散打 / 街霸 / 柔道家" // 转职
};
break;
case CHARACTERJOB.GUNNER: // 男神枪手 d
T = {
index = 2, // 索引
nameIndex = 2, // 名称索引
ani = BottomLightAniType.dust,
name = "神枪手",
info = "生活在天界的神枪手,是善于利用枪械压制敌人的战士。", // 介绍
changJob = "漫游枪手 / 枪炮师 / 机械师 / 弹药专家 / 合金战士" // 转职
};
break;
case CHARACTERJOB.MAGE: // 女魔法师 l
T = {
index = 3, // 索引
nameIndex = 3, // 名称索引
ani = BottomLightAniType.light,
name = "魔法师",
info = "善用魔法力量攻击敌人的魔族。", // 介绍
changJob = "元素师 / 召唤师 / 战斗法师 / 魔道学者 / 小魔女" // 转职
};
break;
case CHARACTERJOB.PRIEST: // 男圣职者 l
T = {
index = 4, // 索引
nameIndex = 4 // 名称索引
ani = BottomLightAniType.light,
name = "光职者",
info = "心怀正义,为惩恶扬善甘愿接收严苛训练的勇士。", // 介绍
changJob = "光明骑士 / 蓝拳使者 / 驱魔师 / 惩戒者" // 转职
};
break;
case CHARACTERJOB.AT_GUNNER: // 女神枪手 f
T = {
index = 5, // 索引
nameIndex = 2, // 名称索引
ani = BottomLightAniType.firedust,
name = "神枪手",
info = "生活在天界的神枪手,是善于利用枪械压制敌人的战士。", // 介绍
changJob = "漫游枪手 / 枪炮师 / 机械师 / 弹药专家" // 转职
};
break;
case CHARACTERJOB.THIEF: // 暗夜使者 a
T = {
index = 6, // 索引
nameIndex = 5, // 名称索引
ani = BottomLightAniType.aura,
name = "暗夜使者",
info = "用敏捷身手执行特别人物的暗精灵成员。", // 介绍
changJob = "暗星 / 黑夜术士 / 忍者 / 影武者" // 转职
};
break;
case CHARACTERJOB.AT_FIGHTER: // 男格斗家 f
T = {
index = 7, // 索引
nameIndex = 1, // 名称索引
ani = BottomLightAniType.firedust,
name = "格斗家",
info = "注重身体各不为的锻炼,并熟练运用它们攻击敌人的武道家。", // 介绍
changJob = "气功师 / 散打 / 街霸 / 柔道家" // 转职
};
break;
case CHARACTERJOB.AT_MAGE: // 男魔法师 a
T = {
index = 8, // 索引
nameIndex = 3, // 名称索引
ani = BottomLightAniType.aura,
name = "魔法师",
info = "善用魔法力量攻击敌人的魔族。", // 介绍
changJob = "元素爆破师 / 冰洁师 / 猩红法师 / 逐风者 / 次元行者" // 转职
};
break;
case CHARACTERJOB.DEMONIC_SWORDMAN: // 黑暗武士 a
T = {
index = 9, // 索引
nameIndex = 10, // 名称索引
ani = BottomLightAniType.aura,
name = " 黑暗武士",
info = "跨越时空之门,超越界限之力的剑士。", // 介绍
changJob = "黑暗武士" // 转职
};
break;
case CHARACTERJOB.CREATOR_MAGE: // 缔造者 l
T = {
index = 10, // 索引
nameIndex = 11, // 名称索引
ani = BottomLightAniType.light,
name = " 缔造者",
info = "从异次元裂缝中获得强大力量的魔法师。", // 介绍
changJob = "缔造者" // 转职
};
break;
case CHARACTERJOB.AT_SWORDMAN: // 女鬼剑士 d
T = {
index = 11, // 索引
nameIndex = 0, // 名称索引
ani = BottomLightAniType.dust,
name = "鬼剑士",
info = "同样拥有鬼手,却能实战不同的魔力。", // 介绍
changJob = "驭剑士 / 暗殿骑士 / 契魔者 / 流浪武士 / 刃影" // 转职
};
break;
case CHARACTERJOB.KNIGHT: // 守护者 l
T = {
index = 12, // 索引
nameIndex = 6, // 名称索引
ani = BottomLightAniType.light,
name = "守护者",
info = "穿越各个次元,在战场上驰骋的少女。", // 介绍
changJob = "精灵骑士 / 混沌魔灵 / 帕拉丁 / 龙骑士" // 转职
};
break;
case CHARACTERJOB.DEMONIC_LANCER: // 魔枪士 d
T = {
index = 13, // 索引
nameIndex = 7, // 名称索引
ani = BottomLightAniType.dust,
name = "魔枪士",
info = "使用蕴含魔力的长枪,专研枪术的战士。", // 介绍
changJob = "征战者 / 决战者 / 狩猎者 / 暗枪士" // 转职
};
break;
case CHARACTERJOB.AT_PRIEST: // 女圣职者 l
T = {
index = 14, // 索引
nameIndex = 4, // 名称索引
ani = BottomLightAniType.light,
name = "光职者",
info = "心怀正义,为惩恶扬善甘愿接收严苛训练的勇士。", // 介绍
changJob = "光明骑士 / 正义审判者 / 驱魔师 / 除恶者" // 转职
};
break;
case CHARACTERJOB.GUN_BLADER: // 枪剑士 d
T = {
index = 15, // 索引
nameIndex = 8, // 名称索引
ani = BottomLightAniType.dust,
name = "枪剑士",
info = "执着枪与剑的浪漫的天界人。", // 介绍
changJob = "暗刃 / 特工 / 战线佣兵 / 源能专家" // 转职
};
break;
case CHARACTERJOB.ARCHER: // 弓箭手 l
T = {
index = 16, // 索引
nameIndex = 9, // 名称索引
ani = BottomLightAniType.light,
name = "弓箭手",
info = "为了守护家园,携弓箭走上冒险之旅的神界人。", // 介绍
changJob = "缪斯 / 旅人 / 猎人 / 妖护使" // 转职
};
break;
default:
break;
}
return T;
}
function getJobEnum(index) {
local jobList = [CHARACTERJOB.SWORDMAN, CHARACTERJOB.AT_SWORDMAN, CHARACTERJOB.AT_FIGHTER, CHARACTERJOB.FIGHTER, CHARACTERJOB.GUNNER, CHARACTERJOB.AT_GUNNER, CHARACTERJOB.AT_MAGE, CHARACTERJOB.MAGE, CHARACTERJOB.PRIEST, CHARACTERJOB.AT_PRIEST, CHARACTERJOB.THIEF, CHARACTERJOB.KNIGHT, CHARACTERJOB.DEMONIC_LANCER, CHARACTERJOB.GUN_BLADER, CHARACTERJOB.ARCHER, CHARACTERJOB.DEMONIC_SWORDMAN,CHARACTERJOB.CREATOR_MAGE ];
return jobList[index];
}
//创建角色
class _CreateCharacter extends Yosin_Window {
2024-12-15 21:37:00 +08:00
//调试模式
// DeBugMode = true;
//不是窗口
// NoWindow = true;
//是否可见
// Visible = false;
2024-12-18 07:02:27 +08:00
BackGround = null;
2024-12-18 08:54:32 +08:00
headList = null;
2024-12-18 07:02:27 +08:00
jobImg = null;
nextJobImg = null;
infoWidget = null;
topLightObj = null;
lightAni = null;
dustAni = null;
firedustAni = null;
auraAni = null;
changJobAniClock = null;
changNextJobAniClock = null;
2024-12-15 21:37:00 +08:00
2024-12-18 08:54:32 +08:00
nextJobIndex = null;
2024-12-15 21:37:00 +08:00
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
//注册绘制
RegisterDraw();
//注册控件
RegisterWidget();
}
function PlayBackgroundMusic() {
}
2024-12-18 07:02:27 +08:00
function RegisterWidget() {
//头像
2024-12-18 08:54:32 +08:00
headList = _CreateCharacter_SelectBaseHeadList(135, 40);
2024-12-18 07:02:27 +08:00
AddUIChild(headList);
headList.OnClick = changJob.bindenv(this);
// 职业介绍
infoWidget = _CreateCharacter_SelectBaseInfo(140, 400);
AddUIChild(infoWidget);
infoWidget.SetJob(getJobInfo(CHARACTERJOB.SWORDMAN));
// 创建职业
infoWidget.OnClick = function () {
}.bindenv(this);
2024-12-15 21:37:00 +08:00
}
2024-12-18 07:02:27 +08:00
// 切换职业
function changJob(index) {
if (index == nextJobIndex) return;
2024-12-18 08:54:32 +08:00
2024-12-18 07:02:27 +08:00
local jobEnum = getJobEnum(index);
2024-12-18 08:54:32 +08:00
nextJobIndex = index;
// 切换背景
BackGround.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/characterbackground.img", jobEnum));
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum));
local info = getJobInfo(jobEnum);
// 切换介绍
infoWidget.SetJob(getJobInfo(jobEnum));
// 切换底部光动画
lightAni.SetVisible(false);
firedustAni.SetVisible(false);
dustAni.SetVisible(false);
auraAni.SetVisible(false);
switch (info.ani){
case BottomLightAniType.light:
lightAni.SetVisible(true);
break;
case BottomLightAniType.firedust:
firedustAni.SetVisible(true);
case BottomLightAniType.dust:
dustAni.SetVisible(true);
break;
case BottomLightAniType.aura:
auraAni.SetVisible(true);
break;
}
2024-12-18 07:02:27 +08:00
2024-12-18 08:54:32 +08:00
// 开始切换动画
if (changJobAniClock == null) {
changJobAniClock = clock();
}
changNextJobAniClock = clock();
2024-12-15 21:37:00 +08:00
}
// 切换动画控制
function changJobAniController(progressBlock, doneBlock, next = true) {
2024-12-18 07:02:27 +08:00
if (next) {
if (changNextJobAniClock == null) {
print("NextNull");
return;
}
2024-12-18 07:02:27 +08:00
}else {
if (changJobAniClock == null) {
print("NUll");
return;
}
}
2024-12-18 07:02:27 +08:00
2024-12-18 08:54:32 +08:00
// 动画的前90%后10%,慢
local ani_progress = Math.sq_GetAccel(0, 100, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.3, false);
2024-12-18 08:54:32 +08:00
if (ani_progress >= 90){
ani_progress = Math.sq_GetAccel(0, 10, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.7, false) + 90 ;
2024-12-18 08:54:32 +08:00
}
local x = ani_progress * 5.0;
if (progressBlock != null) progressBlock(ani_progress);
2024-12-18 07:02:27 +08:00
2024-12-18 08:54:32 +08:00
if (ani_progress >= 100){
if (doneBlock != null) doneBlock();
}
}
/// 切换当前职业动画
function changCurrnentJobAni() {
if (changJobAniClock == null) return;
changJobAniController(function(ani_progress) {
local x = ani_progress * 5.0;
jobImg.SetPosition( 0 - x, 0);
jobImg.SetOpacity( (100.0 - ani_progress.tofloat()) / 100.0 );
}.bindenv(this), function () {
2024-12-18 07:02:27 +08:00
changJobAniClock = null;
}.bindenv(this),false );
}
// 切换职业动画
function changNextJobAni() {
if (changNextJobAniClock == null) return;
changJobAniController(function(ani_progress) {
local x = ani_progress * 5.0;
nextJobImg.SetPosition(500 - x, 0);
// 动画的前90%透明度进度为50%后10%透明度进度为剩下的50%
local opacity = ani_progress.tofloat() / 180.0;
if (opacity > 0.5) opacity = (ani_progress.tofloat() - 90.0) / 20.0 + 0.5;
nextJobImg.SetOpacity( opacity );
}.bindenv(this), function () {
changNextJobAniClock = null;
2024-12-18 08:54:32 +08:00
local jobEnum = getJobEnum(nextJobIndex);
jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum ));
jobImg.SetOpacity(1);
jobImg.SetPosition(0, 0);
2024-12-18 08:54:32 +08:00
if (nextJobIndex < 16) {
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(nextJobIndex + 1)));
nextJobImg.SetOpacity(0);
nextJobImg.SetPosition(500, 0);
}
2024-12-18 07:02:27 +08:00
}.bindenv(this) );
}
2024-12-18 07:02:27 +08:00
2024-12-15 21:37:00 +08:00
function RegisterDraw() {
//大背景
2024-12-18 07:02:27 +08:00
BackGround = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbackground.img", 0);
2024-12-15 21:37:00 +08:00
Addchild(BackGround);
2024-12-18 07:02:27 +08:00
// 人物图片
jobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 0);
jobImg.SetPosition(0, 0);
Addchild(jobImg);
// 下一个人物图片
nextJobImg = CL_SpriteObject("sprite/interface2/charactercreatever2/basecharctertitle.img", 11);
nextJobImg.SetPosition(500, 0);
2024-12-18 08:54:32 +08:00
nextJobImg.SetOpacity(0);
2024-12-18 07:02:27 +08:00
Addchild(nextJobImg);
// 光动画 ui/charactercreate/topdodge.ani
topLightObj = Animation("ui/charactercreate/topdodge.ani");
topLightObj.SetPosition(0, 0);
Addchild(topLightObj);
// 底部光动画
lightAni = Animation("ui/charactercreate/dust.ani");
lightAni.SetPosition(0, 0);
// lightAni.SetVisible(false);
Addchild(lightAni);
firedustAni = Animation("ui/charactercreate/firedust.ani");
firedustAni.SetPosition(0, 0);
firedustAni.SetVisible(false);
Addchild(firedustAni);
dustAni = Animation("ui/charactercreate/dust.ani");
dustAni.SetPosition(0, 0);
dustAni.SetVisible(false);
Addchild(dustAni);
auraAni = Animation("ui/charactercreate/aura.ani");
auraAni.SetPosition(0, 0);
auraAni.SetVisible(false);
Addchild(auraAni);
2024-12-15 21:37:00 +08:00
}
//逻辑入口
function Proc(Dt) {
SyncPos(X, Y);
base.Proc(Dt);
changCurrnentJobAni();
changNextJobAni();
2024-12-18 07:02:27 +08:00
}
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
}
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
//选择创建基础介绍
class _CreateCharacter_SelectBaseInfo extends Yosin_Window {
//是否为独立窗口
IsIndependent = false;
icon = null;
name = null;
jobInfo = null;
jobChangeText = null;
OnClick = null;
constructor(gX, gY ) {
base.constructor("创建角色职业介绍信息", gX, gY, 278, 600, 0);
// 职业图标
icon = CL_SpriteObject("sprite/interface2/charactercreatever2/charactermark.img", 0);
icon.SetPosition(0, 0);
Addchild(icon);
//职业名称
name = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 0);
name.SetPosition(55, 10);
Addchild(name);
// 职业介绍
jobInfo = FontAssetManager.GenerateNormal("职业介绍", false, {
color = sq_RGBA(194, 160, 53, 255)
});
jobInfo.SetPosition(0, 52);
Addchild(jobInfo);
local jobChangeTextY = 52 + jobInfo.GetSize().h + 5;
// 转职
jobChangeText = FontAssetManager.GenerateNormal("■ 转职:转职名 / 转职名", true, {
color = sq_RGBA(194, 160, 53, 255)
});
jobChangeText.SetPosition(0, jobChangeTextY);
Addchild(jobChangeText);
//创建角色按钮
local createButton = Yosin_SplicingButton(59, jobChangeTextY + 30, 160, 36, "sprite/interface/lenheartwindowcommon.img", 172, true, false);
2024-12-18 07:02:27 +08:00
//点击事件回调
createButton.OnClick = function(Button) {
if (OnClick) OnClick();
}.bindenv(this);
// 按钮文本
local createText = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 12);
createText.SetPosition(42.5, 8);
createText.SetZOrder(10000);
2024-12-18 07:02:27 +08:00
createButton.Addchild(createText);
AddUIChild(createButton);
2024-12-15 21:37:00 +08:00
}
2024-12-18 07:02:27 +08:00
function SetJob(jobInfoMap) {
icon.SetFrame(CL_SpriteFrameObject( "sprite/interface2/charactercreatever2/charactermark.img", jobInfoMap.index));
name.SetFrame(CL_SpriteFrameObject( "sprite/interface2/charactercreatever2/charctertitle.img", jobInfoMap.nameIndex));
jobInfo.SetText(jobInfoMap.info);
jobChangeText.SetText("■ 转职:" + jobInfoMap.changJob);
2024-12-15 21:37:00 +08:00
}
2024-12-18 07:02:27 +08:00
}
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
//选择创建基础角色头像列表
class _CreateCharacter_SelectBaseHeadList extends Yosin_Window {
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
//是否为独立窗口
IsIndependent = false;
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
// 点击关闭
clickOff = false;
OnClick = null;
buttonList = [];
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
constructor(gX, gY) {
base.constructor("所有的职业头像", gX, gY, 278, 350, 0);
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
local headX = 0;
local headY = 0;
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
for (local i = 0; i < 17; i++) {
local jobEnum = getJobEnum(i);
local headButton = HeadButton(headX, headY, jobEnum, getJobInfo(jobEnum).name);
headButton.tag = i;
AddUIChild(headButton);
buttonList.push(headButton);
headX = headX + 67;
if (i % 4 == 3) {
headX = 0;
headY = headY + 67;
}
}
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
// 点击事件回调
for (local i = 0; i < buttonList.len(); i++) {
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
local headButton = buttonList[i];
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
headButton.OnClick = function (b) {
if (clickOff) return;
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
for (local t = 0; t < buttonList.len(); t++) {
local button = buttonList[t];
button.state = 0;
button.ChangeFrame();
}
headButton.state = 2;
headButton.ChangeFrame();
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
if (OnClick) OnClick(headButton.tag);
}.bindenv(this);
}
local button = buttonList[0];
button.state = 2;
button.ChangeFrame();
}
}
2024-12-15 21:37:00 +08:00
//头像按钮
class HeadButton extends Yosin_CommonUi {
2024-12-18 07:02:27 +08:00
DeBugMode = true;
2024-12-15 21:37:00 +08:00
// 角色名称
name = "";
// 图像id
imageId = 0;
// 状态 0:普通 1:悬停 2:按下 3:不可用
state = 0;
spriteState = 0;
2024-12-18 07:02:27 +08:00
tag = 0;
// 角色头像
Character = null;
jobNameText = null;
// 角色头像覆盖
CharacterCover = null;
yellowBox = null;
blueBox = null;
2024-12-15 21:37:00 +08:00
2024-12-18 07:02:27 +08:00
constructor(X, Y, jobEnum, name, state = 0) {
2024-12-15 21:37:00 +08:00
this.name = name;
this.state = state;
// 计算图像id
this.imageId = jobEnum * 2 + 3;
base.constructor(X, Y, 62, 62);
// 角色头像
2024-12-18 07:02:27 +08:00
Character = CL_SpriteObject( "sprite/interface2/charactercreatever2/characterbtn.img", imageId)
Character.SetPosition(0, 0);
Addchild(Character);
// 转职
jobNameText = FontAssetManager.GenerateNormal(name, true, {
color = sq_RGBA(194, 160, 53, 255)
});
jobNameText.SetPosition( 31 - jobNameText.GetSize().w / 2 , 45);
Addchild(jobNameText);
CharacterCover = CL_SpriteObject( "sprite/interface2/charactercreatever2/characterbtn.img", 0)
CharacterCover.SetPosition(0, 0);
Addchild(CharacterCover);
yellowBox = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbtn.img", 2);
yellowBox.SetPosition(0, 0);
yellowBox.SetVisible(false);
Addchild(yellowBox);
blueBox = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbtn.img", 1);
blueBox.SetPosition(0, 0);
blueBox.SetVisible(false);
Addchild(blueBox);
2024-12-15 21:37:00 +08:00
ChangeFrame();
}
function ChangeFrame() {
if (spriteState == state) return;
2024-12-18 07:02:27 +08:00
spriteState = state;
2024-12-15 21:37:00 +08:00
//不可用
if (state == 3) {
2024-12-18 07:02:27 +08:00
Character.SetFrame(CL_SpriteFrameObject( "sprite/interface2/charactercreatever2/characterbtn.img", imageId + 1));
CharacterCover.SetVisible(false);
yellowBox.SetVisible(false);
blueBox.SetVisible(false);
} else if (state == 2) {
CharacterCover.SetVisible(false);
yellowBox.SetVisible(true);
blueBox.SetVisible(false);
} else if (state == 1) {
CharacterCover.SetVisible(false);
yellowBox.SetVisible(false);
blueBox.SetVisible(true);
2024-12-15 21:37:00 +08:00
}else{
2024-12-18 07:02:27 +08:00
CharacterCover.SetVisible(true);
yellowBox.SetVisible(false);
blueBox.SetVisible(false);
2024-12-15 21:37:00 +08:00
}
2024-12-18 07:02:27 +08:00
2024-12-15 21:37:00 +08:00
}
function Proc(Dt) {
//不可用
if (state == 3) {
return;
} else {
//按下
if (isLBDown) {
2024-12-18 07:02:27 +08:00
// state = 2;
2024-12-15 21:37:00 +08:00
}
//悬停
else if (isInRect) {
if (state == 2) return;
state = 1;
}
//普通
else {
if (state == 2) return;
state = 0;
}
}
ChangeFrame();
}
}