44 lines
1.2 KiB
C#
Executable File
44 lines
1.2 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PickupItemSolo : MonoBehaviour
|
|
{
|
|
[field:SerializeField] public PickupType type{get; private set;}
|
|
[SerializeField]private float radius;
|
|
public bool isActive{get; private set;}
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Collider2D hit = Physics2D.OverlapCircle(transform.position, radius);
|
|
if(hit!=null && hit.GetComponent<SpaceshipControllerSolo>()!=null){
|
|
// Debug.Log(hit.GetComponent<SpaceshipController>().pname +$" collected me at {transform.position}");
|
|
hit.GetComponent<SpaceshipControllerSolo>().CollectPickup(type);
|
|
isActive=false;
|
|
Deactivate();
|
|
}
|
|
}
|
|
|
|
public PickupItemSolo Reposition(Vector3 newPosition){
|
|
isActive=true;
|
|
transform.position = newPosition;
|
|
gameObject.SetActive(true);
|
|
return this;
|
|
}
|
|
public void Deactivate(){
|
|
isActive=false;
|
|
gameObject.SetActive(false);
|
|
MinigameManagerSolo.DeactivatePickup(this);
|
|
}
|
|
public enum PickupType{
|
|
Star,
|
|
Moon,
|
|
Twep
|
|
}
|
|
}
|