Inheritance: MonoBehaviour
 // track the game state
 // track score
 // track money
 // track lives
 // Use this for initialization
 void Start()
 {
     curGameState = GameState.NotInGame;
     gameMenu = gameObject.GetComponent<GameMenu>();
     enemyManager = gameObject.GetComponent < EnemyManager> ();
     gridManager = gameObject.GetComponent<GridManager> ();
 }
Exemple #2
0
 public void gameEnded()
 {
     this.gameCount++;
     this.playerTurn = 1; // Reset player turn
     Console.WriteLine("game ended {0}",this.currentGameState);
     gameMenu = new GameMenu(this);
 }
 void Awake()
 {
     fireArrival = 0;
     player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
     respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>();
     gameMenu = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<GameMenu>();
 }
Exemple #4
0
    GameMgr()
    {
        if (Instance != null) throw new UnityException ("Tried to instantiate singleton more than once: "  + this);
        Instance = this;

        menu = new GameMenu ();
    }
 void Awake()
 {
     wasPlayed = false;
     player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
     respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>();
     gameMenu = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<GameMenu>();
 }
Exemple #6
0
 public Menu(LonharGame game)
     : base(game)
 {
     gameMenu = new GameMenu(GameMenu.Direction.Vertical);
     gameMenu.Buttons.Add(new Button(new Rectangle(50, 50, 200, 50), game, Color.Green, Color.GreenYellow, Button.TEXT_ALIGN_MID, "Play", game.ButtonFont));
     gameMenu.Buttons.Add(new Button(new Rectangle(50, 110, 200, 50), game, Color.Green, Color.GreenYellow, Button.TEXT_ALIGN_MID, "Editor", game.ButtonFont));
     gameMenu.Buttons.Add(new Button(new Rectangle(50, 170, 200, 50), game, Color.Green, Color.GreenYellow, Button.TEXT_ALIGN_MID, "Exit", game.ButtonFont));
 }
Exemple #7
0
 public void ShowMenu(GameMenu menu)
 {
     if (CurrentMenu != null)
     {
         CurrentMenu.IsOpen = false;
     }
     CurrentMenu = menu;
     CurrentMenu.IsOpen = true;
 }
Exemple #8
0
 public Game(LonharGame game)
     : base(game)
 {
     playerShip = new PlayerShip(game, new Vector2(300, 150));
     planets = new List<Planet>();
     planets.Add(new Planet(game, 5500f, 6380000, new Vector2(300, 300)));
     planets.Add(new Planet(game, 5500f, 6380000, new Vector2(600, 300)));
     planets[0].Selected = true;
     pauseMenu = new PauseMenu(game);
 }
Exemple #9
0
        public Editor(LonharGame game)
            : base(game)
        {
            camera = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height);
            cursorPos = new Vector2();
            editorMenu = new GameMenu(GameMenu.Direction.Vertical);
            editorMenu.Buttons.Add(new Button(new Rectangle(650, 50, 125, 50), game, Color.Thistle, Color.White));
            editorMenu.Buttons.Add(new Button(new Rectangle(650, 110, 125, 50), game, Color.Thistle, Color.White));

            pauseMenu = new PauseMenu(game);
        }
    /// <summary>
    /// Initialize EyeX host and game menu on Awake
    /// </summary>
    public void Awake()
    {
        _eyeXHost = EyeXHost.GetInstance();

        _gameMenu = GameObject.Find("Game Menu").GetComponent<GameMenu>();

        // add all GUITextures under game menu to the list of menu items
        foreach (Transform childTransform in transform)
        {
            _menuItems.Add(childTransform);
        }
    }
        public override void Draw(GameMenu menu, bool isSelected, float dt)
        {
            if (Flashing) {
                if (alpha >= 1.0) {
                    diff = -0.7f * dt;
                } else if (alpha <= 0.0) { //completely fade out
                    diff = 0.7f * dt;
                }
                alpha += diff;
            }

            if (isSelected) {
                Stage.renderer.SpriteBatch.Draw(graphicHover, dim, Color.White * alpha);
            } else {
                Stage.renderer.SpriteBatch.Draw(graphic, dim, Color.White * alpha);
            }
        }
Exemple #12
0
        public void AddBrodeeSettingsButton(UIEvent.Handler onReleaseHandler)
        {
            if (!IsButtonContainerAvailable())
            {
                return;
            }
            var buttonListMenuDef = GetButtonListMenuDef();
            var slices            = buttonListMenuDef.m_buttonContainer.m_slices.ToArray();
            var button            = GameMenu.Get().CreateMenuButton(GlobalStrings.BrodeeSettingsButton, "Brodee", onReleaseHandler);

            button.gameObject.SetActive(true);
            buttonListMenuDef.m_buttonContainer.ClearSlices();
            buttonListMenuDef.m_buttonContainer.AddSlice(button.gameObject, Vector3.zero, Vector3.zero);
            foreach (var slice in slices)
            {
                buttonListMenuDef.m_buttonContainer.AddSlice(slice.m_slice, slice.m_minLocalPadding, slice.m_maxLocalPadding, slice.m_reverse);
            }
            buttonListMenuDef.m_buttonContainer.UpdateSlices();
        }
Exemple #13
0
    protected virtual void Start()
    {
        gameMenu    = FindObjectOfType <GameMenu>();
        gameEndText = GameObject.FindGameObjectWithTag("Finish").GetComponent <Text>();
        gameEndText.gameObject.SetActive(false);
        hintCanvas = FindObjectOfType <HintCanvas>();
        hintCanvas.HideHint();

        if (PlayerPrefs.GetString(VersionKey, "") != version)
        {
            PlayerPrefs.SetInt(PlayerFirstWin, 0);
            PlayerPrefs.SetInt(PlayerFirstLose, 0);
            PlayerPrefs.SetInt(PlayerFirstTie, 0);
            PlayerPrefs.SetInt(AiFirstWin, 0);
            PlayerPrefs.SetInt(AiFirstLose, 0);
            PlayerPrefs.SetInt(AiFirstTie, 0);
            PlayerPrefs.SetString(VersionKey, version);
        }
    }
 void Awake()
 {
     onPlayerCaught = new UnityEvent();
     onPlayerCaught.AddListener(PlayerCaught);
     onPlayerWin = new UnityEvent();
     onPlayerWin.AddListener(PlayerWin);
     gameMenu      = GameObject.Find("Canvas").GetComponent <GameMenu>();
     gameOverText  = GameObject.Find("GameOverText").GetComponent <Text>();
     mirrorManager = GameObject.Find("MirrorManager").GetComponent <MirrorManager>();
     playerVision  = GameObject.Find("Player").GetComponent <PlayerVision>();
     progressText  = GameObject.Find("ProgressText").GetComponent <Text>();
     stopwatch     = new Stopwatch();
     stopwatch.Start();
     deathAudio  = GetComponent <AudioSource>();
     secretDoors = new Vector3Int[] { new Vector3Int(-14, 11, 0),
                                      new Vector3Int(-14, 12, 0),
                                      new Vector3Int(13, 11, 0),
                                      new Vector3Int(13, 12, 0) };
 }
