public async Task EditVictimType(VictimType victimType) { try { await _db.ExecuteAsync("UPDATE VictimTypes SET Label = @label WHERE Id = @id AND IsDeleted != 0", new { id = victimType.Id, label = victimType.Label }); } catch (Exception) { throw; } }
public async Task <int> AddVictimType(VictimType victimType) { try { victimType.Id = await _db.QueryFirstAsync <int>("SELECT Id FROM VictimTypes ORDER BY Id DESC"); await _db.ExecuteAsync("INSERT INTO VictimTypes VALUES (@id, @label, 0)", new { id = victimType.Id, label = victimType.Label }); return(victimType.Id); } catch (Exception) { return(0); } }
public static Victim InstantiateType(VictimType type, Vector3 position) { GameObject prefab; switch (type) { case VictimType.Human: prefab = Resources.Load <GameObject>("Victims/Human"); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var v = Instantiate(prefab, position, Quaternion.identity).GetComponent <Victim>(); v.transform.position = position - new Vector3(0, v.transform.InverseTransformPoint(v._renderer.bounds.min).y); return(v); }