예제 #1
0
        private void DoDrop(YnEntity dropped, YnEntity reciever)
        {
            string code  = reciever.AssetName;
            string dcode = dropped.AssetName;

            Console.WriteLine(code + "-" + dcode);

            if (code == "Items/cadenas" && dcode == "Items/item_3")
            {
                // Supprimer le cadenas
                _cadenasCasse = true;
                YnEntity todelete = null;
                foreach (YnEntity img in _itemsOnScreen)
                {
                    if (img.AssetName == "Items/cadenas")
                    {
                        todelete = img;
                    }
                }
                _itemsOnScreen.Remove(todelete);
            }
            else if (code == "Items/masqueporte" && dcode == "Items/item_7")
            {
                _porteOuverte = true;
            }
            else if (code == "Items/douille" && dcode == "Items/item_6")
            {
                _ampoulePosee = true;
                SetData(ImlostGame.Scenes ["scene_18"]);
            }
        }
예제 #2
0
        public SelectLevelState(int shipType)
            : base("Select a level", 3)
        {
            _selectedShip  = shipType;
            _selectedLevel = 0;

            spaceLevelImage       = new YnEntity("Backgrounds/selectStars");
            spaceLevelImage.Scale = SpaceGame.GetScale();
            Add(spaceLevelImage);

            escapeLevelImage       = new YnEntity("Backgrounds/selectEscape");
            escapeLevelImage.Scale = SpaceGame.GetScale();
            Add(escapeLevelImage);

            Rectangle rectangle = new Rectangle(
                YnG.Width / 2 - MenuItem.SmallItemWidth / 2,
                YnG.Height - (int)SpaceGame.GetScaleY(75),
                MenuItem.SmallItemWidth,
                MenuItem.SmallItemHeight);

            MenuItem backItem = new MenuItem("Back", rectangle, 2, false);

            backItem.ItemTextSize = SpaceGame.GetScale();

            backItem.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
            backItem.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
            backItem.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
            Add(backItem);

            items.Add(backItem);
        }
예제 #3
0
        public MenuState()
            : base("Codename : SpaceGame", 6)
        {
            // Les elements qui passent sous le menu
            _planetLogo = new YnEntity(Assets.PlanetRed);
            Add(_planetLogo);

            _shipSprite = new YnSprite(Assets.PlayerShipA);
            Add(_shipSprite);

            _kinectLogo = new YnEntity("Misc/kinect");
            Add(_kinectLogo);

            // 3 - Le menu
            string[] itemNames = { "Arcade", "Multiplayers", "Scores", "Options", "Credits", "Exit" };

            int x = (YnG.Width / 2) - MenuItem.BigItemWidth / 2;
            int y = 0;

            for (int i = 0; i < 3; i++)
            {
                y = (int)SpaceGame.GetScaleY(185) + i * MenuItem.BigItemHeight * 2;

                MenuItem item = new MenuItem(itemNames[i], new Rectangle(
                                                 (int)(x),
                                                 (int)(y),
                                                 MenuItem.BigItemWidth,
                                                 MenuItem.BigItemHeight),
                                             i,
                                             i == 0 ? true : false);

                item.ItemTextSize  = SpaceGame.GetScale();
                item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
                item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
                item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
                Add(item);

                items.Add(item);
            }

            x = 0;
            y = YnG.Height - (MenuItem.SmallItemHeight + MenuItem.SmallItemHeight / 3);

            for (int j = 3; j < 6; j++)
            {
                x = (int)SpaceGame.GetScaleX(350) + (j - 3) * MenuItem.SmallItemWidth * 2;

                MenuItem item = new MenuItem(itemNames[j], new Rectangle(x, y, MenuItem.SmallItemWidth, MenuItem.SmallItemHeight), j, false);
                item.ItemTextSize  = new Vector2(0.6f) * SpaceGame.GetScale();
                item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
                item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
                item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
                Add(item);

                items.Add(item);
            }
        }
예제 #4
0
 /// <summary>
 /// Create an script animator for the given YnObject
 /// </summary>
 /// <param name="target"></param>
 public ScriptAnimator(YnEntity target)
 {
     _target          = target;
     _scriptNodes     = new List <BaseScriptNode>();
     _started         = false;
     _running         = false;
     _nodeIndex       = 0;
     _repeatAnimation = false;
 }
예제 #5
0
        /// <summary>
        /// Wait
        /// </summary>
        /// <param name="gameTime">The game time</param>
        /// <param name="o">Unused here</param>
        public override void Update(GameTime gameTime, YnEntity o)
        {
            _elaspedTime += gameTime.ElapsedGameTime.Milliseconds;

            if (_elaspedTime >= _waitTime)
            {
                _scriptDone = true;
            }
        }