Exemple #15
0
        static void Main(string[] args)
        {
            GameMenu game = new GameMenu();

            for (int i = 0; i < 54; i++)
            {
                (new GameService()).NextTick(game);
            }
            (new StoreService()).Save(game, "C:\\Users\\Nikita\\Desktop\\save.xml");
            Console.ReadKey();
            for (int i = 0; i < 150; i++)
            {
                (new GameService()).NextTick(game);
            }

            game = (new StoreService().Load("C:\\Users\\Nikita\\Desktop\\save.xml"));
            Console.WriteLine(game.Time.ToString("O"));
            Console.ReadKey();
        }
Exemple #16
0
        public void IncomeCalculate(GameMenu game)
        {
            double k = 1;

            if (game.Person.Mood <= 30)
            {
                k = 0.5;
            }
            else
            {
                if (game.Person.Mood > 90)
                {
                    k = 1.5;
                }
            }

            game.Person.Income = (int)(k * game.Person.Jobs[game.Person.Job]);
            //0-30 mood: 0,5*income; 31-90: 1* income; 91-100: 1,5*income
        }
Exemple #17
0
 protected override void Awake()
 {
     base.m_menuParent = this.m_menuBone;
     base.Awake();
     s_instance = this;
     this.LoadRatings();
     this.m_concedeButton = base.CreateMenuButton("ConcedeButton", "GLOBAL_CONCEDE", new UIEvent.Handler(this.ConcedeButtonPressed));
     if (ApplicationMgr.CanQuitGame != null)
     {
         this.m_quitButton = base.CreateMenuButton("QuitButton", "GLOBAL_QUIT", new UIEvent.Handler(this.QuitButtonPressed));
     }
     else
     {
         this.m_quitButton = base.CreateMenuButton("LogoutButton", !Network.ShouldBeConnectedToAurora() ? "GLOBAL_LOGIN" : "GLOBAL_LOGOUT", new UIEvent.Handler(this.LogoutButtonPressed));
     }
     this.m_resumeButton           = base.CreateMenuButton("ResumeButton", "GLOBAL_RESUME_GAME", new UIEvent.Handler(this.ResumeButtonPressed));
     this.m_optionsButton          = base.CreateMenuButton("OptionsButton", "GLOBAL_OPTIONS", new UIEvent.Handler(this.OptionsButtonPressed));
     base.m_menu.m_headerText.Text = GameStrings.Get("GLOBAL_GAME_MENU");
 }
    public void CreateMenu(GameMenu menu)
    {
        GameObject menuObject = Instantiate(menu.gameObject, SceneCanvas.transform);

        SpawnEventSystem();
        GameMenu menuComponent = menuObject.GetComponent <GameMenu>();

        System.Type type = menuComponent.GetType();

        if (type == typeof(StartMenu))
        {
            AddStartMenuFunctionality((StartMenu)menuComponent);
        }
        else if (type == typeof(SettingMenu))
        {
            AddSettingMenuFunctionality((SettingMenu)menuComponent);
        }
        activeMenus.Add(menuComponent);
    }
        private void LoadPlayableMaps()
        {
            contentTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 75f * defaultMapData.Count + 10f);

            int counter = 0;

            foreach (MapData map in defaultMapData)
            {
                string pb = "-";
                long   pbTime;
                Assert.IsNotNull(PlayerSave.current);
                if (PlayerSave.current.GetPersonalBest(map, out pbTime))
                {
                    pb = pbTime.ToTimeString();
                }
                GameObject panel = GameMenu.CreatePanel(counter, mapPanelPrefab, contentTransform);
                panel.GetComponent <MapPanel>().Set(counter++, map, pb);
            }
        }
        public void OnStealAttempt(Settlement currentSettlement, bool wasDetected, int ammountFromProsperity, int quantityStolen)
        {
            if (KleptomaniaSubModule.settings.DebugInfo)
            {
                InformationManager.DisplayMessage(new InformationMessage("Detected = " + wasDetected + ". Steal Quantity = " + quantityStolen, Colors.Yellow));
            }
            KleptomaniaSubModule.Log.Info("Stealing | Steal sucessfull. Quantity: " + quantityStolen.ToString() + " %. Detected: " + wasDetected.ToString());

            if (currentSettlement.IsTown)
            {
                GameMenu.SwitchToMenu("town");
                if (quantityStolen > 0)
                {
                    currentSettlement.Prosperity -= ammountFromProsperity * 5;
                }
            }
            else if (currentSettlement.IsVillage)
            {
                GameMenu.SwitchToMenu("village");
                if (quantityStolen > 0)
                {
                    currentSettlement.Village.Hearth -= ammountFromProsperity;
                }
            }
            if (KleptomaniaSubModule.settings.DebugInfo)
            {
                InformationManager.DisplayMessage(new InformationMessage("Settlement Hearth / prosperity decreased by " + ammountFromProsperity.ToString(), Colors.Yellow));
            }
            KleptomaniaSubModule.Log.Info("Stealing | Settlement " + currentSettlement.Name + " hearth/prosperity decreased by " + ammountFromProsperity.ToString());

            IncreaseRecentStealPenalty(currentSettlement.MapFaction);
            if (wasDetected)
            {
                OnDetection(currentSettlement);
                if (this._settlementLastStealDetectionTimeDictionary != null)
                {
                    _settlementLastStealDetectionTimeDictionary.Add(currentSettlement.StringId, CampaignTime.Now);
                }
            }

            LootStolenGoods(currentSettlement, ammountFromProsperity, quantityStolen);
            stealUtils.GiveRogueryXp(Hero.MainHero);
        }
Exemple #21
0
        //Start animation that replace the current menu with the next.
        private void ToNextMenu(GameMenu nextGameMenu)
        {
            GameMenu     oldGameMenu = _menuesStack.Peek();
            ReplaceMenus animate     = new ReplaceMenus(oldGameMenu, nextGameMenu)
            {
                TimeToReach      = PANEL_TIME_TO_LEAVE,
                WindowSize       = SizeVector,
                AnimateDirection = Direction.Up
            };

            animate.ActionInEnd += () =>
            {
                _menuesStack.Push(nextGameMenu);
                Animations.Remove(animate);
            };

            Animations.Add(animate);
            animate.StartAnimate();
        }
