Beispiel #1
0
        private void Setup(GameObject entity)
        {
            this.health = entity.GetComponent <HealthComponent>();
            this.health.HealthChanged += OnHealthChanged;
            this.health.ShieldChanged += OnShieldChanged;

            this.behaviours = entity.GetComponent <BehavioursComponent>();
            this.behaviours.BehaviourApplied += OnBehaviourApplied;
            this.behaviours.BehaviourRemoved += OnBehaviourRemoved;

            var unit = entity.GetComponent <UnitComponent>();

            View.SetKillButtonActive(entity.IsSummoned() && entity.IsAllyOfPlayer());
            View.ChangeNameText(unit.Name + $" ({I18N.Instance.Get("ui_level")} {unit.Level})", entity.IsEnemyOfPlayer());
            View.ChangeChallengeRatingText(StringUtils.ToRomanNumeral(unit.ChallengeRating));
            View.ClearBehaviours();

            foreach (var behaviour in this.behaviours.Behaviours)
            {
                OnBehaviourApplied(behaviour);
            }

            View.ClearAffixes();
            View.CreateAffixes(this.behaviours.Behaviours.Where(b => b.IsMonsterAffix).ToList());

            OnHealthChanged(this.health);
        }
Beispiel #2
0
        protected override void OnApply(GameObject caster, GameObject target)
        {
            this.behaviours = target.GetComponent <BehavioursComponent>();

            BehavioursComponent.AnyBehaviourApplied += OnAnyBehaviourRemovedOrApplied;
            BehavioursComponent.AnyBehaviourRemoved += OnAnyBehaviourRemovedOrApplied;
        }
Beispiel #3
0
        public void Remove(BehavioursComponent behaviours)
        {
            behaviours.RemoveAllStacks(Behaviour.Id);
            IsApplied = false;

            Removed?.Invoke(this);
        }
Beispiel #4
0
        public void Apply(BehavioursComponent behaviours)
        {
            behaviours.Apply(Behaviour, behaviours.gameObject);
            IsApplied = true;

            Applied?.Invoke(this);
        }
Beispiel #5
0
        protected override void OnApply(GameObject caster, GameObject target)
        {
            this.behaviours = target.GetComponent <BehavioursComponent>();

            this.equipment = target.GetComponent <EquipmentComponent>();
            this.equipment.ItemEquipped   += OnItemEquipped;
            this.equipment.ItemUnequipped += OnItemUnequipped;

            OnItemEquipped(null);
        }
Beispiel #6
0
        protected override void OnApply(GameObject caster, GameObject target)
        {
            BoardCell.AnyCellOccupied     += OnAnyCellOccupied;
            HealthComponent.AnyEntityDied += OnAnyEntityDied;
            target.GetComponent <UnitComponent>().OwnerChanged += OnOwnerChanged;

            this.behaviours = target.GetComponent <BehavioursComponent>();

            Detect();
        }
Beispiel #7
0
        protected override void Apply(GameObject caster, Vector3 target)
        {
            var casterBehaviours = caster.GetComponent <BehavioursComponent>();

            if (casterBehaviours.IsImmobilized || casterBehaviours.IsUncontrollable)
            {
                TriggerFinished();
                return;
            }

            this.destination = BoardNavigator.Instance.WithinCircle(target, 0).FirstOrDefault();

            if (this.destination == null)
            {
                TriggerFinished();
                return;
            }

            var path = this.pathfinder.FindPath(caster, this.destination.transform.position, true);

            var nearest = path.Count > 0 ? path.Last() : caster.transform.position;

            if ((nearest - this.destination.transform.position).magnitude <= 2.3f)
            {
                path.Add(this.destination.transform.position);
            }

            if (path.Count == 0)
            {
                TriggerFinished();
                return;
            }

            this.queue = new Queue <Vector3>(path.Take(GetDistance(caster) + 1));

            this.actor = caster.GetComponent <ActorComponent>();
            this.actor.PlayAnimation(this.data.Animation);

            caster.GetComponent <HealthComponent>().Died += OnDeath;

            this.behaviours = casterBehaviours;
            this.behaviours.BehaviourApplied += OnBehaviourApplied;

            this.mover           = Mover.Factory(new MoverData(MoverType.Linear, GetSpeed(caster), 0, 0, false));
            this.mover.Finished += OnMoverFinished;

            OnMoverFinished();
        }
Beispiel #8
0
        private void Setup(GameObject entity)
        {
            this.movement          = entity.GetComponent <MovementComponent>();
            this.movement.Started += OnMovementStarted;
            this.movement.Stopped += OnMovementStopped;

            this.health = entity.GetComponent <HealthComponent>();
            this.health.HealthChanged += OnHealthChanged;
            this.health.ShieldChanged += OnHealthChanged;
            OnHealthChanged(this.health);

            this.resources = entity.GetComponent <ResourcesComponent>();
            this.resources.ActionPointsChanged += OnActionPointsChanged;
            this.resources.RageChanged         += OnRageChanged;

            OnActionPointsChanged(this.resources.Get(ResourceType.ActionPoint));
            OnRageChanged(this.resources.Get(ResourceType.Rage));

            this.behaviours = entity.GetComponent <BehavioursComponent>();
            this.behaviours.BehaviourApplied += OnBehaviourApplied;
            this.behaviours.BehaviourRemoved += OnBehaviourRemoved;

            foreach (var behaviour in this.behaviours.Behaviours)
            {
                OnBehaviourApplied(behaviour);
            }

            this.equipment = entity.GetComponent <EquipmentComponent>();

            this.spellbook = entity.GetComponent <SpellbookComponent>();
            this.spellbook.SkillCooldownStarted  += OnSkillCooldownStarted;
            this.spellbook.SkillCooldownUpdated  += OnSkillCooldownUpdated;
            this.spellbook.SkillCooldownFinished += OnSkillCooldownFinished;

            View.CreateSkills(this.spellbook.Slots);

            foreach (var slot in this.spellbook.Slots.Where(slot => slot.Skill.IsOnCooldown()))
            {
                View.StartSkillCooldown(slot.Skill);
            }

            UpdateButtonActiveState();
        }
Beispiel #9
0
        protected override void Apply(GameObject caster, GameObject target)
        {
            if (target.GetComponent <BehavioursComponent>().IsImmobilized ||
                target.GetComponent <UnitComponent>().IsMovingViaScript ||
                target.GetComponent <UnitComponent>().IsImmovable)
            {
                TriggerFinished();
                return;
            }

            this.destination = GetDestination(caster, target);

            if (this.destination == null)
            {
                TriggerFinished();
                return;
            }

            this.path = new Queue <Vector3>(this.pathfinder.FindPath(target, this.destination.transform.position, true));

            if (this.path.Count == 0)
            {
                TriggerFinished();
                return;
            }

            this.destination.IsReserved = true;

            this.actor = target.GetComponent <ActorComponent>();
            this.actor.PlayAnimation(this.data.Animation);

            this.behaviours = target.GetComponent <BehavioursComponent>();
            this.behaviours.BehaviourApplied += OnBehaviourApplied;

            this.mover           = Mover.Factory(new MoverData(MoverType.Linear, this.data.Speed, 0, 0, false));
            this.mover.Finished += OnMoverFinished;

            this.actor.GetComponent <UnitComponent>().Flags |= UnitFlags.MovingViaScript;

            OnMoverFinished();
        }
Beispiel #10
0
        public void Initialize(HealthComponent health)
        {
            AlwaysShowChanged += SetAlwaysShow;
            SettingsChanged   += OnSettingsChanged;
            CombatEncounter.AnyCombatTurnStarted += OnAnyCombatTurnStartedOrEnded;
            CombatEncounter.AnyCombatTurnEnded   += OnAnyCombatTurnStartedOrEnded;

            this.shiny.color = Color.white;

            this.health                = health;
            this.health.Damaged       += OnDamage;
            this.health.HealthChanged += OnHealthChanged;
            this.health.ShieldChanged += OnHealthChanged;
            this.health.Terminated    += OnTerminated;

            this.resources = health.GetComponent <ResourcesComponent>();
            this.resources.ActionPointsChanged += OnActionPointsChanged;

            this.behaviours = health.GetComponent <BehavioursComponent>();
            this.behaviours.BehaviourApplied += OnBehaviourApplied;
            this.behaviours.BehaviourRemoved += OnBehaviourRemoved;

            foreach (var behaviour in this.behaviours.Behaviours)
            {
                OnBehaviourApplied(behaviour);
            }

            this.unit = this.health.GetComponent <UnitComponent>();
            this.unit.OwnerChanged += OnOwnerChanged;

            var actor = this.health.GetComponent <ActorComponent>();

            Initialize(alwaysShow, alwaysHide, AttachmentPoint.OverHead, actor, this.health);

            OnSettingsChanged();
            OnOwnerChanged(this.unit);
            OnHealthChanged(health);
            OnActionPointsChanged(this.resources.Get(ResourceType.ActionPoint));
        }
Beispiel #11
0
 private void OnEnable()
 {
     this.behaviours = target as BehavioursComponent;
 }