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
c3d3b3a7
Commit
c3d3b3a7
authored
Apr 21, 2021
by
czy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试版本1.0
parent
2173a3cc
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
4217 additions
and
13352 deletions
+4217
-13352
DemoScenes.unity
StockRunning/Assets/#A1_Scenes/DemoScenes.unity
+2464
-135
FollowTarget.cs
StockRunning/Assets/#A2_Scripts/Camera/FollowTarget.cs
+8
-3
Level2My.prefab
StockRunning/Assets/My/Level2My.prefab
+1651
-13179
AIMove.cs
StockRunning/Assets/My/Scripts/AI/AIMove.cs
+29
-11
ConfigurationFile.cs
StockRunning/Assets/My/Scripts/ConfigurationFile.cs
+26
-0
PlayerMove.cs
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
+19
-14
Enemy_Vertigo.cs
StockRunning/Assets/My/Scripts/Prop/Enemy_Vertigo.cs
+17
-9
Prop.cs
StockRunning/Assets/My/Scripts/Prop/Prop.cs
+3
-1
No files found.
StockRunning/Assets/#A1_Scenes/DemoScenes.unity
View file @
c3d3b3a7
This diff is collapsed.
Click to expand it.
StockRunning/Assets/#A2_Scripts/Camera/FollowTarget.cs
View file @
c3d3b3a7
...
@@ -32,18 +32,23 @@ public class FollowTarget : MonoBehaviour
...
@@ -32,18 +32,23 @@ public class FollowTarget : MonoBehaviour
//2
//2
public
float
backDis
=
-
5.51f
;
public
float
backDis
=
5.51f
;
public
float
upDis
=
8.77f
;
public
float
upDis
=
8.77f
;
public
float
smood
=
10
;
//
public float smood=10;
private
Transform
target
;
private
Transform
target
;
private
void
Start
()
private
void
Start
()
{
{
target
=
GameObject
.
FindGameObjectWithTag
(
"Player"
).
transform
;
target
=
GameObject
.
FindGameObjectWithTag
(
"Player"
).
transform
;
}
}
private
void
LateUpdate
()
private
void
LateUpdate
()
{
{
//读取配置文件数据
backDis
=
ConfigurationFile
.
instance
.
backDis
;
upDis
=
ConfigurationFile
.
instance
.
upDis
;
Vector3
followPoint
=
target
.
position
+
Vector3
.
up
*
upDis
-
target
.
forward
*
backDis
;
Vector3
followPoint
=
target
.
position
+
Vector3
.
up
*
upDis
-
target
.
forward
*
backDis
;
transform
.
position
=
followPoint
;
transform
.
position
=
followPoint
;
//transform.position = Vector3.Lerp(transform.position, followPoint,Time.deltaTime*smood);
//transform.position = Vector3.Lerp(transform.position, followPoint,Time.deltaTime*smood);
...
...
StockRunning/Assets/My/Level2My.prefab
View file @
c3d3b3a7
This diff is collapsed.
Click to expand it.
StockRunning/Assets/My/Scripts/AI/AIMove.cs
View file @
c3d3b3a7
...
@@ -8,7 +8,7 @@ public class AIMove : MonoBehaviour
...
@@ -8,7 +8,7 @@ public class AIMove : MonoBehaviour
{
{
[
Header
(
"控制移动"
)]
[
Header
(
"控制移动"
)]
[
Tooltip
(
"控制向前的速度。"
)]
[
Tooltip
(
"控制向前的速度。"
)]
public
float
VSpeed
=
4
0.0f
;
public
float
VSpeed
=
2
0.0f
;
[
Tooltip
(
"控制左右移动的速度。(未实现)"
)]
[
Tooltip
(
"控制左右移动的速度。(未实现)"
)]
public
float
HSpeed
=
10.0f
;
public
float
HSpeed
=
10.0f
;
public
int
SpeedLevel
=
1
;
public
int
SpeedLevel
=
1
;
...
@@ -49,6 +49,13 @@ public class AIMove : MonoBehaviour
...
@@ -49,6 +49,13 @@ public class AIMove : MonoBehaviour
// Start is called before the first frame update
// Start is called before the first frame update
void
Start
()
void
Start
()
{
{
//从配置文件ConfigurationFile中获取数据
//VSpeed = ConfigurationFile.instance.VSpeed;
SpeedLevel
=
ConfigurationFile
.
instance
.
SpeedLevel
;
//AddSpeed = ConfigurationFile.instance.AddSpeed;
//HSpeed = ConfigurationFile.instance.HSpeed;
characterController
=
GetComponent
<
CharacterController
>();
characterController
=
GetComponent
<
CharacterController
>();
BattleCtrl
.
instance
.
turnDir
+=
TurnDir
;
BattleCtrl
.
instance
.
turnDir
+=
TurnDir
;
//m_rigidBody = GetComponent<Rigidbody>();
//m_rigidBody = GetComponent<Rigidbody>();
...
@@ -151,6 +158,14 @@ public class AIMove : MonoBehaviour
...
@@ -151,6 +158,14 @@ public class AIMove : MonoBehaviour
{
{
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
//从配置文件ConfigurationFile中获取数据
VSpeed
=
ConfigurationFile
.
instance
.
VSpeedAI
;
//SpeedLevel = ConfigurationFile.instance.SpeedLevelAI; //初始化一次。
AddSpeed
=
ConfigurationFile
.
instance
.
AddSpeedAI
;
HSpeed
=
ConfigurationFile
.
instance
.
HSpeedAI
;
if
(!
BattleCtrl
.
instance
.
isStartBattle
)
if
(!
BattleCtrl
.
instance
.
isStartBattle
)
{
{
isAddSpeed
=
true
;
isAddSpeed
=
true
;
...
@@ -161,6 +176,14 @@ public class AIMove : MonoBehaviour
...
@@ -161,6 +176,14 @@ public class AIMove : MonoBehaviour
isAddSpeed
=
true
;
isAddSpeed
=
true
;
return
;
return
;
}
}
//移动
MoveSpeed
=
VSpeed
+
AddSpeed
*
(
SpeedLevel
-
1
);
//是否在地面
Grounded
=
characterController
.
isGrounded
;
//print(""+ MoveSpeed+" "+ Grounded);
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
//射线检测。
//射线检测。
...
@@ -200,14 +223,14 @@ public class AIMove : MonoBehaviour
...
@@ -200,14 +223,14 @@ public class AIMove : MonoBehaviour
}
}
}
}
if
(
m_bIsCanMove
&&
!
BattleCtrl
.
instance
.
isEndBattle
)
if
(
m_bIsCanMove
&&
!
BattleCtrl
.
instance
.
isEndBattle
)
{
{
if
(
timerVertigo
<=
0
)
if
(
timerVertigo
<=
0
)
{
{
timerVertigo
=
0.0f
;
timerVertigo
=
0.0f
;
//AI向前跑。
//AI向前跑。
characterController
.
SimpleMove
(
transform
.
forward
*
(
VSpeed
+
AddSpeed
*
SpeedLevel
)
);
characterController
.
SimpleMove
(
transform
.
forward
*
MoveSpeed
);
//UpdateJoystick();
//UpdateJoystick();
}
}
else
else
...
@@ -217,13 +240,8 @@ public class AIMove : MonoBehaviour
...
@@ -217,13 +240,8 @@ public class AIMove : MonoBehaviour
}
}
}
}
//移动
MoveSpeed
=
VSpeed
+
AddSpeed
*
SpeedLevel
;
//是否在地面
Grounded
=
characterController
.
isGrounded
;
//print(""+ MoveSpeed+" "+ Grounded);
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
}
}
...
@@ -286,7 +304,7 @@ public class AIMove : MonoBehaviour
...
@@ -286,7 +304,7 @@ public class AIMove : MonoBehaviour
}
}
public
void
MoveType3
()
public
void
MoveType3
()
{
{
characterController
.
SimpleMove
(
transform
.
forward
*
(
VSpeed
+
AddSpeed
*
SpeedLevel
)
);
characterController
.
SimpleMove
(
transform
.
forward
*
MoveSpeed
);
if
(
isGround1
||
isGround2
)
if
(
isGround1
||
isGround2
)
{
{
//在地面上才能控制移动
//在地面上才能控制移动
...
...
StockRunning/Assets/My/Scripts/ConfigurationFile.cs
View file @
c3d3b3a7
...
@@ -14,6 +14,32 @@ public class ConfigurationFile : MonoBehaviour
...
@@ -14,6 +14,32 @@ public class ConfigurationFile : MonoBehaviour
[
Tooltip
(
"控制左右移动的速度。"
)]
[
Tooltip
(
"控制左右移动的速度。"
)]
public
float
HSpeed
=
10.0f
;
public
float
HSpeed
=
10.0f
;
[
Header
(
"AI"
)]
[
Tooltip
(
"控制向前的速度。"
)]
public
float
VSpeedAI
=
20.0f
;
public
int
SpeedLevelAI
=
1
;
[
Tooltip
(
"没升一级增加的速度"
)]
public
float
AddSpeedAI
=
10.0f
;
[
Tooltip
(
"控制左右移动的速度。"
)]
public
float
HSpeedAI
=
10.0f
;
[
Header
(
"摄像机"
)]
[
Tooltip
(
"相对主角 向后的距离"
)]
public
float
backDis
=
5.51f
;
[
Tooltip
(
"相对主角 向上的距离"
)]
public
float
upDis
=
8.77f
;
[
Header
(
"打手"
)]
[
Tooltip
(
"基础速度"
)]
public
float
VSpeedEnemy_V
=
20.0f
;
[
Tooltip
(
"速度等级"
)]
public
int
SpeedLevelEnemy_V
=
1
;
[
Tooltip
(
"每升一级增加的速度"
)]
public
float
AddSpeedEnemy_V
=
10.0f
;
[
Tooltip
(
"每个小人眩晕时长"
)]
public
float
VertigoTimeEnemy_V
=
3.0f
;
[
Tooltip
(
"小人出现的位置在目标的前方的距离"
)]
public
float
disZ
=
50
;
public
static
ConfigurationFile
instance
;
public
static
ConfigurationFile
instance
;
...
...
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
View file @
c3d3b3a7
...
@@ -13,12 +13,12 @@ public class PlayerMove : MonoBehaviour
...
@@ -13,12 +13,12 @@ public class PlayerMove : MonoBehaviour
{
{
[
Header
(
"控制移动"
)]
[
Header
(
"控制移动"
)]
[
Tooltip
(
"控制向前的速度。"
)]
[
Tooltip
(
"控制向前的速度。"
)]
p
rivate
float
VSpeed
=
20.0f
;
p
ublic
float
VSpeed
=
20.0f
;
p
rivate
int
SpeedLevel
=
1
;
p
ublic
int
SpeedLevel
=
1
;
[
Tooltip
(
"没升一级增加的速度"
)]
[
Tooltip
(
"没升一级增加的速度"
)]
p
rivate
float
AddSpeed
=
10.0f
;
p
ublic
float
AddSpeed
=
10.0f
;
[
Tooltip
(
"控制左右移动的速度。"
)]
[
Tooltip
(
"控制左右移动的速度。"
)]
p
rivate
float
HSpeed
=
10.0f
;
p
ublic
float
HSpeed
=
10.0f
;
...
@@ -56,8 +56,12 @@ public class PlayerMove : MonoBehaviour
...
@@ -56,8 +56,12 @@ public class PlayerMove : MonoBehaviour
// Start is called before the first frame update
// Start is called before the first frame update
void
Start
()
void
Start
()
{
{
//从配置文件ConfigurationFile中获取数据
//VSpeed = ConfigurationFile.instance.VSpeed;
SpeedLevel
=
ConfigurationFile
.
instance
.
SpeedLevel
;
//AddSpeed = ConfigurationFile.instance.AddSpeed;
//HSpeed = ConfigurationFile.instance.HSpeed;
//委托注册方法
//委托注册方法
...
@@ -169,7 +173,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -169,7 +173,7 @@ public class PlayerMove : MonoBehaviour
//从配置文件ConfigurationFile中获取数据
//从配置文件ConfigurationFile中获取数据
VSpeed
=
ConfigurationFile
.
instance
.
VSpeed
;
VSpeed
=
ConfigurationFile
.
instance
.
VSpeed
;
SpeedLevel
=
ConfigurationFile
.
instance
.
SpeedLevel
;
//SpeedLevel = ConfigurationFile.instance.SpeedLevel; //初始化一次。
AddSpeed
=
ConfigurationFile
.
instance
.
AddSpeed
;
AddSpeed
=
ConfigurationFile
.
instance
.
AddSpeed
;
HSpeed
=
ConfigurationFile
.
instance
.
HSpeed
;
HSpeed
=
ConfigurationFile
.
instance
.
HSpeed
;
...
@@ -185,6 +189,13 @@ public class PlayerMove : MonoBehaviour
...
@@ -185,6 +189,13 @@ public class PlayerMove : MonoBehaviour
isAddSpeed
=
true
;
isAddSpeed
=
true
;
return
;
return
;
}
}
//移动
MoveSpeed
=
VSpeed
+
(
AddSpeed
*
(
SpeedLevel
-
1
));
//是否在地面
Grounded
=
characterController
.
isGrounded
;
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
//射线检测。
//射线检测。
...
@@ -239,13 +250,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -239,13 +250,7 @@ public class PlayerMove : MonoBehaviour
}
}
}
}
//移动
MoveSpeed
=
VSpeed
+(
AddSpeed
*
SpeedLevel
);
//是否在地面
Grounded
=
characterController
.
isGrounded
;
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
}
}
//摇杆控制
//摇杆控制
...
@@ -307,7 +312,7 @@ public class PlayerMove : MonoBehaviour
...
@@ -307,7 +312,7 @@ public class PlayerMove : MonoBehaviour
}
}
public
void
MoveType3
()
public
void
MoveType3
()
{
{
characterController
.
SimpleMove
(
transform
.
forward
*
(
VSpeed
+
AddSpeed
*
SpeedLevel
)
);
characterController
.
SimpleMove
(
transform
.
forward
*
MoveSpeed
);
if
(
isGround1
||
isGround2
)
if
(
isGround1
||
isGround2
)
{
{
//在地面上才能控制移动
//在地面上才能控制移动
...
...
StockRunning/Assets/My/Scripts/Prop/Enemy_Vertigo.cs
View file @
c3d3b3a7
...
@@ -29,20 +29,28 @@ public class Enemy_Vertigo : MonoBehaviour
...
@@ -29,20 +29,28 @@ public class Enemy_Vertigo : MonoBehaviour
// Update is called once per frame
// Update is called once per frame
void
Update
()
void
Update
()
{
{
//读取配置文件数据
V
ector3
direction
=
(
targetPos
.
position
-
transform
.
position
)
;
V
Speed
=
ConfigurationFile
.
instance
.
VSpeedEnemy_V
;
direction
.
y
=
0
;
SpeedLevel
=
ConfigurationFile
.
instance
.
SpeedLevelEnemy_V
;
direction
=
direction
.
normalized
;
AddSpeed
=
ConfigurationFile
.
instance
.
AddSpeedEnemy_V
;
//characterController.SimpleMove(direction*Speed* SpeedLevel)
;
VertigoTime
=
ConfigurationFile
.
instance
.
VertigoTimeEnemy_V
;
characterController
.
Move
(
direction
*
(
VSpeed
+
AddSpeed
*
SpeedLevel
)
*
Time
.
deltaTime
);
//移动
//移动
MoveSpeed
=
VSpeed
+
AddSpeed
*
SpeedLevel
;
MoveSpeed
=
VSpeed
+
AddSpeed
*
(
SpeedLevel
-
1
)
;
//是否在地面
//是否在地面
Grounded
=
characterController
.
isGrounded
;
Grounded
=
characterController
.
isGrounded
;
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
transform
.
LookAt
(
targetPos
);
Vector3
direction
=
(
targetPos
.
position
-
transform
.
position
);
direction
.
y
=
0
;
direction
=
direction
.
normalized
;
//characterController.SimpleMove(direction*Speed* SpeedLevel);
characterController
.
SimpleMove
(
direction
*
MoveSpeed
);
}
}
...
...
StockRunning/Assets/My/Scripts/Prop/Prop.cs
View file @
c3d3b3a7
...
@@ -5,6 +5,7 @@ using UnityEngine;
...
@@ -5,6 +5,7 @@ using UnityEngine;
public
class
Prop
:
MonoBehaviour
public
class
Prop
:
MonoBehaviour
{
{
public
GameObject
enemy3AI
;
public
GameObject
enemy3AI
;
public
float
disZ
=
50
;
void
Start
()
void
Start
()
...
@@ -20,10 +21,11 @@ public class Prop : MonoBehaviour
...
@@ -20,10 +21,11 @@ public class Prop : MonoBehaviour
private
void
OnTriggerEnter
(
Collider
other
)
private
void
OnTriggerEnter
(
Collider
other
)
{
{
disZ
=
ConfigurationFile
.
instance
.
disZ
;
if
((
other
.
tag
==
"Competitor"
||
other
.
tag
==
"Player"
)
&&
DoRanking
.
_instance
.
rankingList
[
2
]
!=
other
.
gameObject
)
if
((
other
.
tag
==
"Competitor"
||
other
.
tag
==
"Player"
)
&&
DoRanking
.
_instance
.
rankingList
[
2
]
!=
other
.
gameObject
)
{
{
//print(DoRanking._instance.rankingList[2].name + "---" + other.gameObject.name+" "+ (DoRanking._instance.rankingList[2]== other.gameObject).ToString());
//print(DoRanking._instance.rankingList[2].name + "---" + other.gameObject.name+" "+ (DoRanking._instance.rankingList[2]== other.gameObject).ToString());
enemy3AI
.
transform
.
position
=
DoRanking
.
_instance
.
rankingList
[
2
].
transform
.
position
+
new
Vector3
(
0
,
0
,
100
);
enemy3AI
.
transform
.
position
=
DoRanking
.
_instance
.
rankingList
[
2
].
transform
.
position
+
new
Vector3
(
0
,
0
,
disZ
);
//new Vector3(0,0, 100)
enemy3AI
.
SetActive
(
true
);
enemy3AI
.
SetActive
(
true
);
Destroy
(
gameObject
);
Destroy
(
gameObject
);
}
}
...
...
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