Exemple #22
0
 public void ReplaceMapPoints()
 {
     points = this.GetMapPoints().ToList();
     // update vanilla points (for compatibility with mods that check them), but make sure they don't peek out from under new map
     if (Game1.activeClickableMenu != null)
     {
         GameMenu gameMenu = (GameMenu)Game1.activeClickableMenu;
         List <IClickableMenu> menuPages = (List <IClickableMenu>) typeof(GameMenu).GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gameMenu);
         MapPage mapPage = (MapPage)menuPages[gameMenu.currentTab];
         List <ClickableComponent> vanillaPoints = Helper.Reflection.GetField <List <ClickableComponent> >(mapPage, "points").GetValue();
         vanillaPoints.Clear();
         foreach (ClickableComponent point in this.GetMapPoints())
         {
             point.label = "";
             point.scale = 0.1f;
             vanillaPoints.Add(point);
         }
     }
 }
Exemple #23
0
        public static void CheckKeyboardInput(GameMenu menu)
        {
            previousKB = currentKB;
            currentKB  = Keyboard.GetState();
            if (currentKB.IsKeyUp(Keys.Escape) && previousKB.IsKeyDown(Keys.Escape))
            {
                                #if PLAY_SOUND
                MediaPlayer.Stop();
                if (GameController.MusicOn)
                {
                    MediaPlayer.Play(GameController.Menusong);
                }
                menu.menuOpen.Play(GameController.SoundVolume, 0, 0);
                                #endif
                GameController.Paused = !GameController.Paused;
            }

            CheckForMuteMusicAndSound();
        }
Exemple #24
0
        private void OnRandomNotificationInspect()
        {
            CEHelper.notificationEventExists = false;
            ExecuteRemove();
            string result = new CEEventChecker(_randomEvent).FlagsDoMatchEventConditions(CharacterObject.PlayerCharacter);

            if (result == null)
            {
                if (!(Game.Current.GameStateManager.ActiveState is MapState mapState))
                {
                    TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met.");
                    InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray));
                    return;
                }

                Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode;

                if (!mapState.AtMenu)
                {
                    if (CECampaignBehavior.ExtraProps != null)
                    {
                        CECampaignBehavior.ExtraProps.menuToSwitchBackTo = null;
                        CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = null;
                    }
                    GameMenu.ActivateGameMenu(_randomEvent.Name);
                }
                else
                {
                    if (CECampaignBehavior.ExtraProps != null)
                    {
                        CECampaignBehavior.ExtraProps.menuToSwitchBackTo = mapState.GameMenuId;
                        CECampaignBehavior.ExtraProps.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName;
                    }
                    GameMenu.SwitchToMenu(_randomEvent.Name);
                }
            }
            else
            {
                TextObject textObject = new TextObject("{=CEEVENTS1058}Event conditions are no longer met.");
                InformationManager.DisplayMessage(new InformationMessage(textObject.ToString(), Colors.Gray));
            }
        }
        private void ArmSeperatists()
        {
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (ItemRosterElement item in PartyBase.MainParty.ItemRoster)
            {
                if (isWeapon(item.EquipmentElement.Item))
                {
                    inquiryElements.Add(new InquiryElement((object)new Tuple <EquipmentElement, int>(item.EquipmentElement, item.Amount), (item.EquipmentElement.ItemModifier == null ? item.EquipmentElement.Item.Name.ToString() : (item.EquipmentElement.ItemModifier.Name.ToString()) + item.EquipmentElement.Item.Name.ToString()) + " - " + item.Amount, new ImageIdentifier(item.EquipmentElement.Item)));
                }
            }
            if (inquiryElements.Count < 1)
            {
                InformationManager.ShowInquiry(new InquiryData("No weapons in inventory", "", true, false, "OK", "", (Action)null, (Action)null), true);
                GameMenu.SwitchToMenu("town");
            }
            else
            {
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("", "Select Weapons to give seperatists", inquiryElements, true, 1000, "Continue", (string)null, (Action <List <InquiryElement> >)(args =>
                {
                    List <InquiryElement> source = args;
                    if (source != null && !source.Any <InquiryElement>())
                    {
                        return;
                    }
                    InformationManager.HideInquiry();
                    float WeaponsValue = 0;
                    IEnumerable <Tuple <EquipmentElement, int> > selected = args.Select <InquiryElement, Tuple <EquipmentElement, int> >((Func <InquiryElement, Tuple <EquipmentElement, int> >)(element => element.Identifier as Tuple <EquipmentElement, int>));
                    foreach (Tuple <EquipmentElement, int> pair in selected)
                    {
                        WeaponsValue += pair.Item2 * (2 + Math.Min((int)pair.Item1.Item.Tierf, 6));
                        PartyBase.MainParty.ItemRoster.Remove(new ItemRosterElement(pair.Item1, pair.Item2));
                    }
                    Settlement.CurrentSettlement.Militia += WeaponsValue / 2;
                    float loyaltyChange = Math.Min(100 * (WeaponsValue / Math.Max(Settlement.CurrentSettlement.Town.Prosperity, 1)), Settlement.CurrentSettlement.Town.Loyalty);
                    Settlement.CurrentSettlement.Town.Loyalty -= loyaltyChange;
                    ChangeRelationAction.ApplyPlayerRelation(Settlement.CurrentSettlement.OwnerClan.Leader, (int)(-1 * loyaltyChange));
                    ChangeCrimeRatingAction.Apply(Settlement.CurrentSettlement.MapFaction, loyaltyChange);
                    Hero.MainHero.AddSkillXp(DefaultSkills.Roguery, WeaponsValue * 10);
                }), (Action <List <InquiryElement> >)null));
            }
        }
Exemple #26
0
    public void HideMenu(MenuTag menuTag)
    {
        if (!CheckInitialized())
        {
            return;
        }

        GameMenu selectedMenu = SelectGameMenu(menuTag);

        if (selectedMenu == null)
        {
            return;
        }

        canvasAnimator.Play("ShowPrompt", 0);
        canvasAnimator.Play(selectedMenu.closePanelAnimName, 1);

        selectedMenu.OnPanelClose();
        AllowPlayer();
    }
Exemple #27
0
        private void MainCastleMenu(CampaignGameStarter campaignGameStarter)
        {
            campaignGameStarter.AddGameMenuOption("castle", "ruler_castle", "Ruler Action", (GameMenuOption.OnConditionDelegate)(args =>
            {
                if (Settlement.CurrentSettlement.OwnerClan != Hero.MainHero.Clan)
                {
                    return(false);
                }
                args.optionLeaveType = GameMenuOption.LeaveType.Submenu;
                return(true);
            }), (GameMenuOption.OnConsequenceDelegate)(args => GameMenu.SwitchToMenu("ruler_castle_menu")), index: 1);

            campaignGameStarter.AddGameMenu("ruler_castle_menu", "You can issue special grants and decrees here", (OnInitDelegate)(args => { }), GameOverlays.MenuOverlayType.SettlementWithBoth);

            campaignGameStarter.AddGameMenuOption("ruler_castle_menu", "ruler_castle_menu_leave", "Back", (GameMenuOption.OnConditionDelegate)(args =>
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Leave;
                return(true);
            }), (GameMenuOption.OnConsequenceDelegate)(args => GameMenu.SwitchToMenu("castle")));
        }
