2020-10-04 18:27:49 -04:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
2020-10-18 20:59:53 -04:00
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
2020-10-04 18:27:49 -04:00
|
|
|
|
|
|
|
class Character extends FlxSprite
|
|
|
|
{
|
|
|
|
public var animOffsets:Map<String, Array<Dynamic>>;
|
|
|
|
public var debugMode:Bool = false;
|
|
|
|
|
2020-10-18 20:59:53 -04:00
|
|
|
public var isPlayer:Bool = false;
|
|
|
|
public var curCharacter:String = 'bf';
|
|
|
|
|
|
|
|
public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false)
|
2020-10-04 18:27:49 -04:00
|
|
|
{
|
|
|
|
animOffsets = new Map<String, Array<Dynamic>>();
|
|
|
|
super(x, y);
|
2020-10-18 20:59:53 -04:00
|
|
|
|
|
|
|
curCharacter = character;
|
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
|
|
|
|
var tex:FlxAtlasFrames;
|
|
|
|
antialiasing = true;
|
|
|
|
|
|
|
|
switch (curCharacter)
|
|
|
|
{
|
|
|
|
case 'bf':
|
|
|
|
case 'gf':
|
|
|
|
// GIRLFRIEND CODE
|
|
|
|
tex = FlxAtlasFrames.fromSparrow(AssetPaths.GF_assets__png, AssetPaths.GF_assets__xml);
|
|
|
|
frames = tex;
|
|
|
|
animation.addByPrefix('cheer', 'GF Cheer', 24, false);
|
|
|
|
animation.addByPrefix('singLEFT', 'GF left note', 24, false);
|
|
|
|
animation.addByPrefix('singRIGHT', 'GF Right Note', 24, false);
|
|
|
|
animation.addByPrefix('singUP', 'GF Up Note', 24, false);
|
|
|
|
animation.addByPrefix('singDOWN', 'GF Down Note', 24, false);
|
|
|
|
animation.addByIndices('sad', 'gf sad', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "", 24, false);
|
|
|
|
animation.addByIndices('danceLeft', 'GF Dancing Beat', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false);
|
|
|
|
animation.addByIndices('danceRight', 'GF Dancing Beat', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false);
|
|
|
|
|
|
|
|
addOffset('cheer');
|
2020-10-23 19:12:38 -04:00
|
|
|
addOffset('sad', -2, -2);
|
|
|
|
addOffset('danceLeft', 0, -9);
|
|
|
|
addOffset('danceRight', 0, -9);
|
2020-10-18 20:59:53 -04:00
|
|
|
|
2020-10-23 19:12:38 -04:00
|
|
|
addOffset("singUP", 0, 4);
|
|
|
|
addOffset("singRIGHT", 0, -20);
|
|
|
|
addOffset("singLEFT", 0, -19);
|
|
|
|
addOffset("singDOWN", 0, -20);
|
2020-10-18 20:59:53 -04:00
|
|
|
|
|
|
|
playAnim('danceRight');
|
|
|
|
|
|
|
|
case 'dad':
|
|
|
|
// DAD ANIMATION LOADING CODE
|
|
|
|
tex = FlxAtlasFrames.fromSparrow(AssetPaths.DADDY_DEAREST__png, AssetPaths.DADDY_DEAREST__xml);
|
|
|
|
frames = tex;
|
|
|
|
animation.addByPrefix('idle', 'Dad idle dance', 24);
|
|
|
|
animation.addByPrefix('singUP', 'Dad Sing Note UP', 24);
|
|
|
|
animation.addByPrefix('singRIGHT', 'Dad Sing Note RIGHT', 24);
|
|
|
|
animation.addByPrefix('singDOWN', 'Dad Sing Note DOWN', 24);
|
|
|
|
animation.addByPrefix('singLEFT', 'Dad Sing Note LEFT', 24);
|
|
|
|
playAnim('idle');
|
|
|
|
|
|
|
|
addOffset('idle');
|
|
|
|
addOffset("singUP", -6, 50);
|
|
|
|
addOffset("singRIGHT", 0, 27);
|
|
|
|
addOffset("singLEFT", -10, 10);
|
|
|
|
addOffset("singDOWN", 0, -30);
|
2020-10-23 19:12:38 -04:00
|
|
|
case 'spooky':
|
|
|
|
tex = FlxAtlasFrames.fromSparrow(AssetPaths.spooky_kids_assets__png, AssetPaths.spooky_kids_assets__xml);
|
|
|
|
frames = tex;
|
|
|
|
animation.addByPrefix('singUP', 'spooky UP NOTE', 24, false);
|
|
|
|
animation.addByPrefix('singDOWN', 'spooky DOWN note', 24, false);
|
|
|
|
animation.addByPrefix('singLEFT', 'note sing left', 24, false);
|
|
|
|
animation.addByPrefix('singRIGHT', 'spooky sing right', 24, false);
|
2020-10-30 19:47:19 -04:00
|
|
|
animation.addByIndices('danceLeft', 'spooky dance idle', [0, 2, 6], "", 12, false);
|
2020-10-23 19:12:38 -04:00
|
|
|
animation.addByIndices('danceRight', 'spooky dance idle', [8, 10, 12, 14], "", 12, false);
|
|
|
|
|
|
|
|
addOffset('danceLeft');
|
|
|
|
addOffset('danceRight');
|
|
|
|
|
|
|
|
addOffset("singUP", -20, 26);
|
|
|
|
addOffset("singRIGHT", -130, -14);
|
|
|
|
addOffset("singLEFT", 130, -10);
|
|
|
|
addOffset("singDOWN", -50, -130);
|
|
|
|
|
|
|
|
playAnim('danceRight');
|
2020-10-30 19:47:19 -04:00
|
|
|
case 'monster':
|
|
|
|
tex = FlxAtlasFrames.fromSparrow(AssetPaths.Monster_Assets__png, AssetPaths.Monster_Assets__xml);
|
|
|
|
frames = tex;
|
|
|
|
animation.addByPrefix('idle', 'monster idle', 24);
|
|
|
|
animation.addByPrefix('singUP', 'monster up note', 24, false);
|
|
|
|
animation.addByPrefix('singDOWN', 'monster down', 24, false);
|
|
|
|
animation.addByPrefix('singLEFT', 'Monster left note', 24, false);
|
|
|
|
animation.addByPrefix('singRIGHT', 'Monster Right note', 24, false);
|
|
|
|
|
|
|
|
addOffset('idle');
|
|
|
|
addOffset("singUP", -20, 50);
|
|
|
|
addOffset("singRIGHT", -51);
|
|
|
|
addOffset("singLEFT", -30);
|
|
|
|
addOffset("singDOWN", -30, -40);
|
|
|
|
playAnim('idle');
|
2020-10-18 20:59:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private var danced:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FOR GF DANCING SHIT
|
|
|
|
*/
|
|
|
|
public function dance()
|
|
|
|
{
|
|
|
|
switch (curCharacter)
|
|
|
|
{
|
|
|
|
case 'gf':
|
|
|
|
danced = !danced;
|
|
|
|
|
2020-10-23 19:12:38 -04:00
|
|
|
if (danced)
|
|
|
|
playAnim('danceRight');
|
|
|
|
else
|
|
|
|
playAnim('danceLeft');
|
|
|
|
case 'spooky':
|
|
|
|
danced = !danced;
|
|
|
|
|
2020-10-18 20:59:53 -04:00
|
|
|
if (danced)
|
|
|
|
playAnim('danceRight');
|
|
|
|
else
|
|
|
|
playAnim('danceLeft');
|
|
|
|
case 'dad':
|
|
|
|
playAnim('idle');
|
2020-10-30 19:47:19 -04:00
|
|
|
case 'monster':
|
|
|
|
playAnim('idle');
|
2020-10-18 20:59:53 -04:00
|
|
|
}
|
2020-10-04 18:27:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void
|
|
|
|
{
|
|
|
|
animation.play(AnimName, Force, Reversed, Frame);
|
|
|
|
|
|
|
|
var daOffset = animOffsets.get(animation.curAnim.name);
|
|
|
|
if (animOffsets.exists(animation.curAnim.name))
|
|
|
|
{
|
|
|
|
offset.set(daOffset[0], daOffset[1]);
|
|
|
|
}
|
2020-10-30 19:47:19 -04:00
|
|
|
|
|
|
|
if (curCharacter == 'gf')
|
|
|
|
{
|
|
|
|
if (AnimName == 'singLEFT')
|
|
|
|
{
|
|
|
|
danced = true;
|
|
|
|
}
|
|
|
|
else if (AnimName == 'singRIGHT')
|
|
|
|
{
|
|
|
|
danced = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (AnimName == 'singUP' || AnimName == 'singDOWN')
|
|
|
|
{
|
|
|
|
danced = !danced;
|
|
|
|
}
|
|
|
|
}
|
2020-10-04 18:27:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addOffset(name:String, x:Float = 0, y:Float = 0)
|
|
|
|
{
|
|
|
|
animOffsets[name] = [x, y];
|
|
|
|
}
|
|
|
|
}
|