public void Setup(Entity e, Context context) { e.AddComp <C_IdentifyMonster>(); C_Position position = e.AddComp <C_Position>(); Entity e1 = context.SelectOne <C_LevelData>(); LinkedListNode <LevelEntry.TileData> first = e1.GetComp <C_LevelData>().paths.First; position.position = first.Value.position; e.AddComp <C_Rotation>(); MonsterEntry monsterEntry = e.GetComp <C_MonsterConfig>().cfg; C_MonsterFindPath monsterFindPath = e.AddComp <C_MonsterFindPath>(); monsterFindPath.target = first; monsterFindPath.rotating = 0; e.AddComp <C_TargetPos>(); e.AddComp <C_MoveToPos>().speed = monsterEntry.speed / 100f; e.AddComp <C_MoveStart>(); C_MonsterHp hp = e.AddComp <C_MonsterHp>(); int h = monsterEntry.hp / 100; hp.max = h; hp.rest = h; C_Asset asset = e.AddComp <C_Asset>(); asset.mesh = "Mesh/MonsterTest"; // monsterEntry.asset; asset.material = "Materials/Red"; e.AddComp <C_Renderer>(); }
public void Update(int filterIndex, Selection selection, float deltaTime) { foreach (var s in selection) { C_MonsterFindPath c = s.GetComp <C_MonsterFindPath>(); if (c.target == null) { return; } if (c.target.Next == null) { C_PlayerProperties p = selection.context.SelectOne <C_PlayerProperties>().GetComp <C_PlayerProperties>(); OnArrive(p); selection.context.Remove(s.id); return; } c.target = c.target.Next; s.SetRotation((c.target.Value.position - s.GetPosition()).ToRotation()); s.GetComp <C_TargetPos>().targetPos = c.target.Value.position; if (s.HasComp <C_MoveStart>()) { s.RemoveComp(s.GetComp <C_MoveStart>()); } if (s.HasComp <C_MoveEnd>()) { s.RemoveComp(s.GetComp <C_MoveEnd>()); } //s.AddComp<C_MoveToPos>(); } }