示例#1
0
		public void AddMonster(Monster monster)
		{
			if (!monsterDic.ContainsKey(monster.Uid))
			{
				monsterDic.Add(monster.Uid, monster);
			}
		}
示例#2
0
		public AIBase (Monster monster)
		{
			currentMonster = monster;
			currentData = monster.Data;

			Uid = monster.Uid;

			blockProxy = ApplicationFacade.Instance.RetrieveProxy<BlockProxy>();
		}
示例#3
0
		public void AddAI(Monster monster)
		{
			if (aiDic.ContainsKey(monster.Uid))
			{
				BaseLogger.LogFormat("Ai already exists: {0}", monster.Uid);
			}

			AIBase ai = null;
			if (monster.Data.AttackType == AttackType.Melee)
			{
				ai = new MeleeAI(monster);
			}
			else
			{
				ai = new ShooterAI(monster);
			}

			aiDic.Add(ai.Uid, ai);

			ai.Start();
		}
示例#4
0
        public void AttackHero(Monster monster, Dictionary<AnimatorParamKey, string> paramDic)
		{
			AttackContext ac = new AttackContext();
			ac.Side = Side.Monster;
            ac.Attack = (int)monster.Info.GetAttribute(BattleAttribute.Attack);
            ac.Critical = (int)monster.Info.GetAttribute(BattleAttribute.Critical);

			if (monster.Data.AttackType == AttackType.Range)
			{
				Bullet bullet = Bullet.Create(monster.Data.BulletKid);
				bullet.AttackContext = ac;
				bullet.Start(monster.Script.EmitTransform);
			}
			else if (monster.Data.AttackType == AttackType.Melee)
			{
				bool inArea = JudgeInArea(hero.Script.transform, monster.Script.transform, paramDic);
				if (inArea)
				{
					DoAttackHero(ac);
				}
			}
		}
示例#5
0
		public void AddMonsterInBlock(Monster monster)
		{
			if (!monsterBlockDic.ContainsKey(monster.Uid))
			{
				monsterBlockDic.Add(monster.Uid, monster);
			}
		}
示例#6
0
		public ShooterAI (Monster monster) : base(monster)
		{
			sqrAttackDistance = currentData.AttackRange * currentData.AttackRange;
			sqrAvoidDistance = currentData.DodgeRange * currentData.DodgeRange;
			sqrDetectDistance = currentData.DetectRange * currentData.DetectRange;
		}
示例#7
0
 private void InitMonsterInHall(Monster monster, Vector3 position)
 {
     bool isNight = ApplicationFacade.Instance.RetrieveProxy<EnvironmentProxy>().IsNight;
     monster.SetAtNight(isNight);
     monster.SetPosition(position);
     monsterProxy.AddMonsterInHall(monster);
     battleProxy.AddMonster(monster);
 }
示例#8
0
		public static void Recycle(Monster monster)
		{
			if (monster != null)
			{
				monster.Data = null;
				monster.Script.StopAllCoroutines();
				ResourceManager.Instance.RecycleAsset(monster.Script.gameObject);
				monster.Script = null;
				monster.battleProxy = null;

				Game.Instance.AICore.RemoveAI(monster.Uid);
			}
			else
			{
				BaseLogger.Log("Recyle a null monster!");
			}
		}
示例#9
0
        public static void Init(Monster monster)
        {
            monster.Script = ResourceManager.Instance.LoadAsset<MonsterScript>(ObjectType.GameObject, monster.Data.GetResPath());
            monster.Script.AnimatorDataDic = AnimatorDataManager.Instance.GetDataDic(monster.Data.Kid);
            monster.Script.Uid = monster.Uid;
            monster.Script.transform.parent = RootTransform.Instance.MonsterRoot; 
            monster.Script.CallbackUpdate = monster.Update;
            monster.Script.CallbackSlowUpdate = monster.SlowUpdate;
            monster.Script.CallbackTrapAttack = monster.OnTrapAttack;
            monster.battleProxy = ApplicationFacade.Instance.RetrieveProxy<BattleProxy>();

            Game.Instance.AICore.AddAI(monster);
        }
示例#10
0
 public static Monster Create(int kid)
 {
     Monster monster = new Monster();
     monster.Uid = Guid.NewGuid().ToString();
     monster.Data = MonsterDataManager.Instance.GetData(kid) as MonsterData;
     monster.Info = new MonsterInfo(monster.Data);
     Init(monster);
     return monster;
 }
示例#11
0
		public static Monster Create(MonsterRecord record)
		{
			Monster monster = new Monster();
			if (record != null)
			{
				monster.Uid = record.Uid;
                monster.Data = MonsterDataManager.Instance.GetData(record.Kid) as MonsterData;
				monster.Info = new MonsterInfo(monster.Data, record);
                Init(monster);
                Dictionary<int, float>.Enumerator enumertor = record.buffRemainTimeDic.GetEnumerator();
                while (enumertor.MoveNext())
                {
                    monster.AddBuff(enumertor.Current.Key, enumertor.Current.Value);
                }
			}
			else
			{
				monster.Uid = Guid.NewGuid().ToString();
				monster.Data = MonsterDataManager.Instance.GetRandomMonsterData();
				monster.Info = new MonsterInfo(monster.Data);
                Init(monster);
			}

			return monster;
		}
示例#12
0
 public void DoAttackMonster(Monster monster, AttackContext attackContext)
 {
     if (!monster.Info.IsAlive)
     {
         return;
     }
     AttackResult result = monster.Info.HurtBy(attackContext);
     NumberItem.Create(monster.WorldPosition, result);
     if (monster.Info.HP > 0)
     {
         monster.Hit();
     }
     else
     {
         monster.Die();
     }
 }
示例#13
0
		private void HandleItemSpawnSingle(Monster monster)
		{
            DropData dropData = DropDataManager.Instance.GetData(monster.Data.DropKid) as DropData;
            Item item = Item.Create(dropData, monster.WorldPosition);
			dropProxy.AddItem(item);
			item.StartFlying(monster.WorldPosition);
		}
示例#14
0
		public MeleeAI (Monster monster) : base(monster)
		{
			sqrAttackDistance = currentData.AttackRange * currentData.AttackRange;
			sqrDetectDistance = currentData.DetectRange * currentData.DetectRange;
		}