Exemple #28
0
    void ShowMenu(MenuTag menuTag)
    {
        if (!CheckInitialized())
        {
            return;
        }

        GameMenu selectedMenu = SelectGameMenu(menuTag);

        if (selectedMenu == null)
        {
            return;
        }

        canvasAnimator.Play("HidePrompt", 0);
        canvasAnimator.Play(selectedMenu.openPanelAnimName, 1);

        selectedMenu.OnPanelOpen();
        BlockPlayer();
    }
Exemple #29
0
        internal void CEKillPlayer(Hero killer)
        {
            GameMenu.ExitToLast();

            try
            {
                if (killer != null)
                {
                    KillCharacterAction.ApplyByMurder(Hero.MainHero, killer);
                }
                else
                {
                    KillCharacterAction.ApplyByMurder(Hero.MainHero);
                }
            }
            catch (Exception e)
            {
                CECustomHandler.ForceLogToFile("Failed CEKillPlayer " + e);
            }
        }
Exemple #30
0
    public void SetZoneData(MenuTag tag)
    {
        if (!CheckInitialized())
        {
            return;
        }

        GameMenu selectedMenu = SelectGameMenu(tag);

        if (selectedMenu == null)
        {
            return;
        }

        zoneTitleText.text  = selectedMenu.title;
        zonePromptText.text = selectedMenu.buttonPrompt;

        zonePromptButton.onClick.RemoveAllListeners();
        zonePromptButton.onClick.AddListener(() => ShowMenu(tag));
    }
Exemple #31
0
        //Start animation that replace the current menu with the old one.
        private void ToOldMenu(Action doInEnd = null)
        {
            GameMenu     currentGameMenu = _menuesStack.Pop();
            GameMenu     oldGameMenu     = _menuesStack.Peek();
            ReplaceMenus animate         = new ReplaceMenus(currentGameMenu, oldGameMenu)
            {
                TimeToReach      = PANEL_TIME_TO_LEAVE,
                WindowSize       = SizeVector,
                AnimateDirection = Direction.Down
            };

            animate.ActionInEnd += () =>
            {
                Animations.Remove(animate);
                doInEnd?.Invoke();
            };

            Animations.Add(animate);
            animate.StartAnimate();
        }
Exemple #32
0
        private void OnUpdateTick(object sender, EventArgs e)
        {
            // Check for menu closed events
            if (!wasMenuClosedInvoked && previousMenu != null && Game1.activeClickableMenu == null)
            {
                wasMenuClosedInvoked = true;
                OnClickableMenuClosed(previousMenu);
            }

            if (isGameMenuOpen)
            {
                GameMenu    gameMenu   = (GameMenu)Game1.activeClickableMenu;
                GameMenuTab currentTab = (GameMenuTab)gameMenu.currentTab;
                if (previousTab != currentTab)
                {
                    OnGameMenuTabChanged(previousTab, currentTab);
                    previousTab = currentTab;
                }
            }
        }
        private static void LordLeavesAlonePrisoners(Settlement settlement, MobileParty captorParty)
        {
            Hero prisoner;

            while ((prisoner = settlement.HeroesWithoutParty.FirstOrDefault(p => PrisonerIsOwnedByHero(p, captorParty.LeaderHero))) != null)
            {
                prisoner.StayingInSettlementOfNotable = null;

                if (prisoner.IsHumanPlayerCharacter)
                {
                    GameMenu.SwitchToMenu("settlement_wait");
                }

#if ENABLE_LOGS
                InformationManager.DisplayMessage(new InformationMessage(captorParty.LeaderHero.Name + " leaves alone prisoner " + prisoner.Name));
#endif // ENABLE_LOGS

                ZenDzeeRomanceHelper.EndLoversRomance(captorParty.LeaderHero, prisoner, ZenDzeeRomanceHelper.RomanceLevel_Prisoner);
            }
        }
        private static void ShowChildrenToAdopt()
        {
            var currentSettlement = Hero.MainHero.CurrentSettlement;
            var lostChildren      = OrphanAdoptionHelper.ChildrenForAdoptionAtSettlement(currentSettlement);

            var inquiryElements = new List <InquiryElement>();

            foreach (var hero in lostChildren)
            {
                var identifier = new ImageIdentifier(CharacterCode.CreateFrom(hero.CharacterObject));
                inquiryElements.Add(new InquiryElement(hero,
                                                       hero.Name + " - " + Math.Floor(hero.BirthDay.ElapsedYearsUntilNow),
                                                       identifier));
            }

            if (inquiryElements.Count < 1)
            {
                InformationManager.ShowInquiry(
                    new InquiryData("No child",
                                    "Empty orphanage", true, false, "OK", "", null, null),
                    true);
                GameMenu.SwitchToMenu("town");
            }
            else
            {
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(
                                                                 "Children you may adopt", "", inquiryElements, true, 1, "Continue", null, args =>
                {
                    if (args == null)
                    {
                        return;
                    }
                    if (!args.Any())
                    {
                        return;
                    }
                    InformationManager.HideInquiry();
                    ConfirmAdoption(args.Select(element => element.Identifier as Hero).First());
                }, null));
            }
        }
Exemple #35
0
        private void Events_DrawTick(object sender, EventArgs e)
        {
            if (Game1.activeClickableMenu == null)
            {
                return;
            }

            Item obj = null;

            if (Game1.activeClickableMenu is GameMenu)
            {
                GameMenu gameMenu            = (GameMenu)Game1.activeClickableMenu;
                IList <IClickableMenu> pages = this.Helper.Reflection.GetPrivateValue <List <IClickableMenu> >(gameMenu, "pages");
                if (gameMenu.currentTab == 0)
                {
                    obj = this.Helper.Reflection.GetPrivateValue <Item>(pages[0], "hoveredItem");
                }
                else if (gameMenu.currentTab == 4)
                {
                    obj = this.Helper.Reflection.GetPrivateValue <Item>(pages[4], "hoverItem");
                }
            }
            else if (Game1.activeClickableMenu is MenuWithInventory)
            {
                MenuWithInventory menuWithInventory = (MenuWithInventory)Game1.activeClickableMenu;
                obj = menuWithInventory.hoveredItem;
            }

            if (obj == null)
            {
                return;
            }

            foreach (int bundleIndex in neededItems.Keys)
            {
                if (obj.parentSheetIndex != -1 && neededItems[bundleIndex].ContainsKey(obj.parentSheetIndex))
                {
                    drawNeededText(Game1.smallFont);
                }
            }
        }
