52 lines
1.0 KiB
C#
52 lines
1.0 KiB
C#
using SHADE;
|
|
using System;
|
|
public class Item : Script
|
|
{
|
|
public enum ItemCategory
|
|
{
|
|
LIGHT,
|
|
MEDIUM,
|
|
HEAVY
|
|
}
|
|
|
|
public int Score = 10;
|
|
|
|
public ItemCategory currCategory;
|
|
private RigidBody rb;
|
|
private Collider collider;
|
|
private bool once = false;
|
|
|
|
protected override void awake()
|
|
{
|
|
collider = GetComponent<Collider>();
|
|
if (collider)
|
|
{
|
|
collider.GetCollisionShape(0).Density = 1;
|
|
}
|
|
rb = GetComponent<RigidBody>();
|
|
if (rb)
|
|
{
|
|
rb.FreezeRotationX = false;
|
|
rb.FreezeRotationY = false;
|
|
rb.FreezeRotationZ = false;
|
|
}
|
|
}
|
|
|
|
protected override void onCollisionEnter(CollisionInfo info)
|
|
{
|
|
if (once)
|
|
{
|
|
if(currCategory == ItemCategory.LIGHT)
|
|
Audio.PlayBGMOnce2D("event:/Props/impact_elastic");
|
|
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
|
|
Audio.PlayBGMOnce2D("event:/Props/impact_hard");
|
|
once = false;
|
|
}
|
|
}
|
|
|
|
protected override void onCollisionExit(CollisionInfo info)
|
|
{
|
|
once = true;
|
|
}
|
|
|
|
} |