Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SaveTheDoge
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Nguyễn Quang Sáng
SaveTheDoge
Commits
1e9ef7d6
Commit
1e9ef7d6
authored
Aug 25, 2023
by
Nguyễn Quang Sáng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
25/8/2023 commit
parent
dd0cf59a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
194 additions
and
19 deletions
+194
-19
9.prefab
assets/Prefabs/Levels/9.prefab
+1
-1
Unlock.png
assets/Resources/Unlock.png
+0
-0
Unlock.png.meta
assets/Resources/Unlock.png.meta
+38
-0
gameplay.fire
assets/Scenes/gameplay.fire
+28
-4
shop.fire
assets/Scenes/shop.fire
+26
-2
GamePlay.ts
assets/Scripts/Controllers/GamePlay.ts
+34
-4
SkinsController.ts
assets/Scripts/Controllers/SkinsController.ts
+26
-2
StageController.ts
assets/Scripts/Controllers/StageController.ts
+9
-3
StartScene.ts
assets/Scripts/Controllers/StartScene.ts
+1
-0
LocalStorage.ts
assets/Scripts/Data/LocalStorage.ts
+26
-1
Dog.ts
assets/Scripts/Objects/Dog.ts
+5
-2
No files found.
assets/Prefabs/Levels/9.prefab
View file @
1e9ef7d6
...
@@ -587,7 +587,7 @@
...
@@ -587,7 +587,7 @@
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
246.705,
246.705,
-72.
4,
192.59
4,
0,
0,
0,
0,
0,
0,
...
...
assets/Resources/Unlock.png
0 → 100644
View file @
1e9ef7d6
272 KB
assets/Resources/Unlock.png.meta
0 → 100644
View file @
1e9ef7d6
{
"ver": "2.3.7",
"uuid": "0de0ba75-fee4-48db-b699-7993a835b98d",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1959,
"height": 701,
"platformSettings": {},
"subMetas": {
"Unlock": {
"ver": "1.0.6",
"uuid": "78d9ec6c-e154-4167-b29b-43fd0420025f",
"importer": "sprite-frame",
"rawTextureUuid": "0de0ba75-fee4-48db-b699-7993a835b98d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1959,
"height": 701,
"rawWidth": 1959,
"rawHeight": 701,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/Scenes/gameplay.fire
View file @
1e9ef7d6
...
@@ -660,6 +660,30 @@
...
@@ -660,6 +660,30 @@
"fadePrefab": {
"fadePrefab": {
"__uuid__": "79ce448b-e4e7-497b-bdc6-908da90391b4"
"__uuid__": "79ce448b-e4e7-497b-bdc6-908da90391b4"
},
},
"skinPlayerPrefabs": [
{
"__uuid__": "c3f6df06-c0ad-4e83-999f-c26983a694bc"
},
{
"__uuid__": "9526677e-44f6-4a50-bbf0-d8180117542b"
},
{
"__uuid__": "adc3f60c-2901-42da-9f28-7e8ea2ac542b"
},
{
"__uuid__": "7ded7ea5-87df-43e8-8312-1160c1b0b81f"
},
{
"__uuid__": "d3de6305-037c-40fc-b7e1-fc868a496b4c"
},
{
"__uuid__": "c0c9cc20-d860-41ce-9821-87879a336594"
},
{
"__uuid__": "21a866b5-0afe-47a4-8ffb-9c86d6ca984a"
}
],
"skinEnemyPrefabs": [],
"_id": "faEXJtWtBDhKF1IlQuz9ef"
"_id": "faEXJtWtBDhKF1IlQuz9ef"
},
},
{
{
...
@@ -3147,8 +3171,8 @@
...
@@ -3147,8 +3171,8 @@
0,
0,
0,
0,
1,
1,
0.904
,
1
,
0.904
,
1
,
0
0
]
]
},
},
...
@@ -3263,10 +3287,10 @@
...
@@ -3263,10 +3287,10 @@
"_srcBlendFactor": 770,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_dstBlendFactor": 771,
"_spriteFrame": {
"_spriteFrame": {
"__uuid__": "
c4251a1f-25f4-4c87-8e13-14c7845bac0d
"
"__uuid__": "
78d9ec6c-e154-4167-b29b-43fd0420025f
"
},
},
"_type": 0,
"_type": 0,
"_sizeMode":
1
,
"_sizeMode":
0
,
"_fillType": 0,
"_fillType": 0,
"_fillCenter": {
"_fillCenter": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
...
assets/Scenes/shop.fire
View file @
1e9ef7d6
...
@@ -330,6 +330,30 @@
...
@@ -330,6 +330,30 @@
"enemySkins": {
"enemySkins": {
"__id__": 90
"__id__": 90
},
},
"skinPlayerPrefabs": [
{
"__uuid__": "c3f6df06-c0ad-4e83-999f-c26983a694bc"
},
{
"__uuid__": "adc3f60c-2901-42da-9f28-7e8ea2ac542b"
},
{
"__uuid__": "21a866b5-0afe-47a4-8ffb-9c86d6ca984a"
},
{
"__uuid__": "9526677e-44f6-4a50-bbf0-d8180117542b"
},
{
"__uuid__": "c0c9cc20-d860-41ce-9821-87879a336594"
},
{
"__uuid__": "d3de6305-037c-40fc-b7e1-fc868a496b4c"
},
{
"__uuid__": "7ded7ea5-87df-43e8-8312-1160c1b0b81f"
}
],
"skinEnemyPrefabs": [],
"_id": "e4AcfCH0hHK4XH2EkmaIYU"
"_id": "e4AcfCH0hHK4XH2EkmaIYU"
},
},
{
{
...
@@ -3758,7 +3782,7 @@
...
@@ -3758,7 +3782,7 @@
"__id__": 78
"__id__": 78
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 80
"__id__": 80
...
@@ -5945,7 +5969,7 @@
...
@@ -5945,7 +5969,7 @@
"__id__": 124
"__id__": 124
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 126
"__id__": 126
...
...
assets/Scripts/Controllers/GamePlay.ts
View file @
1e9ef7d6
import
Dog
from
"../Objects/Dog"
;
import
Dog
from
"../Objects/Dog"
;
import
Hive
from
"../Objects/Hive"
;
import
LimitBar
from
"../Objects/LimitBar"
;
import
LimitBar
from
"../Objects/LimitBar"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
import
PracticeLine
from
"../Objects/PracticeLine"
;
import
PracticeLine
from
"../Objects/PracticeLine"
;
import
Utils
from
"../Tools/Utils"
;
import
Utils
from
"../Tools/Utils"
;
import
Drawer
from
"../Tools/Drawer"
;
import
{
GlobalVariables
}
from
"../Data/GlobalVariables"
;
import
{
GlobalVariables
}
from
"../Data/GlobalVariables"
;
import
Levels
from
"./Levels"
;
import
StageController
from
"./StageController"
;
import
StageController
from
"./StageController"
;
import
SkinController
from
"./SkinsController"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -30,6 +28,10 @@ export default class GamePlay extends cc.Component {
...
@@ -30,6 +28,10 @@ export default class GamePlay extends cc.Component {
@
property
(
cc
.
Node
)
shadow
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
shadow
:
cc
.
Node
=
null
;
@
property
([
cc
.
SpriteFrame
])
starWinSprites
:
cc
.
SpriteFrame
[]
=
[];
@
property
([
cc
.
SpriteFrame
])
starWinSprites
:
cc
.
SpriteFrame
[]
=
[];
@
property
(
cc
.
Prefab
)
fadePrefab
:
cc
.
Prefab
=
null
;
@
property
(
cc
.
Prefab
)
fadePrefab
:
cc
.
Prefab
=
null
;
@
property
(
Array
(
cc
.
Prefab
))
skinPlayerPrefabs
:
Array
<
cc
.
Prefab
>
=
new
Array
<
cc
.
Prefab
>
();
@
property
(
Array
(
cc
.
Prefab
))
skinEnemyPrefabs
:
Array
<
cc
.
Prefab
>
=
new
Array
<
cc
.
Prefab
>
();
static
instance
:
GamePlay
;
static
instance
:
GamePlay
;
...
@@ -44,6 +46,8 @@ export default class GamePlay extends cc.Component {
...
@@ -44,6 +46,8 @@ export default class GamePlay extends cc.Component {
highestLevel
:
number
;
highestLevel
:
number
;
currentAllStar
:
number
;
currentAllStar
:
number
;
currentCoin
:
number
;
currentCoin
:
number
;
currentSkinPlayer
:
string
;
currentSkinEnemy
:
string
;
isGameover
:
boolean
=
false
;
isGameover
:
boolean
=
false
;
isCompleted
:
boolean
=
false
;
isCompleted
:
boolean
=
false
;
...
@@ -68,6 +72,8 @@ export default class GamePlay extends cc.Component {
...
@@ -68,6 +72,8 @@ export default class GamePlay extends cc.Component {
this
.
highestLevel
=
LocalStorage
.
getHighestLevel
();
this
.
highestLevel
=
LocalStorage
.
getHighestLevel
();
this
.
currentLevel
=
LocalStorage
.
getCurrentLevel
();
this
.
currentLevel
=
LocalStorage
.
getCurrentLevel
();
this
.
currentCoin
=
LocalStorage
.
getAllCoin
();
this
.
currentCoin
=
LocalStorage
.
getAllCoin
();
this
.
currentSkinPlayer
=
LocalStorage
.
getCurrentSkinPlayer
();
this
.
currentSkinEnemy
=
LocalStorage
.
getCurrentSkinEnemy
();
this
.
coinLabel
.
getComponent
(
this
.
coinLabel
.
getComponent
(
cc
.
Label
cc
.
Label
).
string
=
`x
${
this
.
currentCoin
.
toString
()}
`
;
).
string
=
`x
${
this
.
currentCoin
.
toString
()}
`
;
...
@@ -105,6 +111,30 @@ export default class GamePlay extends cc.Component {
...
@@ -105,6 +111,30 @@ export default class GamePlay extends cc.Component {
).
string
=
`Level
${
this
.
prefabToLoad
[
level
].
name
}
`
;
).
string
=
`Level
${
this
.
prefabToLoad
[
level
].
name
}
`
;
this
.
isCompleted
=
false
;
this
.
isCompleted
=
false
;
this
.
isGameover
=
false
;
this
.
isGameover
=
false
;
this
.
updateSkin
();
}
updateSkin
()
{
for
(
let
i
=
0
;
i
<
this
.
skinPlayerPrefabs
.
length
;
i
++
)
{
const
skin
=
this
.
skinPlayerPrefabs
[
i
];
if
(
skin
.
name
==
this
.
currentSkinPlayer
)
{
const
defaultAnim
=
this
.
node
.
children
[
0
].
getComponentsInChildren
(
"Dog"
);
for
(
let
i
=
0
;
i
<
defaultAnim
.
length
;
i
++
)
{
const
anim
=
defaultAnim
[
i
].
getComponent
(
cc
.
Animation
);
let
updateAnim
=
skin
.
data
.
getComponent
(
cc
.
Animation
);
anim
.
getClips
()[
0
]
=
updateAnim
.
getClips
()[
0
];
anim
.
getClips
()[
1
]
=
updateAnim
.
getClips
()[
1
];
anim
.
play
(
`
${
this
.
currentSkinPlayer
}
Idle`
);
anim
.
playOnLoad
=
true
;
}
}
}
console
.
log
(
this
.
node
.
children
[
0
].
getChildByName
(
"Dog"
).
getComponent
(
cc
.
Animation
)
);
}
}
onTouchDown
(
event
:
cc
.
Event
.
EventTouch
)
{
onTouchDown
(
event
:
cc
.
Event
.
EventTouch
)
{
...
@@ -252,8 +282,8 @@ export default class GamePlay extends cc.Component {
...
@@ -252,8 +282,8 @@ export default class GamePlay extends cc.Component {
}
}
onLevelCompleted
(
level
)
{
onLevelCompleted
(
level
)
{
this
.
isCompleted
=
true
;
this
.
addCoin
();
this
.
addCoin
();
this
.
isCompleted
=
true
;
StageController
.
instance
.
onCompleted
();
StageController
.
instance
.
onCompleted
();
if
(
this
.
currentLevel
+
1
==
this
.
highestLevel
)
{
if
(
this
.
currentLevel
+
1
==
this
.
highestLevel
)
{
LocalStorage
.
setHighestLevel
((
this
.
highestLevel
+=
1
));
LocalStorage
.
setHighestLevel
((
this
.
highestLevel
+=
1
));
...
...
assets/Scripts/Controllers/SkinsController.ts
View file @
1e9ef7d6
import
{
GlobalVariables
}
from
"../Data/GlobalVariables"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -15,6 +16,28 @@ export default class SkinController extends cc.Component {
...
@@ -15,6 +16,28 @@ export default class SkinController extends cc.Component {
this
.
allCoin
=
LocalStorage
.
getAllCoin
();
this
.
allCoin
=
LocalStorage
.
getAllCoin
();
this
.
allSkins
=
LocalStorage
.
getAllSkins
();
this
.
allSkins
=
LocalStorage
.
getAllSkins
();
this
.
updateStatus
();
this
.
updateStatus
();
this
.
loadCurrentSkin
();
}
loadCurrentSkin
()
{
const
skinPlayer
=
LocalStorage
.
getCurrentSkinPlayer
();
const
enemyPlayer
=
LocalStorage
.
getCurrentSkinEnemy
();
for
(
let
j
=
0
;
j
<
this
.
playerSkins
.
children
.
length
;
j
++
)
{
let
playerSkin
=
this
.
playerSkins
.
children
[
j
];
if
(
playerSkin
.
name
===
skinPlayer
)
{
let
selectedZone
=
playerSkin
.
getChildByName
(
"SelectedZone"
);
selectedZone
.
active
=
true
;
}
}
for
(
let
k
=
0
;
k
<
this
.
enemySkins
.
children
.
length
;
k
++
)
{
let
enemySkin
=
this
.
enemySkins
.
children
[
k
];
if
(
enemySkin
.
name
===
enemyPlayer
)
{
let
selectedZone
=
enemySkin
.
getChildByName
(
"SelectedZone"
);
selectedZone
.
active
=
true
;
}
}
}
}
updateStatus
()
{
updateStatus
()
{
...
@@ -23,7 +46,6 @@ export default class SkinController extends cc.Component {
...
@@ -23,7 +46,6 @@ export default class SkinController extends cc.Component {
for
(
let
i
=
0
;
i
<
this
.
allSkins
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
allSkins
.
length
;
i
++
)
{
let
skin
=
this
.
allSkins
[
i
];
let
skin
=
this
.
allSkins
[
i
];
if
(
skin
.
available
==
true
)
{
if
(
skin
.
available
==
true
)
{
// Kiểm tra playerSkins
for
(
let
j
=
0
;
j
<
this
.
playerSkins
.
children
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
this
.
playerSkins
.
children
.
length
;
j
++
)
{
let
playerSkin
=
this
.
playerSkins
.
children
[
j
];
let
playerSkin
=
this
.
playerSkins
.
children
[
j
];
if
(
playerSkin
.
name
===
skin
.
skin
)
{
if
(
playerSkin
.
name
===
skin
.
skin
)
{
...
@@ -34,7 +56,6 @@ export default class SkinController extends cc.Component {
...
@@ -34,7 +56,6 @@ export default class SkinController extends cc.Component {
}
}
}
}
// Kiểm tra enemySkins
for
(
let
k
=
0
;
k
<
this
.
enemySkins
.
children
.
length
;
k
++
)
{
for
(
let
k
=
0
;
k
<
this
.
enemySkins
.
children
.
length
;
k
++
)
{
let
enemySkin
=
this
.
enemySkins
.
children
[
k
];
let
enemySkin
=
this
.
enemySkins
.
children
[
k
];
if
(
enemySkin
.
name
===
skin
.
skin
)
{
if
(
enemySkin
.
name
===
skin
.
skin
)
{
...
@@ -61,9 +82,11 @@ export default class SkinController extends cc.Component {
...
@@ -61,9 +82,11 @@ export default class SkinController extends cc.Component {
onClickChooseSkin
(
event
:
cc
.
Event
.
EventTouch
)
{
onClickChooseSkin
(
event
:
cc
.
Event
.
EventTouch
)
{
let
skin
=
event
.
currentTarget
;
let
skin
=
event
.
currentTarget
;
if
(
skin
.
parent
.
getChildByName
(
"ButtonBuy"
).
active
==
true
)
return
;
if
(
skin
.
parent
.
getChildByName
(
"ButtonBuy"
).
active
==
true
)
return
;
skin
.
parent
.
getChildByName
(
"SelectedZone"
).
active
=
true
;
skin
.
parent
.
getChildByName
(
"SelectedZone"
).
active
=
true
;
if
(
skin
.
parent
.
parent
.
name
==
"SkinPlayers"
)
{
if
(
skin
.
parent
.
parent
.
name
==
"SkinPlayers"
)
{
LocalStorage
.
setCurrentSkinPlayer
(
skin
.
parent
.
name
);
for
(
let
i
=
0
;
i
<
this
.
playerSkins
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
playerSkins
.
children
.
length
;
i
++
)
{
let
playerSkin
=
this
.
playerSkins
.
children
[
i
];
let
playerSkin
=
this
.
playerSkins
.
children
[
i
];
if
(
playerSkin
.
name
!=
skin
.
parent
.
name
)
{
if
(
playerSkin
.
name
!=
skin
.
parent
.
name
)
{
...
@@ -76,6 +99,7 @@ export default class SkinController extends cc.Component {
...
@@ -76,6 +99,7 @@ export default class SkinController extends cc.Component {
}
}
if
(
skin
.
parent
.
parent
.
name
==
"SkinEnemys"
)
{
if
(
skin
.
parent
.
parent
.
name
==
"SkinEnemys"
)
{
LocalStorage
.
setCurrentSkinEnemy
(
skin
.
parent
.
name
);
for
(
let
i
=
0
;
i
<
this
.
enemySkins
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
enemySkins
.
children
.
length
;
i
++
)
{
let
enemySkin
=
this
.
enemySkins
.
children
[
i
];
let
enemySkin
=
this
.
enemySkins
.
children
[
i
];
if
(
enemySkin
.
name
!=
skin
.
parent
.
name
)
{
if
(
enemySkin
.
name
!=
skin
.
parent
.
name
)
{
...
...
assets/Scripts/Controllers/StageController.ts
View file @
1e9ef7d6
import
{
GlobalVariables
}
from
"../Data/GlobalVariables"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
import
Hive
from
"../Objects/Hive"
;
import
Hive
from
"../Objects/Hive"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -6,12 +8,15 @@ const { ccclass, property } = cc._decorator;
...
@@ -6,12 +8,15 @@ const { ccclass, property } = cc._decorator;
export
default
class
StageController
extends
cc
.
Component
{
export
default
class
StageController
extends
cc
.
Component
{
@
property
(
Array
(
cc
.
Node
))
dogList
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
();
@
property
(
Array
(
cc
.
Node
))
dogList
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
();
@
property
(
Array
(
cc
.
Node
))
hiveList
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
();
@
property
(
Array
(
cc
.
Node
))
hiveList
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
();
@
property
(
Array
(
cc
.
Node
))
blockedObjects
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
()
@
property
(
Array
(
cc
.
Node
))
blockedObjects
:
Array
<
cc
.
Node
>
=
new
Array
<
cc
.
Node
>
();
static
instance
:
StageController
;
static
instance
:
StageController
;
currentSkin
:
string
;
protected
onLoad
():
void
{
protected
onLoad
():
void
{
StageController
.
instance
=
this
;
StageController
.
instance
=
this
;
this
.
currentSkin
=
LocalStorage
.
getCurrentSkinPlayer
();
}
}
onHunting
()
{
onHunting
()
{
...
@@ -22,14 +27,15 @@ export default class StageController extends cc.Component {
...
@@ -22,14 +27,15 @@ export default class StageController extends cc.Component {
for
(
let
i
=
0
;
i
<
this
.
dogList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
dogList
.
length
;
i
++
)
{
let
dog
=
this
.
dogList
[
i
];
let
dog
=
this
.
dogList
[
i
];
dog
.
getComponent
(
cc
.
RigidBody
).
type
=
cc
.
RigidBodyType
.
Dynamic
;
dog
.
getComponent
(
cc
.
RigidBody
).
type
=
cc
.
RigidBodyType
.
Dynamic
;
dog
.
getComponent
(
cc
.
Animation
).
play
(
"DogScare"
);
if
(
this
.
currentSkin
==
"Dog"
)
dog
.
getComponent
(
cc
.
Animation
).
play
(
"DogScare"
);
}
}
}
}
onCompleted
()
{
onCompleted
()
{
for
(
let
i
=
0
;
i
<
this
.
dogList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
dogList
.
length
;
i
++
)
{
let
dog
=
this
.
dogList
[
i
];
let
dog
=
this
.
dogList
[
i
];
dog
.
getComponent
(
cc
.
Animation
).
play
(
"DogIdle"
);
dog
.
getComponent
(
cc
.
Animation
).
play
(
`
${
this
.
currentSkin
}
Idle`
);
}
}
}
}
}
}
assets/Scripts/Controllers/StartScene.ts
View file @
1e9ef7d6
...
@@ -45,6 +45,7 @@ export default class StartScene extends cc.Component {
...
@@ -45,6 +45,7 @@ export default class StartScene extends cc.Component {
onLastFrame
()
{
onLastFrame
()
{
if
(
this
.
currentAnimation
===
"DogRun"
)
{
if
(
this
.
currentAnimation
===
"DogRun"
)
{
this
.
currentAnimation
=
"DogRolling"
;
this
.
currentAnimation
=
"DogRolling"
;
}
else
{
}
else
{
this
.
currentAnimation
=
"DogRun"
;
this
.
currentAnimation
=
"DogRun"
;
}
}
...
...
assets/Scripts/Data/LocalStorage.ts
View file @
1e9ef7d6
...
@@ -105,7 +105,7 @@ export default class LocalStorage extends cc.Component {
...
@@ -105,7 +105,7 @@ export default class LocalStorage extends cc.Component {
return
JSON
.
parse
(
skins
);
return
JSON
.
parse
(
skins
);
}
}
}
}
public
static
setSkinAvailability
(
skinName
:
string
,
available
:
boolean
)
{
public
static
setSkinAvailability
(
skinName
:
string
,
available
:
boolean
)
{
const
allSkins
=
this
.
getAllSkins
();
const
allSkins
=
this
.
getAllSkins
();
const
skinEntry
=
allSkins
.
find
((
entry
)
=>
entry
.
skin
===
skinName
);
const
skinEntry
=
allSkins
.
find
((
entry
)
=>
entry
.
skin
===
skinName
);
...
@@ -117,4 +117,29 @@ export default class LocalStorage extends cc.Component {
...
@@ -117,4 +117,29 @@ export default class LocalStorage extends cc.Component {
JSON
.
stringify
(
allSkins
)
JSON
.
stringify
(
allSkins
)
);
);
}
}
public
static
setCurrentSkinPlayer
(
name
:
string
)
{
cc
.
sys
.
localStorage
.
setItem
(
"SaveTheDoge - CurrentSkinPlayer"
,
name
);
}
public
static
getCurrentSkinPlayer
():
string
{
if
(
cc
.
sys
.
localStorage
.
getItem
(
"SaveTheDoge - CurrentSkinPlayer"
)
==
null
)
{
cc
.
sys
.
localStorage
.
setItem
(
"SaveTheDoge - CurrentSkinPlayer"
,
"Dog"
);
return
"Dog"
;
}
else
return
cc
.
sys
.
localStorage
.
getItem
(
"SaveTheDoge - CurrentSkinPlayer"
);
}
public
static
setCurrentSkinEnemy
(
name
:
string
)
{
cc
.
sys
.
localStorage
.
setItem
(
"SaveTheDoge - CurrentSkinEnemy"
,
name
);
}
public
static
getCurrentSkinEnemy
():
string
{
if
(
cc
.
sys
.
localStorage
.
getItem
(
"SaveTheDoge - CurrentSkinEnemy"
)
==
null
)
{
cc
.
sys
.
localStorage
.
setItem
(
"SaveTheDoge - CurrentSkinEnemy"
,
"Bee"
);
return
"Bee"
;
}
else
return
cc
.
sys
.
localStorage
.
getItem
(
"SaveTheDoge - CurrentSkinEnemy"
);
}
}
}
assets/Scripts/Objects/Dog.ts
View file @
1e9ef7d6
import
GamePlay
from
"../Controllers/GamePlay"
;
import
GamePlay
from
"../Controllers/GamePlay"
;
import
Bubble
from
"../Tools/Bubble"
;
import
{
GlobalVariables
}
from
"../Data/GlobalVariables"
;
import
LocalStorage
from
"../Data/LocalStorage"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -7,9 +8,11 @@ const { ccclass, property } = cc._decorator;
...
@@ -7,9 +8,11 @@ const { ccclass, property } = cc._decorator;
export
default
class
Dog
extends
cc
.
Component
{
export
default
class
Dog
extends
cc
.
Component
{
static
instance
:
Dog
;
static
instance
:
Dog
;
attacked
=
false
;
attacked
=
false
;
currentSkin
:
string
;
protected
onLoad
():
void
{
protected
onLoad
():
void
{
Dog
.
instance
=
this
;
Dog
.
instance
=
this
;
this
.
currentSkin
=
LocalStorage
.
getCurrentSkinPlayer
();
}
}
onBeginContact
(
contact
,
selfCollider
,
otherCollider
)
{
onBeginContact
(
contact
,
selfCollider
,
otherCollider
)
{
...
@@ -17,7 +20,7 @@ export default class Dog extends cc.Component {
...
@@ -17,7 +20,7 @@ export default class Dog extends cc.Component {
if
(
!
this
.
attacked
&&
otherCollider
.
tag
==
1
)
{
if
(
!
this
.
attacked
&&
otherCollider
.
tag
==
1
)
{
this
.
attacked
=
true
;
this
.
attacked
=
true
;
GamePlay
.
instance
.
isGameover
=
true
;
GamePlay
.
instance
.
isGameover
=
true
;
this
.
node
.
getComponent
(
cc
.
Animation
).
play
(
"DogHurt"
);
this
.
node
.
getComponent
(
cc
.
Animation
).
play
(
`
${
this
.
currentSkin
}
Hurt`
);
}
}
if
(
otherCollider
.
tag
==
3
)
{
if
(
otherCollider
.
tag
==
3
)
{
let
effect
=
cc
.
instantiate
(
GamePlay
.
instance
.
fadePrefab
);
let
effect
=
cc
.
instantiate
(
GamePlay
.
instance
.
fadePrefab
);
...
...
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