示例#1
0
 public void UseDrill(Player mountedPlayer)
 {
     if (this._type == 8 && this._abilityActive)
     {
         DrillMountData drillMountData = (DrillMountData)this._mountSpecificData;
         if (drillMountData.beamCooldown == 0)
         {
             for (int i = 0; i < drillMountData.beams.Length; i++)
             {
                 DrillBeam drillBeam = drillMountData.beams[i];
                 if (drillBeam.cooldown == 0)
                 {
                     Point16 point = this.DrillSmartCursor(mountedPlayer, drillMountData);
                     if (point != Point16.NegativeOne)
                     {
                         drillBeam.curTileTarget = point;
                         int  pickPower = drillPickPower;
                         bool flag      = mountedPlayer.whoAmI == Main.myPlayer;
                         if (flag)
                         {
                             bool flag2 = true;
                             if (WorldGen.InWorld(point.X, point.Y, 0) && Main.tile[point.X, point.Y] != null && Main.tile[point.X, point.Y].type == 26 && !Main.hardMode)
                             {
                                 flag2 = false;
                                 mountedPlayer.Hurt(PlayerDeathReason.ByOther(4), mountedPlayer.statLife / 2, -mountedPlayer.direction, false, false, false, -1);
                             }
                             if (mountedPlayer.noBuilding)
                             {
                                 flag2 = false;
                             }
                             if (flag2)
                             {
                                 mountedPlayer.PickTile(point.X, point.Y, pickPower);
                             }
                         }
                         Vector2 vector = new Vector2((float)(point.X << 4) + 8f, (float)(point.Y << 4) + 8f);
                         float   num    = (vector - mountedPlayer.Center).ToRotation();
                         for (int j = 0; j < 2; j++)
                         {
                             float   num2    = num + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f;
                             float   num3    = (float)Main.rand.NextDouble() * 2f + 2f;
                             Vector2 vector2 = new Vector2((float)Math.Cos((double)num2) * num3, (float)Math.Sin((double)num2) * num3);
                             int     num4    = Dust.NewDust(vector, 0, 0, 230, vector2.X, vector2.Y, 0, default(Color), 1f);
                             Main.dust[num4].noGravity  = true;
                             Main.dust[num4].customData = mountedPlayer;
                         }
                         if (flag)
                         {
                             Tile.SmoothSlope(point.X, point.Y, true);
                         }
                         drillBeam.cooldown = drillPickTime;
                     }
                     break;
                 }
             }
             drillMountData.beamCooldown = drillBeamCooldownMax;
         }
     }
 }
示例#2
0
        public void UpdateDrill(Player mountedPlayer, bool controlUp, bool controlDown)
        {
            DrillMountData drillMountData = (DrillMountData)this._mountSpecificData;

            for (int i = 0; i < drillMountData.beams.Length; i++)
            {
                DrillBeam drillBeam = drillMountData.beams[i];
                if (drillBeam.cooldown > 1)
                {
                    drillBeam.cooldown--;
                }
                else if (drillBeam.cooldown == 1)
                {
                    drillBeam.cooldown      = 0;
                    drillBeam.curTileTarget = Point16.NegativeOne;
                }
            }
            drillMountData.diodeRotation = drillMountData.diodeRotation * 0.85f + 0.15f * drillMountData.diodeRotationTarget;
            if (drillMountData.beamCooldown > 0)
            {
                drillMountData.beamCooldown--;
            }
        }
