Project
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AppleValue : MonoBehaviour
|
||||
{
|
||||
public int value;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bb1ecbf7a7b8e6439fb4102807b0b17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Item : MonoBehaviour
|
||||
{
|
||||
private Animator animator;
|
||||
private float timeCollected = 0f;
|
||||
private const float delayDestroy = 0.5f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (timeCollected > 0)
|
||||
{
|
||||
if (Time.time - timeCollected > delayDestroy)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Collect()
|
||||
{
|
||||
Destroy(GetComponent<CircleCollider2D>());
|
||||
animator.SetInteger("value", 1);
|
||||
timeCollected = Time.time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acec425baaf8b534aba25766ae6b3096
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemBox : MonoBehaviour
|
||||
{
|
||||
private Animator animator;
|
||||
private float timeHit = 0;
|
||||
private float destroyDelay = 0.4f;
|
||||
[SerializeField] private GameObject itemPrefab;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (timeHit != 0)
|
||||
{
|
||||
if (Time.time - timeHit > destroyDelay)
|
||||
{
|
||||
if(itemPrefab != null)
|
||||
{
|
||||
GameObject instance = Instantiate(itemPrefab);
|
||||
instance.transform.position = transform.position;
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit()
|
||||
{
|
||||
animator.SetInteger("value", 1);
|
||||
timeHit = Time.time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97fb1c1d099696d47aea104eb76de82d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user