static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); BoxInt <int> box = new BoxInt <int>(); for (int i = 0; i < n; i++) { box.BoxItem.Add(int.Parse(Console.ReadLine())); } var nums = Console.ReadLine().Split().Select(int.Parse).ToArray(); box.SwapMe(nums[0], nums[1]); for (int i = 0; i < box.BoxItem.Count; i++) { Console.WriteLine($"{box.BoxItem[i].GetType()}: {box.BoxItem[i]}"); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Traps")) { gameManager.DelHealth(); } if (collision.gameObject.CompareTag("Box")) { BoxBin x = collision.gameObject.GetComponent <BoxBin>(); int k = 1; if (x.value == 0) { k = -1; } gameManager.Check(k * x.values + gameManager.key); } else if (collision.gameObject.CompareTag("BoxInt")) { BoxInt x = collision.gameObject.GetComponent <BoxInt>(); if (x.operat == '+') { gameManager.Check(x.value + gameManager.key); } else if (x.operat == '-') { gameManager.Check(-x.value + gameManager.key); } else if (x.operat == '*') { gameManager.Check(x.value * gameManager.key); } else if (x.operat == ':') { gameManager.Check(x.value / gameManager.key); } } }