Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_MonkyTree
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
NJ_MonkyTree
Commits
4f4ed69a
Commit
4f4ed69a
authored
Sep 23, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
dcb010f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
155 additions
and
152 deletions
+155
-152
NJ_MonkyTree.ts
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
+155
-152
No files found.
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
View file @
4f4ed69a
...
@@ -57,7 +57,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -57,7 +57,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
rootAttrTree
=
this
.
getComponent
(
'
Attributes
'
);
this
.
rootAttrTree
=
this
.
getComponent
(
'
Attributes
'
);
this
.
initBg
();
this
.
initBg
();
this
.
initUnitViewPager
();
this
.
initUnitViewPager
();
this
.
createFiniteStateMachines
();
await
this
.
createFiniteStateMachines
();
const
BackViewButtons
=
this
.
rootAttrTree
.
querySelectorAll
(
'
.back-view
'
);
const
BackViewButtons
=
this
.
rootAttrTree
.
querySelectorAll
(
'
.back-view
'
);
BackViewButtons
.
forEach
(
b
=>
{
BackViewButtons
.
forEach
(
b
=>
{
buttonOnClick
(
b
,
()
=>
{
buttonOnClick
(
b
,
()
=>
{
...
@@ -227,172 +227,175 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -227,172 +227,175 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc
.
audioEngine
.
playMusic
(
audio
,
true
);
cc
.
audioEngine
.
playMusic
(
audio
,
true
);
}
}
createFiniteStateMachines
()
{
createFiniteStateMachines
()
{
return
new
Promise
((
resolve
)
=>
{
let
pid
=
21228
;
// 本地测试用
let
pid
=
21228
;
// 本地测试用
let
pname
=
'
level 1
'
;
// 本地测试用
let
pname
=
'
level 1
'
;
// 本地测试用
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
if
(
middleLayer
)
{
pid
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getData
(
'
NJ_MonkyTree
'
);
pid
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getData
(
'
NJ_MonkyTree
'
);
pname
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getData
(
'
NJ_MonkyTree_name
'
);
pname
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getData
(
'
NJ_MonkyTree_name
'
);
if
(
pname
)
{
if
(
pname
)
{
pname
=
pname
.
toLowerCase
().
trim
();
pname
=
pname
.
toLowerCase
().
trim
();
}
}
}
}
// 根据不同级别渲染图片
// 根据不同级别渲染图片
this
.
drawLevelItemPic
(
pname
);
this
.
drawLevelItemPic
(
pname
);
const
operationState
=
{
const
operationState
=
{
id
:
'
operation
'
,
id
:
'
operation
'
,
initial
:
'
UnitView
'
,
initial
:
'
UnitView
'
,
context
:
{
context
:
{
UnitViewData
:
null
,
UnitViewData
:
null
,
currentDataset
:
null
,
currentDataset
:
null
,
},
},
states
:
{
states
:
{
UnitView
:
{
UnitView
:
{
entry
:
(
ctx
,
event
)
=>
{
entry
:
(
ctx
,
event
)
=>
{
console
.
log
(
'
entry UnitView stage
'
);
console
.
log
(
'
entry UnitView stage
'
);
this
.
UnitView
.
active
=
true
;
this
.
UnitView
.
active
=
true
;
if
(
pname
==
'
level 1
'
)
{
if
(
pname
==
'
level 1
'
)
{
this
.
playBgMusic
(
this
.
bgMusic2
);
this
.
playBgMusic
(
this
.
bgMusic2
);
}
else
if
(
pname
==
'
level 2
'
)
{
}
else
if
(
pname
==
'
level 2
'
)
{
this
.
playBgMusic
(
this
.
bgMusic3
);
this
.
playBgMusic
(
this
.
bgMusic3
);
}
else
if
(
pname
==
'
level 3
'
)
{
}
else
if
(
pname
==
'
level 3
'
)
{
this
.
playBgMusic
(
this
.
bgMusic4
);
this
.
playBgMusic
(
this
.
bgMusic4
);
}
const
lessonsBtn
=
this
.
rootAttrTree
.
querySelectorAll
(
'
.lesson-button
'
);
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
lock
.
active
=
true
;
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
const
outline
=
'
#000
'
;
const
name
=
""
;
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
if
(
!
richText
.
fontSizeBase
)
{
richText
.
fontSizeBase
=
richText
.
fontSize
;
}
richText
.
fontSize
=
richText
.
fontSizeBase
;
if
(
name
.
length
>
14
)
{
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
}
}
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
const
lessonsBtn
=
this
.
rootAttrTree
.
querySelectorAll
(
'
.lesson-button
'
);
width=4>
${
name
}
</outline>`
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
// const pos = exchangeNodePos(b, titleNode);
lock
.
active
=
true
;
// titleNode.x = pos.x;
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
// titleNode.y = pos.y;
// titleNode.parent = b;
const
outline
=
'
#000
'
;
const
name
=
""
;
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
// const textPng = this.getSprNode("Game");
if
(
!
richText
.
fontSizeBase
)
{
// titleNode.addChild(textPng);
richText
.
fontSizeBase
=
richText
.
fontSize
;
// textPng.y = -titleNode.height;
}
// textPng.active = false;
richText
.
fontSize
=
richText
.
fontSizeBase
;
// titleNode.textPng = textPng;
if
(
name
.
length
>
14
)
{
});
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
}
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
callNetworkApiGet
(
'
/api/syllabus/v2/tree
'
,
{
pid
,
deep
:
1
},
(
resp
:
any
)
=>
{
resp
=
JSON
.
parse
(
resp
);
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
if
(
resp
.
msg
==
'
success
'
)
{
width=4>
${
name
}
</outline>`
let
{
rows
}
=
resp
;
const
list
=
rows
.
reduce
((
result
,
next
)
=>
{
const
{
children
}
=
next
;
// const pos = exchangeNodePos(b, titleNode);
// has_courseware true 是文件夹
// titleNode.x = pos.x;
let
childrenList
=
children
.
filter
(
r
=>
r
.
has_courseware
)
// titleNode.y = pos.y;
if
(
childrenList
.
length
>
3
)
{
// titleNode.parent = b;
childrenList
.
length
=
3
}
result
=
[...
result
,
...
childrenList
]
// const textPng = this.getSprNode("Game");
return
result
// titleNode.addChild(textPng);
},
[]);
// textPng.y = -titleNode.height;
// rows = rows.filter(r => !r.has_courseware)
// textPng.active = false;
// titleNode.textPng = textPng;
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
});
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
const
index
=
attr
.
attrMap
[
'
index
'
];
callNetworkApiGet
(
'
/api/syllabus/v2/tree
'
,
{
pid
,
deep
:
1
},
(
resp
:
any
)
=>
{
const
lesson
=
list
[
index
];
resp
=
JSON
.
parse
(
resp
);
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
if
(
resp
.
msg
==
'
success
'
)
{
// console.log("===liu2===", index);
let
{
rows
}
=
resp
;
// if (index == 0) {
const
list
=
rows
.
reduce
((
result
,
next
)
=>
{
// lock.active = false;
const
{
children
}
=
next
;
// } else {
// has_courseware true 是文件夹
lock
.
active
=
true
;
let
childrenList
=
children
.
filter
(
r
=>
r
.
has_courseware
)
// }
if
(
childrenList
.
length
>
3
)
{
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
childrenList
.
length
=
3
if
(
!
lesson
)
{
return
;
}
b
.
attr
({
'
data_id
'
:
lesson
.
id
});
b
.
attr
({
'
data_pid
'
:
lesson
.
pid
});
if
(
index
==
0
||
(
this
.
kidInfo
&&
this
.
kidInfo
.
unlock_syllabuses
?.
includes
(
lesson
.
id
+
""
)
&&
(
index
-
0
)
%
3
===
0
))
{
lock
.
active
=
false
;
const
outline
=
this
.
drawTextBorder
(
pname
,
b
.
name
);
const
name
=
lesson
.
name
;
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
if
(
!
richText
.
fontSizeBase
)
{
richText
.
fontSizeBase
=
richText
.
fontSize
;
}
}
richText
.
fontSize
=
richText
.
fontSizeBase
;
result
=
[...
result
,
...
childrenList
]
if
(
name
.
length
>
14
)
{
return
result
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
},
[]);
// rows = rows.filter(r => !r.has_courseware)
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
const
index
=
attr
.
attrMap
[
'
index
'
];
const
lesson
=
list
[
index
];
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
// console.log("===liu2===", index);
// if (index == 0) {
// lock.active = false;
// } else {
lock
.
active
=
true
;
// }
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
if
(
!
lesson
)
{
return
;
}
}
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
b
.
attr
({
'
data_id
'
:
lesson
.
id
});
b
.
attr
({
'
data_pid
'
:
lesson
.
pid
});
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
width=4>
${
name
}
</outline>`
;
const
pos
=
exchangeNodePos
(
b
,
titleNode
);
if
(
index
==
0
||
(
this
.
kidInfo
&&
this
.
kidInfo
.
unlock_syllabuses
?.
includes
(
lesson
.
id
+
""
)
&&
(
index
-
0
)
%
3
===
0
))
{
titleNode
.
x
=
pos
.
x
;
lock
.
active
=
false
;
titleNode
.
y
=
pos
.
y
;
const
outline
=
this
.
drawTextBorder
(
pname
,
b
.
name
);
titleNode
.
parent
=
b
;
// delayCall(1, () => {
const
name
=
lesson
.
name
;
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
if
(
!
richText
.
fontSizeBase
)
{
richText
.
fontSizeBase
=
richText
.
fontSize
;
}
richText
.
fontSize
=
richText
.
fontSizeBase
;
if
(
name
.
length
>
14
)
{
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
}
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
// console.log('idx: ', idx);
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
// console.log("传入按钮名2:", name)
;
width=4>
${
name
}
</outline>`
;
// titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
const
pos
=
exchangeNodePos
(
b
,
titleNode
);
// width=4>${name}</outline>`;
titleNode
.
x
=
pos
.
x
;
// console.log("显示按钮名2:", titleNode.getComponent(cc.RichText).string);
titleNode
.
y
=
pos
.
y
;
titleNode
.
parent
=
b
;
// })
// delayCall(1, () => {
}
});
// console.log('idx: ', idx);
ctx
.
UnitViewData
=
list
;
// console.log("传入按钮名2:", name);
ctx
.
currentDataset
=
list
;
}
});
// titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
// width=4>${name}</outline>`;
// console.log("显示按钮名2:", titleNode.getComponent(cc.RichText).string);
// })
}
});
ctx
.
UnitViewData
=
list
;
ctx
.
currentDataset
=
list
;
}
resolve
();
});
},
exit
:
()
=>
{
// console.log('exit UnitView stage');
},
invoke
:
{
src
:
(
ctx
,
event
)
=>
{
}
},
},
},
exit
:
()
=>
{
}
// console.log('exit UnitView stage');
};
},
invoke
:
{
src
:
(
ctx
,
event
)
=>
{
}
},
},
}
};
const
operationMachine
=
createMachine
(
operationState
);
const
operationMachine
=
createMachine
(
operationState
);
this
.
gameMachineService
=
interpret
(
operationMachine
).
onTransition
((
state
)
=>
{
console
.
log
(
1
,
state
);
});
this
.
gameMachineService
=
interpret
(
operationMachine
).
onTransition
((
state
)
=>
{
console
.
log
(
1
,
state
);
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment