当前位置: 首页>>代码示例>>C#>>正文


C# Monster.setPosition方法代码示例

本文整理汇总了C#中Monster.setPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Monster.setPosition方法的具体用法?C# Monster.setPosition怎么用?C# Monster.setPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monster的用法示例。


在下文中一共展示了Monster.setPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: placeBrother

        public void placeBrother(Quinoa quinoa)
        {
            String caveID = caveBottomIDs[RandomNumber.RandomInteger(caveBottomIDs.Count)];

            RegionHeader header = quinoa.getMap().getRegionHeaderByID(caveID);
            header.recallRegion();

            Position pos = new Position();
            List<Position> tempPos = MapGenerator.getTerrainPositions(TerrainCode.STONE_FLOOR, header.getRegion(), false);
            if (tempPos.Count > 0)
            {
                pos = tempPos[RandomNumber.RandomInteger(tempPos.Count)];
            }

            Monster monster = new Monster();
            monster.monsterCode = MonsterCode.HUMAN;
            MonsterActionManager.initialize(monster);
            monster.role = MonsterRole.BROTHER;
            monster.setPosition(pos.x, pos.y);

            Item lantern = new Item();
            lantern.itemClass = ItemClass.LANTERN;
            monster.inventory.equipItem(lantern, ItemSlot.BELT_1);

            header.getRegion().getMonsters().Add(monster);

            header.storeRegion(true);
        }
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:28,代码来源:MapGenerator.cs

示例2: buildByArray

        public static void buildByArray(Region region, int startX, int startY, Building building, int[,] plan)
        {
            for (int x = 0; x < BuildingManager.getWidth(building.getBuildingType()); x++)
            {
                for (int y = 0; y < BuildingManager.getHeight(building.getBuildingType()); y++)
                {
                    if (x + startX < region.getWidth() && x + startX > 0
                    && y + startY < region.getHeight() && y + startY > 0)
                    {
                        switch (plan[y,x])
                        {
                            case 0:
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_FLOOR);
                                break;

                            case 1:
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_WALL);
                                break;

                            case 9:
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_FLOOR);
                                region.getTerrain(startX + x, startY + y).getParameters().Add(TerrainParameter.HAS_DOOR, Enum.GetName(typeof(DoorCode), DoorCode.CLOSED));
                                building.setDoor(startX + x, startY + y);
                                break;

                            case 8:
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_WALL);
                                region.getTerrain(startX + x, startY + y).getParameters().Add(TerrainParameter.HAS_SIGN, building.getName());
                                break;

                            case 2:
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_FLOOR);
                                Monster newMon = new Monster();
                                switch (building.getBuildingType())
                                {
                                    case BuildingType.BANK:
                                        newMon.monsterCode = MonsterCode.HUMAN;
                                        newMon.role = MonsterRole.BANKER;
                                        break;

                                    case BuildingType.INN:
                                        newMon.monsterCode = MonsterCode.HUMAN;
                                        newMon.role = MonsterRole.NULL;
                                        break;

                                    case BuildingType.FOOD_STORE:
                                        newMon.monsterCode = MonsterCode.HUMAN;
                                        newMon.role = MonsterRole.CHEF;
                                        break;

                                    case BuildingType.TOOL_STORE:
                                        newMon.monsterCode = MonsterCode.HUMAN;
                                        newMon.role = MonsterRole.HANDYMAN;
                                        break;
                                }
                                MonsterActionManager.initialize(newMon);
                                newMon.setPosition(startX + x, startY + y);
                                region.getMonsters().Add(newMon);
                                break;

                            case 3:
                                //Add a bed
                                region.getTerrain(startX + x, startY + y).setCode(TerrainCode.STONE_FLOOR);
                                region.getTerrain(startX + x, startY + y).getParameters().Add(TerrainParameter.HAS_BED, "");
                                break;
                        }
                    }
                }
            }
        }
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:70,代码来源:BuildingManager.cs

示例3: monsterKilled

        public static void monsterKilled(Monster killer, Monster victim, Quinoa quinoa)
        {
            String playerFeedback="The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " is gone.";

            //Give experience
            MonsterActionManager.giveExperience(killer, victim.stats.getExperienceGiven(), quinoa);

            //Drop items
            foreach(Item tempItem in victim.inventory.getItems())
            {
                Item newItem = (Item)tempItem.CopyObject();
                newItem.setPosition(victim.x, victim.y);
                newItem.itemState = ItemState.GROUND;
                quinoa.getCurrentRegionHeader().getRegion().getItems().Add(newItem);
            }

            //Any monster specific items
            switch(victim.monsterCode)
            {
                case MonsterCode.HUMAN:
                break;

                case MonsterCode.GHOST:
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " fades away...";
                break;

                case MonsterCode.SPONGE:
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " crumbles.";
                break;

                case MonsterCode.SLIME:
                for(int i=0; i < 2; i++)
                {
                    Monster newMon = new Monster();
                    newMon.monsterCode = MonsterCode.SMALL_SLIME;
                    MonsterActionManager.initialize(newMon);
                    newMon.setPosition(victim.x + RandomNumber.RandomInteger(5) - 2, victim.y + RandomNumber.RandomInteger(5) - 2);
                    quinoa.getActions().addMonster(newMon);
                }
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " splits!";
                break;

                case MonsterCode.SMALL_SLIME:
                for(int i=0; i < 2; i++)
                {
                    Monster newMon = new Monster();
                    newMon.monsterCode = MonsterCode.TINY_SLIME;
                    MonsterActionManager.initialize(newMon);
                    newMon.setPosition(victim.x + RandomNumber.RandomInteger(7) - 4, victim.y + RandomNumber.RandomInteger(7) - 4);
                    quinoa.getActions().addMonster(newMon);
                }
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " splits!";
                break;

                case MonsterCode.TINY_SLIME:
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " evaporates!";
                break;

                case MonsterCode.DEER:
                case MonsterCode.PIG:
                playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " collapses.";
                break;

                default:
                break;
            }

            //Inform plyer
            if(killer.ID.Equals(MonsterActionManager.PLAYER_ID))
            {
                quinoa.getMessageManager().addMessage(playerFeedback);
            }
        }
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:73,代码来源:MonsterActionManager.cs

示例4: executeMoveCommand

        public static void executeMoveCommand(Monster monster, MonsterCommand command, Quinoa quinoa)
        {
            Region region = quinoa.getCurrentRegionHeader().getRegion();
            Direction direction = (Direction) Enum.Parse(typeof(Direction), command.getParameter("direction"));
            monster.facing = direction;

            int newX = monster.x;
            int newY = monster.y;

            switch(direction)
            {
                case Direction.N: newY--; break;
                case Direction.NE: newY--; newX++; break;
                case Direction.NW: newY--; newX--; break;
                case Direction.S: newY++; break;
                case Direction.SE: newY++; newX++; break;
                case Direction.SW: newY++; newX--; break;
                case Direction.E: newX++; break;
                case Direction.W: newX--; break;
            }

            if(newX >= 0 && newX < region.getWidth()
            && newY >= 0 && newY < region.getHeight())
            {
                Terrain tmpTerrain = region.getTerrain(newX, newY);
                if (TerrainManager.allowsMonsterToPass(tmpTerrain, monster) && quinoa.getMonster(newX, newY) == null)
                {
                    monster.setPosition(newX, newY);
                    TerrainManager.step(region.getTerrain(newX, newY), newX, newY, region, quinoa);
                }
                else
                {
                    //Do nothing
                }
            }
            else
            {
                //out of bounds, but do not inform the player
            }
        }
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:40,代码来源:MonsterActionManager.cs

示例5: executeItemVerbCommand


//.........这里部分代码省略.........
                                    quinoa.getMessageManager().addMessage("You feel better.");
                                }
                                else
                                {
                                    quinoa.getMessageManager().addMessage("You feel worse.");
                                }
                            }
                        }
                    }
                    removeItem = true;
                    break;

                    case ItemVerb.PLACE:
                    removeItem = MonsterActionManager.place(monster, item, x, y, region, quinoa);
                    break;

                    case ItemVerb.USE:
                    removeItem = use(monster, item, x, y, region, quinoa);
                    break;

                }

                if(removeItem)
                {
                    if(item.stackSize > 1)
                    {
                        item.stackSize = item.stackSize - 1;
                    }
                    else
                    {
                        item.RemoveObject();
                    }
                }
            }
            else
            {
                //Non-item verbs
                switch(verb)
                {
                    case ItemVerb.ACTIVATE:
                    MonsterActionManager.activate(monster, x, y, region, quinoa);
                    break;

                    case ItemVerb.TALK:
                    if(isPlayer(monster))
                    {
                        quinoa.getActions().talk(x, y);
                        quinoa.getActions().showDialog();
                    }
                    break;

                    case ItemVerb.LOOK:
                    if(isPlayer(monster))
                    {
                        quinoa.getActions().look(x, y);
                        quinoa.getActions().showDialog();
                    }
                    break;

                    case ItemVerb.TRADE:
                    if(isPlayer(monster))
                    {
                        quinoa.getActions().trade(x, y);
                    }
                    break;

                    case ItemVerb.SLEEP:
                    Item terrainItem = region.getItem(x, y);

                    if(terrainItem != null)
                    {
                        foreach(ItemAttribute ia in terrainItem.attributes)
                        {
                            if(ia.type == ItemAttributeType.SLEEPS_FOR)
                            {
                                int hours = Int32.Parse(ia.parameter.Split(new char[]{' '})[0]);
                                monster.setPosition(x, y);
                                monster.sleeping = Quinoa.TICKS_PER_SECOND * 60 * 60 * hours;
                                break;
                            }
                        }
                    }

                    if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.HAS_BED))
                    {
                        int hours = 4;
                        monster.setPosition(x, y);
                        monster.sleeping = Quinoa.TICKS_PER_SECOND * 60 * 60 * hours;
                    }
                    else
                    {
                        if(isPlayer(monster))
                        {
                            quinoa.getMessageManager().addMessage("You can't sleep there.");
                        }
                    }
                    break;
                }
            }
        }
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:101,代码来源:MonsterActionManager.cs

