示例#1
0
        // Call this periodically (when haste/slow wears off and when moving between depths)
        // to keep environmental updates in sync with player turns.
        public void synchronizePlayerTimeState()
        {
            playerCharacter rogue  = RogueMain.GetInstance().getRogue();
            creature        player = RogueMain.GetInstance().getPlayer();

            rogue.ticksTillUpdateEnvironment = player.ticksUntilTurn;
        }
示例#2
0
 public void initializeGender(creature monst)
 {
     if ((monst.info.flags & MONST_MALE) != 0 && (monst.info.flags & MONST_FEMALE) != 0)
     {
         monst.info.flags &= ~(rand_percent(50) ? MONST_MALE : MONST_FEMALE);
     }
 }
示例#3
0
        public void clearStatus(creature monst)
        {
            short i;

            for (i = 0; i < NUMBER_OF_STATUS_EFFECTS; i++)
            {
                monst.status[i] = monst.maxStatus[i] = 0;
            }
        }
示例#4
0
文件: Light.cs 项目: mebusy/codeLib
        // sets miner's light strength and characteristics based on rings of illumination, scrolls of darkness and water submersion
        public void updateMinersLightRadius()
        {
            playerCharacter rogue  = RogueMain.GetInstance().getRogue();
            creature        player = RogueMain.GetInstance().getPlayer();

            double fraction;
            double lightRadius;

            lightRadius = 100 * rogue.minersLightRadius;

            if (rogue.lightMultiplier < 0)
            {
                lightRadius /= (-1 * rogue.lightMultiplier + 1);
            }
            else
            {
                lightRadius *= (rogue.lightMultiplier);
                lightRadius  = Math.Max(lightRadius, (rogue.lightMultiplier * 2 + 2));
            }

            if (player.status[STATUS_DARKNESS] != 0)
            {
                fraction = (double)Math.Pow(1.0 - (((double)player.status[STATUS_DARKNESS]) / player.maxStatus[STATUS_DARKNESS]), 3);
                if (fraction < 0.05)
                {
                    fraction = 0.05;
                }
            }
            else
            {
                fraction = 1;
            }
            lightRadius = lightRadius * fraction;

            if (lightRadius < 2)
            {
                lightRadius = 2;
            }

            if (rogue.inWater && lightRadius > 3)
            {
                lightRadius = Math.Max(lightRadius / 2, 3);
            }

            rogue.minersLight.radialFadeToPercent = (short)(35 + Math.Max(0, Math.Min(65, rogue.lightMultiplier * 5)) * (fraction + RogueH.FLOAT_FUDGE));

            rogue.minersLight.lightRadius.upperBound = rogue.minersLight.lightRadius.lowerBound = (short)Random.clamp(lightRadius + RogueH.FLOAT_FUDGE, -30000, 30000);
        }
