33 lines
		
	
	
	
		
			735 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			735 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Collections;
 | 
						|
using System.Collections.Generic;
 | 
						|
using UnityEngine;
 | 
						|
 | 
						|
public class ChargePoint : MonoBehaviour
 | 
						|
{
 | 
						|
    public int chargesRequired = 1;
 | 
						|
 | 
						|
    int charges = 0;
 | 
						|
    bool charged = false;
 | 
						|
    ChargeCounter chargeCounter;
 | 
						|
 | 
						|
    void Start()
 | 
						|
    {
 | 
						|
        chargeCounter = GameObject.FindWithTag("Charge Counter").GetComponent<ChargeCounter>();
 | 
						|
    }
 | 
						|
 | 
						|
    public void adjustCharges(int amount = 1)
 | 
						|
    {
 | 
						|
        charges += amount;
 | 
						|
 | 
						|
        if (charges >= chargesRequired)
 | 
						|
        {
 | 
						|
            if (!charged) chargeCounter.AddChargedPoint(gameObject);
 | 
						|
            charged = true;
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
            chargeCounter.RemoveChargedPoint(gameObject);
 | 
						|
            charged = false;
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |