private void Awake() { if (instance == null) { instance = this; } else { if (instance != this) { Destroy(gameObject); } } passangerIndicatorList = new List <IndicatorMapper> (); //register mothership indicator audioSource = GetComponent <AudioSource> (); Assert.IsNotNull(audioSource); Assert.IsNotNull(_player); Assert.IsNotNull(passangerIndicatorPrefab); Assert.IsNotNull(mothershipIndicatorPrefab); Assert.IsNotNull(mothershipGate); Assert.IsNotNull(gameOverScreen); Assert.IsNotNull(levelChanger); // Assert.IsNotNull (PassangerSound); SpriteRenderer indicator = Instantiate(mothershipIndicatorPrefab, new Vector3(0f, 0f, 5f), Quaternion.identity); indicator.gameObject.SetActive(false); mothershipIndicator = new IndicatorMapper(mothershipGate, indicator); }
static void Main(string[] args) { var connStr = ConfigurationManager.ConnectionStrings["CustomMapperConnStr"]; using (var conn = new SqlConnection(connStr.ConnectionString)) { conn.Open(); var unit1 = new Unit { Name = "USD" }; new UnitMapper(conn).Save(unit1); var unit2 = new Unit { Name = "РУБ", Description = "рубли" }; new UnitMapper(conn).Save(unit2); var allUnits = new UnitMapper(conn).GetAll(); var unit = new UnitMapper(conn).Get(unit1.Id); unit.Description = "$"; new UnitMapper(conn).Save(unit); new UnitMapper(conn).Delete(new Unit {Id = unit2.Id}); var indicator1 = new Indicator {Title = "Ind1"}; new IndicatorMapper(conn).Save(indicator1); var indicator2 = new Indicator { Title = "Ind2", UnitId = unit1.Id}; new IndicatorMapper(conn).Save(indicator2); try { var indicator3 = new Indicator { Title = "Ind3", UnitId = 1000 }; new IndicatorMapper(conn).Save(indicator3); } catch (Exception) { // } var allIndicators = new IndicatorMapper(conn).GetAll(); var i1 = new IndicatorMapper(conn).Get(indicator1.Id); try { new UnitMapper(conn).Delete(unit1); } catch (Exception) { } new IndicatorMapper(conn).Delete(indicator2); new UnitMapper(conn).Delete(unit1); conn.Close(); } }
private void DrawIndicator(IndicatorMapper im) { Vector2 vPassanger = Camera.main.WorldToViewportPoint(im.go.transform.position); if (vPassanger.x > 1.02f || vPassanger.x < -0.02f || vPassanger.y > 1.02f || vPassanger.y < -0.02f) { im.indicator.gameObject.SetActive(true); Vector2 WorldPos = new Vector2(vPassanger.x - 0.5f, vPassanger.y - 0.5f) * 2f; // mapping to range [-1, 1] float max = Mathf.Max(Mathf.Abs(WorldPos.x), Mathf.Abs(WorldPos.y)); //get largest offset WorldPos = (WorldPos / (max * 2f)) + new Vector2(0.5f, 0.5f); //undo mapping WorldPos = Camera.main.ViewportToWorldPoint(WorldPos); im.indicator.transform.position = WorldPos; Vector2 v = new Vector2(im.go.transform.position.x - player.transform.position.x, im.go.transform.position.y - player.transform.position.y); float angle = Mathf.Atan2(v.y, v.x); im.indicator.transform.rotation = Quaternion.Euler(0f, 0f, angle * Mathf.Rad2Deg); } else { im.indicator.gameObject.SetActive(false); } }