コード例 #1
0
        /// <summary>
        /// Sets the Employee for the UI
        /// </summary>
        /// <param name="_empData">EmployeeData of the Emp</param>
        /// <param name="buttonAction">The Action to be performed when the Button is clicked</param>
        public virtual void SetEmp(EmployeeData _empData, UnityAction buttonAction)
        {
            this.employeeData = _empData;
            factory           = new EmployeeFactory();
            GenerateSkillGui();
            if (employeeData.generatedData != null)
            {
                empImage.material = factory.GenerateMaterialForEmployee(employeeData.generatedData, true);
                empName.text      = employeeData.generatedData.name;
            }
            else
            {
                empName.text = employeeData.EmployeeDefinition.EmployeeName;
            }

            foreach (var special in employeeData.GetSpecials())
            {
                addSpecial(special);
            }

            button.onClick.AddListener(buttonAction);
            //EmployeeName, specials and Salary are not going to change, so they can be set once.
            salaryTime.text = "a Week";
            salary.text     = $"{employeeData.Salary} $";

            specialsChangedAction = onSpecialsChanged;
            _empData.SpecialsChanged.AddListener(specialsChangedAction);
        }
コード例 #2
0
        public void GenerateColorForEmployeeTest()
        {
            var      emp = GenerateMockedEmployee();
            Material mat = factory.GenerateMaterialForEmployee(emp);
            var      tex = mat.GetTexture("_SwapTex") as Texture2D;

            Assert.AreEqual((Color)emp.eyeColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.eyes, 0));
            Assert.AreEqual((Color)emp.hairColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.hair, 0));
            Assert.AreEqual((Color)emp.shirtColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.shirt, 0));
            Assert.AreEqual((Color)emp.shoeColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.shoes, 0));
            Assert.AreEqual((Color)emp.shortsColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.shorts, 0));
            Assert.AreEqual((Color)emp.skinColor, tex.GetPixel((int)EmployeeFactory.SwapIndex.skin, 0));
        }