Пример #1
0
        public void SelectLevel(object sender, EventArgs e, uint levelNum)
        {
            if (levelNum >= LevelXMLPaths.Length)
            {
                Console.WriteLine("MarioGame: Error! Tried to select level {0} but only {1} level paths are defined!", levelNum, LevelXMLPaths.Length);
                return;
            }

            if (!gameTypeSelected)
            {
                LevelCreator.Instance.LoadLevelFromXML(Environment.CurrentDirectory + LevelXMLPaths[levelNum], out levelBackground, out mainCamera, out players, out enemies, out tiles, out items);
                if (levelNum == 0)
                {
                    game_Mode = GameMode.OnePlayer;
                }
                else
                {
                    game_Mode = GameMode.TwoPlayer;
                }


                if (levelNum < LevelHUDs.Length)
                {
                    levelHUD = LevelHUDs[levelNum].Invoke();
                }
                gameTypeSelected = true;
            }
        }
Пример #2
0
        public static void LoadLayout(Stream stream, IHUD hud, int screenWidth, int screenHeight)
        {
            HUDLayout layout = (HUDLayout)Serializers.XmlDeserialize(stream, typeof(HUDLayout));

            foreach (HUDComponent clayout in layout.Components)
            {
                Dictionary <string, string> data = new Dictionary <string, string>(clayout.Data.Count);
                foreach (string dataItem in clayout.Data.FindAll(di => !string.IsNullOrEmpty(di)))
                {
                    string[] tokens = dataItem.Split('=');
                    if (!data.ContainsKey(tokens[0]))
                    {
                        data.Add(tokens[0], tokens[1]);
                    }
                }

                // parse the element
                // if the element doesn't exist quit right here
                if (!_mapping.ContainsKey(clayout.Id))
                {
                    // error, id not found
                    System.Diagnostics.Trace.TraceWarning("No IHUDComponent found with id {0}! Ignoring this entry.", clayout.Id);
                    continue;
                }

                // create this hud component and add it
                IHUDComponent component = (IHUDComponent)Activator.CreateInstance(_mapping[clayout.Id], false);
                component.X       = GetAbsX(screenWidth, clayout.X);
                component.Y       = GetAbsY(screenHeight, clayout.Y);
                component.Enabled = true;
                component.Visible = clayout.Visible;
                component.OnLoadLayout(data);
                hud.AddComponent(component);
            }
        }
Пример #3
0
        public static void SaveLayout(Stream stream, IHUD hud)
        {
            //XDocument document = new XDocument();
            //document.Add(new XElement("Layout"));

            ////foreach(IHUDComponent component in hud.

            //// currently only components are supported... more may be to come
            //foreach (var componentE in document.Root.Elements("Component"))
            //{
            //    string id = null;
            //    float posX = 0;
            //    float posY = 0;
            //    bool visible = true;
            //    Dictionary<string, string> componentData = new Dictionary<string, string>(4);

            //    foreach (var attribute in componentE.Attributes())
            //    {
            //        switch (attribute.Name.LocalName)
            //        {
            //            case "Id":
            //                id = attribute.Value;
            //                break;
            //            case "X":
            //                // CultureInfo.InvariantCulture to ensure that a ',' stays a ',' and not a '.' (german: '.' vs. english: ',' and vice versa)!
            //                float.TryParse(attribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out posX);
            //                break;
            //            case "Y":
            //                // CultureInfo.InvariantCulture to ensure that a ',' stays a ',' and not a '.' (german: '.' vs. english: ',' and vice versa)!
            //                float.TryParse(attribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out posY);
            //                break;
            //            case "Visible":
            //                bool.TryParse(attribute.Value, out visible);
            //                break;
            //            default:
            //                // unrecognized attributes are put into the data dictionary
            //                componentData.Add(attribute.Name.LocalName, attribute.Value);
            //                break;
            //        }
            //    }

            //    // parse the element
            //    // if the element doesn't exist quit right here
            //    if (!_mapping.ContainsKey(id))
            //    {
            //        // error, id not found
            //        System.Diagnostics.Trace.WriteLine("Error: No IHudComponent found with id "   id   "!");
            //        continue;
            //    }

            //    // create this hud component and add it
            //    IHUDComponent component = (IHUDComponent)Activator.CreateInstance(_mapping[id], false);
            //    // TODO: these values need to be put into percentual coordinates
            //    component.X = posX;
            //    component.Y = posY;
            //    component.Visible = visible;
            //    component.OnLoadLayout(componentData);
            //    hud.AddComponent(component);
            //}
        }
Пример #4
0
        public static void LoadScene(string sceneKey)
        {
            IsLoadingScene = true;
            canLoadScene   = CurrentScene == sceneKey;

            if (!texturesRegistered)
            {
                for (int i = 0; i < AUDIO_TEXTURES.Length; i++)
                {
                    AUDIO_TEXTURES_IDS[i] = Animator.RegisterTexture(AUDIO_TEXTURES[i]);
                    audioTextures[i]      = new Texture(gl, AUDIO_TEXTURES_IDS[i], 1);
                }
                texturesRegistered = true;

                audioIcon.Animator.AddTexture("VOLUME", AUDIO_TEXTURES_IDS[0]);
                audioIcon.Animator.AddTexture("MUTE", AUDIO_TEXTURES_IDS[1]);
                audioIcon.Animator.CurrentTexture = "VOLUME";
                audioIcon.Animator.ZIndex         = 4;

                audioIcon.Transform.SetPositionFn(() => {
                    audioIcon.Transform.Position.X = ScreenSize.X - audioSize.X - PADDING;
                    audioIcon.Transform.Position.Y = ScreenSize.Y - audioSize.Y - PADDING - (CurrentScene == "GAME" ? Game.CameraYPosition : 0);
                });
                audioIcon.AddOnClickListener(() => {
                    IsMute = !IsMute;
                    audioIcon.Animator.CurrentTexture = !IsMute ? "VOLUME" : "MUTE";
                });
            }

            IsPaused   = false;
            pauseDelay = new TimeSpan();
            for (int i = 0; i < SceneObjects.Count; i++)
            {
                SceneObjects[i].Destroy();
            }

            SceneObjects.Clear();

            HUD    = null;
            Aim    = null;
            Player = null;

            // Remove old scene
            if (!string.IsNullOrEmpty(CurrentScene) && CurrentScene != sceneKey)
            {
                scenes[CurrentScene].DisposeScene();
            }

            // Initiate the new scene
            CurrentScene = sceneKey;

            if (!canLoadScene)
            {
                // Show the loading screen before starts to load the scene
                new Thread(new ThreadStart(() => {
                    Thread.Sleep(100);
                    canLoadScene = true;
                })).Start();
            }
        }
Пример #5
0
        public override void LoadContent()
        {
            if (Camera == null)
            {
                Camera = new Camera2D(ScreenManager.GraphicsDevice);
            }

            iHUD = ScreenManager.Game.Services.GetService(typeof(IHUD)) as IHUD;
            iVisualiser = ScreenManager.Game.Services.GetService(typeof(IVisualiser)) as IVisualiser;

            //Swinger texture
            SwingerTexture = ScreenManager.Content.Load<Texture2D>("Common/slider");
            //Halo texture
            HaloTexture = ScreenManager.Content.Load<Texture2D>("Common/halo");
            //SpeedBoost texture
            SpeedBoostTexture = ScreenManager.Content.Load<Texture2D>("Common/slider");
            //bullet texture
            BulletTexture = ScreenManager.Content.Load<Texture2D>("Common/bullet");
            
            ////////////////////////////////
            //ObstacleManager
            ////////////////////////////////
            ObstacleManager = new ObstacleManager();
            ObstacleManager.LoadContent(ScreenManager);
            
            base.LoadContent();
        }
    public IHUD XCreateHUD()
    {
        global::System.IntPtr cPtr = IronSightEnginePINVOKE.IOutputWindow_XCreateHUD(swigCPtr);
        IHUD ret = (cPtr == global::System.IntPtr.Zero) ? null : new IHUD(cPtr, false);

        return(ret);
    }
Пример #7
0
 public void SetUp()
 {
     hudView         = Substitute.For <ISignupHUDView>();
     avatarEditorHUD = Substitute.For <IHUD>();
     hudController   = Substitute.ForPartsOf <SignupHUDController>();
     hudController.Configure().CreateView().Returns(info => hudView);
     hudController.Initialize(avatarEditorHUD);
 }
Пример #8
0
        private IEnumerator SetUp()
        {
            panelView       = SettingsPanelHUDView.Create();
            hudController   = Substitute.For <IHUD>();
            panelController = Substitute.For <ISettingsPanelHUDController>();

            yield return(null);
        }
Пример #9
0
        //protected IReset iReset;

        public GameScreenBase(Game game)
        {
            //iReset = game.Services.GetService(typeof(IReset)) as IReset;
            iHUD = game.Services.GetService(typeof(IHUD)) as IHUD;
            iPopUp = game.Services.GetService(typeof(IPopUpManager)) as IPopUpManager;
            World = new World(new Vector2(0, 30));
            iSoundEffect = game.Services.GetService(typeof(ISoundEffect)) as ISoundEffect;
            iScrollingBackground = game.Services.GetService(typeof(IScrollingBackground)) as IScrollingBackground;
            iVisualiser = game.Services.GetService(typeof(IVisualiser)) as IVisualiser;

        }
Пример #10
0
        public void Initialize(Stream fileStream, ICamera2D camera, IHUD hud)
        {
            Camera = camera;

            HUD = hud;

            Level = new Level(this);

            InitCrosshair();

            AddGameObjects(Level.LoadLevel(fileStream));

            AddGameObject(Player = new Player(this, Level.StartLocation));
            Player.PlayerDied   += OnPlayerDied;
        }
Пример #11
0
        public Trail(Game game)
            : base(game)
        {
            Line = game.Content.Load<Texture2D>("Materials/line");
            Sba = new SpriteBatch(game.GraphicsDevice);

            //get the visualizer service 
            iVisualiser = game.Services.GetService(typeof(IVisualiser)) as IVisualiser;
            if (iVisualiser == null)
                throw new InvalidOperationException("iVisualizer Service not found.");

            iHUD = game.Services.GetService(typeof(IHUD)) as IHUD;
            ////get the PopupManger service
            //iPopUpManager = game.Services.GetService(typeof(IPopUpManager)) as IPopUpManager;
            //if (iPopUpManager == null)
            //    throw new InvalidOperationException("iPopUpManager Serivce not found");
        }
        public void Initialize(IHUD avatarEditorHUD)
        {
            view = CreateView();
            if (view == null)
            {
                return;
            }

            this.avatarEditorHUD = avatarEditorHUD;

            signupVisible.OnChange += OnSignupVisibleChanged;
            signupVisible.Set(false);

            view.OnNameScreenNext       += OnNameScreenNext;
            view.OnEditAvatar           += OnEditAvatar;
            view.OnTermsOfServiceAgreed += OnTermsOfServiceAgreed;
            view.OnTermsOfServiceBack   += OnTermsOfServiceBack;
        }
        public void Initialize(IHUD hudController, ISettingsPanelHUDController settingsPanelController)
        {
            this.hudController           = hudController;
            this.settingsPanelController = settingsPanelController;

            openAction.OnTriggered += OpenAction_OnTriggered;

            resetAllButton.onClick.AddListener(ShowResetAllConfirmation);
            resetAllCancelButton.onClick.AddListener(HideResetAllConfirmation);
            resetAllOkButton.onClick.AddListener(ResetAllSettings);

            closeButton.onClick.AddListener(CloseSettingsPanel);
            settingsAnimator.OnWillFinishHide += OnFinishHide;

            CreateSections();
            isOpen = !settingsAnimator.hideOnEnable;
            settingsAnimator.Hide(true);
        }
Пример #14
0
        public void Initialize(Stream fileStream, ICamera2D camera, IHUD hud)
        {
            Camera = camera;

            HUD = hud;

            Level = new Level(this);

            InitCrosshair();

            AddGameObjects(Level.LoadLevel(fileStream));

            AddGameObject(Player = new Player(this, Level.StartLocation));
            Player.PlayerDied += OnPlayerDied;
        }
Пример #15
0
 public virtual void OnAttach(IHUD hud)
 {
     this.HUD = hud;
 }
 public void Initialize(IHUD hudController, ISettingsPanelHUDController settingsPanelController, SettingsSectionList sections)
 {
     settingsPanelConfig.sections = sections;
     Initialize(hudController, settingsPanelController);
 }
Пример #17
0
        public static void LoadLayout(Stream stream, IHUD hud, int screenWidth, int screenHeight)
        {
            HUDLayout layout = (HUDLayout)Serializers.XmlDeserialize(stream, typeof(HUDLayout));
            foreach (HUDComponent clayout in layout.Components)
            {
                Dictionary<string, string> data = new Dictionary<string, string>(clayout.Data.Count);
                foreach (string dataItem in clayout.Data.FindAll(di => !string.IsNullOrEmpty(di)))
                {

                    string[] tokens = dataItem.Split('=');
                    if (!data.ContainsKey(tokens[0]))
                    {
                        data.Add(tokens[0], tokens[1]);
                    }
                }

                // parse the element
                // if the element doesn't exist quit right here
                if (!_mapping.ContainsKey(clayout.Id))
                {
                    // error, id not found
                    System.Diagnostics.Trace.TraceWarning("No IHUDComponent found with id {0}! Ignoring this entry.", clayout.Id);
                    continue;
                }

                // create this hud component and add it
                IHUDComponent component = (IHUDComponent)Activator.CreateInstance(_mapping[clayout.Id], false);
                component.X = GetAbsX(screenWidth, clayout.X);
                component.Y = GetAbsY(screenHeight, clayout.Y);
                component.Enabled = true;
                component.Visible = clayout.Visible;
                component.OnLoadLayout(data);
                hud.AddComponent(component);
            }
        }
Пример #18
0
        public static void SaveLayout(Stream stream, IHUD hud)
        {
            //XDocument document = new XDocument();
            //document.Add(new XElement("Layout"));

            ////foreach(IHUDComponent component in hud.

            //// currently only components are supported... more may be to come
            //foreach (var componentE in document.Root.Elements("Component"))
            //{
            //    string id = null;
            //    float posX = 0;
            //    float posY = 0;
            //    bool visible = true;
            //    Dictionary<string, string> componentData = new Dictionary<string, string>(4);

            //    foreach (var attribute in componentE.Attributes())
            //    {
            //        switch (attribute.Name.LocalName)
            //        {
            //            case "Id":
            //                id = attribute.Value;
            //                break;
            //            case "X":
            //                // CultureInfo.InvariantCulture to ensure that a ',' stays a ',' and not a '.' (german: '.' vs. english: ',' and vice versa)!
            //                float.TryParse(attribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out posX);
            //                break;
            //            case "Y":
            //                // CultureInfo.InvariantCulture to ensure that a ',' stays a ',' and not a '.' (german: '.' vs. english: ',' and vice versa)!
            //                float.TryParse(attribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out posY);
            //                break;
            //            case "Visible":
            //                bool.TryParse(attribute.Value, out visible);
            //                break;
            //            default:
            //                // unrecognized attributes are put into the data dictionary
            //                componentData.Add(attribute.Name.LocalName, attribute.Value);
            //                break;
            //        }
            //    }

            //    // parse the element
            //    // if the element doesn't exist quit right here
            //    if (!_mapping.ContainsKey(id))
            //    {
            //        // error, id not found
            //        System.Diagnostics.Trace.WriteLine("Error: No IHudComponent found with id "   id   "!");
            //        continue;
            //    }

            //    // create this hud component and add it
            //    IHUDComponent component = (IHUDComponent)Activator.CreateInstance(_mapping[id], false);
            //    // TODO: these values need to be put into percentual coordinates
            //    component.X = posX;
            //    component.Y = posY;
            //    component.Visible = visible;
            //    component.OnLoadLayout(componentData);
            //    hud.AddComponent(component);
            //}
        }