示例#3
0
        public void Draw(List <DrawData> playerDrawData, int drawType, Player drawPlayer, Vector2 Position, Color drawColor, SpriteEffects playerEffect, float shadow)
        {
            if (playerDrawData != null)
            {
                Texture2D texture2D;
                Texture2D texture2D2;
                switch (drawType)
                {
                case 0:
                    texture2D  = this._data.backTexture;
                    texture2D2 = this._data.backTextureGlow;
                    break;

                case 1:
                    texture2D  = this._data.backTextureExtra;
                    texture2D2 = this._data.backTextureExtraGlow;
                    break;

                case 2:
                    if (this._type == 0 && this._idleTime >= this._idleTimeNext)
                    {
                        return;
                    }
                    texture2D  = this._data.frontTexture;
                    texture2D2 = this._data.frontTextureGlow;
                    break;

                case 3:
                    texture2D  = this._data.frontTextureExtra;
                    texture2D2 = this._data.frontTextureExtraGlow;
                    break;

                default:
                    texture2D  = null;
                    texture2D2 = null;
                    break;
                }
                if (texture2D != null)
                {
                    int type = this._type;
                    if ((type == 0 || type == 9) && drawType == 3 && shadow != 0f)
                    {
                        return;
                    }
                    int num  = this.XOffset;
                    int num2 = this.YOffset + this.PlayerOffset;
                    if (drawPlayer.direction <= 0 && (!this.Cart || !this.Directional))
                    {
                        num *= -1;
                    }
                    Position.X = (float)(int)(Position.X - Main.screenPosition.X + (float)(drawPlayer.width / 2) + (float)num);
                    Position.Y = (float)(int)(Position.Y - Main.screenPosition.Y + (float)(drawPlayer.height / 2) + (float)num2);
                    int  num3 = 0;
                    bool flag = false;
                    switch (this._type)
                    {
                    case 9:
                        flag = true;
                        switch (drawType)
                        {
                        case 0:
                            num3 = this._frame;
                            break;

                        case 2:
                            num3 = this._frameExtra;
                            break;

                        case 3:
                            num3 = this._frameExtra;
                            break;

                        default:
                            num3 = 0;
                            break;
                        }
                        break;

                    case 5:
                        switch (drawType)
                        {
                        case 0:
                            num3 = this._frame;
                            break;

                        case 1:
                            num3 = this._frameExtra;
                            break;

                        default:
                            num3 = 0;
                            break;
                        }
                        break;

                    default:
                        num3 = this._frame;
                        break;
                    }
                    int       num4  = this._data.textureHeight / this._data.totalFrames;
                    Rectangle value = new Rectangle(0, num4 * num3, this._data.textureWidth, num4);
                    if (flag)
                    {
                        value.Height -= 2;
                    }
                    switch (this._type)
                    {
                    case 0:
                        if (drawType == 3)
                        {
                            drawColor = Color.White;
                        }
                        break;

                    case 9:
                        if (drawType != 3)
                        {
                            break;
                        }
                        if (this._abilityCharge != 0)
                        {
                            drawColor   = Color.Multiply(Color.White, (float)this._abilityCharge / (float)this._data.abilityChargeMax);
                            drawColor.A = 0;
                            break;
                        }
                        return;

                    case 7:
                        if (drawType == 3)
                        {
                            drawColor = new Color(250, 250, 250, 255) * drawPlayer.stealth * (1f - shadow);
                        }
                        break;
                    }
                    Color color = new Color(drawColor.ToVector4() * 0.25f + new Vector4(0.75f));
                    switch (this._type)
                    {
                    case 11:
                        if (drawType == 2)
                        {
                            color   = Color.White;
                            color.A = 127;
                        }
                        break;

                    case 12:
                        if (drawType == 0)
                        {
                            float scale = MathHelper.Clamp(drawPlayer.MountFishronSpecialCounter / 60f, 0f, 1f);
                            color = Colors.CurrentLiquidColor;
                            if (color == Color.Transparent)
                            {
                                color = Color.White;
                            }
                            color.A = 127;
                            color  *= scale;
                        }
                        break;
                    }
                    float num5 = 0f;
                    switch (this._type)
                    {
                    case 8:
                    {
                        DrillMountData drillMountData = (DrillMountData)this._mountSpecificData;
                        switch (drawType)
                        {
                        case 0:
                            num5 = drillMountData.outerRingRotation - num5;
                            break;

                        case 3:
                            num5 = drillMountData.diodeRotation - num5 - drawPlayer.fullRotation;
                            break;
                        }
                        break;
                    }

                    case 7:
                        num5 = drawPlayer.fullRotation;
                        break;
                    }
                    Vector2 origin = this.Origin;
                    type = this._type;
                    float         scale2 = 1f;
                    SpriteEffects effect;
                    switch (this._type)
                    {
                    case 7:
                        effect = SpriteEffects.None;
                        break;

                    case 8:
                        effect = (SpriteEffects)((drawPlayer.direction == 1 && drawType == 2) ? 1 : 0);
                        break;

                    case 6:
                    case 13:
                        effect = (SpriteEffects)(this._flipDraw ? 1 : 0);
                        break;

                    case 11:
                        effect = ((Math.Sign(drawPlayer.velocity.X) == -drawPlayer.direction) ? (playerEffect ^ SpriteEffects.FlipHorizontally) : playerEffect);
                        break;

                    default:
                        effect = playerEffect;
                        break;
                    }
                    type = this._type;
                    DrawData item;
                    if (MountLoader.Draw(new Mount(), playerDrawData, drawType, drawPlayer, ref texture2D, ref texture2D2, ref Position, ref value, ref drawColor, ref color, ref num5, ref effect, ref origin, ref scale2, shadow))
                    {
                        item        = new DrawData(texture2D, Position, value, drawColor, num5, origin, scale2, effect, 0);
                        item.shader = Mount.currentShader;
                        playerDrawData.Add(item);
                        if (texture2D2 != null)
                        {
                            item        = new DrawData(texture2D2, Position, value, color * ((float)(int)drawColor.A / 255f), num5, origin, scale2, effect, 0);
                            item.shader = Mount.currentShader;
                        }
                        playerDrawData.Add(item);
                    }
                    type = this._type;
                    if (type == 8 && drawType == 3)
                    {
                        DrillMountData drillMountData2 = (DrillMountData)this._mountSpecificData;
                        Rectangle      value2          = new Rectangle(0, 0, 1, 1);
                        Vector2        vector          = Mount.drillDiodePoint1.RotatedBy((double)drillMountData2.diodeRotation, default(Vector2));
                        Vector2        vector2         = Mount.drillDiodePoint2.RotatedBy((double)drillMountData2.diodeRotation, default(Vector2));
                        for (int i = 0; i < drillMountData2.beams.Length; i++)
                        {
                            DrillBeam drillBeam = drillMountData2.beams[i];
                            if (!(drillBeam.curTileTarget == Point16.NegativeOne))
                            {
                                for (int j = 0; j < 2; j++)
                                {
                                    Vector2 value3 = new Vector2((float)(drillBeam.curTileTarget.X * 16 + 8), (float)(drillBeam.curTileTarget.Y * 16 + 8)) - Main.screenPosition - Position;
                                    Vector2 vector3;
                                    Color   color2;
                                    if (j == 0)
                                    {
                                        vector3 = vector;
                                        color2  = Color.CornflowerBlue;
                                    }
                                    else
                                    {
                                        vector3 = vector2;
                                        color2  = Color.LightGreen;
                                    }
                                    color2.A = 128;
                                    color2  *= 0.5f;
                                    Vector2 v      = value3 - vector3;
                                    float   num6   = v.ToRotation();
                                    float   y      = v.Length();
                                    Vector2 scale3 = new Vector2(2f, y);
                                    item = new DrawData(Main.magicPixel, vector3 + Position, value2, color2, num6 - 1.57079637f, Vector2.Zero, scale3, SpriteEffects.None, 0);
                                    item.ignorePlayerRotation = true;
                                    item.shader = Mount.currentShader;
                                    playerDrawData.Add(item);
                                }
                            }
                        }
                    }
                }
            }
        }