Exemple #36
0
        private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
        {
            if (Game1.activeClickableMenu is GameMenu)
            {
                GameMenu activeMenu = (GameMenu)Game1.activeClickableMenu;
                List <IClickableMenu> gameMenuPages = Helper.Reflection.GetPrivateField <List <IClickableMenu> >(activeMenu, "pages").GetValue();

                foreach (IClickableMenu menu in gameMenuPages)
                {
                    if (menu is CraftingPage)
                    {
                        List <ClickableTextureComponent> replaceComponents = new List <ClickableTextureComponent>();
                        CraftingPage craftingPage = (CraftingPage)menu;
                        List <Dictionary <ClickableTextureComponent, CraftingRecipe> > pagesOfCraftingRecipes = craftingPage.pagesOfCraftingRecipes;

                        foreach (Dictionary <ClickableTextureComponent, CraftingRecipe> dict in pagesOfCraftingRecipes)
                        {
                            foreach (ClickableTextureComponent ctc in dict.Keys)
                            {
                                if (ctc.sourceRect.X < 0 || ctc.sourceRect.Y < 0)
                                {
                                    ctc.name = dict[ctc].name;
                                    replaceComponents.Add(ctc);
                                }
                            }
                        }

                        for (int c = 0; c < replaceComponents.Count; c++)
                        {
                            if (machinesForCrafting.ContainsKey(replaceComponents[c].name))
                            {
                                replaceComponents[c].texture    = machinesForCrafting[replaceComponents[c].name].Texture;
                                replaceComponents[c].sourceRect = machinesForCrafting[replaceComponents[c].name].sourceRectangle;
                            }
                        }
                    }
                }

                Helper.Reflection.GetPrivateField <List <IClickableMenu> >(Game1.activeClickableMenu, "pages").SetValue(gameMenuPages);
            }
        }
        /// <summary>
        /// Reduces the cost of the crab pot - intended to be used if the player has the Tapper profession
        /// </summary>
        /// <param name="gameMenu">The game menu that needs its cost adjusted</param>
        private static void ReduceCrabPotCost(GameMenu gameMenu)
        {
            CraftingPage craftingPage = (CraftingPage)gameMenu.pages[GameMenu.craftingTab];

            List <Dictionary <ClickableTextureComponent, CraftingRecipe> > pagesOfCraftingRecipes =
                (List <Dictionary <ClickableTextureComponent, CraftingRecipe> >)GetInstanceField(craftingPage, "pagesOfCraftingRecipes");

            foreach (Dictionary <ClickableTextureComponent, CraftingRecipe> page in pagesOfCraftingRecipes)
            {
                foreach (ClickableTextureComponent key in page.Keys)
                {
                    CraftingRecipe recipe = page[key];
                    if (recipe.name == "Crab Pot")
                    {
                        CraftableItem         crabPot          = (CraftableItem)ItemList.Items[(int)ObjectIndexes.CrabPot];
                        Dictionary <int, int> randomizedRecipe = crabPot.LastRecipeGenerated;
                        ReduceRecipeCost(page[key], randomizedRecipe);
                    }
                }
            }
        }
Exemple #38
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        isPlaying = false;
        gameMenu  = gameObject.AddComponent <GameMenu>();

        Vector3 screenInfo     = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height));
        float   playableWidth  = screenInfo.x * 0.85f;
        float   playableHeight = screenInfo.y * 0.85f;

        xMax = System.Math.Min(5.0f, playableWidth); xMin = System.Math.Max(-4.75f, -playableWidth);
        yMax = playableHeight; yMin = -playableHeight / 2.0f;
    }
Exemple #39
0
        public void OnBackToMenu()
        {
            Game.Components.Remove(this.gameMenu);

            if (this.gameMenu != null)
            {
                this.gameMenu.Dispose();
            }

            this.gameMenu = null;
            this.Initialize();
            Menu menu = new Menu(this.game);

            Game.Components.Add(menu);
            Camera      cam = Game.Services.GetService(typeof(Camera)) as Camera;
            IHUDService hud = Game.Services.GetService(typeof(IHUDService)) as IHUDService;

            hud.clearMessage();
            cam.resetCamera();
            this.gameLogicInputController.pause();
        }
