예제 #1
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));
        }
예제 #2
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);
            }
        }
예제 #3
0
        public override void Initialize()
        {
            base.Initialize();

            _scaleFactor = ScreenHelper.GetScale();

            timeCounterWheelEntity.Scale     = _scaleFactor;
            timeCounterWheelEntity.Position  = new Vector2(YnG.Width / 2 - timeCounterWheelEntity.ScaledWidth / 2 + (timeCounterWheelEntity.Origin.X * timeCounterWheelEntity.Scale.X), ScreenHelper.GetScaleY(-70));
            timeCounterNeedleEntity.Scale    = _scaleFactor;
            timeCounterNeedleEntity.Position = new Vector2(YnG.Width / 2 - timeCounterNeedleEntity.ScaledWidth / 2, 0);
            timeText.Scale   *= _scaleFactor;
            timeText.Position = new Vector2(YnG.Width / 2 - timeText.ScaledWidth / 2, timeCounterNeedleEntity.ScaledHeight + ScreenHelper.GetScaleY(10));

            scoreCounterEntity.Scale    = _scaleFactor;
            scoreCounterEntity.Position = new Vector2(0, ScreenHelper.GetScaleY(15));
            scoreText.Scale            *= _scaleFactor;
            scoreText.Position          = new Vector2(scoreCounterEntity.ScaledWidth + ScreenHelper.GetScaleX(10), scoreCounterEntity.Y + scoreCounterEntity.ScaledHeight / 2 - scoreText.ScaledHeight / 2);

            itemsCounterEntity.Scale    = _scaleFactor;
            itemsCounterEntity.Position = new Vector2(0, scoreCounterEntity.Y + scoreCounterEntity.ScaledHeight);
            itemsCounter.Scale         *= _scaleFactor;
            itemsCounter.Position       = new Vector2(itemsCounterEntity.ScaledWidth + ScreenHelper.GetScaleX(10), itemsCounterEntity.Y + itemsCounterEntity.ScaledHeight / 2 - scoreText.ScaledHeight / 2);

            bottomBar.Rectangle = new Rectangle(0, (int)(YnG.Height - bottomBar.ScaledHeight), YnG.Width, bottomBar.Height);
            bottomLogo.Position = new Vector2(YnG.Width / 2 - bottomLogo.ScaledWidth / 2, YnG.Height - bottomLogo.ScaledHeight);
        }
예제 #4
0
        public override void Initialize()
        {
            base.Initialize();

            int x         = (YnG.Width / 2) - menuItems[0].Width / 2;
            int y         = 0;
            int topOffset = (int)ScreenHelper.GetScaleY(290);

            for (int i = 0; i < 3; i++)
            {
                y = (int)(topOffset + i * menuItems[i].ScaledHeight * 2.25f);
                menuItems[i].Position = new Vector2(x, y);
            }

            menuItems[4].Position     = new Vector2(YnG.Width - menuItems[4].ScaledWidth - ScreenHelper.GetScaleX(45), YnG.Height - menuItems[4].ScaledHeight - ScreenHelper.GetScaleY(5));
            menuItems[3].Position     = new Vector2(menuItems[4].X - menuItems[4].ScaledWidth - ScreenHelper.GetScaleX(45), menuItems[4].Y);
            menuItemSelector.Position = new Vector2(0, menuItems[0].Y + menuItems[0].ScaledHeight / 2 - menuItemSelector.ScaledHeight / 2);
        }
예제 #5
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;
            }
        }