Esempio n. 1
0
 private void CheckSliders(CharacterNode unit)
 {
     _state = State.Waiting;
     if (!_healthTween.Active)
     {
         var healthPercent  = unit.GetVital(_targetVital).CurrentPercent;
         var statDifference = Math.Abs(_healthSlider.value - healthPercent);
         if (statDifference > 0.01f)
         {
             _healthTween.Restart
                 (_healthSlider.value, healthPercent, Mathf.Lerp(0.15f, _maxTweenLength, statDifference));
         }
     }
     else
     {
         _state = State.Active;
         _healthSlider.value = _healthTween.Get();
     }
     //if (!_shieldTween.Active) {
     //    //var shieldPercent = unit.VitalStats[Vitals.Shield].CurrentPercent;
     //    var statDifference = Math.Abs(_shieldSlider.value - shieldPercent);
     //    if ( statDifference > 0.01f) {
     //        _shieldTween.Restart
     //            (_shieldSlider.value, shieldPercent, Mathf.Lerp(0.15f, _maxTweenLength, statDifference));
     //    }
     //}
     //else {
     //    _shieldSlider.value = _shieldTween.Get();
     //    _state = State.Active;
     //}
 }
Esempio n. 2
0
        public static void Setup()
        {
            IsSetup = true;
            if (Instance == null)
            {
                return;
            }
            NodeFilter <VisibleNode> .New(VisibleNode.GetTypes());

            NodeFilter <CharacterNode> .New(CharacterNode.GetTypes());

            Get <AnimatorSystem>();
            Get <CameraSystem>();
            Get <CollisionCheckSystem>();
            Get <CommandSystem>();
            Get <CollisionEventSystem>();
            Get <DespawnEntitySystem>();
            Get <DistanceSystem>();
            Get <EntityModifierSystem>();
            Get <FactionSystem>();
            Get <ItemSceneSystem>();
            Get <MoverSystem>();
            Get <PhysicsMoverSystem>();
            Get <RadiusSystem>();
            Get <TurnBasedSystem>();
            Get <CharacterRectSystem>();
            Get <SensorSystem>();
            Get <EntityUIPoolSystem>();
            EcsDebug.RegisterDebugCommands();
            //TODO: default setup here
        }
Esempio n. 3
0
 /// <summary>
 /// Should showing target hit points be locked behind a skill?
 /// Maybe also add a right click option to show more stats behind skill/spell
 /// </summary>
 /// <param name="actor"></param>
 public static void SetTargetActor(CharacterNode actor)
 {
     if (_actorLock || _character == actor)
     {
         return;
     }
     _clearTextTimer.Triggered = false;
     if (_character != null)
     {
         _main.RemoveActor();
     }
     _character = actor;
     if (_character == null)
     {
         return;
     }
     _main._textHolder.maxVisibleCharacters = 0;
     _main._textHolder.text = _character.Label.Text;
     if (_currentWriting != null)
     {
         TimeManager.Cancel(_currentWriting);
     }
     _currentWriting = TimeManager.StartUnscaled(_main.RevealText(), _main.CurrentNull);
     if (_character != null)
     {
         _character.Entity.AddObserver(_main);
     }
     for (int i = 0; i < _main._vitals.Length; i++)
     {
         _main._vitals[i].SetNewTarget(_character);
     }
     _main.CheckMods();
     _character.Entity.AddObserver(_main);
 }
Esempio n. 4
0
 public ActionStateEvent(CharacterNode origin, CharacterNode target, Vector3 position, Quaternion rotation, ActionStateEvents state)
 {
     Origin   = origin;
     Target   = target;
     Position = position;
     Rotation = rotation;
     State    = state;
 }
Esempio n. 5
0
 public TakeDamageEvent(float amount, CharacterNode origin, CharacterNode target, string damageType, string targetVital)
 {
     Impact      = default(ImpactEvent);
     Amount      = amount;
     Origin      = origin;
     Target      = target;
     DamageType  = damageType;
     TargetVital = targetVital;
 }
Esempio n. 6
0
 public void RemoveActor()
 {
     if (_actor != null)
     {
         _actor.Entity.RemoveObserver(this);
     }
     _actor = null;
     RemoveAmmo();
 }
Esempio n. 7
0
 public ImpactEvent(CollisionEvent collisionEvent, CharacterNode origin, CharacterNode target)
 {
     Source    = collisionEvent.Source;
     Origin    = origin;
     Target    = target;
     HitPoint  = collisionEvent.HitPoint;
     HitNormal = collisionEvent.HitNormal;
     Hit       = collisionEvent.Hit;
 }
Esempio n. 8
0
 public void Assign(IEntityModifier mod, CharacterNode target)
 {
     _target     = target;
     _watchedMod = mod;
     if (_watchedMod != null)
     {
         _iconImage.sprite = mod.Icon != null ? mod.Icon : _defaultIcon;
         UpdateCoolDown();
     }
 }
Esempio n. 9
0
 public void SetNewTarget(CharacterNode actor)
 {
     if (_actor != null)
     {
         RemoveActor();
     }
     _actor = actor;
     if (_actor != null)
     {
         _actor.Entity.AddObserver(this);
         SetupActorStat();
     }
 }
Esempio n. 10
0
 public void SetupActor(CharacterNode actor)
 {
     if (_actor != null)
     {
         _actor.Entity.RemoveObserver(this);
     }
     _actor = actor;
     if (_actor == null)
     {
         return;
     }
     _actor.Entity.AddObserver(this);
 }
Esempio n. 11
0
 public void RemoveActor()
 {
     if (_actor != null)
     {
         _actor.GetVital(_targetStat).OnStatChanged -= CheckStat;
         _actor.Entity.RemoveObserver(this);
     }
     _statSlider.value = 0;
     _actor            = null;
     if (_statText != null)
     {
         _statText.text = "";
     }
 }
Esempio n. 12
0
 public void SetupActor(CharacterNode actor)
 {
     if (_actor != null)
     {
         _actor.Entity.RemoveObserver(this);
         MessageKit.removeObserver(Messages.ModifiersUpdated, UpdateMods);
     }
     _actor = actor;
     if (_actor == null)
     {
         return;
     }
     _actor.Entity.AddObserver(this);
     MessageKit.addObserver(Messages.ModifiersUpdated, UpdateMods);
 }
Esempio n. 13
0
        public static void FillUnknownSpellsList(int level, string skill, CharacterNode actor, ref List <AbilityConfig> spells)
        {
            if (!_setup)
            {
                Init();
            }
            var spellsContainer = actor.Entity.Get <SpellsContainer>();
            var list            = _spellMaxLevels[level];

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Skill == skill && !spellsContainer.HasSpell(list[i]))
                {
                    spells.Add(list[i]);
                }
            }
        }
Esempio n. 14
0
        public static float GetHitMultiplier(int hit, CharacterNode entity)
        {
            var multi = 1f;

            if (hit == CollisionResult.CriticalHit)
            {
                var critStat = entity.Stats.Get(Stats.CriticalMulti);
                if (critStat != null)
                {
                    multi = critStat.Value;
                }
            }
            if (hit == CollisionResult.Graze)
            {
                multi = 0.5f;
            }
            return(multi);
        }
Esempio n. 15
0
        public bool Chase(CharacterNode target)
        {
            //var gridPosition = target.Get<GridPosition>().Position;
            //if (gridPosition.IsNeighbor(Position.c.Position)) {
            //    return false;
            //}
            if (!World.Get <FactionSystem>().AreEnemies(Entity, target))
            {
                return(false);
            }
            Chasing = true;
            Entity.Post(new SetMoveTarget(Entity, target.Tr, null));
            Entity.Post(new SetLookTarget(Entity, target, false));
#if DEBUG
            DebugLog.Add(Entity.DebugId + " chasing " + target.Entity.DebugId);
#endif
            return(true);
        }
Esempio n. 16
0
        public static void Setup()
        {
            IsSetup = true;
            if (Instance == null)
            {
                return;
            }
            NodeFilter <VisibleNode> .Setup(VisibleNode.GetTypes());

            NodeFilter <CharacterNode> .Setup(CharacterNode.GetTypes());

            NodeFilter <CollidableNode> .Setup(CollidableNode.GetTypes());

            Get <AnimatorSystem>();
            Get <CommandSystem>();
            Get <CollisionCheckSystem>();
            Get <DespawnEntitySystem>();
            Get <DistanceSystem>();
            Get <FactionSystem>();
            Get <ItemSceneSystem>();
            Get <ModifierSystem>();
            Get <MoverSystem>();
            Get <PhysicsMoverSystem>();
            Get <CharacterRectSystem>();
            Get <SensorSystem>();
            Get <EntityUIPoolSystem>();

            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            for (int a = 0; a < assemblies.Length; a++)
            {
                var types = assemblies[a].GetTypes();
                for (int t = 0; t < types.Length; t++)
                {
                    var type = types[t];
                    if (type.IsDefined(typeof(AutoRegisterAttribute), false))
                    {
                        CreateSystem(type);
                    }
                }
            }
        }
Esempio n. 17
0
        public static SpellData GetRandomMinNoDuplicate(int level, string skill, CharacterNode actor)
        {
            if (!_setup)
            {
                Init();
            }
            var spellsContainer = actor.Entity.Get <SpellsContainer>();
            int chk             = 0;

            while (chk < 10000)
            {
                chk++;
                var template = _spellMinLevels[level].RandomElement();
                if (template.Skill == skill && !spellsContainer.HasSpell(template))
                {
                    return(AbilityFactory.BuildAbility(template, false).Get <SpellData>());
                }
            }
            return(null);
        }
Esempio n. 18
0
 public void RemoveActor()
 {
     if (_actor != null)
     {
         if (!_actor.Disposed)
         {
             var vital = _actor.GetVital(_targetStat);
             if (vital != null)
             {
                 vital.OnStatChanged -= CheckStat;
             }
         }
         _actor.Entity.RemoveObserver(this);
     }
     _statSlider.value = 0;
     _actor            = null;
     if (_statText != null)
     {
         _statText.text = "";
     }
 }
Esempio n. 19
0
        public void SetNewTarget(CharacterNode actor)
        {
            if (_actor != null)
            {
                RemoveActor();
            }
            _actor = actor;
            if (_actor == null)
            {
                return;
            }
            _actor.Entity.AddObserver(this);
            var action = _actor.CurrentActions.GetAction(_targetUsable);

            if (action != null)
            {
                _currentAmmo = action.Ammo.Amount;
                _currentAmmo.OnResourceChanged += CheckAmmo;
                _statSlider.value = _currentAmmo.CurrentPercent;
            }
        }
Esempio n. 20
0
        private IEnumerator UpdateBar(CharacterNode unit, float offset)
        {
            _healthSlider.value = unit.GetVital(_targetVital).CurrentPercent;
            //_shieldSlider.value = unit.VitalStats[Vitals.Shield].CurrentPercent;
            _endTime           = TimeManager.Time + _timeOut;
            _state             = State.Waiting;
            transform.position = unit.Entity.GetPosition();
            _canvasGroup.alpha = 1;
            var v3Offset = new Vector3(0, offset, 0);

            while (true)
            {
                transform.position = unit.Entity.GetPosition() + v3Offset;
                Player.Cam.FaceCamera(transform, false);
                if (_state != State.Fading)
                {
                    CheckSliders(unit);
                }
                if (_state == State.Waiting && TimeManager.Time > _endTime)
                {
                    _fadeTween.Restart(1, 0);
                    _state = State.Fading;
                }
                if (_state == State.Fading)
                {
                    if (_fadeTween.Active)
                    {
                        _canvasGroup.alpha = _fadeTween.Get();
                    }
                    else
                    {
                        break;
                    }
                }
                yield return(null);
            }
            _activeBars.Remove(unit);
            ItemPool.Despawn(gameObject);
        }
Esempio n. 21
0
 private void RemoveActor()
 {
     if (_character != null)
     {
         _character.Entity.RemoveObserver(this);
     }
     ClearModList();
     for (int i = 0; i < _main._vitals.Length; i++)
     {
         _main._vitals[i].RemoveActor();
     }
     _sliderBackground.enabled = false;
     _character       = null;
     _actorLock       = false;
     _textHolder.text = "";
     if (!string.IsNullOrEmpty(_queuedText))
     {
         SetTextOnly(_queuedText, _lockedText);
         if (!_lockedText)
         {
             _queuedText = "";
         }
     }
 }
Esempio n. 22
0
 public virtual void SetActor(CharacterNode actor)
 {
     Actor = actor;
 }
Esempio n. 23
0
 public RaiseDeadEvent(CharacterNode source, CharacterNode target)
 {
     Source = source;
     Target = target;
 }
Esempio n. 24
0
 public DeathEvent(CharacterNode caused, CharacterNode target, float overKill)
 {
     Caused   = caused;
     Target   = target;
     OverKill = overKill;
 }
Esempio n. 25
0
        public static List <AbilityConfig> GetUnknownSpellsList(int level, string skill, CharacterNode actor)
        {
            List <AbilityConfig> spells = new List <AbilityConfig>();

            FillUnknownSpellsList(level, skill, actor, ref spells);
            return(spells);
        }