Fix swim confict cause by intelligent route
This commit is contained in:
@@ -1152,6 +1152,11 @@ namespace BrewMonster.Scripts
|
||||
// vUp = a3d_RotatePosAroundAxis(vUp, vPushDir, m_fPushPitch);
|
||||
|
||||
//m_pHost.StartModelMove(vPushDir, vUp, 0);
|
||||
|
||||
if (vPushDir != Vector3.zero)
|
||||
{
|
||||
m_pHost.SetRotationHPWithTime(vPushDir, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
// if (bPush)
|
||||
|
||||
@@ -16,6 +16,7 @@ using ModelRenderer.Scripts.GameData;
|
||||
using PerfectWorld.Scripts;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -4524,6 +4525,14 @@ namespace BrewMonster
|
||||
vPushDir = Vector3.zero;
|
||||
if (joystick.Horizontal == 0 && joystick.Vertical == 0)
|
||||
{
|
||||
if (isPressMoveUp)
|
||||
{
|
||||
vPushDir = Vector3.up;
|
||||
}
|
||||
else if (isPressMoveDown)
|
||||
{
|
||||
vPushDir = Vector3.down;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4532,10 +4541,22 @@ namespace BrewMonster
|
||||
}
|
||||
else if (m_iMoveEnv == Move_environment.MOVEENV_WATER)
|
||||
{
|
||||
vPushDir.x = joystick.Horizontal;
|
||||
vPushDir.y = (transform.position - mainCam.transform.position).normalized.y;
|
||||
vPushDir.z = joystick.Vertical;
|
||||
vPushDir.Normalize();
|
||||
float angle = Vector2.Angle(new Vector2(joystick.Horizontal, joystick.Vertical), Vector2.up);
|
||||
angle *= joystick.Horizontal < 0 ? 1 : -1;
|
||||
Vector2 v2Cam = new Vector2(mainCam.transform.forward.x, mainCam.transform.forward.z);
|
||||
v2Cam = Quaternion.Euler(0, 0, angle) * v2Cam;
|
||||
v2Cam.Normalize();
|
||||
vPushDir.x = v2Cam.x;
|
||||
vPushDir.y = ((transform.position + Vector3.up * m_CDRInfo.vExtent.y) - mainCam.transform.position).normalized.y;
|
||||
if (isPressMoveUp)
|
||||
{
|
||||
vPushDir.y = Math.Abs(vPushDir.y) * Time.deltaTime;
|
||||
}
|
||||
else if (isPressMoveDown)
|
||||
{
|
||||
vPushDir.y = -Math.Abs(vPushDir.y) * Time.deltaTime;
|
||||
}
|
||||
vPushDir.z = v2Cam.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4555,12 +4576,28 @@ namespace BrewMonster
|
||||
// Is under water
|
||||
bool CanTakeOffWater()
|
||||
{
|
||||
return true;
|
||||
// TO DO: fix later
|
||||
//A3DVECTOR3 vPos = GetPos();
|
||||
//if (vPos.y < EC_Game.GetGameRun().GetWorld().GetWaterHeight(vPos) - m_MoveConst.fShoreDepth)
|
||||
// return false;
|
||||
//else
|
||||
// return true;
|
||||
|
||||
A3DVECTOR3 vPos = GetPos();
|
||||
float h0 = 0f;
|
||||
int countHits0 = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPos) + Vector3.up * 500f, Vector3.down, hits, 1000f, 1 << 8);
|
||||
if (countHits0 > 0)
|
||||
{
|
||||
h0 = hits[0].point.y;
|
||||
}
|
||||
if(vPos.y < h0 - m_MoveConst.fShoreDepth)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsUsingItem()
|
||||
@@ -4584,6 +4621,27 @@ namespace BrewMonster
|
||||
transform.rotation = Quaternion.LookRotation(dir);
|
||||
}
|
||||
|
||||
public void SetRotationHPWithTime(Vector3 dir, float time)
|
||||
{
|
||||
StartCoroutine(RotateToDir(transform, dir, time));
|
||||
}
|
||||
|
||||
IEnumerator RotateToDir(Transform target, Vector3 dir, float duration)
|
||||
{
|
||||
Quaternion startRot = target.rotation;
|
||||
Quaternion endRot = Quaternion.LookRotation(dir);
|
||||
float t = 0f;
|
||||
|
||||
while (t < duration)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
target.rotation = Quaternion.Slerp(startRot, endRot, t / duration);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
target.rotation = endRot;
|
||||
}
|
||||
|
||||
void SetJumpInWater(bool b)
|
||||
{
|
||||
m_bJumpInWater = b;
|
||||
@@ -5419,7 +5477,7 @@ namespace BrewMonster
|
||||
VertRayTrace(EC_Utility.ToVector3(vTestPos), ref vGndPos, ref m_GndInfo.vGndNormal, 1000f);
|
||||
m_GndInfo.fGndHei = vGndPos.y;
|
||||
|
||||
if(Physics.RaycastNonAlloc(EC_Utility.ToVector3(vTestPos), Vector3.down, hits, 1000f, 1<<8) > 0)
|
||||
if (Physics.RaycastNonAlloc(EC_Utility.ToVector3(vTestPos) + Vector3.up * 500f, Vector3.down, hits, 1000f, 1 << 8) > 0)
|
||||
{
|
||||
m_GndInfo.fWaterHei = hits[0].point.y;
|
||||
}
|
||||
@@ -5521,13 +5579,13 @@ namespace BrewMonster
|
||||
|
||||
LayerMask layerMaskTerrain = 1 << 6;
|
||||
LayerMask layerMaskBush = 1 << 7;
|
||||
if (Physics.RaycastNonAlloc(vPos, (vPos + Vector3.down), hits, layerMaskTerrain) > 0)
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, 1000f, layerMaskTerrain) > 0)
|
||||
{
|
||||
vTerrainPos = hits[0].point;
|
||||
vTerrainNormal = hits[0].normal;
|
||||
}
|
||||
|
||||
if (Physics.RaycastNonAlloc(vPos, (vPos + Vector3.down), hits, DeltaY, layerMaskTerrain) > 0)
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, DeltaY, layerMaskBush) > 0)
|
||||
{
|
||||
if (vBuildingPos.y > vTerrainPos.y)
|
||||
{
|
||||
@@ -5555,16 +5613,38 @@ namespace BrewMonster
|
||||
vHitPos.y -= DeltaY;
|
||||
|
||||
LayerMask layerMask = 1 << 6 | 1 << 7;
|
||||
if (Physics.BoxCastNonAlloc(vCenter, vExt, (vCenter + Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask) == 0)
|
||||
hits = new RaycastHit[5];
|
||||
int count = Physics.BoxCastNonAlloc(vCenter, vExt, (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if (count == 0)
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
}
|
||||
else
|
||||
{
|
||||
vHitPos = hits[0].point;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
{
|
||||
if (Math.Abs(hits[0].distance - 0f) <= float.Epsilon)
|
||||
{
|
||||
count = Physics.BoxCastNonAlloc(vCenter, new Vector3(vExt.x, 0.05f, vExt.z), (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if(count == 0)
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
}
|
||||
else
|
||||
{
|
||||
vHitPos = hits[0].point;
|
||||
vHitPos.y += vExt.y;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vHitPos = hits[0].point;
|
||||
vHitPos.y += vExt.y;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user