public static void Recycle() { Hero hero = instance; if (hero != null) { hero.Data = null; hero.IsUpdating = false; hero.IsSlowUpdating = false; hero.Script.StopAllCoroutines(); ResourceManager.Instance.RecycleAsset(hero.Script.gameObject); hero.Script = null; hero.battleProxy = null; instance = null; } else { BaseLogger.Log("Recyle a null hero!"); } }
public static Hero Create(int heroKid, HeroInfo info) { Hero hero = new Hero(); hero.Uid = Guid.NewGuid().ToString(); hero.Data = HeroDataManager.Instance.GetData(heroKid) as HeroData; hero.Info = new HeroInfo(hero.Data, info); hero.Script = ResourceManager.Instance.LoadAsset<HeroScript>(ObjectType.GameObject, hero.Data.GetResPath()); hero.Script.Uid = hero.Uid; hero.Script.CallbackUpdate = hero.Update; hero.Script.CallbackSlowUpdate = hero.SlowUpdate; hero.Script.CallbackDie = hero.OnDie; hero.Script.CallbackTrapAttack = hero.OnTrapAttack; hero.Script.AnimatorDataDic = AnimatorDataManager.Instance.GetDataDic(hero.Data.Kid); hero.battleProxy = ApplicationFacade.Instance.RetrieveProxy<BattleProxy>(); hero.inputManager = InputManager.Instance; instance = hero; return hero; }
private void HandleHeroInit(HeroRecord record) { //Preload resources List<HeroData> dataList = heroProxy.GetAllHeroDataList(); for (int i = 0; i < dataList.Count; ++i) { HeroData heroData = dataList[i]; ResourceManager.Instance.PreloadAsset(ObjectType.GameObject, heroData.GetResPath()); } ResourceManager.Instance.PreloadAsset(ObjectType.GameObject, "Effects/ConversionEffect"); //Init if(record == null) { int heroKid = IDManager.Instance.GetID(IDType.Hero, 1); hero = Hero.Create(heroKid, null); MazeData mazeData = MazeDataManager.Instance.CurrentMazeData; Vector3 startPosition = MazeUtil.GetWorldPosition(mazeData.StartCol, mazeData.StartRow, mazeData.BlockSize); hero.SetPosition(startPosition); } else { hero = Hero.Create(record); hero.SetPosition(record.WorldPosition.ToVector3()); hero.SetRotation(record.WorldAngle); hero.Info.IsInHall = record.IsInHall; hero.IsVisible = record.IsVisible; } hero.CallbackDie = OnHeroDie; //Battle BattleProxy battleProxy = ApplicationFacade.Instance.RetrieveProxy<BattleProxy>(); battleProxy.SetHero(hero); //Conversion convertEffect = ResourceManager.Instance.LoadAsset<EffectScript>(ObjectType.GameObject, "Effects/ConversionEffect"); convertEffect.Deactive(); //Input // InputManager.Instance.SetKeyboardAction(KeyboardActionType.Attack, OnHeroAttack); // InputManager.Instance.SetKeyboardAction(KeyboardActionType.Function, OnHeroFunction); hero.Info.AddHP(999999); }
private void OnConversionMiddle(object param) { int heroKid = (int)param; Vector3 position = hero.WorldPosition; float angle = hero.Script.transform.localEulerAngles.y; Hero.Recycle(); Hero newHero = Hero.Create(heroKid, hero.Info); newHero.SetPosition(position); newHero.SetRotation(angle); hero = newHero; hero.CallbackDie = OnHeroDie; BattleProxy battleProxy = ApplicationFacade.Instance.RetrieveProxy<BattleProxy>(); battleProxy.SetHero(newHero); }
public void Dispose() { hero = null; monsterDic.Clear(); }
public void SetHero(Hero hero) { this.hero = hero; }