예제 #6
0
        public MessageBoxButton(MessageBoxButtonType type, string text)
        {
            button = new YnEntity("Misc/button");
            Add(button);

            label       = new YnText("Font/kozuka_20", text);
            label.Color = Color.White;
            Add(label);
        }
예제 #7
0
        public SplashscreenState()
            : base("splash", true)
        {
            background = new YnEntity("Backgrounds/Splash");
            Add(background);

            timer            = new YnTimer(3000, 0);
            timer.Completed += timer_Completed;
        }
예제 #8
0
        public SplashState(string name)
            : base(name)
        {
            splashScreen = new YnEntity(Assets.TextureSplashScreen);
            Add(splashScreen);

            waitTimer            = new YnTimer(1500, 0);
            waitTimer.Completed += (s, e) => stateManager.SetActive("menu", true);
            waitTimer.Start();
            Add(waitTimer);
        }
예제 #9
0
        protected override void item_MouseJustClicked(object sender, MouseClickEntityEventArgs e)
        {
            YnEntity levelScreen = sender as YnEntity;

            if (levelScreen != null)
            {
                YnG.AudioManager.PlaySound(Assets.SoundCrystal);

                int levelId = int.Parse(levelScreen.Name.Split(new char[] { '_' })[1].ToString());
                GameConfiguration.SetStartLevel(levelId);
                (YnG.Game as MazeGame).PrepareNewLevel(levelId, true);
            }
        }
예제 #10
0
        protected List <MenuItem> items;                // Elements du menu

        /// <summary>
        /// Représente un écran de menu standard avec un titre et des items
        /// </summary>
        public BaseMenu(string name, string title, int numItems)
            : base(name)
        {
            _background = new YnEntity(Assets.TextureMenuBase);
            Add(_background);

            // 1 - Le titre
            _title       = new YnText(Assets.FontKozuka30, title);
            _title.Color = Color.GhostWhite;
            _title.Scale = new Vector2(1.5f, 1.5f);
            Add(_title);

            items = new List <MenuItem>(numItems);
        }
예제 #11
0
        public GameHUD()
        {
            itemsCount       = 0;
            nbItemsCollected = 0;

            itemsCounter       = new YnText("Font/Desiree_20", "{0} / {1} Cristaux");
            itemsCounter.Scale = new Vector2(1.2f);
            itemsCounter.Color = TextColor;
            Add(itemsCounter);

            scoreText       = new YnText("Font/Desiree_20", "0 pt");
            scoreText.Scale = new Vector2(1.4f);
            scoreText.Color = TextColor;
            Add(scoreText);

            scoreCounterEntity = new YnEntity("UI/needle");
            Add(scoreCounterEntity);

            timeText       = new YnText("Font/Desiree_30", "00 : 00");
            timeText.Scale = new Vector2(2.0f);
            timeText.Color = TextColor;
            Add(timeText);

            itemsCounterEntity = new YnEntity("UI/needle");
            Add(itemsCounterEntity);

            timeCounterWheelEntity = new YnEntity("UI/topWheel");
            Add(timeCounterWheelEntity);

            timeCounterNeedleEntity = new YnEntity("UI/needle-watch");
            Add(timeCounterNeedleEntity);

            miniMapLeftBorder = new YnEntity("UI/mapBorderLeft");
            Add(miniMapLeftBorder);

            miniMapBottomBorder = new YnEntity("UI/mapBorderBottom");
            Add(miniMapBottomBorder);

            bottomBar       = new YnEntity(new Rectangle(0, 0, YnG.Width, (int)ScreenHelper.GetScaleY(40)), Color.Black);
            bottomBar.Alpha = 0.4f;
            Add(bottomBar);

            bottomLogo = new YnEntity("UI/bottomWheel");
            Add(bottomLogo);

            highlightTimer            = new YnTimer(1000);
            highlightTimer.Completed += highlightTimer_Completed;
        }
예제 #12
0
        public void showSplash(string assetName)
        {
            _showSplash = true;

            if (_splash == null)
            {
                _splash = new YnEntity("Splashes/" + assetName);
            }
            else
            {
                _splash.AssetName = "Splashes/" + assetName;
            }

            _splash.LoadContent();
            _splash.SetFullScreen();
        }
