예제 #1
0
        // Checks the current node for an additional shadow copy and sets it's entity node according to the centre of its image.
        public void SetEntityPosition(Node node, AddShadowCopy shadowCopy)
        {
            // Stores the centre of the shadow copy based on its rectangle.
            Vector2 v2CopyCentre = shadowCopy.EntityPosition + new Vector2(shadowCopy.RectEntity.Width / 2, shadowCopy.RectEntity.Height / 2);

            if (v2CopyCentre != null)
            {
                if (node.Tile.Contains(new Point((int)v2CopyCentre.X, (int)v2CopyCentre.Y)))
                {
                    shadowCopy.EntityNode = node;
                }
            }
        }
예제 #2
0
        // Processes whatever power-up/item the player has equipped.
        public void ProcessItem(GridLayer grid, AddShadowCopy[] addShadowCopies, ShadowCopy[] shadowCopies, Texture2D tx2ShadowCopy)
        {
            switch (strItem)
            {
            case "drk":     // If the node contained a dark area, spawn an additional shadow copy.
            {
                if (addShadowCopies.Contains(null))
                {
                    int intNewCopyIndex;
                    intNewCopyIndex = Array.IndexOf(addShadowCopies, null);
                    addShadowCopies[intNewCopyIndex]             = new AddShadowCopy();
                    addShadowCopies[intNewCopyIndex].EntityImage = tx2ShadowCopy;
                    addShadowCopies[intNewCopyIndex].Initialize(EntityNode);
                }
            }
                strItem = null;
                break;

            case "bld":
                EntityNode.Colour = Color.Red;     // Make the colour of the node the player is in red, to show a blade is equipped.
                for (int intCopyIndex = 0; intCopyIndex < shadowCopies.GetLength(0); intCopyIndex++)
                {
                    if (shadowCopies[intCopyIndex] != null && EntityNode.Tile.Intersects(shadowCopies[intCopyIndex].EntityNode.Tile))
                    {                   // If a shadow copy exists and it intersects the player, remove the copy.
                        shadowCopies[intCopyIndex] = null;
                        strItem = null; // Remove the player's item after use.
                    }
                }
                for (int intCopyIndex = 0; intCopyIndex < addShadowCopies.GetLength(0); intCopyIndex++)
                {
                    if (addShadowCopies[intCopyIndex] != null && EntityNode.Tile.Intersects(addShadowCopies[intCopyIndex].EntityNode.Tile))
                    {                   // If a shadow copy exists and it intersects the player, remove the copy.
                        addShadowCopies[intCopyIndex] = null;
                        strItem = null; // Remove the player's item after use.
                    }
                }
                // if a shadow copy is in the same node as a player with a blade. Remove the shadow copy.
                break;

            case "lbm":                                                       // Casts a light ray where the player is facing from the centre of the player.
                LightRay lightBeam = new LightRay(EntityPosition + new Vector2(RectEntityWidth / 2, RectEntityHeight / 2), EntityDirection, 200, grid);
                BeamKillCopy(grid, lightBeam, addShadowCopies, shadowCopies); // If the beam intersects a shadow copy, remove it.
                break;

            case "frt":
                intHealth = 1000;     // If the player has a fruit, reset the player's health to 100.
                strItem   = null;
                break;
            }
        }