2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2018-01-03 17:26:54 +08:00
|
|
|
|
using System;
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-01-03 17:26:54 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-08-03 07:32:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-12-31 21:09:07 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-01-03 19:52:11 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawable.Pieces;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using OpenTK;
|
2017-12-01 14:08:12 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2018-01-11 20:49:20 +08:00
|
|
|
|
public class DrawableFruit : PalpableCatchHitObject<Fruit>
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2017-12-31 21:09:07 +08:00
|
|
|
|
private Circle border;
|
|
|
|
|
|
2017-10-10 15:34:01 +08:00
|
|
|
|
public DrawableFruit(Fruit h)
|
2017-08-08 11:46:37 +08:00
|
|
|
|
: base(h)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2017-10-11 17:18:06 +08:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2018-01-03 17:26:54 +08:00
|
|
|
|
Size = new Vector2((float)CatchHitObject.OBJECT_RADIUS);
|
2017-09-15 19:55:04 +08:00
|
|
|
|
Masking = false;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2018-01-03 19:52:11 +08:00
|
|
|
|
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-08-02 18:37:20 +08:00
|
|
|
|
private void load()
|
|
|
|
|
{
|
2018-03-15 14:58:04 +08:00
|
|
|
|
// todo: this should come from the skin.
|
|
|
|
|
AccentColour = colourForRrepesentation(HitObject.VisualRepresentation);
|
|
|
|
|
|
2018-03-15 12:41:06 +08:00
|
|
|
|
InternalChildren = new[]
|
2017-08-02 18:37:20 +08:00
|
|
|
|
{
|
2018-01-03 17:26:54 +08:00
|
|
|
|
createPulp(HitObject.VisualRepresentation),
|
2017-12-31 21:09:07 +08:00
|
|
|
|
border = new Circle
|
|
|
|
|
{
|
2018-01-03 17:26:54 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
2018-01-03 19:55:52 +08:00
|
|
|
|
Hollow = !HitObject.HyperDash,
|
2018-01-03 17:26:54 +08:00
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 4,
|
2018-01-03 19:55:52 +08:00
|
|
|
|
Colour = HitObject.HyperDash ? Color4.Red : AccentColour.Darken(1).Opacity(0.6f)
|
2018-01-03 17:26:54 +08:00
|
|
|
|
},
|
|
|
|
|
Size = new Vector2(Height * 1.5f),
|
2017-12-31 21:09:07 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-01-03 17:26:54 +08:00
|
|
|
|
BorderColour = Color4.White,
|
2018-01-03 17:38:29 +08:00
|
|
|
|
BorderThickness = 4f,
|
2017-12-31 21:09:07 +08:00
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Colour = AccentColour,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-08-02 18:37:20 +08:00
|
|
|
|
};
|
2017-12-01 14:08:12 +08:00
|
|
|
|
|
|
|
|
|
if (HitObject.HyperDash)
|
|
|
|
|
{
|
2018-03-15 12:41:06 +08:00
|
|
|
|
AddInternal(new Pulp
|
2017-12-01 14:08:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
AccentColour = Color4.Red,
|
|
|
|
|
Blending = BlendingMode.Additive,
|
|
|
|
|
Alpha = 0.5f,
|
2018-01-03 17:26:54 +08:00
|
|
|
|
Scale = new Vector2(1.333f)
|
2017-12-01 14:08:12 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-08-02 18:37:20 +08:00
|
|
|
|
}
|
2017-12-31 21:09:07 +08:00
|
|
|
|
|
2018-01-03 17:26:54 +08:00
|
|
|
|
private Framework.Graphics.Drawable createPulp(FruitVisualRepresentation representation)
|
|
|
|
|
{
|
|
|
|
|
const float large_pulp_3 = 13f;
|
|
|
|
|
const float distance_from_centre_3 = 0.23f;
|
|
|
|
|
|
|
|
|
|
const float large_pulp_4 = large_pulp_3 * 0.925f;
|
|
|
|
|
const float distance_from_centre_4 = distance_from_centre_3 / 0.925f;
|
|
|
|
|
|
|
|
|
|
const float small_pulp = large_pulp_3 / 2;
|
|
|
|
|
|
|
|
|
|
Vector2 positionAt(float angle, float distance) => new Vector2(
|
|
|
|
|
distance * (float)Math.Sin(angle * Math.PI / 180),
|
|
|
|
|
distance * (float)Math.Cos(angle * Math.PI / 180));
|
|
|
|
|
|
|
|
|
|
switch (representation)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2018-01-03 19:55:52 +08:00
|
|
|
|
return new Container();
|
2018-01-04 17:20:23 +08:00
|
|
|
|
case FruitVisualRepresentation.Raspberry:
|
2018-01-03 17:26:54 +08:00
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(small_pulp),
|
|
|
|
|
Y = 0.05f,
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(0, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(90, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(180, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Position = positionAt(270, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case FruitVisualRepresentation.Pineapple:
|
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(small_pulp),
|
|
|
|
|
Y = 0.1f,
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(45, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(135, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
Position = positionAt(225, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(large_pulp_4),
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Position = positionAt(315, distance_from_centre_4),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-01-04 17:20:23 +08:00
|
|
|
|
case FruitVisualRepresentation.Pear:
|
2018-01-03 17:26:54 +08:00
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(small_pulp),
|
|
|
|
|
Y = -0.1f,
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
Position = positionAt(60, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
Position = positionAt(180, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Position = positionAt(300, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case FruitVisualRepresentation.Grape:
|
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(small_pulp),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
Position = positionAt(0, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
Position = positionAt(120, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(large_pulp_3),
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Position = positionAt(240, distance_from_centre_3),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-01-04 17:32:16 +08:00
|
|
|
|
case FruitVisualRepresentation.Banana:
|
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(small_pulp),
|
|
|
|
|
Y = -0.15f
|
|
|
|
|
},
|
|
|
|
|
new Pulp
|
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
Size = new Vector2(large_pulp_4 * 1.2f, large_pulp_4 * 3),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-01-03 17:26:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-31 21:09:07 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2018-01-03 17:38:29 +08:00
|
|
|
|
|
|
|
|
|
border.Alpha = (float)MathHelper.Clamp((HitObject.StartTime - Time.Current) / 500, 0, 1);
|
2017-12-31 21:09:07 +08:00
|
|
|
|
}
|
2018-03-15 14:58:04 +08:00
|
|
|
|
|
|
|
|
|
private Color4 colourForRrepesentation(FruitVisualRepresentation representation)
|
|
|
|
|
{
|
|
|
|
|
switch (representation)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case FruitVisualRepresentation.Pear:
|
|
|
|
|
return new Color4(17, 136, 170, 255);
|
|
|
|
|
case FruitVisualRepresentation.Grape:
|
|
|
|
|
return new Color4(204, 102, 0, 255);
|
|
|
|
|
case FruitVisualRepresentation.Raspberry:
|
|
|
|
|
return new Color4(121, 9, 13, 255);
|
|
|
|
|
case FruitVisualRepresentation.Pineapple:
|
|
|
|
|
return new Color4(102, 136, 0, 255);
|
|
|
|
|
case FruitVisualRepresentation.Banana:
|
|
|
|
|
switch (RNG.Next(0, 3))
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return new Color4(255, 240, 0, 255);
|
|
|
|
|
case 1:
|
|
|
|
|
return new Color4(255, 192, 0, 255);
|
|
|
|
|
case 2:
|
|
|
|
|
return new Color4(214, 221, 28, 255);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|