Exemplo n.º 1
0
 private void CheckSliders(CharacterTemplate 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;
     //}
 }
Exemplo n.º 2
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(CharacterTemplate 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);
 }
Exemplo n.º 3
0
 public DeathEvent(CharacterTemplate caused, CharacterTemplate target, Vector3 hitPoint, float overKill)
 {
     Origin   = caused;
     Target   = target;
     OverKill = overKill;
     HitPoint = hitPoint;
 }
Exemplo n.º 4
0
 public GatherActionRange(BaseActionTemplate action, CharacterTemplate origin, CharacterTemplate target, int range)
 {
     Action = action;
     Origin = origin;
     Target = target;
     Range  = range;
 }
Exemplo n.º 5
0
 public HitData(int result, CharacterTemplate target, Vector3 point, Vector3 normal)
 {
     Result = result;
     Target = target;
     Point  = point;
     Normal = normal;
 }
        public bool CanTarget(BaseActionTemplate template, CharacterTemplate character, CharacterTemplate target)
        {
            var weapon = character.EquipmentSlots.GetSlot(EquipmentSlotType.Weapon).Item;

            if (weapon == null)
            {
                return(_type == Types.Unarmed);
            }
            if (_type == Types.Any)
            {
                return(true);
            }
            var data = weapon.Get <GenericDataComponent>();

            if (data == null)
            {
                return(false);
            }
            var weaponType = data.GetString(GenericDataTypes.WeaponType);

            switch (_type)
            {
            case Types.Melee:
                return(weaponType == WeaponTypes.Melee);

            case Types.Ranged:
                return(weaponType == WeaponTypes.Ranged);
            }
            return(true);
        }
Exemplo n.º 7
0
 public ImpactEvent(BaseActionTemplate action, CharacterTemplate origin, CharacterTemplate target, Vector3 hitPoint, Vector3 hitNormal)
 {
     Source = action.Entity;
     Hit    = new HitData(CollisionResult.Hit, target, hitPoint, hitNormal);
     Origin = origin;
     Target = target;
     Action = action;
 }
Exemplo n.º 8
0
 public ImpactEvent(CollisionEvent collisionEvent, BaseActionTemplate action, CharacterTemplate origin, CharacterTemplate target)
 {
     Source = collisionEvent.Source;
     Hit    = new HitData(CollisionResult.Hit, target, collisionEvent.HitPoint, collisionEvent.HitNormal);
     Origin = origin;
     Target = target;
     Action = action;
 }
Exemplo n.º 9
0
 public PrepareDamageEvent(ImpactEvent impact, CharacterTemplate origin, CharacterTemplate target)
 {
     Entries = GenericPools.New <List <DamageEntry> >();
     Impact  = impact;
     Origin  = origin;
     Target  = target;
     Action  = impact.Action;
 }
 public string Description(BaseActionTemplate template, CharacterTemplate character)
 {
     if (_minLevel > 1)
     {
         return(string.Format("Requires: {0} {1}", _minLevel, _label));
     }
     return(string.Format("Requires: {0}", _label));
 }
Exemplo n.º 11
0
 public bool AreFriends(CharacterTemplate source, CharacterTemplate target)
 {
     if (source == null || target == null)
     {
         return(false);
     }
     return(AreFriends(source.Faction, target.Faction));
 }
 public GatherMoveSpeedEvent(CharacterTemplate origin, float bonus)
 {
     Action = null;
     Origin = origin;
     Target = origin;
     Base   = origin.Stats.GetValue(Stats.MoveSpeed);
     Bonus  = bonus;
 }
Exemplo n.º 13
0
 public HealingEvent(BaseActionTemplate action, float amount, CharacterTemplate origin, CharacterTemplate target, string targetVital)
 {
     Action      = action;
     Amount      = amount;
     Origin      = origin;
     Target      = target;
     TargetVital = targetVital;
 }
Exemplo n.º 14
0
 public PrepareDamageEvent(CharacterTemplate origin, CharacterTemplate target, BaseActionTemplate action, HitData hit)
 {
     Entries = GenericPools.New <List <DamageEntry> >();
     Origin  = origin;
     Target  = target;
     Action  = action;
     Hit     = hit;
 }
Exemplo n.º 15
0
 public DeathEvent(CharacterTemplate caused, CharacterTemplate target, ImpactEvent impact, float overKill)
 {
     Action   = impact.Action;
     Origin   = caused;
     Target   = target;
     OverKill = overKill;
     Impact   = impact;
 }
Exemplo n.º 16
0
 public void RemoveActor()
 {
     if (_actor != null)
     {
         _actor.Entity.RemoveObserver(this);
     }
     _actor = null;
     RemoveAmmo();
 }
Exemplo n.º 17
0
 public bool CanEffect(BaseActionTemplate template, CharacterTemplate character, CharacterTemplate target)
 {
     if (_type == ActionDataTargetType.Target)
     {
         var data = target.GenericData;
         return(data != null && data.GetInt(_data) >= _minAmount);
     }
     return(true);
 }
Exemplo n.º 18
0
        public static void PostImpactEvent(CharacterTemplate origin, CharacterTemplate target, BaseActionTemplate action, Vector3 hitPoint,
                                           Vector3 hitNormal)
        {
            var hitRotation = hitNormal == Vector3.zero ? Quaternion.identity : Quaternion.LookRotation(hitNormal);
            var ae          = new ActionEvent(action, origin, target, hitPoint, hitRotation, ActionState.Impact);

            World.Get <RulesSystem>().Post(new ImpactEvent(action, origin, target, hitPoint, hitNormal));
            origin.Post(ae);
        }
Exemplo n.º 19
0
 public ActionEvent(CharacterTemplate origin, CharacterTemplate target, Vector3 position, Quaternion rotation, ActionState state)
 {
     Action   = origin.CurrentAction;
     Origin   = origin;
     Target   = target;
     Position = position;
     Rotation = rotation;
     State    = state;
 }
Exemplo n.º 20
0
 public ActionEvent(BaseActionTemplate action, CharacterTemplate origin, Entity target, ActionState state)
 {
     Action   = action;
     Origin   = origin;
     Target   = target.GetTemplate <CharacterTemplate>();
     Position = target.GetPosition();
     Rotation = target.GetRotation();
     State    = state;
 }
Exemplo n.º 21
0
 public RollInitiativeEvent(CharacterTemplate origin, int roll, int bonus)
 {
     Action = null;
     Source = origin.Entity;
     Origin = origin;
     Target = origin;
     Roll   = roll;
     Bonus  = bonus;
 }
Exemplo n.º 22
0
 public CheckHitEvent(BaseActionTemplate action, CharacterTemplate origin, CharacterTemplate target, string targetDefense)
 {
     Action        = action;
     Origin        = origin;
     Target        = target;
     TargetDefense = targetDefense;
     DefenseTotal  = 0;
     AttackTotal   = 0;
     Result        = 0;
 }
Exemplo n.º 23
0
 public ImpactEvent(CollisionEvent collisionEvent, ActionTemplate action, CharacterTemplate origin, CharacterTemplate target)
 {
     Source    = collisionEvent.Source;
     Hit       = collisionEvent.Hit;
     Origin    = origin;
     Target    = target;
     HitPoint  = collisionEvent.HitPoint;
     HitNormal = collisionEvent.HitNormal;
     Action    = action;
 }
Exemplo n.º 24
0
        public ActionEvent(CharacterTemplate origin, CharacterTemplate target, Vector3 position, Quaternion rotation, ActionState state)
        {
            var action = origin.Entity.GetTemplate <ActionCharacterTemplate>();

            Action   = action?.CurrentAction;
            Origin   = origin;
            Target   = target;
            Position = position;
            Rotation = rotation;
            State    = state;
        }
Exemplo n.º 25
0
 public bool CanEffect(BaseActionTemplate template, CharacterTemplate character, CharacterTemplate target)
 {
     for (int i = 0; i < Requirements.Count; i++)
     {
         if (!Requirements[i].CanEffect(template, character, target))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 26
0
 public void SetNewTarget(CharacterTemplate actor)
 {
     if (_actor != null)
     {
         RemoveActor();
     }
     _actor = actor;
     if (_actor != null)
     {
         _actor.Entity.AddObserver(this);
         SetupActorStat();
     }
 }
Exemplo n.º 27
0
 public void SetupActor(CharacterTemplate actor)
 {
     if (_actor != null)
     {
         _actor.Entity.RemoveObserver(this);
     }
     _actor = actor;
     if (_actor == null)
     {
         return;
     }
     _actor.Entity.AddObserver(this);
 }
        public string Description(BaseActionTemplate template, CharacterTemplate character)
        {
            switch (_type)
            {
            case Types.Melee:
                return("Requires: Melee Weapon");

            case Types.Ranged:
                return("Requires: Ranged Weapon");

            case Types.Unarmed:
                return("Requires: Unarmed");
            }
            return("");
        }
Exemplo n.º 29
0
        public static void FillUnknownSpellsList(int level, string skill, CharacterTemplate 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]);
                }
            }
        }
Exemplo n.º 30
0
        public bool Chase(CharacterTemplate 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);
        }