예제 #13
0
        public MenuState(string name)
            : base(name, true)
        {
            _background = new YnEntity("Backgrounds/Accueil");
            Add(_background);

            playRectangle = new Rectangle(
                (int)ScreenHelper.GetScaleX(135),
                (int)ScreenHelper.GetScaleY(265),
                (int)(ScreenHelper.GetScale().X * 226),
                (int)(ScreenHelper.GetScale().Y * 65));

            quitRectangle = new Rectangle(
                (int)ScreenHelper.GetScaleX(135),
                (int)ScreenHelper.GetScaleY(420),
                (int)(ScreenHelper.GetScale().X * 226),
                (int)(ScreenHelper.GetScale().Y * 65));
        }
예제 #14
0
        public override void LoadContent()
        {
            base.LoadContent();
            _levelTiles = new YnEntity[GameConfiguration.LevelCount];

            YnText levelText = null;
            int    cursor    = 0;
            float  x         = (int)ScreenHelper.GetScaleX(65);
            float  y         = (int)ScreenHelper.GetScaleX(145);
            float  maxWidth  = (int)(YnG.Width / 4 - ScreenHelper.GetScaleX(90));
            float  offsetX   = ScreenHelper.GetScaleX(40);
            float  offsetY   = ScreenHelper.GetScaleY(35);
            float  paddingX  = 1.25f;

            YnText.DefaultColor = Color.Yellow;

            for (int i = 0; i < GameConfiguration.LevelCount; i++)
            {
                _levelTiles[i] = new YnEntity("Misc/mapPreview");
                _levelTiles[i].LoadContent();

                if (i == 4)
                {
                    y     += (int)(maxWidth + offsetY);
                    cursor = 0;
                }

                x = (cursor++ *maxWidth * paddingX) + offsetX;

                _levelTiles[i].Position = new Vector2(x, y);
                _levelTiles[i].Name     = "level_" + (i + 1);
                _levelTiles[i].Scale    = new Vector2((float)(maxWidth / _levelTiles[i].Width), (float)(maxWidth / _levelTiles[i].Height));
                Add(_levelTiles[i]);

                levelText = new YnText(Assets.FontKozuka30, (i + 1).ToString());
                levelText.LoadContent();
                levelText.Scale    = new Vector2(1.5f);
                levelText.Position = new Vector2(
                    _levelTiles[i].X + _levelTiles[i].ScaledWidth / 2 - levelText.ScaledWidth / 2,
                    _levelTiles[i].Y + _levelTiles[i].ScaledHeight / 2 - levelText.ScaledHeight / 2);
                Add(levelText);
            }
        }
예제 #15
0
        public PopupState(string name)
            : base(name, false)
        {
            int y = YnG.Height / 2 - ((YnG.Height / 4) / 2);

            _background       = new YnSprite(new Rectangle(0, y, YnG.Width, (int)(ScreenHelper.GetScaleY(300))), Color.WhiteSmoke);
            _background.Alpha = 0.9f;
            Add(_background);

            _headerBackground = new YnEntity(new Rectangle((int)_background.X, (int)_background.Y, YnG.Width, (int)ScreenHelper.GetScaleY(50)), Color.DarkGray);
            Add(_headerBackground);

            _title       = new YnText(Assets.FontKozuka30, "Fin de partie");
            _title.Color = Color.White;
            _title.Scale = ScreenHelper.GetScale() * 1.25f;
            Add(_title);

            _content       = new YnText(Assets.FontKozuka20, "Vous avez terminé le niveau, que voulez vous faire ?");
            _content.Color = Color.Black;
            _content.Scale = ScreenHelper.GetScale() * 1.1f;
            Add(_content);

            _waitMessage        = new YnText(Assets.FontKozuka30, "Chargement en cours...");
            _waitMessage.Color  = Color.White;
            _waitMessage.Scale  = ScreenHelper.GetScale() * 1.2f;
            _waitMessage.Active = false;
            Add(_waitMessage);

            _itemActionA               = new MessageBoxButton(MessageBoxButtonType.Cancel, "Menu");
            _itemActionA.Position      = new Vector2(_background.Width / 3, _background.Y + _background.Height - ScreenHelper.GetScaleY(100));
            _itemActionA.MouseClicked += (s, e) => OnActionMenu(new MessageBoxEventArgs(false, true));
            _itemActionA.Scale         = ScreenHelper.GetScale();
            Add(_itemActionA);

            _itemActionB               = new MessageBoxButton(MessageBoxButtonType.Validate, "Suivant");
            _itemActionB.Position      = new Vector2((_background.Width / 3) * 2, _itemActionA.Y);
            _itemActionB.MouseClicked += (s, e) => OnActionMenu(new MessageBoxEventArgs(true, false));
            _itemActionB.Scale         = ScreenHelper.GetScale();
            Add(_itemActionB);

            _enabled = true;
        }
예제 #16
0
        public OptionsState()
            : base("Options", 1)
        {
            background = new YnEntity("Backgrounds/options");
            Add(background);

            Rectangle rectangle = new Rectangle(
                YnG.Width / 2 - MenuItem.SmallItemWidth / 2,
                YnG.Height - 75,
                MenuItem.SmallItemWidth,
                MenuItem.SmallItemHeight);

            MenuItem item = new MenuItem("Menu", rectangle, 0, false);

            item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
            item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
            item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
            Add(item);

            items.Add(item);
        }
예제 #17
0
        public MenuState(string name)
            : base(name, "", 3)
        {
            YnG.ShowMouse = true;

            _checkForNext  = false;
            _checkForHover = false;
            menuItemIndex  = 0;

            menuItemSelector = new YnEntity("UI/menuItemBar");
            Add(menuItemSelector);

            string[] itemNames = new string[5]
            {
                MazeLang.Text.Menus.New,
                MazeLang.Text.Menus.Choose,
                MazeLang.Text.Menus.Options,
                MazeLang.Text.Menus.Credits,
                MazeLang.Text.Menus.Exit
            };

            menuItems = new YnText[5];
            for (int i = 0, l = itemNames.Length; i < l; i++)
            {
                menuItems[i]               = new YnText("Font/kozuka_30", itemNames[i]);
                menuItems[i].Color         = Color.White;
                menuItems[i].Name          = "mi_" + i;
                menuItems[i].MouseClicked += MenuState_MouseClicked;
                menuItems[i].MouseOver    += MenuState_MouseOver;

                if (i > 2)
                {
                    menuItems[i].Scale = new Vector2(0.75f);
                }

                Add(menuItems[i]);
            }

            _background.AssetName = Assets.TextureMenuTitle;
        }
예제 #18
0
        /// <summary>
        /// Moves the object until the target point is reached
        /// </summary>
        /// <param name="gameTime">The game time</param>
        /// <param name="o">The object to move</param>
        public override void Update(GameTime gameTime, YnEntity o)
        {
            Vector2 position = o.Position;

            if (position == _destination)
            {
                // The destination is reached by the object
                _scriptDone = true;
            }
            else
            {
                // Create the normalized vector aiming to the target point
                Vector2 direction = _destination - position;
                direction.Normalize();

                // Apply speed factor on the direction
                Vector2 newPosition = Vector2.Multiply(direction, _speed);

                // Move the object
                o.Translate(newPosition);
            }
        }
예제 #19
0
        public CreditsState()
            : base("Credits", 1)
        {
            background = new YnEntity("Backgrounds/credits");
            Add(background);

            Rectangle rectangle = new Rectangle(
                YnG.Width / 2 - MenuItem.SmallItemWidth / 2,
                YnG.Height - (int)SpaceGame.GetScaleY(75),
                MenuItem.SmallItemWidth,
                MenuItem.SmallItemHeight);

            MenuItem item = new MenuItem("Menu", rectangle, 0, false);

            item.ItemTextSize = SpaceGame.GetScale();

            item.MouseClicked += new EventHandler <MouseClickEntityEventArgs>(item_MouseJustClicked);
            item.MouseLeave   += new EventHandler <MouseLeaveEntityEventArgs>(item_MouseLeave);
            item.MouseOver    += new EventHandler <MouseOverEntityEventArgs>(item_MouseOver);
            Add(item);

            items.Add(item);
        }
예제 #20
0
        protected bool _kinectValidedAction;            // Indique si l'item a été validé après le temps d'activation
#endif
        /// <summary>
        /// Représente un écran de menu standard avec un titre et des items
        /// </summary>
        public BaseMenu(string title, int numItems)
            : base("basemenu", true)
        {
            // 1 - Le titre
            _title       = new YnText("Fonts/Menu", title);
            _title.Color = Color.GhostWhite;
            _title.Scale = new Vector2(1.5f, 1.5f);
            Add(_title);

            string pointerAssetName = Assets.MouseCursor;

#if COMPLETE
            kinect = KinectSensorController.Instance;

            _lastKinectPosition = Vector3.Zero;

            // Aucune action validée pour le moment
            _kinectValidedAction = false;

            // Evenements kinect
            _timerKinectOver            = new YnTimer(KinectTimerDuration, 0);
            _timerKinectOver.Completed += new EventHandler <EventArgs>(_timerKinectOver_Completed);
            _timerKinectOver.ReStarted += new EventHandler <EventArgs>(_timerKinectOver_ReStarted);

            _transitionKinectOver = new YnTransition(KinectTimerDuration);

            if (kinect.IsAvailable)
            {
                pointerAssetName = Assets.KinectCursor;
            }
#endif

            items = new List <MenuItem>(numItems);

            // Le curseur de souris/Kinect
            _handSelector = new YnEntity(pointerAssetName);
        }
예제 #21
0
 public virtual void Remove(YnEntity entity)
 {
     _entities.Remove(entity);
 }
예제 #22
0
 /// <summary>
 /// Perform an iteration of the script
 /// </summary>
 /// <param name="gameTime">The game time</param>
 /// <param name="o">The object to perform the script on</param>
 public abstract void Update(GameTime gameTime, YnEntity o);
예제 #23
0
        /// <summary>
        /// Initialise le nouvel objet de données
        /// </summary>
        /// <param name="data">Le conteneur de données</param>
        public void SetData(SceneData data)
        {
            _sceneData = data;

            // On cache le texte
            _narationText.Active = false;

            // Réinitialisation du DSOD : le Deadly Screen Of Death
            _deadlySceenOfDeath = false;

            if (_sceneData.LeftScene != String.Empty)
            {
                _goLeft.Visible = true;
            }
            else
            {
                _goLeft.Visible = false;
            }

            if (_sceneData.TopScene != String.Empty)
            {
                _goUp.Visible = true;
            }
            else
            {
                _goUp.Visible = false;
            }

            if (_sceneData.RightScene != String.Empty)
            {
                _goRight.Visible = true;
            }
            else
            {
                _goRight.Visible = false;
            }

            if (_sceneData.BottomScene != String.Empty)
            {
                _goDown.Visible = true;
            }
            else
            {
                _goDown.Visible = false;
            }

            if (!_visitedScreens.ContainsKey(data.Code))
            {
                _visitedScreens.Add(data.Code, false);
            }
            else
            {
                _visitedScreens [data.Code] = true;
            }

            if (_visitedScreens [data.Code] == false)
            {
                // Découverte de la zone : affichage d'un message TODO
                if (data.Message != String.Empty)
                {
                    string message = data.Message;
                    _narationText.Text   = message;
                    _narationText.Active = true;
                    _narationTimer.Start();
                    _vocalSynthetizer.SpeakAsync(message);
                }
            }

            if (GetMemberByName("background") != null)
            {
                _background.AssetName = data.Background;

                if (data.Code == "scene_18" && _ampoulePosee)
                {
                    _background.AssetName = data.Background + "_1";
                }

                _background.LoadContent();
                _background.SetFullScreen();
            }
            else
            {
                _background      = new YnEntity(data.Background);
                _background.Name = "background";
                Add(_background);

                _background.SetFullScreen();
            }

            if (_sceneData.LeftScene != String.Empty && GetMemberByName("go_left") == null)
            {
                Add(_goLeft);
            }

            if (_sceneData.TopScene != String.Empty && GetMemberByName("go_up") == null)
            {
                Add(_goUp);
            }

            if (_sceneData.RightScene != String.Empty && GetMemberByName("go_right") == null)
            {
                Add(_goRight);
            }

            if (_sceneData.BottomScene != String.Empty && GetMemberByName("go_down") == null)
            {
                Add(_goDown);
            }

            if (_sceneData.AmbienceZone > 0)
            {
                AmbianceManager.AmbianceZone zone = AmbianceManager.AmbianceZone.Outside;

                if (_sceneData.AmbienceZone == 2)
                {
                    zone = AmbianceManager.AmbianceZone.Hall;
                }
                if (_sceneData.AmbienceZone == 3)
                {
                    zone = AmbianceManager.AmbianceZone.Bathroom;
                }
                if (_sceneData.AmbienceZone == 4)
                {
                    zone = AmbianceManager.AmbianceZone.Stairs;
                }
                if (_sceneData.AmbienceZone == 5)
                {
                    zone = AmbianceManager.AmbianceZone.Room;
                }

                _ambianceManager.SetAmbianceZone(zone);
            }

            // 1 - on clean la scène
            _itemsOnScreen.Clear();

            foreach (SceneObject sceneObject in data.Objects)
            {
                if (sceneObject.AssetName != String.Empty)
                {
                    bool mustAddObject = true;
                    if ((ActionType)sceneObject.ActionID == ActionType.Pick)
                    {
                        // Ne pas ajouter les éléments déjà dans l'inventaire
                        foreach (InventoryItem item in _inventory)
                        {
                            if (item.Code == sceneObject.Name)
                            {
                                mustAddObject = false;
                            }
                        }
                    }

                    if (mustAddObject)
                    {
                        YnEntity imageObject = new YnEntity(sceneObject.AssetName);
                        imageObject.LoadContent();

                        imageObject.MouseClicked += (s, e) =>
                        {
                            if (sceneObject.SoundName != String.Empty)
                            {
                                YnG.AudioManager.PlaySound(sceneObject.SoundName, 1.0f, 1.0f, 1.0f);
                            }

                            if ((ActionType)sceneObject.ActionID == ActionType.Pick)
                            {
                                AddItem(sceneObject.Name);

                                if (sceneObject.Name.Equals("SceneObject_1"))
                                {
                                    _ticket1Ramasse = true;
                                    _ambianceManager.SetGuideSound(AmbianceManager.GuideSound.Carhonk);
                                }
                                if (sceneObject.Name.Equals("SceneObject_2"))
                                {
                                    _marteauRamasse = true;
                                    _ambianceManager.SetGuideSound(AmbianceManager.GuideSound.None);
                                }
                                if (sceneObject.Name.Equals("SceneObject_3"))
                                {
                                    _anneauRamasse = true;
                                }
                                if (sceneObject.Name.Equals("SceneObject_4"))
                                {
                                    _cleRecue = true;
                                }
                                if (sceneObject.Name.Equals("SceneObject_5"))
                                {
                                    _ampouleRamasse = true;
                                }
                                if (sceneObject.Name.Equals("SceneObject_6"))
                                {
                                    _diamantRamasse = true;
                                }
                                if (sceneObject.Name.Equals("SceneObject_7"))
                                {
                                    _diamantRamasse = true;
                                }

                                string temp  = sceneObject.Name.Split(new char[] { '_' })[1];
                                bool   valid = true;

                                try
                                {
                                    int c = int.Parse(temp);
                                }
                                catch (Exception ex)
                                {
                                    valid = false;
                                    Console.WriteLine(ex.Message);
                                }

                                if (valid)
                                {
                                    showSplash(sceneObject.Name);

                                    // Suppression de l'item de la scène
                                    YnEntity imgToDelete = null;

                                    foreach (YnEntity i in _itemsOnScreen)
                                    {
                                        if (i.AssetName == sceneObject.AssetName)
                                        {
                                            imgToDelete = i;
                                        }
                                    }

                                    _itemsOnScreen.Remove(imgToDelete);
                                }
                            }
                        };
                        _itemsOnScreen.Add(imageObject);

                        imageObject.X = (int)ScreenHelper.GetScaleX(sceneObject.X);
                        imageObject.Y = (int)ScreenHelper.GetScaleY(sceneObject.Y);
                    }
                }
            }

            // Si c'est une scène "mortelle" on passe un flag à true
            // TODO Ajouter ici les scènes mortelles
            if (data.Code == "scene_4")
            {
                _deadlySceenOfDeath = true;
                _ambianceManager.PlayDeath(AmbianceManager.TypeOfDeath.Ghost);
                _deathAlpha = 0.0F;
            }
        }
예제 #24
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _ambianceManager.Update(gameTime);

            _narationTimer.Update(gameTime);

            if (_deadlySceenOfDeath)
            {
                // Le joueur est là où il ne devrait pas!
                // Fondu qui va bien
                _deathAlpha += 0.01F;

                if (_deathAlpha >= 1.0F && _ambianceManager.TransitionDone())
                {
                    // Le joueur est mort : TP sur le banc
                    _deathAlpha = 0.0F;
                    SetData(ImlostGame.Scenes ["scene_1"]);
                }
            }
            else
            {
                if (_showSplash)
                {
                    // Splash affiché, on le masque si on clique n'importe où
                    if (YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        _showSplash = false;
                    }
                }
                else
                {
                    _menuIcon.Update(gameTime);
                    _notesIcon.Update(gameTime);

                    //Gestion du curseur par manette xbox360
                    if (GamePad.GetState(PlayerIndex.One).IsConnected)
                    {
#if !LINUX
                        Mouse.SetPosition(YnG.Mouse.X + (int)YnG.Gamepad.RightStickValue(PlayerIndex.One).X * 20, YnG.Mouse.Y - (int)YnG.Gamepad.RightStickValue(PlayerIndex.One).Y * 20);
#endif
                    }

                    if (MouseInRectangle(_menuIcon.Rectangle) && YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        // Click sur le menu
                        // TODO
                    }

                    // Images sur la scène
                    List <YnEntity> safeList = new List <YnEntity>(_itemsOnScreen);
                    foreach (YnEntity img in safeList)
                    {
                        img.Update(gameTime);
                    }

                    if (YnG.Mouse.MouseState.LeftButton == ButtonState.Pressed && !_dragging)
                    {
                        foreach (YnEntity img in _itemImages.Values)
                        {
                            if (MouseInRectangle(img.Rectangle))
                            {
                                _dragging = true;

                                _draggedImage = new YnEntity(img.AssetName);
                                _draggedImage.LoadContent();
                            }
                        }
                    }

                    if (YnG.Mouse.Released(MouseButton.Left) && _dragging)
                    {
                        _draggedImage.Position = new Vector2(YnG.Mouse.X - _draggedImage.Width / 2, YnG.Mouse.Y - _draggedImage.Height / 2);

                        if (YnG.Mouse.Released(MouseButton.Left))
                        {
                            // Drop
                            List <YnEntity> safeList2 = new List <YnEntity>(_itemsOnScreen);
                            foreach (YnEntity img in safeList2)
                            {
                                if (img.Rectangle.Intersects(_draggedImage.Rectangle))
                                {
                                    // Intersection
                                    DoDrop(_draggedImage, img);
                                }
                            }
                        }
                    }

                    if (_dragging)
                    {
                        _draggedImage.Position = new Vector2(YnG.Mouse.X - _draggedImage.Width / 2, YnG.Mouse.Y - _draggedImage.Height / 2);
                    }

                    if (YnG.Mouse.Released(MouseButton.Left))
                    {
                        _dragging = false;
                    }

                    // Déplacement au clavier, et manette Xbox360
                    if ((YnG.Keys.JustPressed(Keys.Z) || YnG.Keys.JustPressed(Keys.Up) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickUp)) &&
                        _sceneData.TopScene != String.Empty)
                    {
                        GoUp();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.S) || YnG.Keys.JustPressed(Keys.Down) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickDown)) &&
                             _sceneData.BottomScene != String.Empty)
                    {
                        GoDown();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.Q) || YnG.Keys.JustPressed(Keys.Left) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickLeft)) &&
                             _sceneData.LeftScene != String.Empty)
                    {
                        GoLeft();
                    }
                    else if ((YnG.Keys.JustPressed(Keys.D) || YnG.Keys.JustPressed(Keys.Right) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.LeftThumbstickRight)) &&
                             _sceneData.RightScene != String.Empty)
                    {
                        GoRight();
                    }
                    else if (YnG.Keys.JustPressed(Keys.Escape) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Back))
                    {
                        YnG.Exit();
                    }

                    if (YnG.Mouse.JustClicked(MouseButton.Left) || GetTouchState() ||
                        YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                    {
                        // Click sur le bouton de menu
                        int mx = YnG.Mouse.X;
                        int my = YnG.Mouse.Y;
                        if (MouseInRectangle(_menuHitbox) || TouchInRectangle(_menuHitbox) ||
                            YnG.Keys.JustPressed(Keys.C) || YnG.Keys.JustPressed(Keys.NumPad0) || YnG.Gamepad.JustPressed(PlayerIndex.One, Buttons.Y))
                        {
                            // Afficher ou masquer le menu
                            // 97 => hauteur du menu
                            // 25 => hauteur de la poignée
                            int delta = 97 - 25;
                            if (_menuIsShown)
                            {
                                // Déplacement de la hitbox vers le haut
                                _menuHitbox.Y += delta;

                                // Déplacement du background vers le haut
                                _menuBackground.Y += delta;
                            }
                            else
                            {
                                // Déplacement de la hitbox vers le bas
                                _menuHitbox.Y -= delta;

                                // Déplacement du background vers le bas
                                _menuBackground.Y -= delta;
                            }
                            _menuIsShown = !_menuIsShown;

                            _menuIcon.Visible  = _menuIsShown;
                            _notesIcon.Visible = _menuIsShown;

                            // Un peu brutasse comme méthode...
                            // On cache tout
                            foreach (KeyValuePair <string, YnEntity> pair in _itemImages)
                            {
                                pair.Value.Visible = false;
                            }

                            // Et on ne raffiche que ce qui est dans l'inventaire du joueur
                            int itemPadding = 20;
                            int nbItems     = _inventory.Count;
                            int x           = YnG.Width / 2 - (56 * nbItems) / 2;
                            if (nbItems > 1)
                            {
                                x -= ((nbItems - 1) * itemPadding) / 2;
                            }

                            foreach (InventoryItem item in _inventory)
                            {
                                if (_menuIsShown)
                                {
                                    _itemImages [item.Code].Visible = true;

                                    // Replacement de l'élément, centré en bas, de gauche à droite
                                    Vector2 pos = new Vector2(x, YnG.Height - 63);
                                    _itemImages [item.Code].Position = pos;

                                    x += 56 + itemPadding;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #25
0
        public SceneState(string name)
            : base(name, false)
        {
            _vocalSynthetizer = new VocalSynthetizer();

            InitParcours();
            _menuIsShown    = false;
            _visitedScreens = new Dictionary <string, bool>(); // 18 écrans
            _itemsOnScreen  = new List <YnEntity>();

            _narationText       = new YnText("Fonts/GameText", "Dummy");
            _narationText.Color = Color.DarkBlue;
            _narationText.Scale = new Vector2(1.5f) * Yna.Engine.Helpers.ScreenHelper.GetScale().X;

            _narationTimer            = new YnTimer(3500);
            _narationTimer.Completed += (s, e) => _narationText.Active = false;

            _leftSceneHitbox   = new Rectangle(0, _arrowHitboxSize, _arrowHitboxSize, YnG.Height - (97 - 25) - 2 * _arrowHitboxSize);
            _topSceneHitbox    = new Rectangle(_arrowHitboxSize, 0, YnG.Width - 2 * _arrowHitboxSize, _arrowHitboxSize);
            _rightSceneHitbox  = new Rectangle(YnG.Width - _arrowHitboxSize, _arrowHitboxSize, _arrowHitboxSize, YnG.Height - (97 - 25) - 2 * _arrowHitboxSize);
            _bottomSceneHitbox = new Rectangle(_arrowHitboxSize, YnG.Height - (97 - 25) - _arrowHitboxSize, YnG.Width - 2 * _arrowHitboxSize, _arrowHitboxSize);

            _menuHitbox = new Rectangle(YnG.Width / 2 - _buttonWidth / 2, YnG.Height - _buttonHeight, _buttonWidth, _buttonHeight);

            int padding       = 30;
            int imageHalfSize = 30;
            int imageSize     = imageHalfSize * 2;

            _goLeft               = new YnEntity("Textures/icone-fleche-gauche", new Vector2(padding, YnG.Height / 2 - imageHalfSize));
            _goLeft.Visible       = false;
            _goLeft.Name          = "go_left";
            _goLeft.MouseClicked += (s, e) => GoLeft();

            _goUp               = new YnEntity("Textures/icone-fleche-haut", new Vector2(YnG.Width / 2 - imageHalfSize, padding));
            _goUp.Visible       = false;
            _goUp.Name          = "go_up";
            _goUp.MouseClicked += (s, e) => GoUp();

            _goRight               = new YnEntity("Textures/icone-fleche-droite", new Vector2(YnG.Width - padding - imageSize, YnG.Height / 2 - imageHalfSize));
            _goRight.Visible       = false;
            _goRight.Name          = "go_right";
            _goRight.MouseClicked += (s, e) => GoRight();

            _goDown               = new YnEntity("Textures/icone-fleche-bas", new Vector2(YnG.Width / 2 - imageHalfSize, YnG.Height - padding - imageSize - 97 + 25));
            _goDown.Visible       = false;
            _goDown.Name          = "go_down";
            _goDown.MouseClicked += (e, s) => GoDown();

            _menuClosedY    = YnG.Height - 25;
            _menuOpenedY    = YnG.Height - 97;
            _menuBackground = new YnEntity("Textures/liste-inventaire", new Vector2(0, _menuClosedY));

            int iconPadding = 15;
            int x           = iconPadding;
            int y           = YnG.Height - 60;

            _menuIcon               = new YnEntity("Textures/btn-menu", new Vector2(x, y));
            _menuIcon.Visible       = false;
            _menuIcon.MouseClicked += (e, s) =>
            {
                if (!_menuIcon.Visible)
                {
                    return;
                }
            };

            y                        = YnG.Height - 69;
            x                        = YnG.Width - iconPadding - 80;
            _notesIcon               = new YnEntity("Textures/btn-notes", new Vector2(x, y));
            _notesIcon.Visible       = false;
            _notesIcon.MouseClicked += (e, s) =>
            {
                if (!_notesIcon.Visible)
                {
                    return;
                }

                // TODO Afficher les notes
                if (ImlostGame.Debug)
                {
                    Console.WriteLine("Clicked on NOTES");
                }
            };

            _inventory = new List <InventoryItem>();

            _itemImages = new Dictionary <string, YnEntity>();

            foreach (InventoryItem item in ImlostGame.InventoryItems.Values)
            {
                YnEntity img = new YnEntity(item.AssetName);
                img.Visible = false;
                _itemImages.Add(item.Code, img);
            }

            _ambianceManager = new AmbianceManager();
        }
예제 #26
0
 public virtual void Remove(YnEntity entity)
 {
     _entities.Remove(entity);
 }