コード例 #1
0
ファイル: HitscanWeapon.cs プロジェクト: rbarraud/blarg4
 public override void OnTick()
 {
     if (refireTime > 0)
     {
         refireTime -= World.deltaTime;
     }
     if (sustainTarget != null)
     {
         if (!sustainTarget.isAlive)
         {
             sustainTarget = null;
             refireTime    = fireRate + sustainRemaining;
             return;
         }
         var dist = entity.Range(sustainTarget);
         Logger.Log("distance {0} range {1} target {3} possible damage {2}",
                    dist, range, damage * World.deltaTime,
                    entity.modelName);
         if (dist <= range)
         {
             sustainTarget.Damage(damage * World.deltaTime);
         }
         sustainRemaining -= World.deltaTime;
         if (sustainRemaining <= 0)
         {
             sustainTarget = null;
             refireTime    = fireRate;
         }
     }
 }
コード例 #2
0
ファイル: HitscanWeapon.cs プロジェクト: rbarraud/blarg4
        public void FireAt(Entity target)
        {
            if (refireTime > 0 || sustainTarget != null)
            {
                return;
            }

            var dist = entity.Range(target);

            if (dist > range)
            {
                return;
            }

            World.current.eventListener.Animate(entity, "Fire");
            if (sustainTime == 0)
            {
                target.Damage(damage);
                refireTime = fireRate;
                World.current.eventListener.HitscanBurstFire(this, effect, target);
            }
            else
            {
                World.current.eventListener.HitscanSustainedFire(this, effect, target, sustainTime);
                sustainRemaining = sustainTime;
                sustainTarget    = target;
            }
        }
コード例 #3
0
 /// <summary>
 /// Damages the enemy for some amount of damage.
 /// </summary>
 public virtual void Attack(float damage)
 {
     if (CurrentEnemy)
     {
         CurrentEnemy.Damage(damage);
     }
 }