Ejemplo n.º 1
0
    /// <summary>
    /// 初始化成功攀登几率
    /// </summary>
    /// <param name="gameData"></param>
    public void InitSuccessRate(GameItemsManager gameItemsManager, List <CharacterBean> listMemberData)
    {
        int totalLife    = 0;
        int totalCook    = 0;
        int totalSpeed   = 0;
        int totalAccount = 0;
        int totalCharm   = 0;
        int totalForce   = 0;
        int totalLucky   = 0;

        for (int i = 0; i < listMemberData.Count; i++)
        {
            CharacterBean itemCharacterData = listMemberData[i];
            itemCharacterData.GetAttributes(out CharacterAttributesBean characterAttributes);

            totalLife    += characterAttributes.life;
            totalCook    += characterAttributes.cook;
            totalSpeed   += characterAttributes.speed;
            totalAccount += characterAttributes.account;
            totalCharm   += characterAttributes.charm;
            totalForce   += characterAttributes.force;
            totalLucky   += characterAttributes.lucky;
        }

        teamFactor = totalLife / 10 + totalCook + totalSpeed + totalAccount + totalCharm + totalForce + totalLucky;
    }
Ejemplo n.º 2
0
        protected override void GameSetup()
        {
            base.GameSetup();

            var sb = new System.Text.StringBuilder();

            MyDebug.DebugLevel = DebugLevel;

            sb.Append("GameManager: GameSetup()");
            sb.Append("\nApplication.systemLanguage: ").Append(Application.systemLanguage);


            // Gameplay related properties
            IsUnlocked = PlayerPrefs.GetInt("IsUnlocked", 0) != 0;
#pragma warning disable 618
            IsUserInteractionEnabled = true;
#pragma warning restore 618
            IsSplashScreenShown = false;
            TimesGamePlayed     = PlayerPrefs.GetInt("TimesGamePlayed", 0);
            TimesGamePlayed++;
            TimesLevelsPlayed          = PlayerPrefs.GetInt("TimesLevelsPlayed", 0);
            TimesPlayedForRatingPrompt = PlayerPrefs.GetInt("TimesPlayedForRatingPrompt", 0);
            TimesPlayedForRatingPrompt++;
            sb.Append("\nTimesGamePlayed: ").Append(TimesGamePlayed);
            sb.Append("\nTimesLevelsPlayed: ").Append(TimesLevelsPlayed);
            sb.Append("\nTimesPlayedForRatingPrompt: ").Append(TimesPlayedForRatingPrompt);
            sb.Append("\nApplication.PersistantDataPath: ").Append(Application.persistentDataPath);

            MyDebug.Log(sb.ToString());

            // audio related properties
            BackGroundAudioVolume = 1;              // default if nothing else is set.
            EffectAudioVolume     = 1;              // default if nothing else is set.
            var audioSources = GetComponents <AudioSource>();
            if (audioSources.Length == 0)
            {
                MyDebug.LogWarning(
                    "To make use of the Game Manager audio functions you should add 2 AudioSource components to the same gameobject as the GameManager. The first for background audio and the second for effects.");
            }
            else
            {
                if (audioSources.Length > 0)
                {
                    BackGroundAudioSource = audioSources[0];
                    BackGroundAudioVolume = BackGroundAudioSource.volume;
                }
                if (audioSources.Length > 1)
                {
                    EffectAudioSources = new AudioSource[audioSources.Length - 1];
                    Array.Copy(audioSources, 1, EffectAudioSources, 0, audioSources.Length - 1);
                    EffectAudioVolume = EffectAudioSources[0].volume;
                }
            }

            BackGroundAudioVolume = PlayerPrefs.GetFloat("BackGroundAudioVolume", BackGroundAudioVolume);
            EffectAudioVolume     = PlayerPrefs.GetFloat("EffectAudioVolume", EffectAudioVolume);


            // display related properties
            SetDisplayProperties();

            // Localisation setup. If nothing stored then use system Language if it exists. Otherwise we will default to English.
            LocaliseText.AllowedLanguages = SupportedLanguages;

            // setup players.
            Players = new Player[Instance.PlayerCount];
            for (var i = 0; i < Instance.PlayerCount; i++)
            {
                Players[i] = CreatePlayer(i);
            }
            SetPlayerByNumber(0);

            // setup worlds if auto setup
            if (AutoCreateWorlds)
            {
                Worlds = new GameItemsManager <World, GameItem>();
                if (WorldUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, CoinsToUnlockLevels, LoadWorldDatafromResources);
                }
                else
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, loadFromResources: LoadWorldDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateLevels)
            {
                int startLevel = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Min : 1;
                int endLevel   = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Max : NumberOfAutoCreatedLevels;
                Levels = new GameItemsManager <Level, GameItem>();
                if (LevelUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, CoinsToUnlockLevels, LoadLevelDatafromResources);
                }
                else
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, loadFromResources: LoadLevelDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateCharacters)
            {
                Characters = new GameItemsManager <Character, GameItem>();
                if (CharacterUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, CoinsToUnlockCharacters, LoadCharacterDatafromResources);
                }
                else
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, loadFromResources: LoadCharacterDatafromResources);
                }
            }

            // coroutine to check for display changes (don't need to do this every frame)
            if (!Mathf.Approximately(DisplayChangeCheckDelay, 0))
            {
                StartCoroutine(CheckForDisplayChanges());
            }

            // flag as initialised
            IsInitialised = true;
        }