示例6: spawnMonsters

        public void spawnMonsters()
        {
            //get a list of how many monsters are on the map
            Region region = quinoa.getCurrentRegionHeader().getRegion();
            quinoa.getLightMap().calculate(region);
            Dictionary<MonsterCode, Int32> monsterCount = new Dictionary<MonsterCode, Int32>();
            foreach(MonsterCode mc in Enum.GetValues(typeof(MonsterCode)))
            {
                int newCount = TerrainManager.getMonsterCount(region, mc);
                monsterCount.Add(mc, newCount);
            }

            //look for oppurtunities to spawn monsters
            for(int x=0; x < region.getWidth(); x++)
            {
                for(int y=0; y < region.getHeight(); y++)
                {
                    Terrain terrain = region.getTerrain(x, y);

                    if(quinoa.getLightMap().getCalc(x, y) < LightMap.DARKNESS_LIGHT_LEVEL)
                    {
                        //dark spawning monsters

                        //GHOST spawn
                        if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_GRAVE))
                        {
                            GraveCode gc = (GraveCode)Enum.Parse(typeof(GraveCode),(TerrainManager.getParameter(terrain, TerrainParameter.HAS_GRAVE)));
                            if(gc == GraveCode.BROKEN || (gc == GraveCode.SPECIAL && RandomNumber.RandomDouble() < 0.1))
                            {
                                if(RandomNumber.RandomDouble() < MonsterActionManager.getSpawnRate(MonsterCode.GHOST)
                                && monsterCount[MonsterCode.GHOST] < MonsterActionManager.getMaxMonsterPerRegion(MonsterCode.GHOST))
                                {
                                    //spawn a ghost
                                    Monster newMon = new Monster();
                                    newMon.monsterCode = MonsterCode.GHOST;
                                    MonsterActionManager.initialize(newMon);
                                    newMon.setPosition(x, y);
                                    quinoa.getActions().addMonster(newMon);
                                    monsterCount.Add(MonsterCode.GHOST, monsterCount[MonsterCode.GHOST] + 1);
                                }
                            }
                        }

                        //SPONGE spawn
                        if(terrain.getWater() > 0)
                        {
                            if(terrain.getWater() > TerrainManager.DEEP_WATER
                            && RandomNumber.RandomDouble() < MonsterActionManager.getSpawnRate(MonsterCode.SPONGE)
                            && monsterCount[MonsterCode.SPONGE] < MonsterActionManager.getMaxMonsterPerRegion(MonsterCode.SPONGE))
                            {
                                //spawn a sponge
                                Monster newMon = new Monster();
                                newMon.monsterCode = MonsterCode.SPONGE;
                                MonsterActionManager.initialize(newMon);
                                newMon.setPosition(x, y);
                                quinoa.getActions().addMonster(newMon);
                                monsterCount.Add(MonsterCode.SPONGE, monsterCount[MonsterCode.SPONGE] + 1);
                            }
                        }

                        //SLIME spawn
                        if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_MOSS))
                        {
                            if(RandomNumber.RandomDouble() < MonsterActionManager.getSpawnRate(MonsterCode.SLIME)
                            && monsterCount[MonsterCode.SLIME] < MonsterActionManager.getMaxMonsterPerRegion(MonsterCode.SLIME))
                            {
                                //spawn a slime
                                Monster newMon = new Monster();
                                newMon.monsterCode = MonsterCode.SLIME;
                                MonsterActionManager.initialize(newMon);
                                newMon.setPosition(x, y);
                                quinoa.getActions().addMonster(newMon);
                                monsterCount.Add(MonsterCode.SLIME, monsterCount[MonsterCode.SLIME] + 1);
                            }
                        }

                    }
                    else
                    {
                        //Light spawning monsters

                        //TINY_SLIME spawn
                        if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_MOSS))
                        {
                            if(RandomNumber.RandomDouble() < MonsterActionManager.getSpawnRate(MonsterCode.TINY_SLIME)
                            && monsterCount[MonsterCode.TINY_SLIME] < MonsterActionManager.getMaxMonsterPerRegion(MonsterCode.TINY_SLIME))
                            {
                                //spawn a tiny slime
                                Monster newMon = new Monster();
                                newMon.monsterCode = MonsterCode.TINY_SLIME;
                                MonsterActionManager.initialize(newMon);
                                newMon.setPosition(x, y);
                                quinoa.getActions().addMonster(newMon);
                                monsterCount.Add(MonsterCode.TINY_SLIME, monsterCount[MonsterCode.TINY_SLIME] + 1);
                            }
                        }

                        //PIG spawn
                        if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_MUSHROOM_SPORES) && region.getLightingModel() == LightingModel.ABOVE_GROUND)
                        {
//.........这里部分代码省略.........
开发者ID:seaweedfactory,项目名称:LumberjackRL,代码行数:101,代码来源:QuinoaActions.cs


注:本文中的Monster.setPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。