Exemple #40
0
 private static void WatchSiegeConsequence(MenuCallbackArgs args)
 {
     try
     {
         if (PlayerEncounter.IsActive)
         {
             PlayerEncounter.LeaveEncounter = false;
         }
         else
         {
             TaleWorlds.CampaignSystem.Campaign.Current.HandleSettlementEncounter(MobileParty.MainParty, PlayerSiege.PlayerSiegeEvent.BesiegedSettlement);
         }
         WatchMode = true;
         GameMenu.SwitchToMenu("assault_town");
     }
     catch (Exception e)
     {
         WatchMode = false;
         Utility.DisplayMessage(e.ToString());
     }
 }
        public void HandleMenu(GameObject menu)
        {
            GameMenu gameMenu = menu.GetComponent <GameMenu>();

            if (gameMenu.visible)
            {
                gameMenu.FadeOut(menu);
            }
            else
            {
                foreach (GameObject m in menus.Where(m => m != menu))
                {
                    GameMenu gm = m.GetComponent <GameMenu>();
                    if (gm.visible)
                    {
                        gm.FadeOut(m);
                    }
                }
                gameMenu.FadeIn(menu);
            }
        }
 // Remembers state information, makes decisions
 // gets input from others, informs whoever needs it whenever they need it
 // TODO: Next round....
 void Start()
 {
     towerCreator = gameObject.GetComponent<TowerCreator> ();
     gameManager = gameObject.GetComponent<GameManager> ();
     gameMenu = gameObject.GetComponent<GameMenu> ();
     towerInfo = gameObject.GetComponent<TowerInfo> ();
     enemyManager = gameObject.GetComponent<EnemyManager> ();
 }
    void StartChangeGameMenu(State state)
    {
        ResetAllMenusAndButtons ();

        if (mCurrentGameMenu == mGameMenus[(int)state])
        {
            if (mMenuChangePhase)
            {
                // switch
                GameMenu a = mNextGameMenu;
                mNextGameMenu = mCurrentGameMenu;
                mCurrentGameMenu = a;
                MenuCamera.Instance.StartMenuMove (mNextGameMenu.gameObject);
            }
            else
            {
                // don't move if already there
            }

            UpdateMenusAndButtons();
            return;
        }

        mMenuChangePhase = true;
        mNextGameMenu = mGameMenus[(int)state];
        mNextGameMenu.gameObject.SetActive (true);

        MenuCamera.Instance.StartMenuMove (mNextGameMenu.gameObject);
        AudioManager.Instance.PlaySound (fmodSwipe);

        UpdateMenusAndButtons();
    }
        public SolitaireCanvas()
        {
            Width = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

            new TiledBackgroundImage(
                new felt().Source,
                    64, 64,

                    // repeaters
                    x: 32,
                    y: 24
            ).AttachContainerTo(this);

            var ShadowSize = 40;

            new GameBorders(DefaultWidth, DefaultHeight, ShadowSize, this).AttachContainerTo(this);

            //new Image
            //{
            //    Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(),
            //    Width = 96,
            //    Height = 96
            //}.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(this);

            var Content = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight
            }.AttachTo(this);


            //new GameSocialLinks(this)
            //{
            //    new GameSocialLinks.Button { 
            //        Source = (KnownAssets.Path.Assets + "/plus_google.png").ToSource(),
            //        Width = 62,
            //        Height = 17,
            //        Hyperlink = new Uri(Info.GoogleGadgetAddLink)
            //    },
            //    new GameSocialLinks.Button { 
            //        Source = (KnownAssets.Path.Assets + "/su.png").ToSource(),
            //        Width = 16,
            //        Height = 16,
            //        Hyperlink = new Uri( "http://www.stumbleupon.com/submit?url=" + Info.URL)
            //    }
            //};


            // redefine the ctor to fit our context
            //Func<string, string, string, GameMenuOption> Option =
            //    (Text, Image, href) =>
            //        new GameMenuOption
            //        {
            //            Text = "Play " + Text + "!",
            //            Source = (KnownAssets.Path.SocialLinks + "/" + Image + ".png").ToSource(),
            //            Hyperlink = new Uri(href),
            //            MarginAfter = Math.PI / 6
            //        };

            var Game = default(SolitaireGame);
            var GameFocusBoost = false;



            Action AtSizeChanged = delegate
            {
                if (Game != null)
                    Game.MoveTo(
                        (this.Width - DefaultWidth) / 2,
                        (this.Height - DefaultHeight)
                    );
            };

            this.SizeChanged +=
                delegate
                {
                    AtSizeChanged();


                };

            this.Menu = new GameMenu(DefaultWidth, DefaultHeight, ShadowSize, this)
			{
				new GameMenuOption
				{
					Text = "Solitaire - medium difficulty",
					Source = new Preview120x90().Source,
					MarginAfter = 3 * Math.PI / 6,
					Click =
						delegate
						{
							GameFocusBoost = true;

							Game.Orphanize();
							Game = new SolitaireGame().AttachTo(Content);
							Game.MyDeck.Sounds = this.Sounds;

                            AtSizeChanged();

							this.Menu.Hide();

					

							500.AtDelay(() => GameFocusBoost = false);
						}
				},
                //Option("FreeCell", "Preview_FreeCell",  "http://nonoba.com/zproxy/avalon-freecell"),
                //Option("Spider Solitaire", "Preview_Spider",  "http://nonoba.com/zproxy/avalon-spider-solitaire"),
                //Option("Treasure Hunt", "Preview_TreasureHunt",  "http://nonoba.com/zproxy/treasure-hunt"),
                //Option("FlashMinesweeper:MP", "Preview_Minesweeper", "http://nonoba.com/zproxy/flashminesweepermp"),
                //Option("Multiplayer Mahjong", "Preview_Mahjong", "http://nonoba.com/zproxy/mahjong-multiplayer"),
                //Option("Multiplayer SpaceInvaders", "Preview_SpaceInvaders", "http://nonoba.com/zproxy/flashspaceinvaders"),

				
			};

            this.Menu.ValidateHide = () => Game != null;
            this.Menu.ValidateShow = () => !GameFocusBoost;

            this.Menu.AttachContainerTo(this);

            this.Menu.Show();
        }
Exemple #45
0
    // Use this for initialization
    void Start()
    {
        Rotate_X = transform.localEulerAngles.x;
        Rotate_Y = transform.localEulerAngles.y;
        Rotate_Z = transform.localEulerAngles.z;

        player = GameObject.FindGameObjectWithTag("Greta");

        ASPath = GameObject.Find("AstarPathing01").GetComponent<AstarPath>();
        //gm = GameObject.Find("Person/Main Camera").GetComponent<GameMenu>();
        //gm = Camera.current.GetComponent<GameMenu>();
        gm = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<GameMenu>();

        OpeningSpeed = 1.75f;

        //if (DoorBlinTexture[2])
        //this.renderer.material.SetTexture("_MainTex", DoorBlinTexture[2]);
    }
Exemple #46
0
 void Start()
 {
     gm = GameObject.FindGameObjectWithTag("GameMenu").GetComponent<GameMenu>();
 }
	void Awake() 
    {
        dialog = FindObjectOfType<DialogBox>();
        grayscale = FindObjectOfType<Grayscale>();
        gameMenu = FindObjectOfType<GameMenu>();
	}
Exemple #48
0
	// Use this for initialization
	void Start ()
	{
		_GM = GameObject.FindGameObjectWithTag("MainUI").GetComponent<GameMenu>();
	}
		public SpiderCanvas()
		{
			Width = DefaultWidth;
			Height = DefaultHeight;

			this.ClipTo(0, 0, DefaultWidth, DefaultHeight);


			new TiledBackgroundImage(
				(global::ScriptCoreLib.Shared.Avalon.Cards.KnownAssets.Path.DefaultCards + "/felt.png").ToSource(),
					64, 64,
					14, 10
			).AttachContainerTo(this);

			var ShadowHeight = 40;

			new GameBorders(DefaultWidth, DefaultHeight, ShadowHeight).AttachContainerTo(this);


			var Margin = (DefaultWidth - CardInfo.Width * 10) / 11;
			new Image
			{
				Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(),
				Width = 96,
				Height = 96
			}.MoveTo(DefaultWidth - 96, DefaultHeight - 96 - 17 - Margin).AttachTo(this);

			var Content = new Canvas
			{
				Width = DefaultWidth,
				Height = DefaultHeight
			}.AttachTo(this);


			var Game = default(SpiderGame);

			var GameFocusBoost = false;


			new GameSocialLinks(this)
			{
				new GameSocialLinks.Button { 
					Source = (KnownAssets.Path.Assets + "/plus_google.png").ToSource(),
					Width = 62,
					Height = 17,
					Hyperlink = new Uri(Info.GoogleGadgetAddLink)
				},
				new GameSocialLinks.Button { 
					Source = (KnownAssets.Path.Assets + "/su.png").ToSource(),
					Width = 16,
					Height = 16,
					Hyperlink = new Uri( "http://www.stumbleupon.com/submit?url=" + Info.URL)
				}
			};

			// Select a difficulty for a new game!

			// redefine the ctor to fit our context
			Func<string, string, string, GameMenu.Option> Option =
				(Text, Image, href) =>
					new GameMenu.Option
					{
						Text = "Play " + Text + "!",
						Source = (KnownAssets.Path.Assets + "/" + Image + ".png").ToSource(),
						Hyperlink = new Uri(href),
						MarginAfter = Math.PI / 4
					};

			Func<string, string, Func<SpiderGame>, GameMenu.Option> Level =
				(Text, Image, ctor) =>
					new GameMenu.Option
					{
						Text = Text,
						Source = (KnownAssets.Path.Assets + "/" + Image + ".png").ToSource(),
						MarginAfter = Math.PI / 4,
						Click =
							delegate
							{
								GameFocusBoost = true;

								Game.Orphanize();
								Game = ctor();
								Game.AttachTo(Content);
								Game.MyDeck.Sounds = Sounds;

								Menu.Hide();

								500.AtDelay(() => GameFocusBoost = false);
							}
					};

			this.Menu = new GameMenu(DefaultWidth, DefaultHeight, ShadowHeight)
			{
				Level("Play easy Spider Solitaire!", "PreviewEasy", () =>  new SpiderGame(LevelEasy)),
				Level("Play medium Spider Solitaire!", "PreviewMedium", () =>  new SpiderGame(LevelMedium)),
				Level("Play hard Spider Solitaire!", "PreviewHard", () =>  new SpiderGame(LevelHard)),
				
				//Option("Spider Solitaire", "Preview_Spider",  "http://nonoba.com/zproxy/avalon-spider-solitaire"),

				Option("Treasure Hunt", "Preview_TreasureHunt",  "http://nonoba.com/zproxy/treasure-hunt").Apply(k => k.MarginBefore = Math.PI / 4),
				Option("FlashMinesweeper:MP", "Preview_Minesweeper", "http://nonoba.com/zproxy/flashminesweepermp"),
				Option("Multiplayer Mahjong", "Preview_Mahjong", "http://nonoba.com/zproxy/mahjong-multiplayer"),
				Option("Multiplayer SpaceInvaders", "Preview_SpaceInvaders", "http://nonoba.com/zproxy/flashspaceinvaders"),

			};

			Menu.AttachContainerTo(this);


			Menu.ValidateHide = () => Game != null;
			Menu.ValidateShow = () => !GameFocusBoost;


			Menu.Show();

		}
    void Start()
    {
        _menu = GetComponentInChildren<GameMenu>();
        _hud = GetComponentInChildren<GameHud>();

        _camEffects = Camera.main.GetComponent<CameraEffects>();
        _camController = Camera.main.GetComponent<CameraController>();

        _hud.FinalScoreMode(false);
        _hud.gameObject.SetActive(false);
        _menu.Show(OnStartNewGame, null);

        _introState = new IntroState(this) { TimeInState = 5, TimeAwake = 4f };
        _unarmedState = new UnarmedState(this);
        _accState = new AccState(this);
        _powerUpState = new PowerUpState(this);
        _blockadesAndEnemiesState = new BlockadeAndEnemiesState(this);
        _aliensState = new AliensState(this);
        _pauseState = new PauseState(this);
        _aliensFinalState = new AliensFinalState(this);

        _accState.ExitState = _unarmedState;

        Spawner = new Spawner(GamePrefabs);
        Spawner.OnRewardEvent += (reward_pts) =>
        {
            pts += reward_pts;
            _hud.SetPoints(pts);
        };
    }
