Пример #1
0
        private void CheckTrig(ParticleManager pMan)
        {
            int frameIdx = charDef.GetAnimation(Anim).GetKeyFrame(AnimFrame).FrameRef;

            Frame frame = charDef.GetFrame(frameIdx);

            for (int i = 0; i < frame.GetPartArray().Length; i++)
            {
                Part part = frame.GetPart(i);
                if (part.Index >= 1000)
                {
                    float rotation = part.Rotation;

                    Vector2 location = part.Location * Scale + Loc;

                    if (Face == CharDir.Left)
                    {
                        location.X -= part.Location.X * Scale * 2.0f;
                    }

                    FireTrig(part.Index - 1000, location, pMan);
                }
            }
        }
Пример #2
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Rectangle sRect = new Rectangle();

            int frameIdx = charDef.GetAnimation(Anim).GetKeyFrame(AnimFrame).FrameRef;

            Frame frame = charDef.GetFrame(frameIdx);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            for (int i = 0; i < frame.GetPartArray().Length; i++)
            {
                Part part = frame.GetPart(i);
                if (part.Index > -1 && part.Index < 1000)
                {
                    sRect.X      = ((part.Index % 64) % 5) * 64;
                    sRect.Y      = ((part.Index % 64) / 5) * 64;
                    sRect.Width  = 64;
                    sRect.Height = 64;
                    if (part.Index >= 192)
                    {
                        sRect.X     = ((part.Index % 64) % 4) * 80;
                        sRect.Y     = ((part.Index % 64) / 4) * 64;
                        sRect.Width = 80;
                    }

                    float rotation = part.Rotation;


                    Vector2 location = part.Location * Scale + Loc -
                                       Game1.Scroll;
                    Vector2 scaling = part.Scaling * Scale;
                    if (part.Index >= 128)
                    {
                        scaling *= 1.35f;
                    }

                    if (Face == CharDir.Left)
                    {
                        rotation    = -rotation;
                        location.X -= part.Location.X * Scale * 2.0f;
                    }

                    Texture2D texture;

                    int t = part.Index / 64;
                    switch (t)
                    {
                    case 0:
                        texture = headTex[charDef.HeadIndex];
                        break;

                    case 1:
                        texture = torsoTex[charDef.TorsoIndex];
                        break;

                    case 2:
                        texture = legsTex[charDef.LegsIndex];
                        break;

                    case 3:
                        texture = weaponTex[charDef.WeaponIndex];
                        break;

                    default:
                        texture = null;
                        break;
                    }
                    if (ID == 1 && Game1.Players == 2)
                    {
                        switch (t)
                        {
                        case 0:
                            texture = headTex[3];
                            break;

                        case 1:
                            texture = torsoTex[3];
                            break;

                        case 2:
                            texture = legsTex[2];
                            break;
                        }
                    }
                    Color color = new Color(new
                                            Vector4(1.0f, 1.0f, 1.0f, 1f));

                    if (DyingFrame > 0f)
                    {
                        color = new Color(new Vector4(
                                              1f - DyingFrame,
                                              1f - DyingFrame,
                                              1f - DyingFrame,
                                              1f - DyingFrame));
                    }

                    bool flip = false;

                    if ((Face == CharDir.Right && part.Flip == 0) ||
                        (Face == CharDir.Left && part.Flip == 1))
                    {
                        flip = true;
                    }


                    if (texture != null)
                    {
                        spriteBatch.Draw(texture, location, sRect,
                                         color, rotation, new Vector2(
                                             (float)sRect.Width / 2f, 32.0f),
                                         scaling, (flip ?
                                                   SpriteEffects.None : SpriteEffects.FlipHorizontally),
                                         1.0f);
                    }
                }
            }

            spriteBatch.End();
        }