Some Power edit

This commit is contained in:
haitem 2021-01-31 06:05:43 +01:00
parent bda2349e16
commit 86db826a77
5 changed files with 61 additions and 43 deletions

View File

@ -30,7 +30,7 @@ Transform:
m_GameObject: {fileID: 7120608647080996497} m_GameObject: {fileID: 7120608647080996497}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.67, y: 0.76, z: 0} m_LocalPosition: {x: 4.67, y: 0.76, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1.2, y: 1.2, z: 1.2}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
@ -104,13 +104,13 @@ Rigidbody:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7120608647080996497} m_GameObject: {fileID: 7120608647080996497}
serializedVersion: 2 serializedVersion: 2
m_Mass: 70 m_Mass: 80
m_Drag: 0 m_Drag: 0
m_AngularDrag: 0.05 m_AngularDrag: 0.05
m_UseGravity: 1 m_UseGravity: 1
m_IsKinematic: 0 m_IsKinematic: 0
m_Interpolate: 0 m_Interpolate: 0
m_Constraints: 120 m_Constraints: 122
m_CollisionDetection: 0 m_CollisionDetection: 0
--- !u!114 &7120608647080996507 --- !u!114 &7120608647080996507
MonoBehaviour: MonoBehaviour:
@ -125,3 +125,5 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 1 objectType: 1
detailSign: {fileID: 0}
MovePoints: []

View File

@ -591,31 +591,11 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: PushPullCube value: PushPullCube
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7120608647080996502, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3}
propertyPath: m_Mass
value: 10000
objectReference: {fileID: 0}
- target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3} type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 6 value: 6
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3}
propertyPath: m_LocalScale.x
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3}
propertyPath: m_LocalScale.y
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3}
propertyPath: m_LocalScale.z
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -1619,7 +1599,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1663971021} m_GameObject: {fileID: 1663971021}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.51, y: 2.2, z: 0} m_LocalPosition: {x: -3.51, y: 2.31, z: 0}
m_LocalScale: {x: 2, y: 1.8, z: 2} m_LocalScale: {x: 2, y: 1.8, z: 2}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

@ -118,6 +118,23 @@ public class ObjectManager : MonoBehaviour
} }
} }
private void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
if (objectType == ObjectType.Ladder)
{
playerManager = other.gameObject.GetComponent<PlayerManager>();
if (playerManager.activeAbility.Count > 0 && playerManager.activeAbility[0] == 4)
{
playerManager.onLadder = true;
playerManager.GetComponent<Rigidbody>().useGravity = false;
interact = true;
}
}
}
}
private void OnTriggerExit(Collider other) private void OnTriggerExit(Collider other)
{ {
if (other.gameObject.tag == "Player") if (other.gameObject.tag == "Player")

View File

@ -27,11 +27,13 @@ public class PlayerManager : MonoBehaviour
public Image powerImage; public Image powerImage;
private bool dubleJump = true; private bool dubleJump = true;
private GameObject pushPullObject; private GameObject pushPullObject;
private float pushPullObjectDistance;
public float dashPower = 40f; public float dashPower = 40f;
public float dashTime = 0.2f; public float dashTime = 0.2f;
private float actualDashTime; private float actualDashTime;
private int dashButton; private int dashButton;
private bool dash = false; private bool dash = false;
private bool cannotMove = false;
private bool startEating = false; private bool startEating = false;
@ -67,6 +69,7 @@ public class PlayerManager : MonoBehaviour
} }
if (actualHealth <= 0 || gameObject.transform.position.y < -400.0f) if (actualHealth <= 0 || gameObject.transform.position.y < -400.0f)
{ {
cannotMove = true;
playerAnimator.Play("Die"); playerAnimator.Play("Die");
} }
if (interact) if (interact)
@ -87,9 +90,11 @@ public class PlayerManager : MonoBehaviour
} }
AbilityAction(); AbilityAction();
DeactivePowerCube(); DeactivePowerCube();
Move(); if (!cannotMove) {
RunSwitch(); Move();
Animation(); RunSwitch();
Animation();
}
if (startEating) if (startEating)
{ {
@ -107,7 +112,10 @@ public class PlayerManager : MonoBehaviour
private void FixedUpdate() private void FixedUpdate()
{ {
Jump(); if (!cannotMove && !onLadder)
{
Jump();
}
} }
private void AbilityAction() private void AbilityAction()
@ -116,10 +124,20 @@ public class PlayerManager : MonoBehaviour
{ {
if (pushPullObject != null) if (pushPullObject != null)
{ {
pushPullObject.GetComponent<Rigidbody>().MovePosition( float distance = Vector3.Distance(pushPullObject.transform.position, gameObject.transform.position);
pushPullObject.transform.position + if (pushPullObjectDistance - 0.1f <= distance && pushPullObjectDistance + 0.1f >= distance)
(pushPullObject.transform.right * (run ? runSpeed : speed) * Input.GetAxis("Horizontal") * Time.deltaTime) {
); Rigidbody pcmRigidB = pushPullObject.GetComponent<Rigidbody>();
pcmRigidB.constraints = RigidbodyConstraints.FreezeRotation;
pushPullObject.GetComponent<Rigidbody>().MovePosition(
pushPullObject.transform.position +
(pushPullObject.transform.right * (run ? runSpeed : speed) * Input.GetAxis("Horizontal") * Time.deltaTime)
);
}
else
{
RemovePushPullObject();
}
} }
powerImage.sprite = powerIcons[1]; powerImage.sprite = powerIcons[1];
} }
@ -185,13 +203,21 @@ public class PlayerManager : MonoBehaviour
public void SetPushPullObject(GameObject objectPP) public void SetPushPullObject(GameObject objectPP)
{ {
if (activeAbility.Count > 0 && activeAbility[0] == 2) { if (activeAbility.Count > 0 && activeAbility[0] == 2) {
if (pushPullObject != null)
{
pushPullObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX;
}
pushPullObject = objectPP; pushPullObject = objectPP;
pushPullObjectDistance = Vector3.Distance(pushPullObject.transform.position, gameObject.transform.position);
} }
} }
public void RemovePushPullObject() public void RemovePushPullObject()
{ {
pushPullObject = null; if (pushPullObject != null) {
pushPullObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX;
pushPullObject = null;
}
} }
void RunSwitch() void RunSwitch()
@ -326,16 +352,6 @@ public class PlayerManager : MonoBehaviour
transform.localScale.y + savePower, transform.localScale.y + savePower,
transform.localScale.z + savePower transform.localScale.z + savePower
); );
/*transform.localScale = new Vector3(
transform.localScale.x + power,
transform.localScale.y + power,
transform.localScale.z + power
);*/
/*transform.localPosition = new Vector3(
transform.localPosition.x,
transform.localPosition.y + power * 2,
transform.localPosition.z
);*/
} }
else if (powerType == PowerCubeManager.PowerType.Faster) else if (powerType == PowerCubeManager.PowerType.Faster)
@ -464,11 +480,13 @@ public class PlayerManager : MonoBehaviour
public void StartEatPowerCube() public void StartEatPowerCube()
{ {
cannotMove = true;
startEating = true; startEating = true;
} }
public void EndEatPowerCube() public void EndEatPowerCube()
{ {
cannotMove = false;
startEating = false; startEating = false;
ActivePowerCube(powerCubeManager.powerUnit, powerCubeManager.powerTime, powerCubeManager.powerType, powerCubeManager.nextSceneName); ActivePowerCube(powerCubeManager.powerUnit, powerCubeManager.powerTime, powerCubeManager.powerType, powerCubeManager.nextSceneName);
Destroy(powerCubeManager.gameObject); Destroy(powerCubeManager.gameObject);

View File

@ -58,6 +58,7 @@ public class PowerCubeManager : MonoBehaviour
} }
} }
} }
private void OnTriggerExit(Collider other) private void OnTriggerExit(Collider other)
{ {
if (other.gameObject.tag == "Player") if (other.gameObject.tag == "Player")