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
c9420865
Commit
c9420865
authored
Apr 22, 2021
by
czy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加巨石道具
parent
28ace866
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
756 additions
and
12 deletions
+756
-12
PropMat1.mat
StockRunning/Assets/My/Materials/PropMat1.mat
+77
-0
PropMat1.mat.meta
StockRunning/Assets/My/Materials/PropMat1.mat.meta
+8
-0
PropMat2.mat
StockRunning/Assets/My/Materials/PropMat2.mat
+77
-0
PropMat2.mat.meta
StockRunning/Assets/My/Materials/PropMat2.mat.meta
+8
-0
AIMove.cs
StockRunning/Assets/My/Scripts/AI/AIMove.cs
+102
-3
DoRanking.cs
StockRunning/Assets/My/Scripts/DoRanking.cs
+22
-0
PlayerMove.cs
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
+2
-2
GiantRock.cs
StockRunning/Assets/My/Scripts/Prop/GiantRock.cs
+41
-0
GiantRock.cs.meta
StockRunning/Assets/My/Scripts/Prop/GiantRock.cs.meta
+11
-0
Prop.cs
StockRunning/Assets/My/Scripts/Prop/Prop.cs
+49
-7
Level2My.prefab
StockRunning/Assets/Prefabs/Level2My.prefab
+359
-0
No files found.
StockRunning/Assets/My/Materials/PropMat1.mat
0 → 100644
View file @
c9420865
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!21
&2100000
Material
:
serializedVersion
:
6
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
PropMat1
m_Shader
:
{
fileID
:
46
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_ShaderKeywords
:
m_LightmapFlags
:
4
m_EnableInstancingVariants
:
0
m_DoubleSidedGI
:
0
m_CustomRenderQueue
:
-1
stringTagMap
:
{}
disabledShaderPasses
:
[]
m_SavedProperties
:
serializedVersion
:
3
m_TexEnvs
:
-
_BumpMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailAlbedoMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailMask
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailNormalMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_EmissionMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_MainTex
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_MetallicGlossMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_OcclusionMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_ParallaxMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
m_Floats
:
-
_BumpScale
:
1
-
_Cutoff
:
0.5
-
_DetailNormalMapScale
:
1
-
_DstBlend
:
0
-
_GlossMapScale
:
1
-
_Glossiness
:
0.5
-
_GlossyReflections
:
1
-
_Metallic
:
0
-
_Mode
:
0
-
_OcclusionStrength
:
1
-
_Parallax
:
0.02
-
_SmoothnessTextureChannel
:
0
-
_SpecularHighlights
:
1
-
_SrcBlend
:
1
-
_UVSec
:
0
-
_ZWrite
:
1
m_Colors
:
-
_Color
:
{
r
:
0.40465352
,
g
:
0.39489147
,
b
:
0.9622642
,
a
:
1
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
StockRunning/Assets/My/Materials/PropMat1.mat.meta
0 → 100644
View file @
c9420865
fileFormatVersion: 2
guid: aa85b67d719a9e442bd1f9cb674981d4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
StockRunning/Assets/My/Materials/PropMat2.mat
0 → 100644
View file @
c9420865
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!21
&2100000
Material
:
serializedVersion
:
6
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
PropMat2
m_Shader
:
{
fileID
:
46
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_ShaderKeywords
:
m_LightmapFlags
:
4
m_EnableInstancingVariants
:
0
m_DoubleSidedGI
:
0
m_CustomRenderQueue
:
-1
stringTagMap
:
{}
disabledShaderPasses
:
[]
m_SavedProperties
:
serializedVersion
:
3
m_TexEnvs
:
-
_BumpMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailAlbedoMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailMask
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_DetailNormalMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_EmissionMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_MainTex
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_MetallicGlossMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_OcclusionMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
-
_ParallaxMap
:
m_Texture
:
{
fileID
:
0
}
m_Scale
:
{
x
:
1
,
y
:
1
}
m_Offset
:
{
x
:
0
,
y
:
0
}
m_Floats
:
-
_BumpScale
:
1
-
_Cutoff
:
0.5
-
_DetailNormalMapScale
:
1
-
_DstBlend
:
0
-
_GlossMapScale
:
1
-
_Glossiness
:
0.5
-
_GlossyReflections
:
1
-
_Metallic
:
0
-
_Mode
:
0
-
_OcclusionStrength
:
1
-
_Parallax
:
0.02
-
_SmoothnessTextureChannel
:
0
-
_SpecularHighlights
:
1
-
_SrcBlend
:
1
-
_UVSec
:
0
-
_ZWrite
:
1
m_Colors
:
-
_Color
:
{
r
:
0.6320754
,
g
:
0.39060158
,
b
:
0.15205587
,
a
:
1
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
StockRunning/Assets/My/Materials/PropMat2.mat.meta
0 → 100644
View file @
c9420865
fileFormatVersion: 2
guid: 341db8bac7fccc144ab45c6a36d1da6a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
StockRunning/Assets/My/Scripts/AI/AIMove.cs
View file @
c9420865
...
...
@@ -36,6 +36,13 @@ public class AIMove : MonoBehaviour
private
bool
isGround2
=
true
;
private
bool
isAddSpeed
=
true
;
private
float
timer
=
0.0f
;
//控制移动的中间变量
private
float
SpeedY
=
0
;
//相当于重力
private
float
deltaX
=
0.0f
;
//左右移动的距离。
//眩晕
private
float
timerVertigo
=
0.0f
;
//眩晕时间。
//动画
...
...
@@ -43,7 +50,7 @@ public class AIMove : MonoBehaviour
//状态
public
float
MoveSpeed
=
0.0f
;
private
bool
Grounded
=
false
;
private
GameObject
targetObj
;
// Start is called before the first frame update
...
...
@@ -179,6 +186,18 @@ public class AIMove : MonoBehaviour
isAddSpeed
=
true
;
return
;
}
if
(
targetObj
==
null
)
{
targetObj
=
GetTargetPos
();
print
(
"获取新目标:"
+
targetObj
);
}
else
if
(
targetObj
.
transform
.
position
.
z
<
transform
.
position
.
z
)
{
targetObj
=
GetTargetPos
();
print
(
"获取新目标:"
+
targetObj
);
}
//移动
MoveSpeed
=
VSpeed
+
AddSpeed
*
(
SpeedLevel
-
1
);
//是否在地面
...
...
@@ -187,7 +206,30 @@ public class AIMove : MonoBehaviour
animator
.
SetFloat
(
"MoveSpeed"
,
MoveSpeed
);
animator
.
SetBool
(
"Grounded"
,
Grounded
);
if
(!
Grounded
)
{
SpeedY
+=
-
9.8f
*
5
*
Time
.
deltaTime
;
}
else
{
//在地面上,计算导航去目标位置,每次移动的距离。
if
(
targetObj
!=
null
)
{
if
(
targetObj
.
transform
.
position
.
x
-
transform
.
position
.
x
>
0.3f
)
//误差值0.3
{
deltaX
=
HSpeed
*
Time
.
deltaTime
;
}
else
if
(
targetObj
.
transform
.
position
.
x
-
transform
.
position
.
x
<
-
0.3f
)
{
deltaX
=
-
HSpeed
*
Time
.
deltaTime
;
}
else
{
deltaX
=
0
;
}
}
}
//射线检测。
//Debug.DrawRay(transform.position, Vector3.down * 10f, Color.red);
...
...
@@ -233,7 +275,10 @@ public class AIMove : MonoBehaviour
{
timerVertigo
=
0.0f
;
//AI向前跑。
characterController
.
SimpleMove
(
transform
.
forward
*
MoveSpeed
);
//characterController.SimpleMove(transform.forward * MoveSpeed);
characterController
.
Move
((
transform
.
forward
*
MoveSpeed
+
new
Vector3
(
0
,
SpeedY
,
0
))*
Time
.
deltaTime
+
new
Vector3
(
deltaX
,
0
,
0
));
//UpdateJoystick();
}
else
...
...
@@ -408,6 +453,60 @@ public class AIMove : MonoBehaviour
{
}
//获取目标点
public
GameObject
GetTargetPos
()
{
GameObject
[]
golds
=
GameObject
.
FindGameObjectsWithTag
(
"Gold"
);
//金币
GameObject
[]
props
=
GameObject
.
FindGameObjectsWithTag
(
"Prop"
);
//道具
//排序,z从小到大。
golds
=
DoRanking
.
_instance
.
DoRankingFun2
(
golds
);
props
=
DoRanking
.
_instance
.
DoRankingFun2
(
props
);
GameObject
goldObj
=
null
;
GameObject
propObj
=
null
;
foreach
(
var
prop
in
props
)
{
if
((
prop
.
transform
.
position
.
z
)>
transform
.
position
.
z
+
0.5f
)
{
propObj
=
prop
;
break
;
}
}
foreach
(
var
gold
in
golds
)
{
if
((
gold
.
transform
.
position
.
z
)
>
transform
.
position
.
z
+
0.5f
)
{
goldObj
=
gold
;
break
;
}
}
//print("propObj:" + propObj + "goldObj:" +goldObj);
//返回策略
if
(
propObj
!=
null
&&
goldObj
!=
null
)
{
if
((
propObj
.
transform
.
position
.
z
-
transform
.
position
.
z
)
>
(
goldObj
.
transform
.
position
.
z
-
transform
.
position
.
z
)+
5
)
{
//道具比金币还要远5距离就返回金币,否则返回道具。
return
goldObj
;
}
else
{
return
propObj
;
}
}
else
{
if
(
propObj
==
null
&&
goldObj
==
null
)
{
return
null
;
}
else
{
return
propObj
==
null
?
goldObj
:
propObj
;
}
}
}
public
void
TurnDir
(
float
angle
)
{
...
...
StockRunning/Assets/My/Scripts/DoRanking.cs
View file @
c9420865
...
...
@@ -54,6 +54,28 @@ public class DoRanking : MonoBehaviour
}
return
list
;
}
//冒泡排序z值从小到大。
public
GameObject
[]
DoRankingFun2
(
GameObject
[]
array
)
{
GameObject
temp
=
tempGO
;
for
(
int
i
=
0
;
i
<
array
.
Length
;
i
++)
{
for
(
int
j
=
0
;
j
<
array
.
Length
-
i
-
1
;
j
++)
{
//if (list[j].transform.position.z > list[j + 1].transform.position.z) //保留一位小数
if
(
Math
.
Round
(
array
[
j
].
transform
.
position
.
z
,
1
)
>
Math
.
Round
(
array
[
j
+
1
].
transform
.
position
.
z
,
1
))
//保留一位小数
{
temp
=
array
[
j
];
array
[
j
]
=
array
[
j
+
1
];
array
[
j
+
1
]
=
temp
;
}
}
}
return
array
;
}
public
void
UpdateRanking
()
{
rankingList
=
DoRankingFun
(
rankingList
);
...
...
StockRunning/Assets/My/Scripts/Player/PlayerMove.cs
View file @
c9420865
...
...
@@ -184,8 +184,8 @@ public class PlayerMove : MonoBehaviour
private
void
FixedUpdate
()
{
print
(
"游戏是否开始:"
+
BattleCtrl
.
instance
.
isStartBattle
);
print
(
"游戏是否结束:"
+
BattleCtrl
.
instance
.
isEndBattle
);
//
print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//
print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
//从配置文件ConfigurationFile中获取数据
VSpeed
=
ConfigurationFile
.
instance
.
VSpeed
;
...
...
StockRunning/Assets/My/Scripts/Prop/GiantRock.cs
0 → 100644
View file @
c9420865
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
GiantRock
:
MonoBehaviour
{
public
Transform
ballModel
;
public
float
VertigoTime
=
3
;
private
Vector3
moveDirection
;
private
CharacterController
characterController
;
void
Start
()
{
characterController
=
GetComponent
<
CharacterController
>();
}
// Update is called once per frame
void
Update
()
{
//moveDirection = transform.TransformDirection(-Vector3.forward) * 10f * Time.deltaTime;
moveDirection
.
z
=
-
10
*
Time
.
deltaTime
;
moveDirection
.
y
-=
9.81f
*
Time
.
deltaTime
;
characterController
.
Move
(
moveDirection
);
ballModel
.
Rotate
(-
Vector3
.
right
*
400
*
Time
.
deltaTime
);
}
private
void
OnControllerColliderHit
(
ControllerColliderHit
hit
)
{
if
(
hit
.
collider
.
tag
==
"Competitor"
)
{
hit
.
gameObject
.
GetComponent
<
AIMove
>().
Vertigo
(
VertigoTime
);
//眩晕1秒
Destroy
(
gameObject
);
}
if
(
hit
.
collider
.
tag
==
"Player"
)
{
hit
.
gameObject
.
GetComponent
<
PlayerMove
>().
Vertigo
(
VertigoTime
);
//眩晕1秒
Destroy
(
gameObject
);
}
}
}
StockRunning/Assets/My/Scripts/Prop/GiantRock.cs.meta
0 → 100644
View file @
c9420865
fileFormatVersion: 2
guid: 6c48ba84146fb1949a1d5e0ec5ff70c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
StockRunning/Assets/My/Scripts/Prop/Prop.cs
View file @
c9420865
...
...
@@ -2,21 +2,46 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
enum
PropType
{
Enemy_Vertigo
=
0
,
GiantRock
=
1
}
public
class
Prop
:
MonoBehaviour
{
[
Header
(
"打手"
)]
public
GameObject
enemy3AI
;
public
float
disZ
=
50
;
public
Material
Enemy_VertigoMat
;
[
Header
(
"巨石"
)]
public
GameObject
giantRockObj
;
public
Material
GiantRockMat
;
private
PropType
propType
;
void
Start
()
{
propType
=
(
PropType
)
Random
.
Range
(
0
,
2
);
//switch (Random.Range(0, 2))
//{
// case 0: propType=pro break;
// case 1:break;
// default: print("有问题。"); break;
//}
}
// Update is called once per frame
void
Update
()
{
switch
(
propType
)
{
case
PropType
.
Enemy_Vertigo
:
GetComponent
<
MeshRenderer
>().
material
=
Enemy_VertigoMat
;
break
;
case
PropType
.
GiantRock
:
GetComponent
<
MeshRenderer
>().
material
=
GiantRockMat
;
break
;
}
}
private
void
OnTriggerEnter
(
Collider
other
)
...
...
@@ -24,10 +49,12 @@ public class Prop : MonoBehaviour
disZ
=
ConfigurationFile
.
instance
.
disZ
;
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());
enemy3AI
.
transform
.
position
=
DoRanking
.
_instance
.
rankingList
[
2
].
transform
.
position
+
new
Vector3
(
0
,
0
,
disZ
);
//new Vector3(0,0, 100)
enemy3AI
.
SetActive
(
true
);
Destroy
(
gameObject
);
switch
(
propType
)
{
case
PropType
.
Enemy_Vertigo
:
ShowEnemyAI
();
break
;
case
PropType
.
GiantRock
:
ShowGiantRock
();
break
;
}
}
//else if (other.tag == "Player" && DoRanking._instance.rankingList[2] != other.gameObject)
//{
...
...
@@ -36,4 +63,19 @@ public class Prop : MonoBehaviour
// Destroy(gameObject);
//}
}
public
void
ShowEnemyAI
()
{
//print("出现打手。");
//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
,
disZ
);
//new Vector3(0,0, 100)
enemy3AI
.
SetActive
(
true
);
Destroy
(
gameObject
);
}
public
void
ShowGiantRock
()
{
//print("出现巨石。");
giantRockObj
.
SetActive
(
true
);
Destroy
(
gameObject
);
}
}
StockRunning/Assets/Prefabs/Level2My.prefab
View file @
c9420865
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