示例#5
0
        public void initializeRogue(ulong seed)
        {
            // short oldRNG;  // moved
            item theItem;

            rogue.RNG = RNG_SUBSTANTIVE;
            //if (!rogue.playbackMode)
            {
                rogue.seed = Random.seedRandomGenerator(seed);
                //previousGameSeed = rogue.seed;
            }

            levels = commonFunc.GetInstance().initialize_1D_objectArray <levelData> (DEEPEST_LEVEL + 1);           // malloc(sizeof(levelData) * (DEEPEST_LEVEL+1));

            // 固定的 level1 入口楼梯
            levels[0].upStairsLoc[0] = (DCOLS - 1) / 2 - 1;
            levels[0].upStairsLoc[1] = DROWS - 2;

            // reset enchant and gain strength frequencies
            rogue.lifePotionFrequency     = 0;
            rogue.strengthPotionFrequency = 40;
            rogue.enchantScrollFrequency  = 60;

            // all DF messages are eligible for display
            Architect.GetInstance().resetDFMessageEligibility();

            // initialize the levels list
            for (int i = 0; i < DEEPEST_LEVEL + 1; i++)
            {
                // qibinyi ,add to avoid crash
                levels[i].scentMap = null;

                levels[i].levelSeed          = (ulong)rand_range(0, 9999);
                levels[i].levelSeed         += (ulong)(10000 * rand_range(0, 9999));
                levels[i].monsters           = null;
                levels[i].dormantMonsters    = null;
                levels[i].items              = null;
                levels[i].visited            = false;
                levels[i].playerExitedVia[0] = 0;
                levels[i].playerExitedVia[1] = 0;

                // 随机 楼梯位置,  DEEPEST_LEVEL 前
                do
                {
                    levels[i].downStairsLoc[0] = (short)rand_range(1, DCOLS - 2);
                    levels[i].downStairsLoc[1] = (short)rand_range(1, DROWS - 2);
                } while (Monsters.distanceBetween(levels[i].upStairsLoc[0], levels[i].upStairsLoc[1],
                                                  levels[i].downStairsLoc[0], levels[i].downStairsLoc[1]) < DCOLS / 3);

                if (i < DEEPEST_LEVEL)
                {
                    levels[i + 1].upStairsLoc[0] = levels[i].downStairsLoc[0];
                    levels[i + 1].upStairsLoc[1] = levels[i].downStairsLoc[1];
                }
            }

            // initialize the waypoints list
            for (int i = 0; i < MAX_WAYPOINT_COUNT; i++)
            {
                rogue.wpDistance [i] = Grid.allocGrid();
                Grid.fillGrid(rogue.wpDistance[i], 0);
            }

            rogue.rewardRoomsGenerated = 0;

            // pre-shuffle the random terrain colors
            oldRNG    = rogue.RNG;
            rogue.RNG = RNG_COSMETIC;
            //assureCosmeticRNG;
            for (int i = 0; i < DCOLS; i++)
            {
                for (int j = 0; j < DROWS; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        terrainRandomValues[i, j, k] = (short)rand_range(0, 1000);
                    }
                }
            }
            rogue.RNG = oldRNG;             //restoreRNG();

            Architect.GetInstance().zeroOutGrid(displayDetail);

            // monsterCatalog ID 初始化
            for (int i = 0; i < NUMBER_MONSTER_KINDS; i++)
            {
                monsterCatalog[i].monsterID = (monsterTypes)i;
            }

            // Debug.Log ( "" + Global. white.red );

            Items.GetInstance().shuffleFlavors();

            for (int i = 0; i < FEAT_COUNT; i++)
            {
                rogue.featRecord[i] = featTable[i].initialValue;
            }

            /* TODO
             * deleteMessages();
             * for (i = 0; i < MESSAGE_ARCHIVE_LINES; i++) { // Clear the message archive.
             *      messageArchive[i][0] = '\0';   // commonFunc.zeroOut_1D_array ?
             * }
             * messageArchivePosition = 0;
             * //*/

            // Seed the stacks.
            floorItems          = new item();
            floorItems.nextItem = null;

            packItems          = new item();
            packItems.nextItem = null;

            monsterItemsHopper          = new item();
            monsterItemsHopper.nextItem = null;

            // item carried by monster
            for (int i = 0; i < MAX_ITEMS_IN_MONSTER_ITEMS_HOPPER; i++)
            {
                theItem                     = generateItem(ALL_ITEMS & ~FOOD, -1); // Monsters can't carry food: the food clock cannot be cheated!
                theItem.nextItem            = monsterItemsHopper.nextItem;
                monsterItemsHopper.nextItem = theItem;
            }
            //*
            monsters = new creature();
            monsters.nextCreature = null;

            dormantMonsters = new creature();
            dormantMonsters.nextCreature = null;

            graveyard = new creature();
            graveyard.nextCreature = null;

            purgatory = new creature();
            purgatory.nextCreature = null;
            //*/

            scentMap = null;

            safetyMap     = Grid.allocGrid();
            allySafetyMap = Grid.allocGrid();
            chokeMap      = Grid.allocGrid();

            rogue.mapToSafeTerrain = Grid.allocGrid();

            // Zero out the dynamic grids, as an essential safeguard against OOSes:
            Grid.fillGrid(safetyMap, 0);
            Grid.fillGrid(allySafetyMap, 0);
            Grid.fillGrid(chokeMap, 0);
            Grid.fillGrid(rogue.mapToSafeTerrain, 0);

            // initialize the player
            player      = new creature();
            player.info = monsterCatalog[0];             // caution: problem may occur

            Monsters.GetInstance().initializeGender(player);
            player.movementSpeed = player.info.movementSpeed;
            player.attackSpeed   = player.info.attackSpeed;
            Monsters.GetInstance().clearStatus(player);
            player.carriedItem = null;
            player.status[STATUS_NUTRITION] = player.maxStatus[STATUS_NUTRITION] = STOMACH_SIZE;
            player.currentHP            = player.info.maxHP;
            rogue.previousHealthPercent = 100;
            rogue.previousPoisonPercent = 0;
            player.creatureState        = MONSTER_ALLY;
            player.ticksUntilTurn       = 0;
            player.mutationIndex        = -1;
            //*/

            // init rogue
            rogue.depthLevel         = 1;
            rogue.deepestLevel       = 1;
            rogue.scentTurnNumber    = 1000;
            rogue.playerTurnNumber   = 0;
            rogue.absoluteTurnNumber = 0;
            rogue.foodSpawned        = 0;
            rogue.lifePotionsSpawned = 0;
            rogue.gold                            = 0;
            rogue.goldGenerated                   = 0;
            rogue.disturbed                       = false;
            rogue.autoPlayingLevel                = false;
            rogue.automationActive                = false;
            rogue.justRested                      = false;
            rogue.easyMode                        = false;
            rogue.inWater                         = false;
            rogue.creaturesWillFlashThisTurn      = false;
            rogue.updatedSafetyMapThisTurn        = false;
            rogue.updatedAllySafetyMapThisTurn    = false;
            rogue.updatedMapToSafeTerrainThisTurn = false;
            rogue.updatedMapToShoreThisTurn       = false;
            rogue.strength                        = 12;
            rogue.weapon                          = null;
            rogue.armor                           = null;
            rogue.ringLeft                        = null;
            rogue.ringRight                       = null;
            rogue.monsterSpawnFuse                = (ushort)rand_range(125, 175);
            rogue.ticksTillUpdateEnvironment      = 100;
            rogue.mapToShore                      = null;
            rogue.cursorLoc[0]                    = rogue.cursorLoc[1] = -1;
            rogue.xpxpThisTurn                    = 0;

            rogue.yendorWarden = null;

            rogue.flares     = null;
            rogue.flareCount = rogue.flareCapacity = 0;


            rogue.minersLight              = lightCatalog[(int)Global.MINERS_LIGHT];
            rogue.clairvoyance             = rogue.regenerationBonus
                                           = rogue.stealthBonus = rogue.transference = rogue.wisdomBonus = rogue.reaping = 0;
            rogue.lightMultiplier          = 1;

            theItem = generateItem(FOOD, (short)foodKind.RATION);
            theItem = addItemToPack(theItem);

            theItem          = generateItem(WEAPON, (short)weaponKind.DAGGER);
            theItem.enchant1 = theItem.enchant2 = 0;
            theItem.flags   &= ~(ITEM_CURSED | ITEM_RUNIC);
            identify(theItem);
            theItem = addItemToPack(theItem);
            equipItem(theItem, false);

            theItem          = generateItem(WEAPON, (short)weaponKind.DART);
            theItem.enchant1 = theItem.enchant2 = 0;
            theItem.quantity = 15;
            theItem.flags   &= ~(ITEM_CURSED | ITEM_RUNIC);
            identify(theItem);
            theItem = addItemToPack(theItem);

            theItem          = generateItem(ARMOR, (short)armorKind.LEATHER_ARMOR);
            theItem.enchant1 = 0;
            theItem.flags   &= ~(ITEM_CURSED | ITEM_RUNIC);
            identify(theItem);
            theItem = addItemToPack(theItem);
            equipItem(theItem, false);
            player.status[STATUS_DONNING] = 0;

            recalculateEquipmentBonuses();

            /* TODO
             * blackOutScreen();
             *
             * //*/
            welcome();
        }         //  end initializeRogue