示例#1
0
        private void BuildMenu()
        {
            ReadSetting();
            var page1 = new MasterPageItem()
            {
                Id = 1, Title = "New Game", Icon = "itemIcon5.png"
            };
            var page2 = new MasterPageItem()
            {
                Id = 2, Title = "Board size", Icon = "itemIcon2.png", CurrentValue = $"{currentBoardSize}x{currentBoardSize}"
            };
            var page3 = new MasterPageItem()
            {
                Id = 3, Title = "Difficulty level", Icon = "itemIcon3.png", CurrentValue = currentDifficulyLevel.ToString()
            };
            var page4 = new MasterPageItem()
            {
                Id = 4, Title = "First move", Icon = "itemIcon4.png", CurrentValue = currentFirstMove ? "CPU" : "You"
            };
            var page5 = new MasterPageItem()
            {
                Id = 5, Title = "Sound", Icon = "sound.png", CurrentValue = IsMute ? "Off" : "On"
            };
            var page6 = new MasterPageItem()
            {
                Id = 6, Title = "Give Feedback", Icon = "feedback.png"
            };

            menuList.Add(page1);
            menuList.Add(page2);
            menuList.Add(page3);
            menuList.Add(page4);
            menuList.Add(page5);
            menuList.Add(page6);
        }
        // Helper to combine the attributes into a single line, to make it easier to display the character as a string
        public override string FormatOutput()
        {
            var myReturn = Name;

            myReturn += " , " + Description;
            myReturn += " , Level : " + Level.ToString();
            myReturn += " , Difficulty : " + DifficultyLevel.ToString();
            myReturn += " , Total Experience : " + Experience;
            myReturn += " , Items : " + ItemSlotsFormatOutput();
            myReturn += " , Damage : " + GetDamageTotalString;

            return(myReturn);
        }
示例#3
0
    public static int GetPlayerLives(DifficultyLevel diff)
    {
        switch (diff)
        {
        case DifficultyLevel.EASY:
            return(lives_easy);

        case DifficultyLevel.NORMAL:
            return(lives_normal);

        case DifficultyLevel.HARD:
            return(lives_hard);

        default:
            throw new UnityException("Unknown difficulty level (" + diff.ToString() + ")");
        }
    }
示例#4
0
        public static void SaveEngineConfig()
        {
            String[] configuration = new String[20];
            configuration[0]  = BloomEnabled.ToString();
            configuration[1]  = SoundEnabled.ToString();
            configuration[2]  = SoundSystem.ToString();
            configuration[3]  = SoundVolume.ToString();
            configuration[4]  = MusicVolume.ToString();
            configuration[5]  = LowDetails.ToString();
            configuration[6]  = InverseKeys.ToString();
            configuration[7]  = UseAlternativeSpinControl.ToString();// Settings.Default.Language;
            configuration[8]  = Difficulty.ToString();
            configuration[9]  = ShowIntro.ToString();
            configuration[10] = DisplayMinimap.ToString();
            configuration[11] = UseHydrax.ToString();
            configuration[12] = ShadowsQuality.ToString();
            configuration[13] = AudioStreaming.ToString();
            configuration[14] = UseHardwareTexturePreloader.ToString();
            configuration[15] = Gore.ToString();
            configuration[16] = HardwareTexturePreloaderTextureLimit.ToString();
            configuration[17] = UseAsyncModel.ToString();
            configuration[18] = UpdateHydraxEveryFrame.ToString();
            configuration[19] = CurrentPlayerPlaneType.ToString();


            ExplosionLights = !LowDetails;
            BodiesStay      = !LowDetails;

            //File.Create(C_ENGINE_CONFIG);
            File.WriteAllLines(C_ENGINE_CONFIG, configuration);

            //  string materialDir = "../../media/materials/scripts/ParentScripts/";
            if (ShadowsQuality > 0 /*&& UseHydrax*/)
            {
                //	File.Copy(materialDir+"0NormalMappedSpecular.base", materialDir+"0NormalMappedSpecular.material",true );
            }
            else
            {
                //	File.Copy(materialDir+"0NormalMappedSpecularNoShadows.base", materialDir+"0NormalMappedSpecular.material",true );
            }
        }
示例#5
0
        public override string ToString()
        {
            string chestString = Name + ", ";

            chestString += DifficultyLevel.ToString() + ", ";
            chestString += IsTrapped.ToString() + ", ";
            chestString += IsLocked.ToString() + ", ";
            chestString += TrapName + ", ";
            chestString += KeyName + ", ";
            chestString += KeyType + ", ";
            chestString += KeysRequired.ToString() + ", ";
            chestString += MinGold.ToString() + ", ";
            chestString += MaxGold.ToString();

            foreach (KeyValuePair <string, string> pair in ItemCollection)
            {
                chestString += ", " + pair.Key + "+" + pair.Value;
            }

            return(chestString);
        }
