Esempio n. 1
0
        private bool CreateEnergyTanks(
            Random rng,
            out String result)
        {
            bool success = true;

            result = SuccessMessages.GENERAL_SUCCESS;

            for (RoomIndexIterator iterator = new RoomIndexIterator(m_roomGrid);
                 success && iterator.Valid;
                 iterator.Next())
            {
                RoomIndex    roomIndex    = iterator.Current;
                RoomLayout   room         = GetRoomByIndex(roomIndex);
                RoomTemplate roomTemplate = m_roomTemplateSet.GetTemplateByName(room.static_room_data.room_template_name);

                foreach (EnergyTankTemplate energyTankTemplate in roomTemplate.EnergyTankTemplates)
                {
                    //TODO: CreateEnergyTanks - Scale back energy tank distribution based on difficulty
                    EnergyTank energyTank = EnergyTank.CreateEnergyTank(room.room_key, energyTankTemplate);

                    room.energyTanks.Add(energyTank);
                }
            }

            return(success);
        }
Esempio n. 2
0
        public static EnergyTank CreateEnergyTank(EnergyTanks dbEnergyTank)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key       = new RoomKey(dbEnergyTank.GameID, dbEnergyTank.RoomX, dbEnergyTank.RoomY, dbEnergyTank.RoomZ);
            newEnergyTank.m_energy_tank_id = dbEnergyTank.EnergyTankID;
            newEnergyTank.m_position       = new Point3d(dbEnergyTank.X, dbEnergyTank.Y, dbEnergyTank.Z);
            newEnergyTank.m_energy         = dbEnergyTank.Energy;
            newEnergyTank.m_faction        = (GameConstants.eFaction)dbEnergyTank.Ownership;

            return(newEnergyTank);
        }
Esempio n. 3
0
        public static EnergyTank CreateEnergyTank(RoomKey roomKey, EnergyTankTemplate template)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key       = new RoomKey(roomKey);
            newEnergyTank.m_energy_tank_id = -1; // energy tank ID not set until this gets saved into the DB
            newEnergyTank.m_position       = new Point3d(template.Position);
            newEnergyTank.m_energy         = template.Energy;
            newEnergyTank.m_faction        = GameConstants.eFaction.neutral;

            return(newEnergyTank);
        }
Esempio n. 4
0
        public static EnergyTank CreateEnergyTank(RoomKey roomKey, EnergyTankTemplate template)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key = new RoomKey(roomKey);
            newEnergyTank.m_energy_tank_id = -1; // energy tank ID not set until this gets saved into the DB
            newEnergyTank.m_position = new Point3d(template.Position);
            newEnergyTank.m_energy = template.Energy;
            newEnergyTank.m_faction = GameConstants.eFaction.neutral;

            return newEnergyTank;
        }
        public HackEnergyTankRequestProcessor(
            int character_id,
            int energy_tank_id)
        {
            m_character_id = character_id;
            m_energy_tank_id = energy_tank_id;

            m_world = null;
            m_room = null;
            m_energy_tank = null;
            m_current_room_key = null;
            m_current_character_position = new Point3d();
            m_current_character_angle = 0.0f;
            m_game_id = -1;
            m_move_to_target = false;
            m_ai_relevant_events = new List<GameEventParameters>();

            m_result_event_list = null;
        }
Esempio n. 6
0
        public static void UpdateEnergyTank(
            AsyncRPGDataContext db_context,
            EnergyTank energyTank)
        {
            var dbEnergyTank =
                (from e in db_context.EnergyTanks
                 where e.EnergyTankID == energyTank.ID
                 select e).SingleOrDefault();

            dbEnergyTank.GameID = energyTank.RoomKey.game_id;
            dbEnergyTank.RoomX = energyTank.RoomKey.x;
            dbEnergyTank.RoomY = energyTank.RoomKey.y;
            dbEnergyTank.RoomZ = energyTank.RoomKey.z;
            dbEnergyTank.X = energyTank.Position.x;
            dbEnergyTank.Y = energyTank.Position.y;
            dbEnergyTank.Z = energyTank.Position.z;
            dbEnergyTank.Ownership = (int)energyTank.Faction;
            dbEnergyTank.Energy = energyTank.Energy;

            db_context.SubmitChanges();
        }
Esempio n. 7
0
        public static void UpdateEnergyTankOwnership(
            AsyncRPGDataContext db_context,
            EnergyTank energyTank,
            GameConstants.eFaction newOwnership)
        {
            var energyTankQuery =
                (from e in db_context.EnergyTanks
                    where e.EnergyTankID == energyTank.ID
                    select e).SingleOrDefault();

            energyTankQuery.Ownership = (int)newOwnership;

            db_context.SubmitChanges();

            energyTank.Faction = newOwnership;
        }
        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;
        }
Esempio n. 9
0
        public static EnergyTank CreateEnergyTank(EnergyTanks dbEnergyTank)
        {
            EnergyTank newEnergyTank = new EnergyTank();

            newEnergyTank.m_room_key = new RoomKey(dbEnergyTank.GameID, dbEnergyTank.RoomX, dbEnergyTank.RoomY, dbEnergyTank.RoomZ);
            newEnergyTank.m_energy_tank_id = dbEnergyTank.EnergyTankID;
            newEnergyTank.m_position = new Point3d(dbEnergyTank.X, dbEnergyTank.Y, dbEnergyTank.Z);
            newEnergyTank.m_energy = dbEnergyTank.Energy;
            newEnergyTank.m_faction = (GameConstants.eFaction)dbEnergyTank.Ownership;

            return newEnergyTank;
        }