Exemplo n.º 1
0
            //----------------------------------------------------------------------------------------------------------------
            // - Isometric Buffer Node Constructor
            //----------------------------------------------------------------------------------------------------------------
            public IsometricBufferNode(IsometricObject target, IsometricBuffer container)
            {
                Target = target;

                // Add events to target to dispose this node when the target is disposed, and alert this node of any changes
                // in position
                if (Target != null)
                {
                    Target.Disposed        += (s, e) => { Dispose(); };
                    Target.PositionChanged += (s, e) => { Alert(); };
                }

                Container = container;

                // New nodes immediately signal a re-sort call
                if (Target != null && Container != null)
                {
                    Alert();
                }
            }
Exemplo n.º 2
0
 //----------------------------------------------------------------------------------------------------------------
 // - Compare Painter's Order Of Target Objects
 //----------------------------------------------------------------------------------------------------------------
 private bool Compare(IsometricObject a, IsometricObject b)
 {
     if (a != null && b != null)
     {
         // If A.Z is above B.Z + B.Height relative to A, then A is on top
         if (a.Position.Z >= b.Position.Z + b.Height(new Vector2f(a.Position.X - b.Position.X, a.Position.Y - b.Position.Y)))
         {
             return(true);
         }
         // Else, if A.Z + A.Height relative to B is lower than B.Z, B is on top
         else if (b.Position.Z >= a.Position.Z + a.Height(new Vector2f(a.Position.X - b.Position.X, a.Position.Y - b.Position.Y)))
         {
             return(false);
         }
         // If neither, then compare isometric X+Y (closeness) relationship ...
         else
         {
             return(a.Position.X + a.Position.Y >= b.Position.X + b.Position.Y);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------------------------
        // - Remove Object From Buffer
        //--------------------------------------------------------------------------------------------------------------------
        public void Remove(IsometricObject obj)
        {
            IsometricBufferNode node = Nodes.FirstOrDefault(n => n.Target == obj);

            node?.Dispose();
        }
Exemplo n.º 4
0
 //--------------------------------------------------------------------------------------------------------------------
 // - Add New Object To Buffer
 //--------------------------------------------------------------------------------------------------------------------
 public void Add(IsometricObject obj)
 {
     // Will signal this buffer to re-sort by setting Dirty
     Nodes.Add(new IsometricBufferNode(obj, this));
 }