Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Storage
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
wanqing
Storage
Commits
201890dc
Commit
201890dc
authored
Mar 15, 2021
by
wanqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
85f2bdd5
Pipeline
#136
canceled with stages
Changes
7
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
288 additions
and
1344 deletions
+288
-1344
.suo
Storage/.vs/Storage/v16/.suo
+0
-0
Assembly-CSharp.csproj
Storage/Assembly-CSharp.csproj
+1
-0
TargetCollision.cs
...ge/Assets/#A2_Scripts/Battle/Collision/TargetCollision.cs
+2
-2
StorageView.cs
Storage/Assets/#A2_Scripts/Battle/View/StorageView.cs
+163
-0
StorageView.cs.meta
Storage/Assets/#A2_Scripts/Battle/View/StorageView.cs.meta
+11
-0
LevelCtrl.cs
Storage/Assets/#A2_Scripts/Level/LevelCtrl.cs
+2
-0
Level1.prefab
Storage/Assets/Res/Levels/Level1.prefab
+109
-1342
No files found.
Storage/.vs/Storage/v16/.suo
View file @
201890dc
No preview for this file type
Storage/Assembly-CSharp.csproj
View file @
201890dc
...
@@ -93,6 +93,7 @@
...
@@ -93,6 +93,7 @@
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainDragView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainDragView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainRopeView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainRopeView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\ChainView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\StorageView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\TargetView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Battle\View\TargetView.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Camera\CameraMove.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Camera\CameraMove.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Camera\FollowTarget.cs"
/>
<Compile
Include=
"Assets\#A2_Scripts\Camera\FollowTarget.cs"
/>
...
...
Storage/Assets/#A2_Scripts/Battle/Collision/TargetCollision.cs
View file @
201890dc
...
@@ -10,7 +10,7 @@ public class TargetCollision : MonoBehaviour
...
@@ -10,7 +10,7 @@ public class TargetCollision : MonoBehaviour
if
(
other
.
collider
.
gameObject
.
CompareTag
(
"Target"
)
&&
m_bControl
)
if
(
other
.
collider
.
gameObject
.
CompareTag
(
"Target"
)
&&
m_bControl
)
{
{
m_bControl
=
false
;
m_bControl
=
false
;
BattleCtrl
.
instance
.
levelManager
.
curLevel
.
car
View
.
SetTargetCollison
(
transform
,
true
);
BattleCtrl
.
instance
.
levelManager
.
curLevel
.
storage
View
.
SetTargetCollison
(
transform
,
true
);
}
}
}
}
private
void
OnCollisionExit
(
Collision
other
)
private
void
OnCollisionExit
(
Collision
other
)
...
@@ -19,7 +19,7 @@ public class TargetCollision : MonoBehaviour
...
@@ -19,7 +19,7 @@ public class TargetCollision : MonoBehaviour
{
{
m_bControl
=
true
;
m_bControl
=
true
;
MeshCollider
varBox
=
other
.
collider
.
gameObject
.
GetComponent
<
MeshCollider
>();
MeshCollider
varBox
=
other
.
collider
.
gameObject
.
GetComponent
<
MeshCollider
>();
BattleCtrl
.
instance
.
levelManager
.
curLevel
.
car
View
.
SetTargetCollison
(
transform
,
false
);
BattleCtrl
.
instance
.
levelManager
.
curLevel
.
storage
View
.
SetTargetCollison
(
transform
,
false
);
}
}
}
}
}
}
Storage/Assets/#A2_Scripts/Battle/View/StorageView.cs
0 → 100644
View file @
201890dc
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
StorageView
:
MonoBehaviour
{
public
Transform
m_targetParentTrans
;
//障碍物父节点
private
MeshCollider
[]
m_targetTrans
;
//所有目标
private
MeshCollider
m_curTargetTrans
;
//当前抓的目标
private
Vector3
m_offset
;
//偏移值
private
Vector3
m_targetScreenVec
;
//当前物体对应的屏幕坐标
private
Transform
m_collisonTargetTrans
;
//碰到的其他目标
private
bool
m_bIsCollisonTarget
=
false
;
//是否碰到了其他目标
private
Dictionary
<
MeshCollider
,
bool
>
m_dicBox
=
new
Dictionary
<
MeshCollider
,
bool
>();
private
Vector3
m_cameraTargetPos
=
new
Vector3
(
1
,
5.6f
,
-
4.5f
);
//镜头目标位置
private
Quaternion
m_cameraTargetRotate
=
Quaternion
.
Euler
(
60
,
0
,
0
);
//镜头目标旋转
private
float
m_topHeight
=
1.25f
;
//顶部高度
private
float
m_bottomHeight
=
0.25f
;
//底部高度
private
Camera
m_camera
;
private
bool
m_bIsHitTarget
=
false
;
// Start is called before the first frame update
void
Start
()
{
m_targetTrans
=
m_targetParentTrans
.
GetComponentsInChildren
<
MeshCollider
>();
for
(
int
i
=
0
;
i
<
m_targetTrans
.
Length
;
i
++)
{
m_dicBox
.
Add
(
m_targetTrans
[
i
],
false
);
}
m_camera
=
Camera
.
main
;
GameServices
.
inputService
.
pad
.
onTouchUp
+=
OnTouchUp
;
}
private
void
OnCollisionEnter
(
Collision
other
)
{
if
(
other
.
collider
.
gameObject
.
CompareTag
(
"Target"
))
{
MeshCollider
varBox
=
other
.
collider
.
gameObject
.
GetComponent
<
MeshCollider
>();
if
(
m_dicBox
.
ContainsKey
(
varBox
))
{
m_dicBox
[
varBox
]
=
true
;
}
}
}
private
void
OnCollisionExit
(
Collision
other
)
{
if
(
other
.
collider
.
gameObject
.
CompareTag
(
"Target"
))
{
MeshCollider
varBox
=
other
.
collider
.
gameObject
.
GetComponent
<
MeshCollider
>();
if
(
m_dicBox
.
ContainsKey
(
varBox
))
{
m_dicBox
[
varBox
]
=
false
;
}
}
}
// Update is called once per frame
void
Update
()
{
if
(!
BattleCtrl
.
instance
.
isStartBattle
)
{
return
;
}
if
(
Input
.
GetMouseButtonDown
(
0
))
{
Clicked
();
}
if
(
Input
.
GetMouseButton
(
0
))
{
if
(
m_curTargetTrans
)
{
m_targetScreenVec
=
Camera
.
main
.
WorldToScreenPoint
(
m_curTargetTrans
.
transform
.
position
);
m_curTargetTrans
.
transform
.
position
=
Camera
.
main
.
ScreenToWorldPoint
(
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
m_targetScreenVec
.
z
))
+
m_offset
;
//十字架位置
float
varX
=
(
Input
.
mousePosition
.
x
-
Screen
.
width
/
2f
)
/
(
Screen
.
width
/
GlobalConfig
.
NormalWidth
);
float
varY
=
(
Input
.
mousePosition
.
y
-
Screen
.
height
/
2f
)
/
(
Screen
.
width
/
GlobalConfig
.
NormalWidth
);
BattleCtrl
.
instance
.
battleUI
.
SetSymbolPos
(
varX
,
varY
);
}
}
//确保最低位置
if
(
m_curTargetTrans
)
{
Vector3
varPos
=
m_curTargetTrans
.
transform
.
position
;
if
(
varPos
.
y
<
m_bottomHeight
)
{
varPos
.
y
=
m_bottomHeight
;
}
if
(
m_dicBox
.
ContainsKey
(
m_curTargetTrans
)
&&
m_dicBox
[
m_curTargetTrans
])
{
varPos
.
y
=
m_topHeight
;
}
else
{
//varPos.y = m_bottomHeight;
}
if
(
m_collisonTargetTrans
&&
m_bIsCollisonTarget
)
{
varPos
.
y
=
m_collisonTargetTrans
.
localPosition
.
y
+
m_collisonTargetTrans
.
localScale
.
y
;
}
m_curTargetTrans
.
transform
.
position
=
varPos
;
}
if
(
m_bIsHitTarget
)
{
m_camera
.
transform
.
position
=
Vector3
.
Lerp
(
m_camera
.
transform
.
position
,
m_cameraTargetPos
,
0.2f
);
m_camera
.
transform
.
rotation
=
Quaternion
.
Lerp
(
m_camera
.
transform
.
rotation
,
m_cameraTargetRotate
,
0.2f
);
}
}
// 抬起回调
void
OnTouchUp
()
{
if
(
m_curTargetTrans
)
{
MeshCollider
varBox
=
m_curTargetTrans
.
GetComponent
<
MeshCollider
>();
if
(
m_dicBox
.
ContainsKey
(
varBox
))
{
m_dicBox
[
varBox
]
=
false
;
}
m_curTargetTrans
=
null
;
}
m_collisonTargetTrans
=
null
;
m_bIsCollisonTarget
=
false
;
BattleCtrl
.
instance
.
battleUI
.
SetSymbolPos
(
0
,
0
);
}
//碰到其他目标
public
void
SetTargetCollison
(
Transform
trans
,
bool
bool_
)
{
m_collisonTargetTrans
=
trans
;
m_bIsCollisonTarget
=
bool_
;
}
void
Clicked
()
{
Ray
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
RaycastHit
hit
=
new
RaycastHit
();
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
if
(
hit
.
collider
&&
hit
.
collider
.
gameObject
.
CompareTag
(
"Target"
))
{
m_bIsHitTarget
=
true
;
for
(
int
i
=
0
;
i
<
m_targetTrans
.
Length
;
i
++)
{
if
(
string
.
Equals
(
hit
.
collider
.
name
,
m_targetTrans
[
i
].
name
))
{
m_curTargetTrans
=
m_targetTrans
[
i
];
break
;
}
}
m_targetScreenVec
=
Camera
.
main
.
WorldToScreenPoint
(
m_curTargetTrans
.
transform
.
position
);
//偏移值=物体的世界坐标,减去转化之后的鼠标世界坐标(z轴的值为物体屏幕坐标的z值)
m_offset
=
m_curTargetTrans
.
transform
.
position
-
Camera
.
main
.
ScreenToWorldPoint
(
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
m_targetScreenVec
.
z
));
}
}
}
private
void
OnDestroy
()
{
m_targetTrans
=
null
;
m_curTargetTrans
=
null
;
if
(
GameServices
.
inputService
!=
null
)
{
GameServices
.
inputService
.
pad
.
onTouchUp
-=
OnTouchUp
;
}
}
}
Storage/Assets/#A2_Scripts/Battle/View/StorageView.cs.meta
0 → 100644
View file @
201890dc
fileFormatVersion: 2
guid: 4de63a6add2120742b127d4aad5f7f85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Storage/Assets/#A2_Scripts/Level/LevelCtrl.cs
View file @
201890dc
...
@@ -14,11 +14,13 @@ public class LevelCtrl : MonoBehaviour
...
@@ -14,11 +14,13 @@ public class LevelCtrl : MonoBehaviour
public
ChainRopeView
m_chainRopeView
;
//娃娃机爪钩
public
ChainRopeView
m_chainRopeView
;
//娃娃机爪钩
public
Camera
m_camera
;
public
Camera
m_camera
;
public
CarView
m_carView
;
//车
public
CarView
m_carView
;
//车
public
StorageView
m_storageView
;
//public TargetView m_targetView;//触发器
//public TargetView m_targetView;//触发器
public
ChainView
chainView
=>
m_chainView
;
public
ChainView
chainView
=>
m_chainView
;
public
ChainRopeView
chainRopeView
=>
m_chainRopeView
;
public
ChainRopeView
chainRopeView
=>
m_chainRopeView
;
public
Camera
cam
=>
m_camera
;
public
Camera
cam
=>
m_camera
;
public
CarView
carView
=>
m_carView
;
public
CarView
carView
=>
m_carView
;
public
StorageView
storageView
=>
m_storageView
;
//public TargetView targetView => m_targetView;
//public TargetView targetView => m_targetView;
BattleCtrl
_BattleCtrl
;
BattleCtrl
_BattleCtrl
;
...
...
Storage/Assets/Res/Levels/Level1.prefab
View file @
201890dc
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