예제 #1
0
파일: Hero.cs 프로젝트: sigmadruid/NewMaze
		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!");
			}
		}
예제 #2
0
파일: Hero.cs 프로젝트: sigmadruid/NewMaze
		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;
		}
예제 #3
0
        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);
		}
예제 #4
0
		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);
		}
예제 #5
0
		public void Dispose()
		{
			hero = null;
			monsterDic.Clear();
		}
예제 #6
0
		public void SetHero(Hero hero)
		{
			this.hero = hero;
		}