Exemple #51
0
 public static SGameMenu ConstructFromBaseClass(GameMenu baseClass)
 {
     var s = new SGameMenu {BaseGameMenu = baseClass};
     return s;
 }
Exemple #52
0
    // Use this for initialization
    void Start()
    {
        UserPl = transform.parent.GetComponent<UserPlayer>();
        playerInv = GetComponent<InventoryV2>();
        escScript = GetComponent<GameMenu>();

        sx = Screen.width;
        sy = Screen.height;

        cwLocX = mainX + 2;
        cwLocY = mainY + 40;
        cwWidth = 200;
        cwHeight = mainH - 40 - 50;

        picX = mainX + cwWidth + 10;
        picY = cwLocY;
        btnW = cwWidth - 16;

        recX = picX + picW + 5;
        recY = picY;
        recW = mainX + mainW - recX - 2;
        recH = cwHeight;
        rbtnW = recW - 16;

        crBtnX = mainX + 10;
        crBtnY = cwLocY + cwHeight + 10;
        crBtnW = mainW - 20;
        crBtnH = mainH - cwHeight - 40 - 20;

        canCraft = new bool[craftList.Length];
    }
Exemple #53
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (!gcTracker.IsAlive)
            {
                System.Diagnostics.Debug.WriteLine("A garbage collection occurred!");
                gcTracker = new WeakReference(new object());
            }

            getTouchInput(gameTime);
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            switch(gameRunState)
            {
                case GameState.StateLoading:
                    break;
                case GameState.StateMenu:
                    titleScreen.Update();
                    break;
                //State where game is stopped
                case GameState.StateWorld:
                    if (activeCutscene != null)
                    {
                        gameRunState = GameState.StateCutscene;
                    }
                    else
                    {
                        updateGameWorld();
                    }
                    break;
                //State where ninja is running through level
                case GameState.StateRunning:
                    updateGameWorld();
                    currentGameRunTime++;

                    //if the level was just completed, create the completion screen and pass in the completion time
                    if (objectManager.WOMstate == WOMState.LevelComplete)
                    {
                        bool newrecord;
                        int number = (LevelParser.getCurrentLevelNumber() - 1) + (10 * (LevelParser.getCurrentChapterNumber() - 1));
                        TargetElapsedTime = TimeSpan.FromMilliseconds(1000.0 / 30.0);
                        TimeSpan t = gameTime.TotalGameTime - objectManager.StartTime;
                        TimeSpan r = new TimeSpan((long)_gameData.RecordTimeInTicks[number]);
                        if (t.Ticks < r.Ticks)
                        {
                            newrecord = true;
                            _gameData.RecordTimeInTicks[number] = t.Ticks;
                        }
                        else
                            newrecord = false;

                        if (CurrentLevelNumber == LevelParser.getChapterLevelCount())
                            levelMenu = new ChapterCompletionScreen(t, r, newrecord);
                        else
                            levelMenu = new CompletionScreen(t, r, newrecord);
                        gameRunState = GameState.StateCompleted;
                    }

                    break;

                //State where the game is displaying the completion menu
                case GameState.StateCompleted:
                    // Handled so that the default case doesn't crash us.
                    levelMenu.Update();
                    break;
                case GameState.StatePaused:
                    pauseMenu.Update();
                    break;
                case GameState.StateCutscene:
                    activeCutscene.Update();
                    break;
                default:
                    throw new Exception("Invalid Game State encountered in Game1.Update(). ");
            }

            base.Update(gameTime);
        }
    public void Enable(State menuState)
    {
        AudioManager.Instance.PlayMusic(fmodMusic);

        ShowComponents(true);

        MenuCamera.Instance.transform.position = mGameMenus[(int)menuState].transform.position + GlobalVariables.Instance.MAIN_CAMERA_OFFSET;

        for (int i = 0; i < mGameMenus.Length; i++)
        {
            mGameMenus[i].gameObject.SetActive (false);
            mGameMenus[i].Unfocus();
        }

        MenuGUICanvas.Instance.SetFadeColor(Color.clear);

        ResetAllMenusAndButtons ();

        mNextGameMenu = null;
        mCurrentGameMenu = mGameMenus[(int)menuState];
        mCurrentGameMenu.gameObject.SetActive (true);

        UpdateMenusAndButtons ();
    }
