Example #1
0
        private static string GetDescription(GameObject entity, SkillSet set, SpellbookComponent spellbook)
        {
            var pieces = spellbook.GetSkillSetPiecesEquipped(set);

            var bestAvailable = set.Behaviours
                                .Where(b => b.Key <= pieces)
                                .OrderByDescending(b => b.Key)
                                .FirstOrDefault();

            var text = "";

            foreach (var bonus in set.Behaviours)
            {
                if (bestAvailable.Key == bonus.Key)
                {
                    text += "<color=white>";
                }
                else
                {
                    text += "<color=#555>";
                }

                text += $"({bonus.Key}) {bonus.Value.First().Description.ToString(new StringVariableContext(entity))}\n";
                text += "</color>";
            }

            return(text);
        }
Example #2
0
 public SpellbookViewController(ISpellbookView view, ISkillCategoryRepository skillCategoryRepository,
                                ISkillSetRepository skillSetRepository, CharacterManager characterManager) : base(view)
 {
     this.skillCategoryRepository = skillCategoryRepository;
     this.skillSetRepository      = skillSetRepository;
     this.spellbook = characterManager.Character.Entity.GetComponent <SpellbookComponent>();
 }
Example #3
0
 public SkillVendorViewController(ISkillVendorView view, CharacterManager characterManager,
                                  ISkillRepository skillRepository, ISkillSetRepository skillSetRepository) : base(view)
 {
     this.skillRepository    = skillRepository;
     this.skillSetRepository = skillSetRepository;
     this.currencies         = characterManager.Character.Entity.GetComponent <CurrenciesComponent>();
     this.spellbook          = characterManager.Character.Entity.GetComponent <SpellbookComponent>();
 }
Example #4
0
 public CommandBoardViewController(ICommandBoardView view, CharacterManager characterManager,
                                   IScenarioDataRepository scenarioDataRepository, IBehaviourRepository behaviourRepository,
                                   IItemRepository itemRepository, IUnitDataRepository unitDataRepository) : base(view)
 {
     this.scenarioDataRepository = scenarioDataRepository;
     this.behaviourRepository    = behaviourRepository;
     this.itemRepository         = itemRepository;
     this.unitDataRepository     = unitDataRepository;
     this.characterManager       = characterManager;
     this.spellbook = this.characterManager.Character.Entity.GetComponent <SpellbookComponent>();
 }
Example #5
0
    private void OnUse(EntityUid uid, SpellbookComponent component, UseInHandEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        AttemptLearn(uid, component, args);

        args.Handled = true;
    }
Example #6
0
        private void OnCharacterSelected(Character character)
        {
            if (!character.Data.IsRandomSkills)
            {
                return;
            }

            this.character             = character;
            this.spellbook             = character.Entity.GetComponent <SpellbookComponent>();
            this.spellbook.Terminated += OnTerminated;

            LevelupPopup.Instance.Hidden += OnLevelupPopupHidden;
        }
Example #7
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();
        }
Example #8
0
    private void AttemptLearn(EntityUid uid, SpellbookComponent component, UseInHandEvent args)
    {
        if (component.CancelToken != null)
        {
            return;
        }

        component.CancelToken = new CancellationTokenSource();

        var doAfterEventArgs = new DoAfterEventArgs(args.User, component.LearnTime, component.CancelToken.Token, uid)
        {
            BreakOnTargetMove    = true,
            BreakOnUserMove      = true,
            BreakOnDamage        = true,
            BreakOnStun          = true,
            NeedHand             = true, //What, are you going to read with your eyes only??
            TargetFinishedEvent  = new LearnDoAfterComplete(args.User),
            TargetCancelledEvent = new LearnDoAfterCancel(),
        };

        _doAfter.DoAfter(doAfterEventArgs);
    }
Example #9
0
        public void Initialize(SpellbookComponent spellbook)
        {
            AlwaysShowToggled += SetAlwaysShow;
            SettingsChanged   += OnSettingsChanged;

            this.spellbook                 = spellbook;
            this.spellbook.Terminated     += OnTerminated;
            this.spellbook.SkillLearned   += OnSkillLearned;
            this.spellbook.SkillUnlearned += OnSkillUnlearned;

            this.skills = new List <FloatingActionBarSkill>();

            foreach (var slot in this.spellbook.Slots)
            {
                OnSkillLearned(slot.Skill);
            }

            Initialize(alwaysShow, false, AttachmentPoint.None,
                       spellbook.GetComponent <ActorComponent>(),
                       spellbook.GetComponent <HealthComponent>()
                       );

            OnSettingsChanged();
        }
Example #10
0
    private void OnInit(EntityUid uid, SpellbookComponent component, ComponentInit args)
    {
        //Negative charges means the spell can be used without it running out.
        foreach (var(id, charges) in component.WorldSpells)
        {
            var spell = new WorldTargetAction(_prototypeManager.Index <WorldTargetActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }

        foreach (var(id, charges) in component.InstantSpells)
        {
            var spell = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }

        foreach (var(id, charges) in component.EntitySpells)
        {
            var spell = new EntityTargetAction(_prototypeManager.Index <EntityTargetActionPrototype>(id));
            _actionsSystem.SetCharges(spell, charges < 0 ? null : charges);
            component.Spells.Add(spell);
        }
    }
Example #11
0
 private void OnLearnCancel(EntityUid uid, SpellbookComponent component, LearnDoAfterCancel args)
 {
     component.CancelToken = null;
 }
Example #12
0
 private void OnLearnComplete(EntityUid uid, SpellbookComponent component, LearnDoAfterComplete ev)
 {
     component.CancelToken = null;
     _actionsSystem.AddActions(ev.User, component.Spells, uid);
 }