public void Initialize(Character character) { this.attributes = character.Entity.GetComponent <AttributesComponent>(); this.attributes.AttributeChanged += OnAttributeChanged; this.properties = character.Entity.GetComponent <PropertiesComponent>(); this.properties.PropertyChanged += OnPropertyChanged; this.experience = character.Entity.GetComponent <ExperienceComponent>(); this.experience.Experience.Changed += OnExperienceChanged; OnExperienceChanged(this.experience.Experience); var actor = character.Entity.GetComponent <ActorComponent>(); this.helmCheckbox.isOn = actor.IsHelmVisible; this.helmCheckbox.onValueChanged.AddListener(b => actor.SetHelmVisible(b)); this.characterNameText.text = character.Name; this.dropdown.onValueChanged.AddListener(OnDropdownChanged); this.dropdown.options = new List <TMP_Dropdown.OptionData> { new TMP_Dropdown.OptionData(I18N.Instance.Get("ui_attributes")), new TMP_Dropdown.OptionData(I18N.Instance.Get("ui_skills")), }; CreateAttributes(this.attributes); CreateProperties(this.properties); CreateSkillSlots(character.Entity.GetComponent <SpellbookComponent>().Slots); OnDropdownChanged(0); }
public static void addXP(int amount, ExperienceComponent component) { component.xp += amount; while (component.xp > getXPNeeded(component.level)) { component.xp -= getXPNeeded(component.level); component.level++; } }
public static float getXPPercentage(ExperienceComponent component) { int xpNeeded = 500; for (int i = 0; i < component.level; i++) { xpNeeded *= 2; } return((float)component.xp / xpNeeded * 100); }
// Use this for initialization void Start() { health = GetComponent <HealthComponent>(); stamina = GetComponent <MovementComponent>(); exp = GetComponent <ExperienceComponent>(); stamina.maxStamina = 90 + (10 * StaminaStat.StatLevel); // base 100 health.maxHealth = 90 + (10 * HealthStat.StatLevel); currentHealthUIDisplay.text = (health.maxHealth).ToString(); newHealthUIDisplay.text = (health.maxHealth + 10).ToString(); currentStaminaUIDisplay.text = (stamina.maxStamina).ToString(); newStaminaUIDisplay.text = (stamina.maxStamina + 10).ToString(); //StartCoroutine(UpdateUI()); }
public void Test() { var experience = gameObject.AddComponent <ExperienceComponent>(); experience.Construct(this.startingLevel, ExperienceComponent.RequiredExperienceAtLevel(this.startingLevel)); var scenarioRepository = Container.Instance.Resolve <IScenarioDataRepository>(); var unitRepository = Container.Instance.Resolve <IUnitDataRepository>(); ClearLog(); foreach (var scenario in scenarioRepository.FindAll() .Where(scenario => scenario.Index.InRange(this.scenarioIndexStart, this.scenarioIndexEnd) && scenario.Type == ScenarioType.Campaign) .OrderBy(scenario => scenario.Index)) { Debug.Log($"----- {I18N.Instance.Get(scenario.NameKey)} -----"); foreach (var episode in scenario.Episodes) { foreach (var unitTableUnit in episode.Encounter.UnitTable.Units) { var unit = unitRepository.Find(unitTableUnit.UnitId); var killExperience = UnitComponent.CalculateKillExperience( experience.Experience.Level, unit.ChallengeRating); experience.Experience.Add(killExperience); } } Debug.Log("Level: " + (experience.Experience.Level + experience.Experience.GetObtainedFraction())); } Destroy(experience); }
void Awake() { agent = GetComponent<NavMeshAgent>(); GameObject healthBarObject = (GameObject) Instantiate(healthBar, new Vector3(), new Quaternion()); healthBarObject.transform.SetParent(transform); healthBarObject.transform.localPosition = new Vector3(0, 3.0f, 0); Image image = healthBarObject.GetComponentInChildren<Image>(); healthComponent.HealthBar = new HealthBarScript(mainCamera, healthBarObject, image); attackComponent = new AttackComponent(animator); experienceComponent = new ExperienceComponent(healthComponent, attackComponent); navComponent = new NavigationComponent(agent, animator); healthComponent.MaxHealth = 100; healthComponent.CurrentHealth = 100; maxMana = 50; currentMana = 50; characterName = "Hattori"; className = "Ninja"; picture = Resources.Load<Sprite>("Icons/ninjaHead"); buttons = null; selectedCircle = transform.FindChild("SelectedCircle").gameObject; }
// Use this for initialization public void Start() { Animator animator = GetComponent<Animator>(); attackComponent = new AttackComponent(animator); NavMeshAgent agent = GetComponent<NavMeshAgent>(); navigationComponent = new NavigationComponent(agent, animator); experienceComponent = new ExperienceComponent(healthComponent, attackComponent); maxMana = 0; currentMana = 0; characterName = "Orc"; className = "Warrior"; experienceComponent.CurrentLevel = 1; experienceComponent.MaxLevel = 1; experienceComponent.CurrentExp = 0; experienceComponent.MaxExp = 100; attackCircle = gameObject.transform.FindChild("AttackCircle").gameObject; selectedCircle = gameObject.transform.FindChild("SelectedCircle").gameObject; picture = Resources.Load<Sprite>("Icons/orc"); }