Esempio n. 1
0
        public void LoadPlayer()
        {
            var player = ProperSave.GetPlayerFromUsername(username);

            if (player == null)
            {
                Debug.Log("Could not find player: " + username);
                return;
            }

            foreach (var minion in minions)
            {
                minion.LoadMinion(player.master);
            }

            var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName);

            player.master.bodyPrefab = bodyPrefab;

            player.master.loadout.Clear();
            player.master.loadout.FromXml(XElement.Parse(loadoutXML));

            inventory.LoadInventory(player.master);

            player.master.money = (uint)money;

            ProperSave.Instance.StartCoroutine(WaitForStart(player));
        }
Esempio n. 2
0
        public void LoadMinion(CharacterMaster playerMaster)
        {
            var masterPrefab = MasterCatalog.GetMasterPrefab((MasterCatalog.MasterIndex)masterIndex);

            var             minionGameObject = UnityEngine.Object.Instantiate(masterPrefab);
            CharacterMaster minionMaster     = minionGameObject.GetComponent <CharacterMaster>();

            minionMaster.teamIndex = TeamIndex.Player;

            //MinionOwnership
            var newOwnerMaster = playerMaster;

            if (newOwnerMaster.minionOwnership.ownerMaster != null)
            {
                newOwnerMaster = newOwnerMaster.minionOwnership.ownerMaster;
            }
            minionMaster.minionOwnership.SetOwner(newOwnerMaster);

            //AIOwnership
            var aiOwnership = minionGameObject.GetComponent <AIOwnership>();

            aiOwnership.ownerMaster = playerMaster;

            BaseAI baseAI = minionGameObject.GetComponent <BaseAI>();

            baseAI.leader.gameObject = playerMaster.gameObject;

            NetworkServer.Spawn(minionGameObject);

            inventory.LoadInventory(minionMaster);
        }
Esempio n. 3
0
        public void LoadPlayer(NetworkUser player)
        {
            foreach (var minion in minions)
            {
                minion.LoadMinion(player.master);
            }

            var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName);

            player.master.bodyPrefab = bodyPrefab;

            loadout.LoadData(player.master);

            inventory.LoadInventory(player.master);

            player.master.money = money;

            player.masterController.SetFieldValue("lunarCoinChanceMultiplier", lunarCoinChanceMultiplier);
            var stats = player.masterController.GetComponent <PlayerStatsComponent>().currentStats;

            for (var i = 0; i < statsFields.Length; i++)
            {
                var fieldValue = statsFields[i];
                stats.SetStatValueFromString(StatDef.allStatDefs[i], fieldValue);
            }
            for (var i = 0; i < statsUnlockables.Length; i++)
            {
                var unlockableIndex = statsUnlockables[i];
                stats.AddUnlockable(new UnlockableIndex(unlockableIndex));
            }

            if (ProperSave.IsTLCDefined)
            {
                Stage.onStageStartGlobal += ResetLunarCoins;
                void ResetLunarCoins(Stage stage)
                {
                    Stage.onStageStartGlobal -= ResetLunarCoins;
                    player.DeductLunarCoins(player.lunarCoins);
                    player.AwardLunarCoins(lunarCoins);
                }
            }
        }