Scripting changes for item and added level 1 scene #330
|
@ -12,33 +12,48 @@ public class Item : Script
|
|||
public int Score = 10;
|
||||
|
||||
public ItemCategory currCategory;
|
||||
private RigidBody rb;
|
||||
private bool once = false;
|
||||
public bool returnBack { get; set; }
|
||||
private Transform transform;
|
||||
private bool playSound = false;
|
||||
private bool caputurePos = false;
|
||||
public Vector3 firstPostion;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
rb = GetComponent<RigidBody>();
|
||||
transform = GetComponent<Transform>();
|
||||
returnBack = false;
|
||||
}
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
if (returnBack)
|
||||
{
|
||||
transform.LocalPosition = firstPostion;
|
||||
returnBack = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void onCollisionEnter(CollisionInfo info)
|
||||
{
|
||||
if (once)
|
||||
if (!caputurePos)
|
||||
{
|
||||
firstPostion = transform.LocalPosition;
|
||||
caputurePos = true;
|
||||
}
|
||||
|
||||
if (playSound)
|
||||
{
|
||||
if(currCategory == ItemCategory.LIGHT)
|
||||
Audio.PlaySFXOnce2D("event:/Props/impact_elastic");
|
||||
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
|
||||
Audio.PlaySFXOnce2D("event:/Props/impact_hard");
|
||||
once = false;
|
||||
playSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void onCollisionExit(CollisionInfo info)
|
||||
{
|
||||
once = true;
|
||||
playSound = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -117,6 +117,13 @@ public class PickAndThrow : Script
|
|||
RetrieveItemComponets();
|
||||
}
|
||||
}
|
||||
|
||||
if (pc.currentState == RaccoonStates.CAUGHT && itemScript)
|
||||
{
|
||||
itemScript.returnBack = true;
|
||||
pc.holdItem = true;
|
||||
ResetItemObject();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void fixedUpdate()
|
||||
|
|
Loading…
Reference in New Issue