Exemple #55
0
 protected override void Initialize()
 {
     graphics.PreferredBackBufferWidth = 410;
     graphics.PreferredBackBufferHeight = 410;
     graphics.ApplyChanges();
     this.IsMouseVisible = true;
     base.Initialize();
     playerTurn = 1;
     gameCount = 0;
     currentGameState = gameStates.GAME_NOT_ON;
     gameMenu = new GameMenu(this);
     gameMenu.Update();
 }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        mSettingAudioManagerBackup = GetComponent<AudioManager> ();

        if (mBackgroundPrefab != null)
        {
            mBackground = GameObject.Instantiate (mBackgroundPrefab);
        }
        else
        {
            mBackground = new GameObject("Menu Background");
        }

        fmodMusic = AudioManager.Instance.GetMusicEvent("MenuMusic/DroneMeny", false);
        fmodSwipe = AudioManager.Instance.GetSoundsEvent("MenuSectionSwipe/MenuSwipeShort", true);

        mGameMenus = GetComponentsInChildren<GameMenu> ();

        mCurrentGameMenu = mGameMenus [0];
    }
        public FreeCellCanvas()
        {
            this.Width = DefaultWidth;
            this.Height = DefaultHeight;

            // is this working?
            this.ClipToBounds = true;


            new TiledBackgroundImage(
                new felt().Source,
                    64, 64,

                    // repeaters
                    x: 32,
                    y: 24
            ).AttachContainerTo(this);

            var ShadowSize = 40;

            new GameBorders(DefaultWidth, DefaultHeight, ShadowSize, this).AttachContainerTo(this);

            var Margin = (DefaultWidth - CardInfo.Width * 10) / 11;
            //new Image
            //{
            //    Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(),
            //    Width = 96,
            //    Height = 96
            //}.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(this);

            this.History = new AeroNavigationBar().MoveContainerTo(
                12,
                8
            );

            // make it bigger for android!
            //this.History.Container.RenderTransform = new ScaleTransform(2, 2);

            var Content = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight
            }.AttachTo(this);

            var Game = default(FreeCellGame);
            var GameFocusBoost = false;

            Action AtSizeChanged = delegate
            {
                if (Game != null)
                    Game.MoveTo(
                        (this.Width - DefaultWidth) / 2,
                        (this.Height - DefaultHeight)
                    );
            };

            this.SizeChanged +=
                delegate
                {
                    AtSizeChanged();


                };

            Action CreateGame =
                delegate
                {
                    var PreviousGame = Game;

                    Game.Orphanize();
                    Game = new FreeCellGame()
                    {
                        History = History,
                    };

                    Game.MyDeck.Sounds = this.Sounds;
                    Game.AttachTo(Content);

                    AtSizeChanged();

                    var CurrentGame = Game;

                    this.History.History.Add(
                        delegate
                        {
                            if (Game == PreviousGame)
                                return;

                            Game.Orphanize();
                            Game = PreviousGame.AttachTo(Content);

                            if (Game == null)
                                this.Menu.Show();
                        },
                        delegate
                        {
                            if (Game == CurrentGame)
                                return;

                            Game.Orphanize();
                            Game = CurrentGame.AttachTo(Content);

                            if (Game != null)
                                this.Menu.Hide();
                        }
                    );
                };



            //new GameSocialLinks(this)
            //{
            //    new GameSocialLinks.Button { 
            //        Source = (KnownAssets.Path.Assets + "/plus_google.png").ToSource(),
            //        Width = 62,
            //        Height = 17,
            //        Hyperlink = new Uri(Info.GoogleGadgetAddLink)
            //    },
            //    new GameSocialLinks.Button { 
            //        Source = (KnownAssets.Path.Assets + "/su.png").ToSource(),
            //        Width = 16,
            //        Height = 16,
            //        Hyperlink = new Uri( "http://www.stumbleupon.com/submit?url=" + Info.URL)
            //    }
            //};

            // redefine the ctor to fit our context
            //Func<string, string, string, GameMenuOption> Option =
            //    (Text, Image, href) =>
            //        new GameMenuOption
            //        {
            //            Text = "Play " + Text + "!",
            //            Source = (KnownAssets.Path.SocialLinks + "/" + Image + ".png").ToSource(),
            //            Hyperlink = new Uri(href),
            //            MarginAfter = Math.PI / 4
            //        };

            this.Menu = new GameMenu((int)this.Width, DefaultHeight, ShadowSize, this)
			{
				new GameMenuOption
				{
					Text = "FreeCell - medium difficulty",
					Source = new Preview().Source,
					MarginAfter = Math.PI / 2,
					Click =
						delegate
						{
							GameFocusBoost = true;


							CreateGame();
                            this.Menu.Hide();

							1000.AtDelay(() => GameFocusBoost = false);
						}
				},
                //Option("Spider Solitaire", "Preview_Spider",  "http://nonoba.com/zproxy/avalon-spider-solitaire"),
                //Option("Treasure Hunt", "Preview_TreasureHunt",  "http://nonoba.com/zproxy/treasure-hunt"),
                //Option("FlashMinesweeper:MP", "Preview_Minesweeper", "http://nonoba.com/zproxy/flashminesweepermp"),
                //Option("Multiplayer Mahjong", "Preview_Mahjong", "http://nonoba.com/zproxy/mahjong-multiplayer"),
                //Option("Multiplayer SpaceInvaders", "Preview_SpaceInvaders", "http://nonoba.com/zproxy/flashspaceinvaders"),
			};

            this.Menu.ValidateHide = () => Game != null;
            this.Menu.ValidateShow = () => !GameFocusBoost;

            this.Menu.AttachContainerTo(this);

            // QA: is this working correctly for flash?
#if DEBUG
            var HistoryNoZone = new Rectangle();

            HistoryNoZone.Fill = Brushes.Yellow;

            HistoryNoZone.Width = 96;
            HistoryNoZone.Height = 48;
            HistoryNoZone.Opacity = 0;
            HistoryNoZone.AttachTo(this);

            this.History.AttachContainerTo(this);
#endif

            this.Menu.Show();
        }
    void EndChangeGameMenu()
    {
        mMenuChangePhase = false;

        mCurrentGameMenu.gameObject.SetActive (false);

        mCurrentGameMenu = mNextGameMenu;
        mNextGameMenu = null;

        AudioManager.Instance.StopSound(fmodSwipe);

        UpdateMenusAndButtons();
    }
Exemple #59
0
    void Start()
    {
        sx = Screen.width;
        sy = Screen.height;
        showGUI = false;
        UserPl = transform.parent.GetComponent<UserPlayer>();
        devArray = transform.parent.GetComponent<GameInv>();
        detScript = GetComponent<Detector>();
        escScript = GetComponent<GameMenu>();

        CheckKnife();
    }
	// Use this for initialization
	void Start () {
		_GM = gameObject.GetComponent<GameMenu>();
	}