Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.isartdigital.plateformer.game.sprites.levelObjects.props.traps;
- import com.isartdigital.plateformer.game.sprites.levelObjects.props.Trap;
- import pixi.core.display.Container;
- import pixi.core.math.Point;
- /**
- * ...
- * @author Rafael Garcin
- */
- enum Orientation {
- HORIZONTAL;
- VERTICAL;
- }
- class KillZoneDynamic extends Trap
- {
- public static function doActions():Void {
- for (killZoneDynamic in list) {
- killZoneDynamic.doAction();
- }
- }
- public static var list:Array<KillZoneDynamic> = new Array<KillZoneDynamic>();
- private static inline var AMPLITUDE:Int = 200;
- public var horizontal(get, null):Bool;
- private var speedValue:Float = 0;
- private var baseAcceleration:Float = 1.8;
- private var origin:Float;
- private var pos:Float;
- private var orientation: Orientation;
- private var way:Int = 1;
- public function new()
- {
- super();
- speedValue = 0.07;
- baseAcceleration = 1;
- }
- override public function init(pName:String,?pStage:Container=null, ?pX:Float=0, ?pY:Float=0, ?pRotation:Float=0, ?pScaleX:Float= 1, ?pScaleY:Float = 1, ?pAssetName:String=null, ?pStart:Bool=true):Void
- {
- super.init(pName,pStage, pX, pY, pRotation, pScaleX, pScaleY, pAssetName, pStart);
- orientation = Math.abs(rotation % Math.PI) <= 0.01 ? Orientation.HORIZONTAL : Orientation.VERTICAL;
- origin = horizontal ? x : y;
- }
- override public function start():Void
- {
- list.push(this);
- super.start();
- }
- override public function destroy():Void
- {
- list.splice(list.indexOf(this), 1);
- super.destroy();
- }
- override function doActionNormal():Void
- {
- pos = origin + Math.cos(Main.getInstance().frames * speedValue) * AMPLITUDE;
- if (horizontal) x = pos;
- else y = pos;
- }
- private function get_horizontal():Bool {
- return orientation == Orientation.HORIZONTAL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement