Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StockRunning
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
czy
StockRunning
Commits
c9d66a03
Commit
c9d66a03
authored
Apr 23, 2021
by
czy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
速度等级不同更换不同模型
parent
716504db
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1016 additions
and
13 deletions
+1016
-13
DemoScenes.unity
StockRunning/Assets/#A1_Scenes/DemoScenes.unity
+315
-2
AIMove.cs
StockRunning/Assets/My/Scripts/AI/AIMove.cs
+31
-2
PlayerMove.cs
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
+30
-5
OnBike.prefab
StockRunning/Assets/Prefabs/Characters/OnBike.prefab
+1
-1
SM_Veh_Car_Sports_01 Variant.prefab
...ts/Prefabs/Characters/SM_Veh_Car_Sports_01 Variant.prefab
+2
-2
Level2My.prefab
StockRunning/Assets/Prefabs/Level2My.prefab
+637
-1
No files found.
StockRunning/Assets/#A1_Scenes/DemoScenes.unity
View file @
c9d66a03
This diff is collapsed.
Click to expand it.
StockRunning/Assets/My/Scripts/AI/AIMove.cs
View file @
c9d66a03
...
@@ -27,6 +27,11 @@ public class AIMove : MonoBehaviour
...
@@ -27,6 +27,11 @@ public class AIMove : MonoBehaviour
public
Transform
raySeeWayPos
;
public
Transform
raySeeWayPos
;
[
Header
(
"AI策略"
)]
[
Header
(
"AI策略"
)]
public
AIStrategy
aIStrategy
;
public
AIStrategy
aIStrategy
;
[
Header
(
"模型控制"
)]
public
Transform
ModelParent
;
public
GameObject
Model1
;
public
GameObject
Model2
;
public
GameObject
Model3
;
private
RaycastHit
RHit
;
private
RaycastHit
RHit
;
private
CharacterController
characterController
;
private
CharacterController
characterController
;
...
@@ -62,6 +67,7 @@ public class AIMove : MonoBehaviour
...
@@ -62,6 +67,7 @@ public class AIMove : MonoBehaviour
//动画
//动画
private
Animator
animator
;
private
Animator
animator
;
//状态
//状态
[
HideInInspector
]
public
float
MoveSpeed
=
0.0f
;
public
float
MoveSpeed
=
0.0f
;
private
bool
Grounded
=
false
;
private
bool
Grounded
=
false
;
private
GameObject
targetObj
;
private
GameObject
targetObj
;
...
@@ -85,6 +91,7 @@ public class AIMove : MonoBehaviour
...
@@ -85,6 +91,7 @@ public class AIMove : MonoBehaviour
m_thumbRT
=
GameServices
.
inputService
.
joyStick
.
thumb
;
m_thumbRT
=
GameServices
.
inputService
.
joyStick
.
thumb
;
//获取animator组件
//获取animator组件
animator
=
GetComponentInChildren
<
Animator
>();
animator
=
GetComponentInChildren
<
Animator
>();
ChangeModel
();
}
}
private
void
OnTriggerEnter
(
Collider
other
)
private
void
OnTriggerEnter
(
Collider
other
)
...
@@ -96,6 +103,7 @@ public class AIMove : MonoBehaviour
...
@@ -96,6 +103,7 @@ public class AIMove : MonoBehaviour
SpeedLevel
+=
1
;
SpeedLevel
+=
1
;
BattleCtrl
.
instance
.
Score
++;
BattleCtrl
.
instance
.
Score
++;
BattleCtrl
.
instance
.
updateScore
?.
Invoke
();
BattleCtrl
.
instance
.
updateScore
?.
Invoke
();
ChangeModel
();
}
}
Destroy
(
other
.
gameObject
);
Destroy
(
other
.
gameObject
);
}
}
...
@@ -104,6 +112,7 @@ public class AIMove : MonoBehaviour
...
@@ -104,6 +112,7 @@ public class AIMove : MonoBehaviour
if
(
this
.
SpeedLevel
>
1
)
if
(
this
.
SpeedLevel
>
1
)
{
{
this
.
SpeedLevel
--;
this
.
SpeedLevel
--;
ChangeModel
();
}
}
}
}
}
}
...
@@ -373,7 +382,7 @@ public class AIMove : MonoBehaviour
...
@@ -373,7 +382,7 @@ public class AIMove : MonoBehaviour
if
(
transform
.
position
.
z
<
maxZ
)
if
(
transform
.
position
.
z
<
maxZ
)
{
{
//print("前方
右
障碍物,开始躲避AvoidDir:"+ AvoidDir+ "transform.position.x:"+ transform.position.x + "avoidX:" + avoidX);
//print("前方
有
障碍物,开始躲避AvoidDir:"+ AvoidDir+ "transform.position.x:"+ transform.position.x + "avoidX:" + avoidX);
//前方右障碍物,开始躲避。
//前方右障碍物,开始躲避。
//关闭金币导航
//关闭金币导航
deltaX
=
0
;
deltaX
=
0
;
...
@@ -626,7 +635,27 @@ public class AIMove : MonoBehaviour
...
@@ -626,7 +635,27 @@ public class AIMove : MonoBehaviour
}
}
public
void
ChangeModel
()
{
switch
(
SpeedLevel
)
{
case
1
:
Model1
.
SetActive
(
true
);
Model2
.
SetActive
(
false
);
Model3
.
SetActive
(
false
);
break
;
case
2
:
Model1
.
SetActive
(
false
);
Model2
.
SetActive
(
true
);
Model3
.
SetActive
(
false
);
break
;
case
3
:
Model1
.
SetActive
(
false
);
Model2
.
SetActive
(
false
);
Model3
.
SetActive
(
true
);
break
;
}
}
private
void
OnDestroy
()
private
void
OnDestroy
()
{
{
m_targetTrans
=
null
;
m_targetTrans
=
null
;
...
...
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
View file @
c9d66a03
...
@@ -21,14 +21,18 @@ public class PlayerMove : MonoBehaviour
...
@@ -21,14 +21,18 @@ public class PlayerMove : MonoBehaviour
public
float
AddSpeed
=
10.0f
;
public
float
AddSpeed
=
10.0f
;
[
Tooltip
(
"控制左右移动的速度。"
)]
[
Tooltip
(
"控制左右移动的速度。"
)]
public
float
HSpeed
=
10.0f
;
public
float
HSpeed
=
10.0f
;
[
Tooltip
(
"主角移动方式"
)]
[
Tooltip
(
"主角移动方式"
)]
public
MoveType
moveType
=
MoveType
.
MoveType3
;
public
MoveType
moveType
=
MoveType
.
MoveType3
;
[
Header
(
"地面检测"
)]
[
Header
(
"地面检测"
)]
public
Transform
ray1Pos
;
public
Transform
ray1Pos
;
public
Transform
ray2Pos
;
public
Transform
ray2Pos
;
[
Header
(
"模型控制"
)]
public
Transform
ModelParent
;
public
GameObject
Model1
;
public
GameObject
Model2
;
public
GameObject
Model3
;
private
RaycastHit
RHit
;
private
RaycastHit
RHit
;
private
CharacterController
characterController
;
private
CharacterController
characterController
;
...
@@ -59,6 +63,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -59,6 +63,7 @@ public class PlayerMove : MonoBehaviour
//动画
//动画
private
Animator
animator
;
private
Animator
animator
;
//状态
//状态
[
HideInInspector
]
public
float
MoveSpeed
=
0.0f
;
public
float
MoveSpeed
=
0.0f
;
private
bool
Grounded
=
false
;
private
bool
Grounded
=
false
;
...
@@ -91,6 +96,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -91,6 +96,7 @@ public class PlayerMove : MonoBehaviour
//m_rigidBody = GetComponent<Rigidbody>();
//m_rigidBody = GetComponent<Rigidbody>();
//获取characterController组件
//获取characterController组件
characterController
=
GetComponent
<
CharacterController
>();
characterController
=
GetComponent
<
CharacterController
>();
ChangeModel
();
}
}
private
void
OnTriggerEnter
(
Collider
other
)
private
void
OnTriggerEnter
(
Collider
other
)
...
@@ -104,6 +110,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -104,6 +110,7 @@ public class PlayerMove : MonoBehaviour
SpeedLevel
+=
1
;
SpeedLevel
+=
1
;
BattleCtrl
.
instance
.
Score
++;
BattleCtrl
.
instance
.
Score
++;
BattleCtrl
.
instance
.
updateScore
?.
Invoke
();
BattleCtrl
.
instance
.
updateScore
?.
Invoke
();
ChangeModel
();
}
}
}
}
else
if
(
other
.
tag
==
"Prickle"
)
else
if
(
other
.
tag
==
"Prickle"
)
...
@@ -111,6 +118,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -111,6 +118,7 @@ public class PlayerMove : MonoBehaviour
if
(
this
.
SpeedLevel
>
1
)
if
(
this
.
SpeedLevel
>
1
)
{
{
this
.
SpeedLevel
--;
this
.
SpeedLevel
--;
ChangeModel
();
}
}
}
}
//else if (other.tag == "Prop" && DoRanking._instance.rankingList[2]!=gameObject) //自己不是最前面的人。
//else if (other.tag == "Prop" && DoRanking._instance.rankingList[2]!=gameObject) //自己不是最前面的人。
...
@@ -499,9 +507,26 @@ public class PlayerMove : MonoBehaviour
...
@@ -499,9 +507,26 @@ public class PlayerMove : MonoBehaviour
//timerVertigo += time; //累加眩晕时长
//timerVertigo += time; //累加眩晕时长
}
}
p
rivate
void
OnControllerColliderHit
(
ControllerColliderHit
hit
)
p
ublic
void
ChangeModel
(
)
{
{
switch
(
SpeedLevel
)
{
case
1
:
Model1
.
SetActive
(
true
);
Model2
.
SetActive
(
false
);
Model3
.
SetActive
(
false
);
break
;
case
2
:
Model1
.
SetActive
(
false
);
Model2
.
SetActive
(
true
);
Model3
.
SetActive
(
false
);
break
;
case
3
:
Model1
.
SetActive
(
false
);
Model2
.
SetActive
(
false
);
Model3
.
SetActive
(
true
);
break
;
}
}
}
private
void
OnDestroy
()
private
void
OnDestroy
()
...
...
StockRunning/Assets/Prefabs/Characters/OnBike.prefab
View file @
c9d66a03
...
@@ -24,7 +24,7 @@ Transform:
...
@@ -24,7 +24,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
4004674577979274087
}
m_GameObject
:
{
fileID
:
4004674577979274087
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0.7755992
,
y
:
-8.
0
60598
,
z
:
13.473129
}
m_LocalPosition
:
{
x
:
0.7755992
,
y
:
-8.
2
60598
,
z
:
13.473129
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
m_Children
:
-
{
fileID
:
4004674578049485334
}
-
{
fileID
:
4004674578049485334
}
...
...
StockRunning/Assets/Prefabs/Characters/SM_Veh_Car_Sports_01 Variant.prefab
View file @
c9d66a03
...
@@ -9,7 +9,7 @@ PrefabInstance:
...
@@ -9,7 +9,7 @@ PrefabInstance:
m_Modifications
:
m_Modifications
:
-
target
:
{
fileID
:
1684007911718038
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
-
target
:
{
fileID
:
1684007911718038
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
propertyPath
:
m_Name
propertyPath
:
m_Name
value
:
SM_Veh_Car_Sports_01
value
:
SM_Veh_Car_Sports_01
Variant
objectReference
:
{
fileID
:
0
}
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
propertyPath
:
m_LocalPosition.x
...
@@ -17,7 +17,7 @@ PrefabInstance:
...
@@ -17,7 +17,7 @@ PrefabInstance:
objectReference
:
{
fileID
:
0
}
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
propertyPath
:
m_LocalPosition.y
value
:
0.48127
value
:
-0.064
objectReference
:
{
fileID
:
0
}
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
-
target
:
{
fileID
:
4996138570027138
,
guid
:
18c5fed9cca812a458ccf567688e3a1f
,
type
:
3
}
propertyPath
:
m_LocalPosition.z
propertyPath
:
m_LocalPosition.z
...
...
StockRunning/Assets/Prefabs/Level2My.prefab
View file @
c9d66a03
This diff is collapsed.
Click to expand it.
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