Last active
August 29, 2015 14:10
-
-
Save kb10uy/1cb7dae68ae802977702 to your computer and use it in GitHub Desktop.
Kbtter5のレーザー実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static OptionSelectionInformation LinearLaserOptionInformation = new OptionSelectionInformation() | |
{ | |
Name = "直線レーザー", | |
Description = "普通のレーザーです", | |
Operation = LinearLaserOption, | |
ModeStrings = new[] { "Kbtter5", "魔理沙" }, | |
UserValueCombination = OptionSelectionValue.Direction | OptionSelectionValue.Mode, | |
DefaultValue = new OptionInitializationInformation() | |
{ | |
Direction = OptionDirection.Up, | |
Mode = 1, | |
} | |
}; | |
private static IEnumerator<bool> LinearLaserOption(PlayerOption option, OptionInitializationInformation info) | |
{ | |
var s = false; | |
var ps = false; | |
var la = false; | |
PlayerLinearLaser ls = null; | |
while (true) | |
{ | |
s = option.Parent.IsShottableTiming; | |
if (!ps && s) | |
{ | |
la = true; | |
ls = new PlayerLinearLaser(option, LinearLaserMarisaStyle, 8, CommonObjects.ImageLaser8) | |
{ | |
Angle = GetAngle(info.Direction) ?? 0, | |
X = option.X, | |
Y = option.Y | |
}; | |
option.ParentManager.Add(ls, (int)GameLayer.PlayerBullet); | |
} | |
if (ps && !s) | |
{ | |
la = false; | |
ls.AddSubOperation(LaserThrowAway(ls.Angle, 20)); | |
} | |
if (la) | |
{ | |
ls.X = option.X; | |
ls.Y = option.Y; | |
} | |
ps = s; | |
yield return true; | |
} | |
} | |
private static IEnumerator<bool> LinearLaserMarisaStyle(UserSprite par, PlayerLinearLaser laser) | |
{ | |
laser.BrightR = (byte)((long)par.SourceUser.Id & 0xFF); | |
laser.BrightG = (byte)((long)(par.SourceUser.Id >> 8) & 0xFF); | |
laser.BrightB = (byte)((long)(par.SourceUser.Id >> 16) & 0xFF); | |
while (true) | |
{ | |
if (laser.Length < 800) laser.Length += 20; | |
yield return true; | |
} | |
} | |
private static CoroutineFunction<MultiAdditionalCoroutineSprite> LaserThrowAway(double angle, double speed) | |
{ | |
return sp => LaserThrowAwayFunction(sp, angle, speed); | |
} | |
private static IEnumerator<bool> LaserThrowAwayFunction(MultiAdditionalCoroutineSprite sp, double angle, double speed) | |
{ | |
while (true) | |
{ | |
sp.X += Math.Cos(angle) * speed; | |
sp.Y += Math.Sin(angle) * speed; | |
yield return true; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment