Exemple #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();
                }
            }
Exemple #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);
 }
Exemple #3
0
        //--------------------------------------------------------------------------------------------------------------------
        // - Remove Object From Buffer
        //--------------------------------------------------------------------------------------------------------------------
        public void Remove(IsometricObject obj)
        {
            IsometricBufferNode node = Nodes.FirstOrDefault(n => n.Target == obj);

            node?.Dispose();
        }
Exemple #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));
 }