示例#6
0
文件: Game.cs 项目: Squomp/Chess960
        /// <summary>
        ///   Save game using the specified file name.
        /// </summary>
        /// <param name="fileName"> The file name. </param>
        private static void SaveGame(string fileName)
        {
            XmlDocument xmldoc      = new XmlDocument();
            XmlElement  xmlnodeGame = xmldoc.CreateElement("Game");

            xmldoc.AppendChild(xmlnodeGame);

            xmlnodeGame.SetAttribute("FEN", FenStartPosition == Fen.GameStartPosition ? string.Empty : FenStartPosition);
            xmlnodeGame.SetAttribute("TurnNo", TurnNo.ToString(CultureInfo.InvariantCulture));
            xmlnodeGame.SetAttribute(
                "WhitePlayer", PlayerWhite.Intellegence == Player.PlayerIntellegenceNames.Human ? "Human" : "Computer");
            xmlnodeGame.SetAttribute(
                "BlackPlayer", PlayerBlack.Intellegence == Player.PlayerIntellegenceNames.Human ? "Human" : "Computer");
            xmlnodeGame.SetAttribute(
                "BoardOrientation", Board.Orientation == Board.OrientationNames.White ? "White" : "Black");
            xmlnodeGame.SetAttribute("Version", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            xmlnodeGame.SetAttribute("DifficultyLevel", DifficultyLevel.ToString(CultureInfo.InvariantCulture));
            xmlnodeGame.SetAttribute("ClockMoves", ClockMaxMoves.ToString(CultureInfo.InvariantCulture));
            xmlnodeGame.SetAttribute("ClockSeconds", ClockTime.TotalSeconds.ToString(CultureInfo.InvariantCulture));
            xmlnodeGame.SetAttribute("MaximumSearchDepth", MaximumSearchDepth.ToString(CultureInfo.InvariantCulture));
            xmlnodeGame.SetAttribute("Pondering", EnablePondering ? "1" : "0");
            xmlnodeGame.SetAttribute("UseRandomOpeningMoves", UseRandomOpeningMoves ? "1" : "0");

            foreach (Move move in MoveHistory)
            {
                AddSaveGameNode(xmldoc, xmlnodeGame, move);
            }

            // Redo moves
            for (int intIndex = MoveRedoList.Count - 1; intIndex >= 0; intIndex--)
            {
                AddSaveGameNode(xmldoc, xmlnodeGame, MoveRedoList[intIndex]);
            }

            xmldoc.Save(fileName);
        }
示例#7
0
        private async void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                //navigationDrawerList.SelectedItem = null;
                if ((e.SelectedItem as MasterPageItem).Id == 1)
                {
                    Detail = new NavigationPage(StartGame());
                }
                else if ((e.SelectedItem as MasterPageItem).Id == 2)
                {
                    var action = await DisplayActionSheet("Choose Board size", "Cancel", null, GetButtons(1));

                    if (action == null || action == "Cancel")
                    {
                        return;
                    }
                    action = action.Replace("» ", "").Trim();
                    int newBoardSize = Convert.ToInt32(action.Split('x')[0]);
                    if (newBoardSize == currentBoardSize)
                    {
                        return;
                    }
                    currentBoardSize = newBoardSize;
                    RebuildMenu(2, action);
                    Detail = new NavigationPage(StartGame());
                    XFToast.LongMessage($"Board size is set to {action}");
                }
                else if ((e.SelectedItem as MasterPageItem).Id == 3)
                {
                    var action = await DisplayActionSheet("Choose Difficulty level", "Cancel", null, GetButtons(2));

                    if (action == null || action == "Cancel")
                    {
                        return;
                    }
                    var newDifficulyLevel = (DifficultyLevel)Enum.Parse(typeof(DifficultyLevel), action.Replace("» ", "").Trim());
                    if (newDifficulyLevel == currentDifficulyLevel)
                    {
                        return;
                    }

                    currentDifficulyLevel = newDifficulyLevel;
                    RebuildMenu(3, currentDifficulyLevel.ToString());
                    Detail = new NavigationPage(StartGame());
                    XFToast.LongMessage($"Difficulty level is set to {currentDifficulyLevel.ToString()}");
                }
                else if ((e.SelectedItem as MasterPageItem).Id == 4)
                {
                    var action = await DisplayActionSheet("Choose who should move first", "Cancel", null, GetButtons(3));

                    if (action == null || action == "Cancel")
                    {
                        return;
                    }
                    action = action.Replace("» ", "").Trim();
                    bool newFirstMove = (action == "CPU");
                    if (newFirstMove == currentFirstMove)
                    {
                        return;
                    }

                    currentFirstMove = newFirstMove;
                    RebuildMenu(4, action);
                    Detail = new NavigationPage(StartGame());
                    XFToast.LongMessage($"First move is set to {action}");
                }
                else if ((e.SelectedItem as MasterPageItem).Id == 5)
                {
                    IsMute = currentGame.IsMute = !currentGame.IsMute;
                    string newValue = currentGame.IsMute ? "Off" : "On";
                    RebuildMenu(5, newValue);
                    XFToast.LongMessage($"Sound is {newValue}");
                }
                else if ((e.SelectedItem as MasterPageItem).Id == 6)
                {
                    Device.OpenUri(new Uri("https://play.google.com/store/apps/details?id=com.game.dotsandboxesfun"));
                }
                //Detail = new NavigationPage(new Test1(currentBoardSize, currentDifficulyLevel, currentFirstMove));
                IsPresented = false;
            }
            catch (Exception ex)
            {
            }
        }
