2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-17 18:16:40 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2020-02-17 17:47:22 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|
|
|
|
{
|
|
|
|
|
public class DrawableFruit : PalpableCatchHitObject<Fruit>
|
|
|
|
|
{
|
2020-02-17 18:16:40 +08:00
|
|
|
|
private Container scaleContainer;
|
2018-05-25 16:33:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public DrawableFruit(Fruit h)
|
|
|
|
|
: base(h)
|
|
|
|
|
{
|
|
|
|
|
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-02-17 18:16:40 +08:00
|
|
|
|
AddRangeInternal(new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
scaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SkinnableDrawable(
|
|
|
|
|
new CatchSkinComponent(getComponent(HitObject.VisualRepresentation)), _ => new FruitPiece())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-17 18:16:40 +08:00
|
|
|
|
scaleContainer.Scale = new Vector2(HitObject.Scale);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-17 17:47:22 +08:00
|
|
|
|
private CatchSkinComponents getComponent(FruitVisualRepresentation hitObjectVisualRepresentation)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-02-17 17:47:22 +08:00
|
|
|
|
switch (hitObjectVisualRepresentation)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-02-17 17:47:22 +08:00
|
|
|
|
case FruitVisualRepresentation.Pear:
|
|
|
|
|
return CatchSkinComponents.FruitPear;
|
|
|
|
|
|
|
|
|
|
case FruitVisualRepresentation.Grape:
|
|
|
|
|
return CatchSkinComponents.FruitGrapes;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case FruitVisualRepresentation.Pineapple:
|
2020-02-17 17:47:22 +08:00
|
|
|
|
return CatchSkinComponents.FruitApple;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2020-02-19 13:31:43 +08:00
|
|
|
|
case FruitVisualRepresentation.Raspberry:
|
|
|
|
|
return CatchSkinComponents.FruitOrange;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case FruitVisualRepresentation.Banana:
|
2020-02-17 17:47:22 +08:00
|
|
|
|
return CatchSkinComponents.FruitBananas;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-17 17:47:22 +08:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(hitObjectVisualRepresentation), hitObjectVisualRepresentation, null);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|