Example #1
0
        private void interact()
        {
            List <Sprite> obstacles = (This.Game.CurrentLevel as FrostbyteLevel).obstacles;
            float         distance  = GroundPosRadius + 50;

            if (obstacles != null)
            {
                List <Sprite> targets = GetTargetsInRange(obstacles, distance);
                foreach (Sprite target in targets)
                {
                    if (target is Obstacles.Door)
                    {
                        for (int x = 0; x < ItemBag.Count; x++)
                        {
                            if (ItemBag[x] is Key)
                            {
                                This.Game.CurrentLevel.RemoveSprite(ItemBag[x]);
                                ItemBag.RemoveAt(x);
                                (target as Obstacles.Door).Open();
                                return;
                            }
                        }
                    }
                    else if (target is Obstacles.Chest)
                    {
                        Item i = (target as Obstacles.Chest).Open();
                        PickUpItem(i);
                        return;
                    }
                    else if (target is Obstacles.DiaryEntry)
                    {
                        This.Game.CurrentLevel.RemoveSprite(target);
                        obstacles.Remove(target);
                        ReadDiaryEntry();
                        return;
                    }
                }
            }
        }