Пример #1
0
        public static List<SceneData> PrepareSceneDatas()
        {
            List<SceneData> datas = new List<SceneData>(16);

            SceneData data;

            for (int i = 0; i < 16; i++)
            {
                data = new SceneData();
                data.Background = "Backgrounds/Background_" + (i + 1);
                data.BottomScene = "scene_1";
                data.RightScene = "scene_2";
                data.LeftScene = "scene_3";
                data.TopScene = "scene_4";
                data.AmbienceZone = 1;
                data.Message = "Message perso";
                data.Code = "scene_" + (i + 1);
                data.Objects = PrepareObjects();
                datas.Add(data);
            }

            return datas;
        }
Пример #2
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;
            }
        }