Commit b9e7c71a authored by Tt's avatar Tt

feat(play): 重构猫咪初始化逻辑并支持双模式显示

parent e8ab8931
......@@ -680,12 +680,20 @@ export class PlayComponent implements OnInit, OnDestroy {
/**
* 初始化鱼游戏
*/
private cat_left: any;
private cat_right: any;
private cat_center: any;
initFishGame() {
this.layoutPage.ref.visible = false;
this.checkBtnElement.ref.visible = false;
this.listItem.ref.visible = false;
// this.initVsView();
this.initCat();
if (this.g_formData.doubleModal) {
this.cat_left = this.createCat('left'); // 创建左侧猫
this.cat_right = this.createCat('right'); // 创建右侧猫
} else {
this.cat_center = this.createCat('center'); // 创建中间猫
}
}
initVsView() {
......@@ -730,70 +738,133 @@ export class PlayComponent implements OnInit, OnDestroy {
// });
}
initCat() {
createCat(type) {
// 创建cat根节点
const cat = new MySprite(this.g_ctx);
cat.x = this.g_canvasWidth / 2;
cat.y = this.g_canvasHeight;
cat.width = 100 * this.g_mapScale;
cat.height = 100 * this.g_mapScale;
const cat = this.g_cartoon.createCartoonElement('cat', 'MySprite');
cat.ref.x = this.g_canvasWidth / 2;
cat.ref.y = this.g_canvasHeight;
cat.ref.width = 100 * this.g_mapScale;
cat.ref.height = 100 * this.g_mapScale;
// 创建鱼竿节点 - 放在猫手上
const yu_gan = this.g_cartoon.createCartoonElement('yu_gan', 'MySprite');
yu_gan.ref.init(this.g_cartoon.images.get('yu_gan'));
yu_gan.ref.scaleX = this.g_mapScale;
yu_gan.ref.scaleY = this.g_mapScale;
yu_gan.ref.x = 0 * this.g_mapScale;
yu_gan.ref.y = -225 * this.g_mapScale;
cat.ref.addChild(yu_gan.ref);
// 创建红水桶节点
const hong_shui_tong = this.g_cartoon.createCartoonElement('hong_shui_tong', 'MySprite');
hong_shui_tong.ref.init(this.g_cartoon.images.get('hong_shui_tong'));
hong_shui_tong.ref.scaleX = this.g_mapScale;
hong_shui_tong.ref.scaleY = this.g_mapScale;
hong_shui_tong.ref.x = -90 * this.g_mapScale;
hong_shui_tong.ref.y = -125 * this.g_mapScale;
cat.ref.addChild(hong_shui_tong.ref);
// 创建鱼箱子节点
const yu_xiang_zi = this.g_cartoon.createCartoonElement('yu_xiang_zi', 'MySprite');
yu_xiang_zi.ref.init(this.g_cartoon.images.get('yu_xiang_zi'));
yu_xiang_zi.ref.scaleX = this.g_mapScale;
yu_xiang_zi.ref.scaleY = this.g_mapScale;
yu_xiang_zi.ref.x = 90 * this.g_mapScale;
yu_xiang_zi.ref.y = -115 * this.g_mapScale;
cat.ref.addChild(yu_xiang_zi.ref);
// 创建船节点 - 作为钓鱼台,放在最下方
const chuan = new MySprite(this.g_ctx);
chuan.init(this.g_cartoon.images.get('chuan'));
chuan.scaleX = this.g_mapScale;
chuan.scaleY = this.g_mapScale;
chuan.x = 0
chuan.y = -38
cat.addChild(chuan);
// 创建橘猫坐着节点 - 放在船顶部中间
const ju_mao_zuo_zhao = new MySprite(this.g_ctx);
ju_mao_zuo_zhao.init(this.g_cartoon.images.get('ju_mao_zuo_zhao'));
ju_mao_zuo_zhao.scaleX = this.g_mapScale;
ju_mao_zuo_zhao.scaleY = this.g_mapScale;
ju_mao_zuo_zhao.x = 50 * this.g_mapScale;
ju_mao_zuo_zhao.y = -60 * this.g_mapScale;
cat.addChild(ju_mao_zuo_zhao);
const ju_mao_zuo_zhao = this.g_cartoon.createCartoonElement('ju_mao_zuo_zhao', 'MySprite');
ju_mao_zuo_zhao.ref.init(this.g_cartoon.images.get('ju_mao_zuo_zhao'));
ju_mao_zuo_zhao.ref.scaleX = this.g_mapScale;
ju_mao_zuo_zhao.ref.scaleY = this.g_mapScale;
ju_mao_zuo_zhao.ref.x = 0 * this.g_mapScale;
ju_mao_zuo_zhao.ref.y = -145 * this.g_mapScale;
cat.ref.addChild(ju_mao_zuo_zhao.ref);
// 创建橘猫爬爪节点 - 与ju_mao_zuo_zhao相同坐标
const ju_mao_pa_zhao = this.g_cartoon.createCartoonElement('ju_mao_pa_zhao', 'MySprite');
ju_mao_pa_zhao.ref.init(this.g_cartoon.images.get('ju_mao_pa_zhao'));
ju_mao_pa_zhao.ref.scaleX = this.g_mapScale;
ju_mao_pa_zhao.ref.scaleY = this.g_mapScale;
ju_mao_pa_zhao.ref.x = 20 * this.g_mapScale;
ju_mao_pa_zhao.ref.y = -115 * this.g_mapScale;
cat.ref.addChild(ju_mao_pa_zhao.ref);
// 创建橘猫坐着节点 - 放在船顶部中间
const hui_se_mao_zuo_zhao = this.g_cartoon.createCartoonElement('hui_se_mao_zuo_zhao', 'MySprite');
hui_se_mao_zuo_zhao.ref.init(this.g_cartoon.images.get('hui_se_mao_zuo_zhao'));
hui_se_mao_zuo_zhao.ref.scaleX = this.g_mapScale;
hui_se_mao_zuo_zhao.ref.scaleY = this.g_mapScale;
hui_se_mao_zuo_zhao.ref.x = 0 * this.g_mapScale;
hui_se_mao_zuo_zhao.ref.y = -145 * this.g_mapScale;
cat.ref.addChild(hui_se_mao_zuo_zhao.ref);
// 创建鱼竿节点 - 放在猫手上
const yu_gan = new MySprite(this.g_ctx);
yu_gan.init(this.g_cartoon.images.get('yu_gan'));
yu_gan.scaleX = this.g_mapScale;
yu_gan.scaleY = this.g_mapScale;
yu_gan.x = 65 * this.g_mapScale;
yu_gan.y = 35 * this.g_mapScale;
cat.addChild(yu_gan);
// 创建鱼箱子节点 - 放在猫的左边
const yu_xiang_zi = new MySprite(this.g_ctx);
yu_xiang_zi.init(this.g_cartoon.images.get('yu_xiang_zi'));
yu_xiang_zi.scaleX = this.g_mapScale;
yu_xiang_zi.scaleY = this.g_mapScale;
yu_xiang_zi.x = 15 * this.g_mapScale;
yu_xiang_zi.y = 60 * this.g_mapScale;
cat.addChild(yu_xiang_zi);
// 创建红水桶节点 - 放在猫的右边
const hong_shui_tong = new MySprite(this.g_ctx);
hong_shui_tong.init(this.g_cartoon.images.get('hong_shui_tong'));
hong_shui_tong.scaleX = this.g_mapScale;
hong_shui_tong.scaleY = this.g_mapScale;
hong_shui_tong.x = 85 * this.g_mapScale;
hong_shui_tong.y = 60 * this.g_mapScale;
cat.addChild(hong_shui_tong);
// 创建橘猫爬爪节点 - 与ju_mao_zuo_zhao相同坐标
const ju_mao_pa_zhao = new MySprite(this.g_ctx);
ju_mao_pa_zhao.init(this.g_cartoon.images.get('ju_mao_pa_zhao'));
ju_mao_pa_zhao.scaleX = this.g_mapScale;
ju_mao_pa_zhao.scaleY = this.g_mapScale;
ju_mao_pa_zhao.x = 50 * this.g_mapScale;
ju_mao_pa_zhao.y = 20 * this.g_mapScale;
cat.addChild(ju_mao_pa_zhao);
const hui_se_mao_pa_zhao = this.g_cartoon.createCartoonElement('hui_se_mao_pa_zhao', 'MySprite');
hui_se_mao_pa_zhao.ref.init(this.g_cartoon.images.get('hui_se_mao_pa_zhao'));
hui_se_mao_pa_zhao.ref.scaleX = this.g_mapScale;
hui_se_mao_pa_zhao.ref.scaleY = this.g_mapScale;
hui_se_mao_pa_zhao.ref.x = -20 * this.g_mapScale;
hui_se_mao_pa_zhao.ref.y = -115 * this.g_mapScale;
cat.ref.addChild(hui_se_mao_pa_zhao.ref);
this.render(cat, zIndexMap.card);
// 创建船节点 - 作为钓鱼台,放在最下方
const chuan = this.g_cartoon.createCartoonElement('chuan', 'MySprite');
chuan.ref.init(this.g_cartoon.images.get('chuan'));
chuan.ref.scaleX = this.g_mapScale;
chuan.ref.scaleY = this.g_mapScale;
chuan.ref.x = 0
chuan.ref.y = -38
cat.ref.addChild(chuan.ref);
this.render(cat.ref, zIndexMap.card);
cat["child_gan"] = yu_gan;
cat["child_tong_left"] = hong_shui_tong;
cat["child_tong_right"] = yu_xiang_zi;
cat["child_mao_ju_zuo"] = ju_mao_zuo_zhao;
cat["child_mao_ju_pa"] = ju_mao_pa_zhao;
cat["child_mao_hui_zuo"] = hui_se_mao_zuo_zhao;
cat["child_mao_hui_pa"] = hui_se_mao_pa_zhao;
cat["child_chuan"] = chuan;
console.log('cat', cat)
switch (type) {
case 'center':
cat.ref.x = this.g_canvasWidth / 2;
cat.ref.y = this.g_canvasHeight + 30 * this.g_mapScale;
cat['child_mao_hui_zuo'].ref.visible = false;
cat['child_mao_hui_pa'].ref.visible = false;
cat['child_mao_ju_pa'].ref.visible = false;
cat['child_tong_right'].ref.visible = false;
break;
case 'left':
cat.ref.x = this.g_canvasWidth / 2 - 500 * this.g_mapScale;
cat.ref.y = this.g_canvasHeight + 30 * this.g_mapScale;
cat['child_mao_hui_zuo'].ref.visible = false;
cat['child_mao_hui_pa'].ref.visible = false;
cat['child_mao_ju_pa'].ref.visible = false;
cat['child_tong_right'].ref.visible = false;
break;
case 'right':
cat.ref.x = this.g_canvasWidth / 2 + 500 * this.g_mapScale;
cat.ref.y = this.g_canvasHeight + 30 * this.g_mapScale;
cat['child_mao_ju_zuo'].ref.visible = false;
cat['child_mao_ju_pa'].ref.visible = false;
cat['child_mao_hui_pa'].ref.visible = false;
cat['child_tong_left'].ref.visible = false;
break;
}
return cat;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment