909 lines
28 KiB
Plaintext
909 lines
28 KiB
Plaintext
/*
|
||
文件名:2_create_Character.nut
|
||
路径:User/UI/Window/2_create_Character.nut
|
||
创建日期:2024-12-15 17:40
|
||
文件用途: 创建角色
|
||
*/
|
||
|
||
// 底部光动画类型
|
||
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 {
|
||
//调试模式
|
||
// DeBugMode = true;
|
||
|
||
//不是窗口
|
||
// NoWindow = true;
|
||
|
||
//是否可见
|
||
// Visible = false;
|
||
|
||
BackGround = null;
|
||
headList = null;
|
||
jobImg = null;
|
||
nextJobImg = null;
|
||
|
||
infoWidget = null;
|
||
|
||
topLightObj = null;
|
||
lightAni = null;
|
||
dustAni = null;
|
||
firedustAni = null;
|
||
auraAni = null;
|
||
|
||
enter = null;
|
||
|
||
changJobAniClock = null;
|
||
changNextJobAniClock = null;
|
||
|
||
jobIndex = 0;
|
||
|
||
NoticeBox = null;
|
||
|
||
//临时创建角色
|
||
TempCharacter = null;
|
||
|
||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||
|
||
//注册绘制
|
||
RegisterDraw();
|
||
//注册控件
|
||
RegisterWidget();
|
||
|
||
|
||
// 创建角色回包
|
||
MySocket.RegisterHandler(PACKET_ID.CREATE_CHARACTER_CALLBACK, function(Jso) {
|
||
if (NoticeBox) NoticeBox.CloseWindow();
|
||
if (Jso.type == 0) {
|
||
// 创建成功.
|
||
//关闭创建界面
|
||
NoticeBox.DestroyWindow();
|
||
DestroyWindow();
|
||
MySocket.Send(PACKET_ID.QUERY_CHARACTER_LIST, null);
|
||
|
||
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
|
||
Window.AddUpCharacter(TempCharacter);
|
||
} else {
|
||
// 创建失败.
|
||
NoticeBox = _Yosin_MessageBox("创建失败.");
|
||
}
|
||
}.bindenv(this));
|
||
|
||
}
|
||
|
||
|
||
function RegisterDraw() {
|
||
//大背景
|
||
BackGround = CL_SpriteObject("sprite/interface2/charactercreatever2/characterbackground.img", 0);
|
||
Addchild(BackGround);
|
||
|
||
|
||
// 人物图片
|
||
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);
|
||
nextJobImg.SetOpacity(0);
|
||
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);
|
||
|
||
}
|
||
|
||
function RegisterWidget() {
|
||
//头像
|
||
headList = _CreateCharacter_SelectBaseHeadList(135, 40);
|
||
AddUIChild(headList);
|
||
headList.OnClick = changJob.bindenv(this);
|
||
|
||
// 职业介绍
|
||
infoWidget = _CreateCharacter_SelectBaseInfo(140, 400);
|
||
AddUIChild(infoWidget);
|
||
infoWidget.SetJob(getJobInfo(CHARACTERJOB.SWORDMAN));
|
||
|
||
// 创建职业
|
||
infoWidget.OnClick = function() {
|
||
enter.SetVisible(true);
|
||
}.bindenv(this);
|
||
|
||
|
||
// 返回按钮
|
||
local backButton = Yosin_BaseButton(986, 30, 45, 12 "sprite/interface2/charactercreatever2/common_add.img", 0);
|
||
//点击事件回调
|
||
backButton.OnClick = function(Button) {
|
||
CloseWindow();
|
||
}.bindenv(this);
|
||
|
||
|
||
local backText = FontAssetManager.GenerateNormal("返回", true, {
|
||
color = sq_RGBA(159, 137, 80, 255)
|
||
});
|
||
backText.SetUpdateFunc(function(Text, Dt) {
|
||
if (Text.Parent.State == 1 || Text.Parent.State == 2) {
|
||
Text.SetFillColor(sq_RGBA(225, 218, 126, 255));
|
||
} else if (Text.Parent.State == 0) {
|
||
Text.SetFillColor(sq_RGBA(159, 137, 80, 255));
|
||
}
|
||
})
|
||
backText.SetPosition(16, -2.5);
|
||
backButton.Addchild(backText);
|
||
AddUIChild(backButton);
|
||
|
||
|
||
|
||
// 输入名字
|
||
enter = _create_Character_enterName();
|
||
enter.SetVisible(false);
|
||
AddUIChild(enter);
|
||
|
||
// 确定
|
||
enter.OnClick = function(enterName) {
|
||
local jobEnum = getJobEnum(jobIndex);
|
||
TempCharacter = {
|
||
lv = 1,
|
||
name = enterName,
|
||
job = jobEnum,
|
||
equip = []
|
||
};
|
||
MySocket.Send(PACKET_ID.CREATE_CHARACTER, {
|
||
name = enterName,
|
||
job = jobEnum,
|
||
});
|
||
}.bindenv(this);
|
||
|
||
}
|
||
|
||
|
||
// 切换职业
|
||
function changJob(index) {
|
||
if (index == jobIndex) return;
|
||
|
||
local jobEnum = getJobEnum(index);
|
||
|
||
jobIndex = 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;
|
||
}
|
||
|
||
|
||
// 开始切换动画
|
||
if (changJobAniClock == null) {
|
||
changJobAniClock = clock();
|
||
}
|
||
changNextJobAniClock = clock();
|
||
}
|
||
|
||
// 切换动画控制
|
||
function changJobAniController(progressBlock, doneBlock, next = true) {
|
||
|
||
if (next) {
|
||
if (changNextJobAniClock == null) {
|
||
print("NextNull");
|
||
return;
|
||
}
|
||
|
||
} else {
|
||
if (changJobAniClock == null) {
|
||
print("NUll");
|
||
return;
|
||
}
|
||
}
|
||
|
||
// 动画的前90%,快,后10%,慢
|
||
local ani_progress = Math.sq_GetAccel(0, 100, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.3, false);
|
||
if (ani_progress >= 90) {
|
||
ani_progress = Math.sq_GetAccel(0, 10, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.7, false) + 90;
|
||
}
|
||
local x = ani_progress * 5.0;
|
||
|
||
if (progressBlock != null) progressBlock(ani_progress);
|
||
|
||
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() {
|
||
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;
|
||
|
||
local jobEnum = getJobEnum(jobIndex);
|
||
jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum));
|
||
jobImg.SetOpacity(1);
|
||
jobImg.SetPosition(0, 0);
|
||
|
||
if (jobIndex< 16) {
|
||
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(jobIndex + 1)));
|
||
nextJobImg.SetOpacity(0);
|
||
nextJobImg.SetPosition(500, 0);
|
||
}
|
||
|
||
}.bindenv(this));
|
||
|
||
}
|
||
|
||
|
||
|
||
//逻辑入口
|
||
function Proc(Dt) {
|
||
|
||
SyncPos(X, Y);
|
||
base.Proc(Dt);
|
||
|
||
changCurrnentJobAni();
|
||
changNextJobAni();
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
//选择创建基础介绍
|
||
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);
|
||
//点击事件回调
|
||
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);
|
||
createButton.Addchild(createText);
|
||
AddUIChild(createButton);
|
||
|
||
}
|
||
|
||
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);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
//选择创建基础角色头像列表
|
||
class _CreateCharacter_SelectBaseHeadList extends Yosin_Window {
|
||
|
||
//是否为独立窗口
|
||
IsIndependent = false;
|
||
|
||
// 点击关闭
|
||
clickOff = false;
|
||
|
||
OnClick = null;
|
||
|
||
buttonList = [];
|
||
|
||
constructor(gX, gY) {
|
||
base.constructor("所有的职业头像", gX, gY, 278, 350, 0);
|
||
|
||
local headX = 0;
|
||
local headY = 0;
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
// 点击事件回调
|
||
for (local i = 0; i< buttonList.len(); i++) {
|
||
|
||
local headButton = buttonList[i];
|
||
|
||
headButton.OnClick = function(b) {
|
||
if (clickOff) return;
|
||
|
||
for (local t = 0; t< buttonList.len(); t++) {
|
||
local button = buttonList[t];
|
||
button.state = 0;
|
||
button.ChangeFrame();
|
||
}
|
||
headButton.state = 2;
|
||
headButton.ChangeFrame();
|
||
|
||
if (OnClick) OnClick(headButton.tag);
|
||
|
||
}.bindenv(this);
|
||
}
|
||
|
||
local button = buttonList[0];
|
||
button.state = 2;
|
||
button.ChangeFrame();
|
||
|
||
}
|
||
|
||
}
|
||
|
||
//头像按钮
|
||
class HeadButton extends Yosin_CommonUi {
|
||
|
||
DeBugMode = true;
|
||
|
||
// 角色名称
|
||
name = "";
|
||
|
||
// 图像id
|
||
imageId = 0;
|
||
|
||
// 状态 0:普通 1:悬停 2:按下 3:不可用
|
||
state = 0;
|
||
spriteState = 0;
|
||
|
||
tag = 0;
|
||
|
||
// 角色头像
|
||
Character = null;
|
||
jobNameText = null;
|
||
|
||
// 角色头像覆盖
|
||
CharacterCover = null;
|
||
|
||
yellowBox = null;
|
||
|
||
blueBox = null;
|
||
|
||
|
||
|
||
constructor(X, Y, jobEnum, name, state = 0) {
|
||
|
||
this.name = name;
|
||
this.state = state;
|
||
|
||
// 计算图像id
|
||
this.imageId = jobEnum * 2 + 3;
|
||
|
||
|
||
base.constructor(X, Y, 62, 62);
|
||
|
||
// 角色头像
|
||
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);
|
||
|
||
ChangeFrame();
|
||
}
|
||
|
||
function ChangeFrame() {
|
||
if (spriteState == state) return;
|
||
spriteState = state;
|
||
|
||
//不可用
|
||
if (state == 3) {
|
||
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);
|
||
} else {
|
||
CharacterCover.SetVisible(true);
|
||
yellowBox.SetVisible(false);
|
||
blueBox.SetVisible(false);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
function Proc(Dt) {
|
||
//不可用
|
||
if (state == 3) {
|
||
return;
|
||
} else {
|
||
//按下
|
||
if (isLBDown) {
|
||
// state = 2;
|
||
}
|
||
//悬停
|
||
else if (isInRect) {
|
||
if (state == 2) return;
|
||
state = 1;
|
||
}
|
||
//普通
|
||
else {
|
||
if (state == 2) return;
|
||
state = 0;
|
||
}
|
||
}
|
||
ChangeFrame();
|
||
}
|
||
}
|
||
|
||
// 输入角色名称
|
||
class _create_Character_enterName extends Yosin_Window {
|
||
|
||
nameInputBox = null;
|
||
|
||
//是否为独立窗口
|
||
IsIndependent = false;
|
||
|
||
affirmButton = null;
|
||
|
||
OnClick = null;
|
||
|
||
// 检查过的名称
|
||
checkName = null;
|
||
// 当前名称
|
||
name = null;
|
||
|
||
constructor() {
|
||
base.constructor("输入角色名称", 0, 0, 1066, 600, 0);
|
||
|
||
//背景
|
||
local background = Yosin_NineBoxStretch( 240, 140, "sprite/interface/lenheartwindowcommon.img", 97);
|
||
background.SetPosition(413, 228);
|
||
Addchild(background);
|
||
|
||
// 标题文字
|
||
local title = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 13);
|
||
title.SetPosition(477.5, 240);
|
||
Addchild(title);
|
||
|
||
// 输入框
|
||
local nameInputBox = Yosin_InputBox(433, 270, 150);
|
||
AddUIChild(nameInputBox);
|
||
nameInputBox.SetUpdateFunc(function(inputBox, Dt) {
|
||
inputBox.Parent.name = inputBox.str;
|
||
})
|
||
|
||
// 重复检查按钮
|
||
local checkButton = Yosin_BaseButton(593, 267, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
|
||
checkButton.State = 3;
|
||
checkButton.SetUpdateFunc(function(button, Dt) {
|
||
if (button.Parent.name.len() > 0) {
|
||
button.State = 0;
|
||
} else {
|
||
button.State = 3;
|
||
}
|
||
})
|
||
//点击事件回调
|
||
checkButton.OnClick = function(Button) {
|
||
|
||
MySocket.Send(PACKET_ID.NICKNAME_REPEAT_CHECK, {
|
||
name = nameInputBox.str,
|
||
})
|
||
|
||
}.bindenv(this);
|
||
//按钮文本
|
||
local checkTextActor = FontAssetManager.GenerateNormal("重复", true, {
|
||
color = sq_RGBA(200, 195, 169, 255)
|
||
});
|
||
checkTextActor.SetPosition(11, 4);
|
||
checkButton.Addchild(checkTextActor);
|
||
AddUIChild(checkButton);
|
||
|
||
|
||
//提示文本
|
||
local tipTextActor = FontAssetManager.GenerateNormal("最多可以输入2~6个汉字、12个英文字符。", true, {
|
||
color = sq_RGBA(200, 195, 169, 255)
|
||
wrap_width = 150,
|
||
});
|
||
tipTextActor.SetPosition(458, 300);
|
||
Addchild(tipTextActor);
|
||
|
||
|
||
// 确认按钮
|
||
affirmButton = Yosin_BaseButton(473, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
|
||
affirmButton.State = 3;
|
||
affirmButton.SetUpdateFunc(function(button, Dt) {
|
||
if (button.Parent.name != button.Parent.checkName && button.State != 3) {
|
||
button.State = 3;
|
||
}
|
||
})
|
||
//点击事件回调
|
||
affirmButton.OnClick = function(Button) {
|
||
if (OnClick != null) OnClick(Button.Parent.checkName);
|
||
}.bindenv(this);
|
||
//按钮文本
|
||
local affirmTextActor = FontAssetManager.GenerateNormal("确认", true, {
|
||
color = sq_RGBA(153, 128, 71, 255)
|
||
});
|
||
affirmTextActor.SetPosition(11, 4);
|
||
affirmButton.Addchild(affirmTextActor);
|
||
AddUIChild(affirmButton);
|
||
|
||
|
||
// 取消按钮
|
||
local cancelButton = Yosin_BaseButton(533, 338, 46, 24 "sprite/interface/lenheartwindowcommon.img", 400);
|
||
//点击事件回调
|
||
cancelButton.OnClick = function(button) {
|
||
nameInputBox.str = "";
|
||
button.Parent.SetVisible(false);
|
||
}.bindenv(this);
|
||
//按钮文本
|
||
local cancelTextActor = FontAssetManager.GenerateNormal("取消", true, {
|
||
color = sq_RGBA(153, 128, 71, 255)
|
||
});
|
||
cancelTextActor.SetPosition(11, 4);
|
||
cancelButton.Addchild(cancelTextActor);
|
||
AddUIChild(cancelButton);
|
||
|
||
|
||
|
||
|
||
// 昵称重复检查回包
|
||
MySocket.RegisterHandler(PACKET_ID.NICKNAME_REPEAT_CHECK_CALLBACK, function(Jso) {
|
||
if (Parent.NoticeBox) Parent.NoticeBox.CloseWindow();
|
||
if (Jso.type == 0) {
|
||
// 可以使用的ID 确认按钮可以使用.
|
||
Parent.NoticeBox = _Yosin_MessageBox("可以使用的ID.");
|
||
checkName = name;
|
||
affirmButton.State = 0;
|
||
} else {
|
||
// 名称重复.
|
||
Parent.NoticeBox = _Yosin_MessageBox("名称重复.");
|
||
}
|
||
}.bindenv(this));
|
||
|
||
}
|
||
|
||
//逻辑入口
|
||
function Proc(Dt) {
|
||
|
||
SyncPos(X, Y);
|
||
base.Proc(Dt);
|
||
|
||
}
|
||
|
||
} |