Beispiel #1
0
        public override void update()
        {
            position = position + this.forward() * speed;
            TimeSpan tmElapsed = DateTime.Now - SpawnTime;

            for (int i = 1; i <= Server.clients.Count; i++)
            {
                try{
                    Vector3 playerPos = Server.clients[i].player.position;
                    Player  _player   = Server.clients[i].player;
                    if (playerPos != null)
                    {
                        Vector3 distance = playerPos - position;
                        distance.Y = 0;
                        if (distance.Length() <= 2f)
                        {
                            Vector3 normDistance = this.normalize(distance);
                            _player.addVelocity(normDistance * (.8f + 0.2f * rank));
                            _player.dmg(5);
                            addToCleanup = true;
                        }
                    }
                }catch {}
            }

            if (addToCleanup || tmElapsed.TotalMilliseconds >= lifetime)
            {
                Server.cleanUp.Add(this);
            }
            else
            {
                ServerSend.Instance.updateObject(this);
            }
        }
Beispiel #2
0
        public override void update()
        {
            Player _player = Server.clients[owner].player;

            if (!dashed)
            {
                rotation = _player.rotation;
                _player.addVelocity(forward() * (.9f + (0.1f * rank)));
                dashed = true;
            }
            for (int i = 1; i <= Server.clients.Count; i++)
            {
                try {
                    Vector3 playerPos     = Server.clients[i].player.position;
                    Player  _playerOthers = Server.clients[i].player;
                    if (playerPos != null)
                    {
                        Vector3 distance = playerPos - _player.position;
                        distance.Y = 0;
                        if (distance.Length() <= 2f && owner != Server.clients[i].player.id)
                        {
                            Vector3 normDistance = this.normalize(distance);
                            _playerOthers.addVelocity(normDistance * ((0.2f * (rank - 1)) + .5f));
                            _playerOthers.dmg(10 * rank);
                            _player.setVelocity(new Vector3(0, 0, 0));
                            addToCleanup = true;
                        }
                    }
                } catch { }
            }

            if (addToCleanup || _player.getVelocity().Length() < 0.2)
            {
                Server.cleanUp.Add(this);
            }
        }