Basic functionality
This commit is contained in:
47
Assets/Scripts/Collectible.cs
Normal file
47
Assets/Scripts/Collectible.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Collectible : MonoBehaviour
|
||||
{
|
||||
public int score = 1;
|
||||
|
||||
public bool collected = false;
|
||||
|
||||
public bool isEnabled = true;
|
||||
|
||||
Renderer r;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
r = GetComponent<Renderer>();
|
||||
|
||||
if (collected || !isEnabled)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Collect()
|
||||
{
|
||||
collected = true;
|
||||
Hide();
|
||||
}
|
||||
|
||||
void Hide()
|
||||
{
|
||||
r.enabled = false;
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
r.enabled = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user