2022-11-04 17:31:53 +08:00
|
|
|
|
using SHADE;
|
|
|
|
|
using System;
|
|
|
|
|
public class Item : Script
|
|
|
|
|
{
|
|
|
|
|
public enum ItemCategory
|
|
|
|
|
{
|
|
|
|
|
LIGHT,
|
|
|
|
|
MEDIUM,
|
|
|
|
|
HEAVY
|
|
|
|
|
}
|
2022-11-17 12:54:08 +08:00
|
|
|
|
|
2022-11-17 00:23:38 +08:00
|
|
|
|
public int Score = 10;
|
2022-11-04 17:31:53 +08:00
|
|
|
|
|
|
|
|
|
public ItemCategory currCategory;
|
2023-01-16 21:31:38 +08:00
|
|
|
|
public bool returnBack { get; set; }
|
|
|
|
|
private Transform transform;
|
|
|
|
|
private bool playSound = false;
|
|
|
|
|
private bool caputurePos = false;
|
|
|
|
|
public Vector3 firstPostion;
|
2022-11-04 17:31:53 +08:00
|
|
|
|
|
|
|
|
|
protected override void awake()
|
|
|
|
|
{
|
2023-01-16 21:31:38 +08:00
|
|
|
|
transform = GetComponent<Transform>();
|
|
|
|
|
returnBack = false;
|
2022-11-25 16:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void update()
|
|
|
|
|
{
|
2023-01-16 21:31:38 +08:00
|
|
|
|
if (returnBack)
|
|
|
|
|
{
|
|
|
|
|
transform.LocalPosition = firstPostion;
|
|
|
|
|
returnBack = false;
|
|
|
|
|
}
|
2022-11-04 17:31:53 +08:00
|
|
|
|
}
|
2022-11-17 12:54:08 +08:00
|
|
|
|
|
2022-11-21 21:01:44 +08:00
|
|
|
|
protected override void onCollisionEnter(CollisionInfo info)
|
2022-11-17 12:54:08 +08:00
|
|
|
|
{
|
2023-01-16 21:31:38 +08:00
|
|
|
|
if (!caputurePos)
|
|
|
|
|
{
|
|
|
|
|
firstPostion = transform.LocalPosition;
|
|
|
|
|
caputurePos = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (playSound)
|
2022-11-21 21:01:44 +08:00
|
|
|
|
{
|
|
|
|
|
if(currCategory == ItemCategory.LIGHT)
|
2022-11-23 00:44:27 +08:00
|
|
|
|
Audio.PlaySFXOnce2D("event:/Props/impact_elastic");
|
2022-11-21 21:01:44 +08:00
|
|
|
|
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
|
2022-11-23 00:44:27 +08:00
|
|
|
|
Audio.PlaySFXOnce2D("event:/Props/impact_hard");
|
2023-01-16 21:31:38 +08:00
|
|
|
|
playSound = false;
|
2022-11-21 21:01:44 +08:00
|
|
|
|
}
|
2023-01-25 18:20:26 +08:00
|
|
|
|
|
|
|
|
|
if (info.GameObject.GetScript<Homeowner1>())
|
|
|
|
|
{
|
|
|
|
|
returnBack = true;
|
|
|
|
|
}
|
2022-11-21 21:01:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void onCollisionExit(CollisionInfo info)
|
|
|
|
|
{
|
2023-01-16 21:31:38 +08:00
|
|
|
|
playSound = true;
|
2022-11-17 12:54:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-04 17:31:53 +08:00
|
|
|
|
}
|