Beispiel #1
0
        public void calculCliffs(Scene scene)
        {
            if( scene.IsLoadedCore( (int) X, (int) Y - 1 ) ) {
                CliffN = (int) Math.Ceiling( Z - scene.GetCore( (int) X, (int) Y - 1 ).Z );
            } else {
                CliffN = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X, (int) Y + 1 ) ) {
                CliffS = (int) Math.Ceiling( Z - scene.GetCore( (int) X, (int) Y + 1 ).Z );
            } else {
                CliffS = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X + 1, (int) Y ) ) {
                CliffE = (int) Math.Ceiling( Z - scene.GetCore( (int) X + 1, (int) Y ).Z );
            } else {
                CliffE = (int) Math.Ceiling( Z - 0 );
            }

            if( scene.IsLoadedCore( (int) X - 1, (int) Y ) ) {
                CliffO = (int) Math.Ceiling( Z - scene.GetCore( (int) X - 1, (int) Y ).Z );
            } else {
                CliffO = (int) Math.Ceiling( Z - 0 );
            }
        }
Beispiel #2
0
 public void ApplyLight(Scene scene)
 {
     if (Active)
     {
         Dictionary<Vector2, SortedList<float, Vector2>> collisionMatrix = LightCache.getCacheForARadius(Radius);
         foreach (DrawableEntity ent in listCoreInTheLight)
         {
             if (ent.Z > Position.Z)
             {
                 //hide below blocks when it is taller
                 switch(scene.Orientation) {
                     case Orientation.SO :
                         if (ent.Y - ent.X > Position.Y - Position.X) continue;
                         break;
                     case Orientation.NE:
                         if (ent.Y - ent.X < Position.Y - Position.X) continue;
                         break;
                     case Orientation.SE:
                         if (ent.Y + ent.X > Position.Y + Position.X) continue;
                         break;
                     case Orientation.NO:
                         if (ent.Y + ent.X < Position.Y + Position.X) continue;
                         break;
                 }
             }
             Vector2 relativePositionTarget = new Vector2(Position.X - ent.X, Position.Y - ent.Y);
             SortedList<float, Vector2> collisionTileMatrix ;
             collisionMatrix.TryGetValue(relativePositionTarget,out collisionTileMatrix) ;
             if (collisionTileMatrix != null)
             {
                 bool show = true;
                 foreach (KeyValuePair<float, Vector2> kvp in collisionTileMatrix)
                 {
                     if (relativePositionTarget.Length() < kvp.Value.Length()) break;
                     if (scene.IsLoadedCore((int)Position.X - (int)kvp.Value.X, (int)Position.Y - (int)kvp.Value.Y))
                     {
                         if (scene.GetCore((int)Position.X - (int)kvp.Value.X, (int)Position.Y - (int)kvp.Value.Y).Z > Position.Z)
                         {
                             show = false;
                         }
                     }
                 }
                 if (show)
                 {
                     addLightToAnEntity(ent);
                 }
             }
         }
     }
 }
Beispiel #3
0
 public List<DrawableEntity> RegisterCoreInTheLight(Scene scene)
 {
     listCoreInTheLight.Clear();
     for (float i = Position.X - Radius; i < Position.X + Radius;i++ )
     {
         for (float j = Position.Y - Radius; j < Position.Y + Radius; j++)
         {
             if (scene.IsLoadedCore((int)Math.Ceiling(i), (int)Math.Ceiling(j)))
             {
                 CoreProxy core = scene.GetCore((int)Math.Ceiling(i), (int)Math.Ceiling(j));
                 float distance_to_core = Vector2.Subtract(new Vector2(core.X, core.Y), new Vector2(Position.X, Position.Y)).Length();
                 if (distance_to_core <= Radius)
                 {
                     listCoreInTheLight.Add(core);
                 }
             }
         }
     }
     return listCoreInTheLight;
 }