private void Awake() { playerCameraRef = Camera.main; playerRef = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <Transform>(); playerController = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <ControllerBase>(); playerUnit = GameObject.FindGameObjectWithTag(Tags.player).GetComponentInChildren <UnitsBase>(); }
static void Main(string[] args) { do { int sale = Reader.Read <int>("Enter discount value", "Smth wrong with your input, reenter pls", (arg) => arg >= 0 && arg <= 100); UnitsBase[] arr = new UnitsBase[rnd.Next(5, 7)]; for (int i = 0; i < arr.Length; ++i) { int gen = rnd.Next(0, 3); if (gen == 0) { arr[i] = new CD(rnd.Next(5, 100), rnd.GenerateString(5, 6), rnd.Generate(10, 20), rnd.GenerateInt(500, 5000)); } else if (gen == 1) { arr[i] = new Cards(rnd.Next(5, 100), rnd.Generate(10, 20), rnd.GenerateString(5, 6), rnd.GenerateString(10, 20)); } else { arr[i] = new Book(rnd.Next(5, 100), rnd.Generate(10, 20), rnd.GenerateString(5, 6), rnd.GenerateInt(100, 2000), rnd.Generatebool()); } Console.WriteLine(arr[i]); Console.WriteLine(arr[i].Dicsount(sale).ToString("F3")); } Console.WriteLine("Press escape to exit"); } while (Console.ReadKey().Key != ConsoleKey.Escape); }
// Use this for initialization protected virtual void Start() { globalGameController = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <GlobalGameController>(); controlledUnit = gameObject.GetComponentInChildren <UnitsBase>(); unitCollider = controlledUnit.GetComponent <Collider>(); pawnController = GetComponent <CharacterController>(); isEncumbered = false; }
public static void RemoveUnitFromUnitsArray(this List <UnitsBase> arrayToRemove, UnitsBase toRemove) { if (!arrayToRemove.Contains(toRemove)) { return; } arrayToRemove.Remove(toRemove); }
public static void AddUnitToUnitsArray(this List <UnitsBase> arrayToAdd, UnitsBase toAdd, bool checkIfOtherTypes = true) { if (arrayToAdd.Count > 0) { if (checkIfOtherTypes && toAdd.GetType() != arrayToAdd.First().GetType()) { return; } if (arrayToAdd.Contains(toAdd)) { return; } } arrayToAdd.Add(toAdd); }