123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using System.Collections;
- using System.Collections.Generic;
- using Excel2Json;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Hero;
- using UnityEngine;
- using Utility;
- public class PlayerManager : Singleton<PlayerManager>
- {
- /// <summary>
- /// 英雄管理
- /// </summary>
- public HeroController heroController = new HeroController();
- public GameConstantConfig gameConstantConfig;
- public long coin;
- public long diamond;
- public long heroExp;
-
- /// <summary>
- /// 上一个强化的英雄
- /// </summary>
- public HeroInfo lastHeroInfo;
- public void Init()
- {
- gameConstantConfig = ConfigComponent.Instance.Get<GameConstantConfig>(1);
- AccountFileInfo.Instance.LoadPlayerData();
- InitGameData();
- }
- private void InitGameData()
- {
- InitBags();
- heroController.InitHeroes();
- // InitHeroes();
- }
- private void InitBags()
- {
- BagController.Instance.Init();
- }
-
- // public void InitTestHero()
- // {
- // heroListInLead.Clear();
- // // AccountFileInfo.Instance.LoadPlayerData();
- //
- // AccountFileInfo.HeroData heroData1 = new AccountFileInfo.HeroData
- // {
- // heroModelId = 105,
- // heroPowerId = 1,
- // heroPromoteId = 3
- // };
- //
- // AccountFileInfo.HeroData heroData2 = new AccountFileInfo.HeroData
- // {
- // heroModelId = 107,
- // heroPowerId = 1,
- // heroPromoteId = 3
- // };
- //
- // AccountFileInfo.HeroData heroData3 = new AccountFileInfo.HeroData
- // {
- // heroModelId = 116,
- // heroPowerId = 1,
- // heroPromoteId = 3
- // };
- // AccountFileInfo.HeroData heroData4 = new AccountFileInfo.HeroData
- // {
- // heroModelId = 113,
- // heroPowerId = 1,
- // heroPromoteId = 3
- // };
- // AccountFileInfo.Instance.playerData.HeroListData.Clear();
- // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData1);
- // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData2);
- // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData3);
- // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData4);
- //
- // for (int i = 0; i < AccountFileInfo.Instance.playerData.HeroListData.Count; i++)
- // {
- // AccountFileInfo.HeroData heroData = AccountFileInfo.Instance.playerData.HeroListData[i];
- // HeroInfo heroInfo = new HeroInfo();
- // heroInfo.InitHero(heroData);
- // heroListInLead.Add(heroInfo);
- // }
- // }
- // public CombatHeroInfo GetHeroInfo(int modelID)
- // {
- // if (lastHeroInfo != null && lastHeroInfo.modelID == modelID)
- // {
- // return lastHeroInfo;
- // }
- //
- // for (int i = 0; i < heroListInLead.Count; i++)
- // {
- // HeroInfo info = heroListInLead[i];
- // if (info.modelID == modelID)
- // {
- // return info;
- // }
- // }
- //
- // return null;
- // }
- /// <summary>
- /// 保存英雄数据
- /// </summary>
- /// <param name="heroInfo"></param>
- public void SaveHeroData(HeroInfo heroInfo)
- {
- AccountFileInfo.Instance.SaveHeroData(heroInfo);
-
- // if (!QuickSaveHeroData(heroInfo))
- // {
- // for (int i = 0; i < AccountFileInfo.Instance.playerData.HeroListInLeadDatas.Count; i++)
- // {
- // AccountFileInfo.HeroData heroData = AccountFileInfo.Instance.playerData.HeroListInLeadDatas[i];
- // if (heroData.heroModelId == heroInfo.modelID)
- // {
- // AccountFileInfo.Instance.playerData.HeroListInLeadDatas[i] = heroInfo.ToHeroData();
- // //存下来,用于快速查找
- // leadHeroIdx = i;
- // AccountFileInfo.Instance.SavePlayerData();
- // return;
- // }
- // }
- // }
- }
- }
|