Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BoomMaster
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
BoomMaster
Commits
65dcd7af
Commit
65dcd7af
authored
Mar 09, 2021
by
wanqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
2e5a196a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
37 deletions
+91
-37
BombView.cs
BoomMaster/Assets/#A2_Scripts/Battle/View/BombView.cs
+91
-37
No files found.
BoomMaster/Assets/#A2_Scripts/Battle/View/BombView.cs
View file @
65dcd7af
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
using
RayFire
;
using
EzySlice
;
public
class
BombView
:
MonoBehaviour
{
...
...
@@ -11,6 +12,8 @@ public class BombView : MonoBehaviour
public
LineRenderer
lineRenderer
;
//线段渲染器
public
GameObject
m_normalObj
;
//普通对象
public
GameObject
m_cutOffObj
;
//切割对象
public
Material
crossMaterial
;
public
LayerMask
layerMask
;
//public GameObject m_bombParticleObj;//炸弹粒子
private
RayfireBomb
m_curBomb
;
//当前的炸弹
...
...
@@ -156,7 +159,7 @@ public class BombView : MonoBehaviour
m_curPropModelObj
.
transform
.
position
=
m_propStartPos
[
4
].
position
;
m_curPropModelObj
.
transform
.
rotation
=
Quaternion
.
identity
;
SetNormalState
(
false
);
//
m_rayFireBlade = m_curPropModelObj.transform.Find("Props4/Props4/Blade_Target").GetComponent<RayfireBlade>();
m_rayFireBlade
=
m_curPropModelObj
.
transform
.
Find
(
"Props4/Props4/Blade_Target"
).
GetComponent
<
RayfireBlade
>();
//m_rayFireBlade.SetTarget(m_childCutTrans.gameObject);
Invoke
(
"InvokeCreateProp"
,
0.1f
);
}
...
...
@@ -190,7 +193,7 @@ public class BombView : MonoBehaviour
{
if
(
m_curModelIndex
==
3
)
{
m_lerpPos
.
x
=
varPos
.
x
-
2
.5f
;
m_lerpPos
.
x
=
varPos
.
x
-
1
.5f
;
}
else
{
...
...
@@ -201,7 +204,7 @@ public class BombView : MonoBehaviour
{
if
(
m_curModelIndex
==
3
)
{
m_lerpPos
.
x
=
varPos
.
x
-
2
.5f
;
m_lerpPos
.
x
=
varPos
.
x
-
1
.5f
;
}
else
{
...
...
@@ -243,6 +246,10 @@ public class BombView : MonoBehaviour
{
m_bLerp
=
true
;
m_bIsFinishAni
=
true
;
if
(
m_curModelIndex
==
1
||
m_curModelIndex
==
3
)
{
m_curPropModelObj
.
transform
.
localScale
=
Vector3
.
one
*
0.7f
;
}
m_lerpPos
=
m_propStartPos
[
m_curModelIndex
].
position
;
}
});
...
...
@@ -350,7 +357,11 @@ public class BombView : MonoBehaviour
// m_curBombEffect = null;
// }
//});
if
(
m_curModelIndex
==
4
)
if
(
m_curPropModelObj
)
{
m_curPropModelObj
.
transform
.
localScale
=
Vector3
.
one
;
}
if
(
m_curModelIndex
==
4
)
{
InvokeRepeating
(
"CalculateCutOffNum"
,
0.3f
,
0.1f
);
}
...
...
@@ -436,6 +447,47 @@ public class BombView : MonoBehaviour
m_lstDamage
.
Clear
();
m_lstDamage
=
null
;
}
void
Slice
()
{
Collider
[]
hits
=
Physics
.
OverlapBox
(
m_rayFireBlade
.
transform
.
position
,
new
Vector3
(
5
,
0.1f
,
5
),
m_rayFireBlade
.
transform
.
rotation
,
layerMask
);
Debug
.
LogError
(
hits
.
Length
);
if
(
hits
.
Length
<=
0
)
return
;
for
(
int
i
=
0
;
i
<
hits
.
Length
;
i
++)
{
//SlicedHull hull = SliceObject(hits[i].gameObject, crossMaterial);
SlicedHull
hull
=
SliceObject
(
hits
[
i
].
gameObject
);
if
(
hull
!=
null
)
{
GameObject
bottom
=
hull
.
CreateLowerHull
(
hits
[
i
].
gameObject
,
crossMaterial
);
GameObject
top
=
hull
.
CreateUpperHull
(
hits
[
i
].
gameObject
,
crossMaterial
);
AddHullComponents
(
bottom
);
AddHullComponents
(
top
);
Destroy
(
hits
[
i
].
gameObject
);
}
}
}
void
AddHullComponents
(
GameObject
go
)
{
go
.
layer
=
9
;
Rigidbody
rb
=
go
.
AddComponent
<
Rigidbody
>();
rb
.
interpolation
=
RigidbodyInterpolation
.
Interpolate
;
MeshCollider
collider
=
go
.
AddComponent
<
MeshCollider
>();
collider
.
convex
=
true
;
rb
.
AddExplosionForce
(
100
,
go
.
transform
.
position
,
20
);
}
SlicedHull
SliceObject
(
GameObject
obj
,
Material
crossSectionMaterial
=
null
)
{
// slice the provided object using the transforms of this object
if
(
obj
.
GetComponent
<
MeshFilter
>()
==
null
)
return
null
;
return
obj
.
Slice
(
m_rayFireBlade
.
transform
.
position
,
m_rayFireBlade
.
transform
.
up
,
crossSectionMaterial
);
}
//刀处理
void
UpdateKniftHandle
()
{
...
...
@@ -443,7 +495,8 @@ public class BombView : MonoBehaviour
{
return
;
}
if
(
m_bFinishCut
/* && m_bDelayFinishCut*/
)
//Slice();
if
(
m_bFinishCut
/* && m_bDelayFinishCut*/
)
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
...
...
@@ -492,41 +545,42 @@ public class BombView : MonoBehaviour
if
(
m_lineIndex
==
0
&&
m_mouseUpIndex
>
0
&&
m_curPropModelObj
&&
!
m_bFinishCut
/* && !m_bDelayFinishCut*/
)
{
m_curPropModelObj
.
transform
.
position
=
Vector3
.
Lerp
(
m_curPropModelObj
.
transform
.
position
,
m_secondBombPos
,
0.2f
);
if
(
Vector3
.
SqrMagnitude
(
m_curPropModelObj
.
transform
.
position
-
m_secondBombPos
)
<=
0.5f
)
if
(
Vector3
.
SqrMagnitude
(
m_curPropModelObj
.
transform
.
position
-
m_secondBombPos
)
<=
0.5f
)
{
lineRenderer
.
positionCount
=
0
;
m_bFinishCut
=
true
;
//
m_rayFireBlade.SliceTarget();
//
GameServices.timerServices.Push(this, 2.0f, delegate
//
{
// if
(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex)
//
{
//
if (m_mouseUpIndex == 1)
//
{
//
m_childCutTrans = m_cutOffObj.transform.Find("column_root/column_fr_0");
//
}
//
else if (m_mouseUpIndex == 2)
//
{
//
m_childCutTrans = m_cutOffObj.transform.Find("column_root/column_fr_0_root/column_fr_0_fr_0");
//
}
//
}
// else if
(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
//
{
//
if (m_mouseUpIndex == 1)
//
{
//
m_childCutTrans = m_cutOffObj.transform.Find("people_root/people_fr_0");
//
}
//
else if (m_mouseUpIndex == 2)
//
{
//
m_childCutTrans = m_cutOffObj.transform.Find("people_root/people_fr_0_root/people_fr_0_fr_0");
//
}
//
}
// if
(m_childCutTrans)
//
{
//
m_bDelayFinishCut = true;
//
m_rayFireBlade.SetTarget(m_childCutTrans.gameObject);
//
}
//
});
m_rayFireBlade
.
SliceTarget
();
GameServices
.
timerServices
.
Push
(
this
,
2.0f
,
delegate
{
if
(
BattleCtrl
.
instance
.
levelManager
.
CurLevelIndex
==
LevelEnum
.
levelOneIndex
)
{
if
(
m_mouseUpIndex
==
1
)
{
m_childCutTrans
=
m_cutOffObj
.
transform
.
Find
(
"column_root/column_fr_0"
);
}
else
if
(
m_mouseUpIndex
==
2
)
{
m_childCutTrans
=
m_cutOffObj
.
transform
.
Find
(
"column_root/column_fr_0_root/column_fr_0_fr_0"
);
}
}
else
if
(
BattleCtrl
.
instance
.
levelManager
.
CurLevelIndex
==
LevelEnum
.
levelTwoIndex
)
{
if
(
m_mouseUpIndex
==
1
)
{
m_childCutTrans
=
m_cutOffObj
.
transform
.
Find
(
"people_root/people_fr_0"
);
}
else
if
(
m_mouseUpIndex
==
2
)
{
m_childCutTrans
=
m_cutOffObj
.
transform
.
Find
(
"people_root/people_fr_0_root/people_fr_0_fr_0"
);
}
}
if
(
m_childCutTrans
)
{
m_bDelayFinishCut
=
true
;
m_rayFireBlade
.
SetTarget
(
m_childCutTrans
.
gameObject
);
}
});
}
}
//if (Input.GetMouseButtonDown(0))
...
...
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