initial commit, kind of working.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package com.arc.dh.objects
|
||||
{
|
||||
import com.arc.dh.Gun;
|
||||
import com.arc.dh.objects.enemies.Enemy;
|
||||
import com.arc.dh.util.Data;
|
||||
import com.arc.flixel.ArcParticleSystem;
|
||||
import com.arc.flixel.ArcU;
|
||||
import org.flixel.FlxG;
|
||||
import org.flixel.FlxPoint;
|
||||
|
||||
public class BulletRebound extends Bullet
|
||||
{
|
||||
|
||||
public static const sprite:Class = BulletRebound_sprite;
|
||||
|
||||
private static const SOLID_TIME:Number = 0.15;
|
||||
|
||||
private var bounces:int = 2;
|
||||
|
||||
public var solidTimer:Number = 0.15;
|
||||
|
||||
private var side:String = "";
|
||||
|
||||
private var _vx:Number;
|
||||
|
||||
private var _vy:Number;
|
||||
|
||||
public var lastEnemy:Enemy;
|
||||
|
||||
public function BulletRebound(param1:Number, param2:Number, param3:Number, param4:Number)
|
||||
{
|
||||
super(param1,param2,param3,param4);
|
||||
loadGraphic(sprite,false,false,4,4);
|
||||
this._vx = velocity.x;
|
||||
this._vy = velocity.y;
|
||||
this.bounces = Data.reboundgun[Gun.SPECIAL_ONE] == 1 ? 3 : 2;
|
||||
}
|
||||
|
||||
override public function update() : void
|
||||
{
|
||||
if(this.solidTimer > 0)
|
||||
{
|
||||
this.solidTimer -= FlxG.elapsed;
|
||||
if(this.solidTimer <= 0)
|
||||
{
|
||||
solid = true;
|
||||
}
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
override public function kill() : void
|
||||
{
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:FlxPoint = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc6_:FlxPoint = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
if(this.bounces > 0 && _collider != null)
|
||||
{
|
||||
this.solidTimer = SOLID_TIME;
|
||||
--this.bounces;
|
||||
_loc1_ = velocity.x * FlxG.elapsed;
|
||||
_loc2_ = velocity.y * FlxG.elapsed;
|
||||
if(touching & (UP | DOWN))
|
||||
{
|
||||
this._vy = 0 - this._vy;
|
||||
velocity.y = this._vy;
|
||||
velocity.x = this._vx;
|
||||
}
|
||||
else if(touching & (LEFT | RIGHT))
|
||||
{
|
||||
this._vx = 0 - this._vx;
|
||||
velocity.y = this._vy;
|
||||
velocity.x = this._vx;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = _collider.getMidpoint();
|
||||
_loc4_ = _loc3_.x;
|
||||
_loc5_ = _loc3_.y;
|
||||
_loc6_ = getMidpoint();
|
||||
_loc7_ = _loc6_.x;
|
||||
_loc8_ = _loc6_.y;
|
||||
_loc9_ = _loc7_ - _loc4_;
|
||||
_loc10_ = _loc8_ - _loc5_;
|
||||
_loc11_ = ArcU.abs(_loc9_);
|
||||
_loc12_ = ArcU.abs(_loc10_);
|
||||
if((_loc11_ > _loc12_ || _loc8_ <= _loc5_ && velocity.y <= 0 || _loc8_ >= _loc5_ && velocity.y >= 0) && (_loc7_ <= _loc4_ && velocity.x >= 0 || _loc7_ >= _loc4_ && velocity.x <= 0))
|
||||
{
|
||||
this._vx = 0 - this._vx;
|
||||
velocity.y = this._vy;
|
||||
velocity.x = this._vx;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._vy = 0 - this._vy;
|
||||
velocity.y = this._vy;
|
||||
velocity.x = this._vx;
|
||||
}
|
||||
}
|
||||
ArcParticleSystem.emit(Data.state.particles,"rebound",x + width / 2,y + width / 2,1,1,3,400,-60,60,-100,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArcParticleSystem.emit(Data.state.particles,"rebound",x + width / 2,y + width / 2,1,3,3,400,-60,60,-100,0);
|
||||
alive = false;
|
||||
exists = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user