public void AddMonster(Monster monster) { if (!monsterDic.ContainsKey(monster.Uid)) { monsterDic.Add(monster.Uid, monster); } }
public AIBase (Monster monster) { currentMonster = monster; currentData = monster.Data; Uid = monster.Uid; blockProxy = ApplicationFacade.Instance.RetrieveProxy<BlockProxy>(); }
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(); }
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); } } }
public void AddMonsterInBlock(Monster monster) { if (!monsterBlockDic.ContainsKey(monster.Uid)) { monsterBlockDic.Add(monster.Uid, monster); } }
public ShooterAI (Monster monster) : base(monster) { sqrAttackDistance = currentData.AttackRange * currentData.AttackRange; sqrAvoidDistance = currentData.DodgeRange * currentData.DodgeRange; sqrDetectDistance = currentData.DetectRange * currentData.DetectRange; }
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); }
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!"); } }
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); }
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; }
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; }
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(); } }
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); }
public MeleeAI (Monster monster) : base(monster) { sqrAttackDistance = currentData.AttackRange * currentData.AttackRange; sqrDetectDistance = currentData.DetectRange * currentData.DetectRange; }