コード例 #1
0
 public MainGameEntity(Data.MainGameData mainGameData)
 {
     foreach (var data in mainGameData.CharacterDatas)
     {
         CharacterEntities.Add(new CharacterEntity(data));
     }
     PlayerEntity = new PlayerEntity(mainGameData.PlayerData);
 }
コード例 #2
0
        internal void testUpdate()
        {
#if DEBUG
            if (MouseController.RightClicked())
            {
                IntVec pos = MouseController.MouseGridPosition();
                if (KeyboardController.IsDown('8'))
                {
                    Item[] items = new Item[statRand.Next(2, 8)];
                    for (int i = 0; i < items.Length; i++)
                    {
                        items[i] = Item.randomItem(DungeonLevel, 1);
                    }
                    InteractableEnvironment.Add(new Chest(items), pos);
                }

                if (KeyboardController.IsDown('9'))
                {
                    CharacterEntities.Add(Enemies.EnemyCreator.GetRandomEnemy(1, DungeonLevel)[0], pos);
                }

                if (KeyboardController.IsDown('0'))
                {
                    CharacterEntities.Add(Enemies.EnemyCreator.GetRandomBoss(DungeonLevel), pos);
                }
            }

            IntVec aMove = new IntVec((KeyboardController.IsTyped('H', 0) ? 1 : 0) - (KeyboardController.IsTyped('F', 0) ? 1 : 0), (KeyboardController.IsTyped('G', 0) ? 1 : 0) - (KeyboardController.IsTyped('T', 0) ? 1 : 0));
            IntVec bMove = new IntVec((KeyboardController.IsPressed('M') ? 1 : 0) - (KeyboardController.IsPressed('B') ? 1 : 0), (KeyboardController.IsPressed('N') ? 1 : 0) - (KeyboardController.IsPressed('J') ? 1 : 0));
            actionsToTake += (KeyboardController.IsDown('2') ? 1 : 0) - (KeyboardController.IsDown('1') ? 1 : 0);

            if (aMove.X != 0 || aMove.Y != 0 || bMove.X != 0 || bMove.Y != 0)
            {
                if (!isSolid(a + aMove))
                {
                    a += aMove;
                }

                if (!isSolid(b + bMove))
                {
                    b += bMove;
                }

                path = AStar.getPathBetween(this, a, b);

                actionsToTake = 1;

                int movement = Math.Abs(aMove.X) + Math.Abs(aMove.Y) + Math.Abs(bMove.X) + Math.Abs(bMove.Y);

                Engine.Engine.Log(string.Format("New A* path length: {0}", path.Length.ToString()));
                if (previousPathDistance != -1 && Math.Abs(previousPathDistance - path.Length) > movement)
                {
                    Engine.Engine.Log(string.Format("<INCONSISTENT PATHFIND; MOVEMENTDELTA={0},PATHDELTA={1}>", movement, Math.Abs(previousPathDistance - path.Length)));
                }

                //moveset = AStar.getTargetLine(this, startPoint, a, true);
                //moveset = AStar.getPossiblePositionsFrom(this, a, 15, AStar.CharacterTargeting.TARGET_FIRST, true);
                moveset = AStar.getPossiblePositionsInBox(this, a, 2, 2, AStar.CharacterTargeting.TARGET_FIRST, true);

                previousPathDistance = path.Length;
            }

            if (KeyboardController.IsPressed('Z'))
            {
                for (int i = 0; i < 100; i++)
                {
                    Item item = Item.getDesireditem(30, 30);

                    Engine.Engine.Log(string.Format("Item Generated: {0}", item.Name));

                    DroppedItems.Add(item, findRandomOpenPosition());
                }
            }

            if (KeyboardController.IsPressed('Q'))
            {
                for (int i = 0; i < 100; i++)
                {
                    Item item = Item.randomLegendary(30, 35);

                    Engine.Engine.Log(string.Format("Item Generated: {0}", item.Name));

                    DroppedItems.Add(item, findRandomOpenPosition());
                }
            }
#endif
        }