Пример #19
0
 public virtual void OnAttach(IHUD hud)
 {
     this.HUD = hud;
 }
Пример #20
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(IHUD obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #21
0
    public virtual IHUD CreateHUD(HUDElementID hudElementId)
    {
        IHUD hudElement = null;

        switch (hudElementId)
        {
        case HUDElementID.NONE:
            break;

        case HUDElementID.MINIMAP:
            hudElement = new MinimapHUDController();
            break;

        case HUDElementID.PROFILE_HUD:
            hudElement = new ProfileHUDController();
            break;

        case HUDElementID.NOTIFICATION:
            hudElement = new NotificationHUDController();
            break;

        case HUDElementID.AVATAR_EDITOR:
            hudElement = new AvatarEditorHUDController();
            break;

        case HUDElementID.SETTINGS_PANEL:
            hudElement = new SettingsPanelHUDController();
            break;

        case HUDElementID.EXPRESSIONS:
            hudElement = new ExpressionsHUDController();
            break;

        case HUDElementID.PLAYER_INFO_CARD:
            hudElement = new PlayerInfoCardHUDController();
            break;

        case HUDElementID.AIRDROPPING:
            hudElement = new AirdroppingHUDController();
            break;

        case HUDElementID.TERMS_OF_SERVICE:
            hudElement = new TermsOfServiceHUDController();
            break;

        case HUDElementID.WORLD_CHAT_WINDOW:
            hudElement = new WorldChatWindowHUDController();
            break;

        case HUDElementID.FRIENDS:
            hudElement = new FriendsHUDController();
            break;

        case HUDElementID.PRIVATE_CHAT_WINDOW:
            hudElement = new PrivateChatWindowHUDController();
            break;

        case HUDElementID.TASKBAR:
            hudElement = new TaskbarHUDController();
            break;

        case HUDElementID.MESSAGE_OF_THE_DAY:
            hudElement = new WelcomeHUDController();
            break;

        case HUDElementID.OPEN_EXTERNAL_URL_PROMPT:
            hudElement = new ExternalUrlPromptHUDController();
            break;

        case HUDElementID.NFT_INFO_DIALOG:
            hudElement = new NFTPromptHUDController();
            break;

        case HUDElementID.TELEPORT_DIALOG:
            hudElement = new TeleportPromptHUDController();
            break;

        case HUDElementID.CONTROLS_HUD:
            hudElement = new ControlsHUDController();
            break;

        case HUDElementID.EXPLORE_HUD:
            hudElement = new ExploreHUDController();
            break;

        case HUDElementID.HELP_AND_SUPPORT_HUD:
            hudElement = new HelpAndSupportHUDController();
            break;

        case HUDElementID.USERS_AROUND_LIST_HUD:
            hudElement = new UsersAroundListHUDController();
            break;

        case HUDElementID.GRAPHIC_CARD_WARNING:
            hudElement = new GraphicCardWarningHUDController();
            break;

        case HUDElementID.BUILDER_IN_WORLD_MAIN:
            hudElement = new BuildModeHUDController();
            break;

        case HUDElementID.QUESTS_PANEL:
            hudElement = new QuestsPanelHUDController();
            break;

        case HUDElementID.QUESTS_TRACKER:
            hudElement = new QuestsTrackerHUDController();
            break;

        case HUDElementID.SIGNUP:
            hudElement = new SignupHUDController();
            break;

        case HUDElementID.BUILDER_PROJECTS_PANEL:
            hudElement = new BuilderProjectsPanelController();
            break;

        case HUDElementID.LOADING:
            hudElement = new LoadingHUDController();
            break;

        case HUDElementID.AVATAR_NAMES:
            hudElement = new AvatarNamesHUDController();
            break;
        }

        return(hudElement);
    }