Esempio n. 1
0
    /*
     * public void TryPowerUp () {
     *      if (PowerManager.Instance.HasCapacity (systemType, powerReq)) {
     *              if (ReactorScript.DirectPower (powerReq)) {
     *                      //sync powerstate here
     *                      if (NetManager.Instance != null) {
     *                              NetManager.Instance.SyncPowerState (gridPos, systemType, true);
     *                      } else {
     *                              ship.IncreaseEvasionChance (componentCapacity);
     *                      }
     *
     *                      PowerManager.Instance.RoutePower (systemType, powerReq);
     *
     *                      isPowered = true;
     *
     *                      //ship.IncreaseEvasionChance (componentCapacity);
     *              } else {
     *                      Debug.Log ("not enough power");
     *              }
     *      }
     * }
     *
     * public void TryPowerDown () {
     *      if (isPowered) {
     *              //frees the power
     *
     *              //sync powerstate here
     *              if (NetManager.Instance != null) {
     *                      NetManager.Instance.SyncPowerState (gridPos, systemType, false);
     *              } else {
     *                      ship.IncreaseEvasionChance (-componentCapacity);
     *              }
     *
     *              ReactorScript.RedirectPower (powerReq);
     *
     *              isPowered = false;
     *              //ship.IncreaseEvasionChance (-componentCapacity);
     *
     *              PowerManager.Instance.RoutePower (systemType, -powerReq);
     *      } else {
     *              Debug.Log ("already powered down");
     *      }
     * }
     */


    public void SyncedPower(bool _isPowered)
    {
        isPowered = _isPowered;

        if (isPowered)
        {
            ship.IncreaseEvasionChance(componentCapacity);
        }
        else
        {
            ship.IncreaseEvasionChance(-componentCapacity);
        }
    }
Esempio n. 2
0
    public void UpdatePowerState(bool _isPowered)
    {
        //at this point we know theres enough power and can power down or up
        if (isPowered)
        {
            //try power down
            pwrMngr.PowerDistribution(systemType, -powerReq, this);
            pwrMngr.UpdateReactor(powerReq);

            ship.IncreaseEvasionChance(-componentCapacity);

            isPowered = false;
        }
        else
        {
            pwrMngr.PowerDistribution(systemType, powerReq, this);

            ship.IncreaseEvasionChance(componentCapacity);

            isPowered = true;
        }

        sysScr.IsPowered = isPowered;
    }