Esempio n. 1
0
        /// <summary>
        /// Notifies users of ifo result
        /// </summary>
        /// <param name="ifo"></param>
        /// <param name="hits"></param>
        public void NotifyIfoResult(Ifo ifo, List <HitResult> hits)
        {
            // while (hits.Count < 4)
            //     hits.Add(HitResult.Unknown);

            RoomInstance.MulticastPacket(new AttackIfoResult(ifo, hits));
        }
Esempio n. 2
0
        /// <summary>
        /// Spawns an ifo
        /// </summary>
        /// <param name="ifo"></param>
        public void SpawnIfo(Ifo ifo)
        {
            if (_ifos.TryAdd(_nextIfoId, ifo))
            {
                ifo.Id = _nextIfoId;
                _nextIfoId++;

                if (_nextIfoId > 10000)
                {
                    _nextIfoId = 1;
                }
            }
        }
Esempio n. 3
0
        public ActionResult <Ifo> AddIfo(Ifo ifo)
        {
            try
            {
                applicationDb.Ifos.Add(ifo);
                applicationDb.SaveChanges();
            }
            catch (Exception e)

            {
                return(BadRequest(e.InnerException.Message));
            }
            return(ifo);
        }
Esempio n. 4
0
 public ActionResult <Ifo> PutIfo(long userId, Ifo ifo)
 {
     if (userId != ifo.UserId)
     {
         return(BadRequest("Id cannot be modified!"));
     }
     try
     {
         applicationDb.Entry(ifo).State = EntityState.Modified;
         applicationDb.SaveChanges();
     }
     catch (Exception e)
     {
         string error = e.Message;
         if (e.InnerException != null)
         {
             error = e.InnerException.Message;
         }
         return(BadRequest(error));
     }
     return(NoContent());
 }
 public AttackIfoResult(Ifo ifo, IEnumerable <HitResult> hits)
 {
     _ifo  = ifo;
     _hits = hits;
 }
Esempio n. 6
0
 public AttackIfo(Unit unit, Weapon weapon, Ifo ifo)
 {
     _unit   = unit;
     _weapon = weapon;
     _ifo    = ifo;
 }
Esempio n. 7
0
        /// <summary>
        /// Called when we need to attack
        /// </summary>
        public override void OnAttack()
        {
            // Do attack

            // For SMG we set attacking flag true and add reload time
            if (Stats.WeaponType == WeaponType.machingun)
            {
                _isAttacking   = true;
                _currentReload = Stats.ReloadTime;
            }

            // Apply overheat
            CurrentOverheat += Stats.OverheatPoint;

            // Check for projectile type
            if (_ifoType == IfoType.ifo_none)
            {
                var damage = 0;

                Target.TryGetTarget(out var target);

                // Check for valid target
                if (target != null && target.State == UnitState.InPlay)
                {
                    // Roll hit for each shot
                    for (var i = 0; i < Stats.NumberOfShots; i++)
                    {
                        var hit = _random.NextFloat();
                        damage += hit <= Stats.HitMinimum ? Stats.Damage : 0;
                        $"Rolled {hit} vs {Stats.HitMinimum:F}".Debug(source: ToString());
                    }

                    // TODO: Handle damage drop off

                    // TODO: Handle splash for non ifo lol
                }

                // Handle recoil
                if (Stats.RecoilDistance > 0)
                {
                    // Get their direction
                    var direction = Owner.GetAimDirection(false);

                    // Calculate end pos
                    var endPos = Owner.WorldPosition + direction * (Stats.RecoilDistance * -1);

                    // Move check
                    Owner.WorldPosition = GameInstance.Map.MoveCheck(Owner.WorldPosition, endPos);
                }

                var result = target == null
                    ? HitResult.Miss
                    : new HitResult
                {
                    Damage     = damage,
                    PushBack   = Vector3.Zero,
                    ResultCode = HitResultCode.Hit,
                    VictimId   = target.Id
                };

                // Broadcast
                GameInstance.NotifyUnitAttacked(Owner, result, this);

                // Apply damage
                target?.Attack(this, damage);
            }
            else
            {
                Ifo ifo;

                if (Stats.IfoType == IfoType.ifo_simple)
                {
                    Target.TryGetTarget(out var target);

                    // Fire IFO
                    ifo = new Ifo(this, Stats.IfoStats, GameInstance, target);
                }
                else
                {
                    ifo = new Ifo(this, Stats.IfoStats, GameInstance);
                }

                // Add to main program
                GameInstance.SpawnIfo(ifo);

                // Notify launched
                GameInstance.NotifyIfoLaunched(Owner, this, ifo);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Notifies users an ifo was launched
 /// </summary>
 /// <param name="ifo"></param>
 /// <param name="hits"></param>
 public void NotifyIfoLaunched(Unit unit, Weapon weapon, Ifo ifo)
 {
     RoomInstance.MulticastPacket(new AttackIfo(unit, weapon, ifo));
 }
Esempio n. 9
0
 /// <summary>
 /// Removes an ifo
 /// </summary>
 /// <param name="ifo"></param>
 public void RemoveIfo(Ifo ifo)
 {
     _ifos.TryRemove(ifo.Id, out var trash);
 }