Changeset 4764 for 2013/30


Ignore:
Timestamp:
2013-10-07 21:47:25 (6 years ago)
Author:
dezhidki
Message:
 
Location:
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Entities/Entity.cs

    r4754 r4764  
    156156        private bool SkipCollisionCheck(BoundingRectangleOwner collidableOwner) 
    157157        { 
    158             if (typeof(Entity).IsAssignableFrom(collidableOwner.GetType())) 
    159                 return !((Entity)collidableOwner).Blocks(this); 
    160             if (typeof(Tile).IsAssignableFrom(collidableOwner.GetType())) 
     158            //if (typeof(Entity).IsAssignableFrom(collidableOwner.GetType())) 
     159            //    return !((Entity)collidableOwner).Blocks(this); 
     160            //if (typeof(Tile).IsAssignableFrom(collidableOwner.GetType())) 
     161            //    return false; 
     162            Entity ent = collidableOwner as Entity; 
     163            if (ent != null) 
     164                return !ent.Blocks(this); 
     165            if (collidableOwner as Tile != null) 
    161166                return false; 
    162167            return true; 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobRanger.cs

    r4756 r4764  
    161161                        StopAttack(); 
    162162                } 
    163                 if (target == null || target.Removed || (typeof(UnitBuilding).IsAssignableFrom(target.GetType()) && ((UnitBuilding)target).IsDestroyed)) 
     163                UnitBuilding ub = target as UnitBuilding; 
     164                if (target == null || target.Removed || ub != null && ub.IsDestroyed) 
    164165                    StopAttack(); 
    165166            } 
     
    182183                    } 
    183184                } 
    184                 if (target == null || target.Removed || (typeof(UnitBuilding).IsAssignableFrom(target.GetType()) && ((UnitBuilding)target).IsDestroyed)) 
     185                UnitBuilding ub = target as UnitBuilding; 
     186                if (target == null || target.Removed || ub != null && ub.IsDestroyed) 
    185187                { 
    186188                    StopAttack(); 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWarrior.cs

    r4756 r4764  
    164164                        StopAttack(); 
    165165                } 
    166                 if (target == null || target.Removed || (typeof(UnitBuilding).IsAssignableFrom(target.GetType()) && ((UnitBuilding)target).IsDestroyed)) 
     166                UnitBuilding ub = target as UnitBuilding; 
     167                if (target == null || target.Removed || ub != null && ub.IsDestroyed) 
    167168                    StopAttack(); 
    168169            } 
     
    185186                    } 
    186187                } 
    187                 if (target == null || target.Removed || (typeof(UnitBuilding).IsAssignableFrom(target.GetType()) && ((UnitBuilding)target).IsDestroyed)) 
     188                UnitBuilding ub = target as UnitBuilding; 
     189                if (target == null || target.Removed || ub != null && ub.IsDestroyed) 
    188190                    StopAttack(); 
    189191            } 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWoodcutter.cs

    r4756 r4764  
    9191            //emmitter.Position = new Vector3(ScreenPos.X, 0.0F, ScreenPos.Y); 
    9292            //Sound2D.PlaySound3D(emmitter, "sword1"); 
    93             TileEntity te = level.GetTileEntity(this, (int)(x / Viewport.TILESIZE), (int)(z / Viewport.TILESIZE)); 
    94             if (te != null && typeof(TileEntityTree).IsAssignableFrom(te.GetType())) 
     93            TileEntityTree te = level.GetTileEntity(this, (int)(x / Viewport.TILESIZE), (int)(z / Viewport.TILESIZE)) as TileEntityTree; 
     94            if (te != null) 
    9595            { 
    9696                if (currentTarget != null) StopChopping(); 
    97                 OrderChop((TileEntityTree)te, sameOrderAmount, wasCalledBefore); 
     97                OrderChop(te, sameOrderAmount, wasCalledBefore); 
    9898            } 
    9999            else 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Level.cs

    r4754 r4764  
    261261            ent.Init(); 
    262262 
    263             if (typeof(TileEntity).IsAssignableFrom(ent.GetType())) 
    264                 tileEntities.Add((TileEntity)ent); 
     263            TileEntity te = ent as TileEntity; 
     264            if (te != null) 
     265                tileEntities.Add(te); 
    265266            else 
    266267                entities.Add(ent); 
    267268 
    268             if (typeof(Unit).IsAssignableFrom(ent.GetType())) 
    269             { 
    270                 Unit u = (Unit)ent; 
     269            Unit u = ent as Unit; 
     270            if (u != null) 
     271            { 
    271272                units[u.Owner.Team.ID].Add(u); 
    272273            } 
     
    509510                    entitiesInTiles[x + z * width].ForEach(delegate(Entity ent) 
    510511                    { 
    511                         if (typeof(T).IsAssignableFrom(ent.GetType())) inRadius.Add((T)ent); 
     512                        T e = ent as T; 
     513                        if (e != null)  
     514                            inRadius.Add(e); 
    512515                    }); 
    513516                } 
Note: See TracChangeset for help on using the changeset viewer.