Beispiel #1
0
        public void HandleShotEnd(ServerPlayer sender, MsgShotEnd shotMessage)
        {
            ShotInfo shot = FindShot(shotMessage.PlayerID, shotMessage.ShotID);

            if (shot == null)
            {
                return;
            }

            bool valid = false;

            if (sender.Info.ShotImmunities > 0)
            {
                sender.Info.ShotImmunities--;
                valid = true;
            }

            if (shot.ShotType == ShotTypes.ThiefShot || shot.ShotType == ShotTypes.GuidedShot)
            {
                valid = true;
            }

            if (!valid)     // don't penalize them for sending this, they just always send it
            {
                return;     // we know that all other cases must be followed by a death to be valid, so just remove the shot then.
            }
            Flags.HandlePlayerTakeHit(sender, shot.Owner, shot);

            ShotHit?.Invoke(this, shot);
            EndShot(shot, shotMessage.Exploded);
        }
    public void Shoot(Vector3 position, Vector3 dir)
    {
        Ray ray = new Ray(position, Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, float.MaxValue))
        {
            ShotHit?.Invoke(hit.collider.gameObject);
        }
    }
Beispiel #3
0
        public void RemoveShotForDeath(ServerPlayer player, int killerID, int shotID)
        {
            ShotInfo shot = FindShot(killerID, shotID);

            if (shot == null)
            {
                shot = FindUndeadShot(killerID, shotID);
                if (shot == null)
                {
                    Logger.Log1("Player " + player.Callsign + " killed by unknown shot");
                    return;
                }
            }
            else
            {
                EndShot(shot, false);
            }

            ShotHit?.Invoke(this, shot);
            ShotKilled?.Invoke(this, new ShotHitArgs(shot, player));
        }