public void CreateInstance_WhenCalled_CreatesAndReturnsPlantCorrectly() { var service = new PlantFactory(); var plant = service.CreateInstance("plant1", 1, new DateTime(2000, 1, 1, 1, 1, 1)); Assert.AreEqual("plant1", plant.Name); Assert.AreEqual(1, plant.WateringPeriod); Assert.AreEqual(new DateTime(2000, 1, 1, 1, 1, 1), plant.LastWateredOn); }
public GameObject SpawnPlant(Vector3 pos, Quaternion rot, PlantType type) { var plant = PlantFactory.InstantiatePlant(pos, rot, type); plant.transform.SetParent(transform); NetworkServer.Spawn(plant.gameObject); if (!m_PlantMap.ContainsKey(plant.Type)) { m_PlantMap.Add(plant.Type, new HashSet <PlantBase>()); } m_PlantMap[plant.Type].Add(plant); return(plant.gameObject); }
private void SetPlantCount(int count) { while (count > CurrentPlantCount) { var t = PlantFactory.GetRandomSpawnableIndividualType(); SpawnPlant(Random.insideUnitSphere * CreatureSpawnExtent, Quaternion.identity, t); Debug.Log("Spawned a " + t); } while (count < CurrentPlantCount && m_PlantMap.Count > 0) { var t = EnumHelper.GetRandomEnum <PlantType>(); if (m_PlantMap.ContainsKey(t)) { KillPlant(m_PlantMap[t].FirstOrDefault()); } foreach (var kvp in m_PlantMap) { kvp.Value.RemoveWhere(p => p == null || p.gameObject == null); } } }
public PlantService(PlantAppDbContext context) { this.plantRepository = new PlantRepository(context); this.plantFactory = new PlantFactory(); this.userRepository = new UserRepository(context); }
private void Awake() { m_Singleton = this; }