private CreatureOldLogic CreateLogic(CreatureInfo info) { var logic = factory.CreateLogic(info); creaturesDic.Add(logic.Info.id, logic); return(logic); }
public MonsterLogic(CreatureInfo info) : base(info) { MonsterState = new MonsterState() { PhysicalAttackRange = new IntRange(1, 3) }; }
public CreatureOldLogic Load(CreatureInfo info) { info.id = idGenerator++; var logic = CreateLogic(info); var view = CreateView(info); logic.SetView(view); return(logic); }
public CreatureView CreateView(CreatureInfo info) { CreatureView view; switch (info.type) { case CreaturesType.Monsters: { GameObject instance = null; switch (info.party) { case CreaturesParty.Player: instance = GameObject.Instantiate(GameEntry.Creatures.PlayerMonsterTemplate, GameEntry.Creatures.transform); break; case CreaturesParty.Enemy: instance = GameObject.Instantiate(GameEntry.Creatures.EnemyMonsterTemplate, GameEntry.Creatures.transform); break; default: throw new InvalidOperationException("没有这种阵营"); } var monsterView = instance.GetOrAddComponent <MonsterView>(); view = monsterView; monsterView.MonsterUI = GameObject.Instantiate(GameEntry.Creatures.MonsterUITemplate, GameEntry.Creatures.transform).GetComponent <MonsterHUD>(); monsterView.MonsterUI.transform.rotation = Quaternion.identity; monsterView.MonsterUI.gameObject.AddComponent <TragetTracker>().Target = monsterView.Bindings.MonsterUIPoint; var sprite = GameEntry.Config.sprite.GetMonsterSprite(info.entryId); try { view.Bindings.mainRenderer.sprite = sprite; } catch (Exception) { throw; } } break; case CreaturesType.Player: { var instance = GameObject.Instantiate(GameEntry.Creatures.PlayerTemplate, GameEntry.Creatures.transform); view = instance.GetOrAddComponent <PlayerView>(); } break; default: throw new NotImplementedException("还没有这种类型的View"); } view.Info = info; return(view); }
public CreatureOldLogic CreateLogic(CreatureInfo info) { CreatureOldLogic logic; switch (info.type) { case CreaturesType.Monsters: logic = new MonsterLogic(info); return(logic); case CreaturesType.Player: logic = new PlayerLogic(info); return(logic); default: throw new NotImplementedException("还没有这种类型的Logic"); } }
private CreatureView CreateView(CreatureInfo info) { var view = factory.CreateView(info); return(view); }
public PlayerLogic(CreatureInfo info) : base(info) { }