示例#1
0
    /*
     * public void OnDamage () {
     *      Debug.Log ("ISystem/Engine");
     *
     *      PowerManager.Instance.DamageSystem (systemType, -powerReq);
     * }
     *
     * //still needs to be implemented as ISystem
     * public void OnRepair () {
     *
     * }
     */

    /*
     * public void UpdateHealth (int _hp) {
     *      //onDamage
     *      if (_hp <= 0 && !isDamaged) {
     *              isDamaged = true;
     *
     *              Debug.Log ("ISystem/Engine Damaged");
     *
     *              if (isLocal) {
     *                      PowerManager.Instance.DamageSystem (systemType, -powerReq);
     *              }
     *      }
     *
     *      //onRepair
     *      if (_hp > 0 && isDamaged) {
     *              isDamaged = false;
     *
     *              Debug.Log ("ISystem/Engine Repaired");
     *
     *              if (isLocal) {
     *                      PowerManager.Instance.DamageSystem (systemType, powerReq);
     *              }
     *      }
     * }
     */

    public void UpdateHealthState(bool _isFullyDamaged, bool _isFullyRepaired)
    {
        Debug.Log("engine: " + gridPos.X + ", " + gridPos.Y);

        if (_isFullyDamaged)
        {
            //PowerManager.Instance.DamageSystem (systemType, -powerReq);

            if (isPowered)
            {
                ReceivePowerUpdate(false);
            }

            pwrMngr.ApplyHealthState(systemType, powerReq, isPowered, this);
            //isPowered = false;
        }

        if (_isFullyRepaired)
        {
            //PowerManager.Instance.DamageSystem (systemType, powerReq);
            pwrMngr.ApplyHealthState(systemType, -powerReq, isPowered, this);
        }

        //Debug.Log ("isFullyDamaged = " + _isFullyDamaged);
        //Debug.Log ("isFullyRepaired = " + _isFullyRepaired);
    }
示例#2
0
    /*
     * void Update () {
     *      if (Input.GetKeyDown (KeyCode.Comma)) {
     *              Debug.Log ("capacity: " + reactorCapacity + ", reactorUsage: " + reactorUsage + "\navailablePower: " + availablePower);
     *      }
     *
     *      //DEBUG -> needs better place
     *      availablePower = reactorCapacity - reactorUsage;
     *
     *      if (availablePower < 0) {
     *              if (PowerManager.Instance != null) {
     *                      //RedirectPower (-availablePower);
     *                      PowerManager.Instance.RandomSystemShutdown ();
     *              } else {
     *                      Debug.LogError ("PowerManager == null");
     *              }
     *      }
     * }
     *
     *
     * private void ReactorSetup () {
     *      if (NetManager.Instance != null) {
     *              if (gridPos.Z == NetManager.Instance.localPlayerID) {
     *                      //reactorCapacity += componentCapacity;
     *                      isLocalReact = true;
     *                      UpdateReactorCapacity (componentCapacity);
     *
     *                      //Debug.Log ("reactorCapacity: " + reactorCapacity);
     *              }
     *      }
     * }
     *
     *
     * public static bool DirectPower (int _amount) {
     *      if (reactorUsage + _amount <= reactorCapacity) {
     *              reactorUsage += _amount;
     *              //UpdateReactorUsage (-_amount);
     *              UpdateUI ();
     *
     *              return true;
     *      } else {
     *              return false;
     *      }
     * }
     *
     *
     * public static bool RedirectPower (int _amount) {
     *      if (reactorUsage - _amount < 0) {
     *              return true;
     *      } else {
     *              reactorUsage -= _amount;
     *              //UpdateReactorUsage (_amount);
     *              UpdateUI ();
     *
     *              return false;
     *      }
     * }
     *
     *
     * private void UpdateReactorCapacity (int _amount) {
     *      reactorCapacity += _amount;
     *
     *      if (PowerManager.Instance != null) {
     *              PowerManager.Instance.UpdateReactorCapacity (_amount);
     *      } else {
     *              //Debug.LogError ("PowerManager == null");
     *      }
     * }
     *
     * private static void UpdateUI () {
     *      if (PowerManager.Instance != null) {
     *              PowerManager.Instance.UpdatePowerDistribution (reactorCapacity - reactorUsage);
     *      }
     * }
     *
     *
     * void OnDestroy () {
     *      //Debug.Log ("waeeee");
     *      if (isLocalReact) {
     *              UpdateReactorCapacity (-componentCapacity);
     *      }
     *      //UpdateUI ();
     * }
     *
     *
     * public void UpdateHealth (int _hp) {
     *      Debug.Log ("ISystem/Reactor");
     *
     *      /*
     *      //onDamage
     *      if (_hp <= 0 && !isDamaged) {
     *              isDamaged = true;
     *
     *              Debug.Log ("ISystem/Engine Damaged");
     *
     *              PowerManager.Instance.DamageSystem (systemType, -powerReq);
     *      }
     *
     *      //onRepair
     *      if (_hp > 0 && isDamaged) {
     *              isDamaged = false;
     *
     *              Debug.Log ("ISystem/Engine Repaired");
     *
     *              PowerManager.Instance.DamageSystem (systemType, powerReq);
     *      }
     *      ////
     * }
     */


    public void UpdateHealthState(bool _isFullyDamaged, bool _isFullyRepaired)
    {
        //Debug.Log ("reactor: " + gridPos.X + ", " + gridPos.Y);

        if (_isFullyDamaged)
        {
            //PowerManager.Instance.DamageSystem (systemType, -powerReq);

            if (isPowered)
            {
                ReceivePowerUpdate(false);
            }

            pwrMngr.ApplyHealthState(systemType, componentCapacity, true, this);
        }

        if (_isFullyRepaired)
        {
            //might cause reaktor bugs!
            //PowerManager.Instance.DamageSystem (systemType, powerReq);
            pwrMngr.ApplyHealthState(systemType, -componentCapacity, true, this);
        }

        //Debug.Log ("reaktor: ");
        //Debug.Log ("isFullyDamaged = " + _isFullyDamaged);
        //Debug.Log ("isFullyRepaired = " + _isFullyRepaired);
    }
示例#3
0
    public void UpdateHealthState(bool _isFullyDamaged, bool _isFullyRepaired)
    {
        Debug.Log("weaponSys: " + gridPos.X + ", " + gridPos.Y);

        if (_isFullyDamaged)
        {
            if (isPowered)
            {
                ReceivePowerUpdate(false);
            }

            pwrMngr.ApplyHealthState(systemType, powerReq, isPowered, this);
        }

        if (_isFullyRepaired)
        {
            pwrMngr.ApplyHealthState(systemType, -powerReq, isPowered, this);
        }
    }