コード例 #1
0
        private bool UpdateEnergyTankState(
            RequestCache requestCache,
            out string result_code)
        {
            bool success = false;

            EnergyTank energyTank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (energyTank != null)
            {
                switch (energyTank.Faction)
                {
                case GameConstants.eFaction.ai:
                    energyTank.Faction = GameConstants.eFaction.neutral;
                    break;

                case GameConstants.eFaction.neutral:
                case GameConstants.eFaction.player:
                    energyTank.Faction = GameConstants.eFaction.player;
                    break;
                }

                result_code = SuccessMessages.GENERAL_SUCCESS;
                success     = true;
            }
            else
            {
                result_code = ErrorMessages.CACHE_ERROR + "(Unable to update energy tank ownership)";
                success     = false;
            }

            return(success);
        }
コード例 #2
0
        private bool VerifyEnergyTank(
            RequestCache requestCache,
            out bool out_is_touching,
            out string result_code)
        {
            bool success = false;

            out_is_touching = false;

            // Make sure the portal actually exists in the room the player is in
            m_energy_tank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (m_energy_tank != null)
            {
                // Remember how much energy the tank had before we drained it
                m_energy_tank_old_energy = m_energy_tank.Energy;

                switch (m_energy_tank.Faction)
                {
                case GameConstants.eFaction.player:
                    result_code = SuccessMessages.GENERAL_SUCCESS;
                    success     = true;
                    break;

                case GameConstants.eFaction.ai:
                case GameConstants.eFaction.neutral:
                    result_code = ErrorMessages.ENERGY_TANK_NOT_PLAYER_OWNED;
                    success     = false;
                    break;

                default:
                    result_code = ErrorMessages.DB_ERROR + "(Invalid energy tank faction)";
                    success     = false;
                    break;
                }

                if (success && m_energy_tank.Energy <= 0)
                {
                    result_code = ErrorMessages.ENERGY_TANK_EMPTY;
                    success     = false;
                }

                if (success)
                {
                    float min_distance_squared = WorldConstants.ROOM_TILE_SIZE * WorldConstants.ROOM_TILE_SIZE;
                    float distance             = Point3d.DistanceSquared(m_current_character_position, m_energy_tank.Position);

                    out_is_touching = distance <= min_distance_squared;
                }
            }
            else
            {
                result_code = ErrorMessages.INVALID_REQUEST;
            }

            return(success);
        }
コード例 #3
0
        private bool UpdateEnergyTankState(
            RequestCache requestCache,
            out string result_code)
        {
            bool success = false;

            EnergyTank energyTank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (energyTank != null)
            {
                energyTank.Energy = 0;

                result_code = SuccessMessages.GENERAL_SUCCESS;
                success     = true;
            }
            else
            {
                result_code = ErrorMessages.CACHE_ERROR + "(Unable to update energy tank state)";
                success     = false;
            }

            return(success);
        }
コード例 #4
0
        private bool VerifyEnergyTank(
            RequestCache requestCache,
            out bool out_is_touching,
            out string result_code)
        {
            bool success = false;

            out_is_touching = false;

            // Make sure the portal actually exists in the room the player is in
            m_energy_tank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (m_energy_tank != null)
            {
                switch (m_energy_tank.Faction)
                {
                    case GameConstants.eFaction.ai:
                    case GameConstants.eFaction.neutral:
                        result_code = SuccessMessages.GENERAL_SUCCESS;
                        success= true;
                        break;
                    case GameConstants.eFaction.player:
                        result_code = ErrorMessages.ENERGY_TANK_PLAYER_OWNED;
                        success= false;
                        break;
                    default:
                        result_code = ErrorMessages.DB_ERROR+"(Unknown faction on energy tank)";
                        success= false;
                        break;
                }

                if (success)
                {
                    float min_distance_squared= WorldConstants.ROOM_TILE_SIZE*WorldConstants.ROOM_TILE_SIZE;
                    float distance = Point3d.DistanceSquared(m_current_character_position, m_energy_tank.Position);

                    out_is_touching = distance <= min_distance_squared;
                }
            }
            else
            {
                result_code = ErrorMessages.INVALID_REQUEST;
            }

            return success;
        }
コード例 #5
0
        private bool UpdateEnergyTankState(
            RequestCache requestCache,
            out string result_code)
        {
            bool success= false;

            EnergyTank energyTank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (energyTank != null)
            {
                switch(energyTank.Faction)
                {
                case GameConstants.eFaction.ai:
                    energyTank.Faction = GameConstants.eFaction.neutral;
                    break;
                case GameConstants.eFaction.neutral:
                case GameConstants.eFaction.player:
                    energyTank.Faction = GameConstants.eFaction.player;
                    break;
                }

                result_code = SuccessMessages.GENERAL_SUCCESS;
                success = true;
            }
            else
            {
                result_code = ErrorMessages.CACHE_ERROR+"(Unable to update energy tank ownership)";
                success = false;
            }

            return success;
        }
コード例 #6
0
        private bool UpdateEnergyTankState(
            RequestCache requestCache,
            out string result_code)
        {
            bool success= false;

            EnergyTank energyTank = requestCache.GetEnergyTank(m_current_room_key, m_energy_tank_id);

            if (energyTank != null)
            {
                energyTank.Energy = 0;

                result_code = SuccessMessages.GENERAL_SUCCESS;
                success = true;
            }
            else
            {
                result_code = ErrorMessages.CACHE_ERROR+"(Unable to update energy tank state)";
                success = false;
            }

            return success;
        }