示例#8
0
        private void SetupGame()
        {
            //on setup, reset all variables to their defaults
            _boardState           = new BoardStateManager(_locationManager);
            _infectionDeckManager = new InfectionDeckManager(_locationManager);
            _cureDeckManager      = new CureDeckManager(_locationManager);
            _infectionDrawCount   = Properties.Settings.Default.DEFAULT_INFECTION_DRAW;

            DifficultyLevel diffLevel = GetDifficulty();

            _epidemicCards = (int)diffLevel;

            int playerCount = GetPlayerCount();

            for (int index = 1; index <= playerCount; index++)
            {
                _interactionManager.OutputContent(String.Format("CHARACTER CREATION FOR PLAYER {0}", index));
                _playerManager.AddPlayer(GetPlayerRole());
            }

            _interactionManager.OutputContent(String.Format("Epidemic Card Count for {0} is {1}", diffLevel.ToString(), _epidemicCards));
            _interactionManager.OutputContent(String.Format("Press any key to start game..."));
            _interactionManager.Pause();
            _interactionManager.ClearOutput();
        }
示例#9
0
    // Update is called once per frame
    private void Update()
    {
        if (Time.timeScale > 0f)
        {
            difficultyIndicator.text = "Difficulty\n" + DifficultyLevel.ToString("0.000");
        }

        //This portion handles what happens if the enemy reaches the opposite side of the screen
        List <GameObject> enemyList = GetEnemiesInRegion(exitPoint);

        //For each enemy, check their attack strength and deduct health accordingly before disabling the enemy
        if (enemyList.Count > 0)
        {
            for (int i = 0; i < enemyList.Count; i++)
            {
                GameObject currentEnemy = enemyList[i];
                int        damage       = currentEnemy.GetComponent <EnemyAttributes>().AttackStrength;
                TakeDamage(damage);
                currentEnemy.SetActive(false);
            }
        }

        //This part handles the Game Over menu
        if (currentHealth <= 0f)
        {
            hasLost = true;
        }

        if (hasLost)
        {
            //If the game over menu isn't already active, make it active, and pause the game
            if (gameOverMenu.activeSelf == false)
            {
                //Updates the final score before showing the game over screen
                finalScore.text = "Final score " + score.ToString();
                gameOverMenu.SetActive(true);
                Time.timeScale = 0f;
            }
        }

        //This part handles pausing and restarting
        if (Input.GetKeyDown(KeyCode.R))
        {
            Restart();
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            Pause();
        }

        //Takes what's in the field CurrentSelection and finds the appropriate tower and puts it in selectedTower
        switch (CurrentSelection)
        {
        case "Basic":
            selectedTower = basicTower;
            break;

        case "Burst":
            selectedTower = burstTower;
            break;

        case "Slow":
            selectedTower = slowTower;
            break;

        case "Laser":
            selectedTower = laserTower;
            break;

        case "Chain":
            selectedTower = chainTower;
            break;

        default:
            selectedTower = basicTower;     //Failsafe
            break;
        }

        //This part handles tower placement
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        //Input.GetMouseButtonDown(0) means click, whereas Time.timeScale > 0f means the game isn't paused
        if (Input.GetMouseButtonDown(0) && Time.timeScale > 0f)
        {
            if (CurrentSelection == "Sell")
            {
                if (MouseIsOverTower())
                {
                    //In this game, the part of the tower clicked is not the tower itself, but the mesh
                    GameObject clickedTowerMesh = hit.transform.gameObject;
                    //Hence, we need to reference the parent instead
                    GameObject clickedTower = clickedTowerMesh.transform.parent.gameObject;
                    SellTower(clickedTower);
                }
            }
            else
            {
                if (MouseIsOverFloor())
                {
                    //Do we have sufficient cash to afford this tower?
                    if (cash >= CalculateCost(selectedTower))
                    {
                        cash -= CalculateCost(selectedTower);

                        //Note that MouseIsOverFloor() implicitly modifies the value of hit. As such,
                        //we can get the hit location by using hit.point
                        SpawnTower(selectedTower, hit.point);
                    }
                }
            }
        }
    }