Esempio n. 1
0
    /// <summary>
    /// Bounce to the system_Ray's Check for canister. The Ship system does not
    /// need direct access to the system_Ray object as it is a child of the canister slot.
    /// </summary>
    /// <returns> The Connected Canister TRUE || FALSE </returns>
    ///

    public bool CheckForCanister()
    {
        if (system_Ray.CheckForCanister())
        {
            //Found a canister
            system_Ray.CurrentCanister = system_Ray.CurrentCanister;
            //system.IsCanisterConnected = true;


            return(true);
        }
        else
        {
            //if (lowChargeWarning != null)
            //{
            //    //Warning Indicator
            //    lowChargeWarning.SetActive(false);
            //}
            //else
            //{
            //    Debug.Log("<color=red>Warning indicator was not found in the canister slot.</color>", this);
            //}

            //system.IsCanisterConnected = false;
            system_Ray.CurrentCanister = null;
            return(false);
        }
    }
    //User Input || !Physics
    private void Update()
    {
        //Have a canister connected
        if (system_Ray.CheckForCanister() /*&& !holdingCanister*/)
        {
            //holdingCanister = true;

            //If the Flux type of the canister is NONE change it
            if (system_Ray.CurrentCanister.Type == FluxType.NONE)
            {
                //Set the currentCanister Type to match the charging type of this charger
                system_Ray.CurrentCanister.Type   = chargingType;
                system_Ray.CurrentCanister.Charge = 1;
            }

            //Safe Gaurd AND validation
            if (system_Ray.CurrentCanister != null && system_Ray.CurrentCanister.Type == chargingType)
            {
                //Only charge the canister when it is a valid canister (not on the list)
                //if (ValidateCanister()/* && holdingCanister*/)
                //{
                ChargeCanister();
                //}
                //else
                //{
                //    Debug.Log("No canister or not a valid canister");
                //}
                chargingParticle.SetActive(true);
            }
        }
        else
        {
            //When a canister leaves or there is none connected to this set it to false
            isValidCanister = false;

            if (system_Ray.CurrentCanister != null)
            {
                Debug.Log("Charge in canister: " + system_Ray.CurrentCanister.Charge);
            }

            system_Ray.CurrentCanister = null;

            chargingParticle.SetActive(false);

            //
            //holdingCanister = false;
        }
    }