Exemplo n.º 1
0
        public int CheckObject(GameObject obj)
        {
            int damage = 0;

            for (int x = 0; x < _attacks.Count; x++)
            {
                if (obj.Collides(_attacks[x]))
                {
                    damage += _attacks[x].Damage;
                    if (_attacks[x].HitOnce)
                    {
                        _attacks.RemoveAt(x);
                        x--;
                    }
                }
            }
            return damage;
        }
Exemplo n.º 2
0
Arquivo: Tile.cs Projeto: MyEyes/Igorr
 public override bool Collides(GameObject obj)
 {
     return base.Collides(obj);
 }
Exemplo n.º 3
0
        public void Add(GameObject obj)
        {
            _server.SetChannel(1);
            _objects.Add(obj);
            Player player = obj as Player;
            SpawnMessage spawn = (SpawnMessage)Server.ProtocolHelper.NewMessage(MessageTypes.Spawn);
            spawn.id = obj.ID;
            spawn.position = obj.Rect;
            spawn.objectType = obj.ObjectType;
            spawn.move = obj.Movement;
            spawn.Info = obj.Info;
            spawn.Encode();

            if (!(obj is Attack))
            {
                _server.SendAllMapReliable(_map, spawn, true);
            }
            else
                _server.SendAllMapReliable(_map, spawn, false);
            if (player != null)
            {
                if (!(obj is NPC))
                    _playerCounter++;
                else
                    player.Body.SendBody(null);
                PositionMessage pm = (PositionMessage)_server.ProtocolHelper.NewMessage(MessageTypes.Position);
                pm.Position = player.Position;
                pm.Move = new Vector3(player.Movement, player.LastSpeed.Y);
                pm.id = player.ID;
                pm.Encode();
                _server.SendAllMapReliable(_map, pm, true);
            }
        }
Exemplo n.º 4
0
 public void RemoveQuiet(GameObject obj)
 {
     if (_objects.Contains(obj))
     {
         if (obj is Player)
             (obj as Player).GetDamage((obj as Player).HP + 1, -1);
         _objects.Remove(obj);
     }
 }
Exemplo n.º 5
0
 public void Remove(GameObject obj)
 {
     _server.SetChannel(1);
     if (_objects.Contains(obj))
     {
         _objects.Remove(obj);
         DeSpawnMessage deSpawn = (DeSpawnMessage)Server.ProtocolHelper.NewMessage(MessageTypes.DeSpawn);
         deSpawn.id = obj.ID;
         if (obj is Player && !(obj is NPC))
         {
             _playerCounter--;
             if (_playerCounter == 0)
                 _updateTimeout = 15f;
         }
         deSpawn.Encode();
         if (!(obj is Attack))
             _server.SendAllMapReliable(_map, deSpawn, true);
         else
             _server.SendAllMapReliable(_map, deSpawn, false);
         Console.WriteLine("Despawned " + obj.ID + " " + obj.Name);
     }
 }
Exemplo n.º 6
0
Arquivo: Map.cs Projeto: MyEyes/Igorr
        public bool Collides(GameObject obj)
        {
            int posX=(int)(obj.MidPosition.X/tileSize);
            int posY=(int)(obj.MidPosition.Y/tileSize);
            int sizeX = (obj.Rect.Width / tileSize)/2+1;
            int sizeY = (obj.Rect.Height / tileSize)/2+1;
            bool result = false;

            for (int x = -sizeX; x <= sizeX; x++)
                for (int y = -sizeY; y <= sizeY; y++)
                    if (isValid(posX + x, posY + y) && _layers[1][posX + x, posY + y] != null)
                        result = (result || _layers[1][posX + x, posY + y].Collides(obj));

            return result;
        }
Exemplo n.º 7
0
 public virtual bool Collides(GameObject obj)
 {
     return obj.Rect.Intersects(this._rect);
 }