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
8bc4d5d6
Commit
8bc4d5d6
authored
Sep 23, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
4f4ed69a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
165 deletions
+156
-165
NJ_MonkyTree.ts
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
+155
-154
MyCocosSceneComponent.ts
assets/NJ_MonkyTree/script/MyCocosSceneComponent.ts
+1
-11
No files found.
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
View file @
8bc4d5d6
...
@@ -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
();
await
this
.
createFiniteStateMachines
();
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,175 +227,176 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -227,175 +227,176 @@ 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
=
{
id
:
'
operation
'
,
const
operationState
=
{
initial
:
'
UnitView
'
,
id
:
'
operation
'
,
context
:
{
initial
:
'
UnitView
'
,
UnitViewData
:
null
,
context
:
{
currentDataset
:
null
,
UnitViewData
:
null
,
},
currentDataset
:
null
,
states
:
{
},
UnitView
:
{
states
:
{
entry
:
(
ctx
,
event
)
=>
{
UnitView
:
{
console
.
log
(
'
entry UnitView stage
'
);
entry
:
(
ctx
,
event
)
=>
{
this
.
UnitView
.
active
=
true
;
console
.
log
(
'
entry UnitView stage
'
);
this
.
UnitView
.
active
=
true
;
if
(
pname
==
'
level 1
'
)
{
this
.
playBgMusic
(
this
.
bgMusic2
);
if
(
pname
==
'
level 1
'
)
{
}
else
if
(
pname
==
'
level 2
'
)
{
this
.
playBgMusic
(
this
.
bgMusic2
);
this
.
playBgMusic
(
this
.
bgMusic3
);
}
else
if
(
pname
==
'
level 2
'
)
{
}
else
if
(
pname
==
'
level 3
'
)
{
this
.
playBgMusic
(
this
.
bgMusic3
);
this
.
playBgMusic
(
this
.
bgMusic4
);
}
else
if
(
pname
==
'
level 3
'
)
{
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
)
{
const
lessonsBtn
=
this
.
rootAttrTree
.
querySelectorAll
(
'
.lesson-button
'
);
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
}
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
lock
.
active
=
true
;
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
width=4>
${
name
}
</outline>`
const
outline
=
'
#000
'
;
const
name
=
""
;
// const pos = exchangeNodePos(b, titleNode);
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
// titleNode.x = pos.x;
if
(
!
richText
.
fontSizeBase
)
{
// titleNode.y = pos.y;
richText
.
fontSizeBase
=
richText
.
fontSize
;
// titleNode.parent = b;
}
richText
.
fontSize
=
richText
.
fontSizeBase
;
if
(
name
.
length
>
14
)
{
// const textPng = this.getSprNode("Game");
richText
.
fontSize
=
richText
.
fontSizeBase
*
0.7
;
// titleNode.addChild(textPng);
}
// textPng.y = -titleNode.height;
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
// textPng.active = false;
// titleNode.textPng = textPng;
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
});
width=4>
${
name
}
</outline>`
callNetworkApiGet
(
'
/api/syllabus/v2/tree
'
,
{
pid
,
deep
:
1
},
(
resp
:
any
)
=>
{
// const pos = exchangeNodePos(b, titleNode);
resp
=
JSON
.
parse
(
resp
);
// titleNode.x = pos.x;
if
(
resp
.
msg
==
'
success
'
)
{
// titleNode.y = pos.y;
let
{
rows
}
=
resp
;
// titleNode.parent = b;
const
list
=
rows
.
reduce
((
result
,
next
)
=>
{
const
{
children
}
=
next
;
// has_courseware true 是文件夹
// const textPng = this.getSprNode("Game");
let
childrenList
=
children
.
filter
(
r
=>
r
.
has_courseware
)
// titleNode.addChild(textPng);
if
(
childrenList
.
length
>
3
)
{
// textPng.y = -titleNode.height;
childrenList
.
length
=
3
// textPng.active = false;
}
// titleNode.textPng = textPng;
result
=
[...
result
,
...
childrenList
]
});
return
result
},
[]);
// rows = rows.filter(r => !r.has_courseware)
callNetworkApiGet
(
'
/api/syllabus/v2/tree
'
,
{
pid
,
deep
:
1
},
(
resp
:
any
)
=>
{
resp
=
JSON
.
parse
(
resp
);
lessonsBtn
.
forEach
((
b
,
idx
)
=>
{
if
(
resp
.
msg
==
'
success
'
)
{
const
attr
:
Attributes
=
b
.
getComponent
(
'
Attributes
'
);
let
{
rows
}
=
resp
;
const
index
=
attr
.
attrMap
[
'
index
'
];
const
list
=
rows
.
reduce
((
result
,
next
)
=>
{
const
{
children
}
=
next
;
const
lesson
=
list
[
index
];
// has_courseware true 是文件夹
const
lock
=
cc
.
find
(
'
icon_key
'
,
b
);
let
childrenList
=
children
.
filter
(
r
=>
r
.
has_courseware
)
// console.log("===liu2===", index);
if
(
childrenList
.
length
>
3
)
{
// if (index == 0) {
childrenList
.
length
=
3
// lock.active = false;
// } else {
lock
.
active
=
true
;
// }
const
titleNode
=
attr
.
querySelector
(
'
.title
'
);
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
;
}
}
result
=
[...
result
,
...
childrenList
]
richText
.
fontSize
=
richText
.
fontSizeBase
;
return
result
if
(
name
.
length
>
14
)
{
},
[]);
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
;
}
}
b
.
attr
({
'
data_id
'
:
lesson
.
id
});
richText
.
font
=
cc
.
find
(
"
Canvas/res/font/BRLNSDB
"
).
getComponent
(
cc
.
Label
).
font
;
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
;
titleNode
.
getComponent
(
cc
.
RichText
).
string
=
`<outline align=top color=
${
outline
}
const
richText
=
titleNode
.
getComponent
(
cc
.
RichText
);
width=4>
${
name
}
</outline>`
;
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
pos
=
exchangeNodePos
(
b
,
titleNode
);
width=4>
${
name
}
</outline>`
;
titleNode
.
x
=
pos
.
x
;
titleNode
.
y
=
pos
.
y
;
titleNode
.
parent
=
b
;
const
pos
=
exchangeNodePos
(
b
,
titleNode
);
// delayCall(1, () => {
titleNode
.
x
=
pos
.
x
;
titleNode
.
y
=
pos
.
y
;
titleNode
.
parent
=
b
;
// delayCall(1, () => {
// console.log('idx: ', idx);
// console.log("传入按钮名2:", name);
// console.log('idx: ', idx);
// titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
// console.log("传入按钮名2:", name);
// width=4>${name}</outline>`;
// console.log("显示按钮名2:", titleNode.getComponent(cc.RichText).string);
// 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
;
}
});
if
(
window
&&
window
[
"
air
"
])
{
ctx
.
UnitViewData
=
list
;
window
[
"
air
"
].
hideAirClassLoading
();
ctx
.
currentDataset
=
list
;
}
resolve
();
});
},
exit
:
()
=>
{
// console.log('exit UnitView stage');
},
invoke
:
{
src
:
(
ctx
,
event
)
=>
{
}
}
},
});
},
}
};
const
operationMachine
=
createMachine
(
operationState
);
},
exit
:
()
=>
{
// console.log('exit UnitView stage');
},
invoke
:
{
src
:
(
ctx
,
event
)
=>
{
}
},
},
}
};
this
.
gameMachineService
=
interpret
(
operationMachine
).
onTransition
((
state
)
=>
{
const
operationMachine
=
createMachine
(
operationState
);
console
.
log
(
1
,
state
);
});
this
.
gameMachineService
=
interpret
(
operationMachine
).
onTransition
((
state
)
=>
{
console
.
log
(
1
,
state
);
});
});
}
}
...
...
assets/NJ_MonkyTree/script/MyCocosSceneComponent.ts
View file @
8bc4d5d6
...
@@ -89,17 +89,7 @@ export class MyCocosSceneComponent extends cc.Component {
...
@@ -89,17 +89,7 @@ export class MyCocosSceneComponent extends cc.Component {
const
preloadArr
=
this
.
_imageResList
.
concat
(
this
.
_audioResList
).
concat
(
this
.
_animaResList
);
const
preloadArr
=
this
.
_imageResList
.
concat
(
this
.
_audioResList
).
concat
(
this
.
_animaResList
);
cc
.
assetManager
.
loadAny
(
preloadArr
,
null
,
null
,
async
(
err
,
data
)
=>
{
cc
.
assetManager
.
loadAny
(
preloadArr
,
null
,
null
,
async
(
err
,
data
)
=>
{
if
(
window
&&
window
[
"
air
"
])
{
this
.
onLoadEnd
();
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
await
this
.
onLoadEnd
();
window
[
"
air
"
].
hideAirClassLoading
();
}
else
{
this
.
onLoadEnd
();
}
cc
.
debug
.
setDisplayStats
(
false
);
cc
.
debug
.
setDisplayStats
(
false
);
});
});
...
...
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