Esempio n. 1
0
    public void ShootLaser(SimpleRay2D ray, PlayerPawn owner)
    {
        List <PlayerPawn> playersHit = CastRay(ray);

        Network.Log("Laser hits " + playersHit.Count + " players.");
        float laserPower       = owner.GetLaserDamage();
        float powerAccumulator = 0.0f;

        for (int i = 0; i < playersHit.Count; ++i)
        {
            if (playersHit[i] == owner)
            {
                continue;
            }

            powerAccumulator += playersHit[i].ReceiveDamage(laserPower);
        }

        owner.AddPower(powerAccumulator);

        ShotEvent se = new ShotEvent();

        se.m_direction       = ray.direction;
        se.m_point           = owner.Position;
        se.m_who             = owner.Id;
        se.m_reliableEventId = Network.Server.GetNewReliableEventId();
        foreach (int id in m_players.Keys)
        {
            Network.Server.Send(se, id, true);
        }
    }