Ejemplo n.º 1
0
        public static bool ValidSide(this SpriteFacing facing, DirectionsEight side)
        {
            if (facing == SpriteFacing.Eightway)
            {
                return(side != DirectionsEight.Top);
            }
            switch (side)
            {
            case DirectionsEight.Front:
            case DirectionsEight.Right:
            case DirectionsEight.Rear:
                return(true);

            case DirectionsEight.Left:
                return(facing == SpriteFacing.Eightway || facing == SpriteFacing.Fourway);
            }
            if (facing == SpriteFacing.EightwayFlipped)
            {
                switch (side)
                {
                case DirectionsEight.FrontRight:
                case DirectionsEight.RearRight:
                    return(true);
                }
            }
            if (facing == SpriteFacing.Eightway)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public (Sprite sprite, bool mirror) GetFacingSprite(SpriteFacing facing)
        {
            switch (facing)
            {
            case SpriteFacing.None:
                return(Front, false);

            case SpriteFacing.Front:
                return(Front, false);

            case SpriteFacing.FrontLeft:
                return(FrontLeft, false);

            case SpriteFacing.Left:
                return(Left, false);

            case SpriteFacing.BackLeft:
                return(BackLeft, false);

            case SpriteFacing.Back:
                return(Back, false);

            case SpriteFacing.BackRight:
                return(BackRight, false);

            case SpriteFacing.Right:
                return(Right, false);

            case SpriteFacing.FrontRight:
                return(FrontRight, false);

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 3
0
 public static bool RequiresFlipping(this SpriteFacing facing)
 {
     switch (facing)
     {
     case SpriteFacing.EightwayFlipped:
     case SpriteFacing.FourwayFlipped:
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the direction the sprite should be facing
        /// </summary>
        /// <param name="Name">Name of the sprite to modify</param>
        /// <param name="Facing">Direction the sprite should be facing</param>
        public void SetSpriteFacing(string Name, SpriteFacing Facing)
        {
            SpriteInfo CurrSprite;

            CurrSprite = cSpriteList[Name];

            CurrSprite.Facing = Facing;

            cSpriteList[Name] = CurrSprite;
        }
Ejemplo n.º 5
0
        public static DirectionsEight GetSide(SpriteFacing facing, float spriteFacingAngle, float margin, out bool inMargin)
        {
            switch (facing)
            {
            case SpriteFacing.Eightway:
            case SpriteFacing.EightwayFlipped:
                return(GetFacing(_dirRangesEight, spriteFacingAngle, margin, out inMargin));

            case SpriteFacing.Fourway:
            default:
                return(GetFacing(DirRangesFour, spriteFacingAngle, margin, out inMargin));
            }
        }
Ejemplo n.º 6
0
    public void DetermineSpriteFacing(Tile previous_tile, Tile next_tile)
    {
        Vector2 difference = next_tile.position - previous_tile.position;

        difference.Normalize();
        if (Mathf.Abs(difference.x) > Mathf.Abs(difference.y))
        {
            difference = new Vector2(Mathf.RoundToInt(difference.x), 0);
        }
        else
        {
            difference = new Vector2(0, Mathf.RoundToInt(difference.y));
        }

        if (difference == new Vector2(1, 0))
        {
            GetComponent <SpriteRenderer>().sprite = player_sprites[1];
            GetComponent <SpriteRenderer>().flipX  = true;
            facing = SpriteFacing.NW;
        }
        else if (difference == new Vector2(0, 1))
        {
            GetComponent <SpriteRenderer>().sprite = player_sprites[0];
            GetComponent <SpriteRenderer>().flipX  = true;
            facing = SpriteFacing.SW;
        }
        else if (difference == new Vector2(-1, 0))
        {
            GetComponent <SpriteRenderer>().sprite = player_sprites[0];
            GetComponent <SpriteRenderer>().flipX  = false;
            facing = SpriteFacing.SE;
        }
        else if (difference == new Vector2(0, -1))
        {
            GetComponent <SpriteRenderer>().sprite = player_sprites[1];
            GetComponent <SpriteRenderer>().flipX  = false;
            facing = SpriteFacing.NE;
        }
        else
        {
            Debug.LogWarning("No matching facing direction");
        }

        if (HasBall())
        {
            GetComponentInChildren <Ball>().FixPositionFacing(this);
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Specify the state of a managed sprite
        /// </summary>
        /// <param name="Name">Name of the sprite to modify</param>
        /// <param name="Animation">Name of an animation for the sprite to begin carrying ouy</param>
        /// <param name="Facing">Which direction the sprite should be facing on screed</param>
        /// <param name="ScreenPosition">Where on the screen the sprite should be drawn, this is in screen coordinates</param>
        /// <param name="TintColor">The color to apply to the sprite, tinting its appearance</param>
        /// <param name="Visible">True if the sprite should be draw, false if it should be left out of when rendering</param>
        public void SetSpriteState(string Name, string Animation, SpriteFacing Facing, Point ScreenPosition, Color TintColor, bool Visible)
        {
            SpriteInfo CurrSprite;

            CurrSprite = cSpriteList[Name];

            CurrSprite.Visible       = Visible;
            CurrSprite.Facing        = Facing;
            CurrSprite.ScreenRect.X  = ScreenPosition.X;
            CurrSprite.ScreenRect.Y  = ScreenPosition.Y;
            CurrSprite.AnimationName = Animation;
            CurrSprite.AnimationTime = 0;
            CurrSprite.TintColor     = TintColor;

            cSpriteList[Name] = CurrSprite;
        }
Ejemplo n.º 8
0
 public SpriteBillboardComponent(SpriteFacing facing, bool backwards, BillboardMode billboard)
 {
     Facing    = facing;
     Backwards = backwards;
     Billboard = billboard;
 }
Ejemplo n.º 9
0
 public static DirectionsEight GetCameraSide(SpriteFacing facing, Transform posTr, Transform forwardTr, float margin, out bool inMargin)
 {
     return(GetSide(facing, GetAngle(posTr, forwardTr, Game.SpriteCamera.transform), margin, out inMargin));
 }