예제 #1
0
 public void PickUp(cCharacter player)
 {
     for (int x = 0; x < player.inventory.width; x++)
     {
         for (int y = 0; y < player.inventory.height; y++)
         {
             if (player.inventory.inventorySlot[x, y].item == null && !added)
             {
                 player.inventory.inventorySlot[x, y].item = key;
                 player.inventory.inventorySlot[x, y].texture = texture;
                 added = true;
             }
         }
     }
 }
예제 #2
0
        public void Update(cCharacter player, Game1 game)
        {
            if (lockedDialogue.isTalking)
            {
                lockedDialogue.Update();
                if (lockedDialogue.isTalking == false)
                {
                    game.currentGameState = Game1.GameState.PLAY;
                }
            }
            if (targetX != -1)
            {
                targetX = fileTargetX;
            }
            else
                this.targetX = player.position.X;

            if (targetY != -1)
            {
                targetY = fileTargetY;
            }
            else
                this.targetY = player.position.Y;

            if (player.attackRectangle.Intersects(warpField))
            {
                Console.WriteLine("intersecting");
                bool hasKey = false;
                for (int x = 0; x < player.inventory.width; x++)
                {
                    for (int y = 0; y < player.inventory.height; y++)
                    {
                        if (player.inventory.inventorySlot[x, y].item == key || key == ".")
                        {
                            hasKey = true;
                            Effect(game);
                            if (doneEffect)
                            {
                                if (player.position.X < warpField.X)
                                {
                                    if (targetX != -1)
                                    {
                                        targetX += 2;
                                    }
                                }
                                Game1.map = game.Content.Load<H_Map.TileMap>(@"Map\" + targetMap);
                                Game1.map.tileset = game.Content.Load<Texture2D>(@"Game\tileset");
                                if (targetX != -1)
                                {
                                    player.position.X = targetX;
                                }
                                if (targetY != -1)
                                {
                                    player.position.Y = targetY;
                                }
                                addAlpha = true;
                                canWalk = true;
                            }
                        }
                    }
                }
                if (!hasKey && !hasShowedLockedMessage)
                {
                    game.currentGameState = Game1.GameState.INTERACT;
                    lockedDialogue.isTalking = true;
                    hasShowedLockedMessage = true;
                }
            }
            else
            {
                hasShowedLockedMessage = false;
            }
        }