mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
implemented rubedoll level item (not after dying yet)
This commit is contained in:
parent
b12bf2bb0c
commit
c67ff78aa0
16 changed files with 3140 additions and 2022 deletions
File diff suppressed because it is too large
Load diff
66
app/Game/Core/GameObjects/Items/RubeDoll.js
Normal file
66
app/Game/Core/GameObjects/Items/RubeDoll.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
define([
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Lib/Vendor/RubeLoader",
|
||||
"Lib/Vendor/Box2D",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/Assert",
|
||||
"json!Game/Asset/RubeDoll.json" // using requirejs json loader plugin
|
||||
],
|
||||
|
||||
function (Parent, RubeLoader, Box2D, Settings, Assert, RubeDollJson) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function RubeDoll(physicsEngine, uid, options) {
|
||||
Assert.number(options.x, options.y);
|
||||
|
||||
this.rubeLoader = null;
|
||||
this.body = null;
|
||||
this.limbs = {};
|
||||
|
||||
var chest = null;
|
||||
var world = physicsEngine.getWorld();
|
||||
this.rubeLoader = new RubeLoader(RubeDollJson, world);
|
||||
var scene = this.rubeLoader.getScene();
|
||||
|
||||
for (var i in scene.bodies) {
|
||||
var body = scene.bodies[i];
|
||||
var position = body.GetPosition().Copy();
|
||||
position.Add(new Box2D.Common.Math.b2Vec2(
|
||||
options.x / Settings.RATIO,
|
||||
options.y / Settings.RATIO
|
||||
));
|
||||
body.SetPosition(position);
|
||||
this.limbs[body.name] = body;
|
||||
}
|
||||
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
world.DestroyBody(this.body);
|
||||
this.body = this.limbs.chest;
|
||||
|
||||
var def = this.body.GetDefinition();
|
||||
def.userData = this;
|
||||
this.body.SetUserData(this);
|
||||
}
|
||||
|
||||
RubeDoll.prototype = Object.create(Parent.prototype);
|
||||
|
||||
RubeDoll.prototype.flip = function(direction) {
|
||||
Parent.prototype.flip.call(this, direction);
|
||||
// Extend
|
||||
};
|
||||
|
||||
RubeDoll.prototype.reposition = function(handPosition, direction) {
|
||||
|
||||
Parent.prototype.reposition.call(this, handPosition, direction);
|
||||
|
||||
var position = new Box2D.Common.Math.b2Vec2(
|
||||
handPosition.x + ((6 / Settings.RATIO) * direction),
|
||||
handPosition.y
|
||||
);
|
||||
|
||||
this.body.SetPosition(position);
|
||||
};
|
||||
|
||||
return RubeDoll;
|
||||
});
|
||||
|
|
@ -8,9 +8,9 @@ define([
|
|||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Items/RagDoll",
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Rube"
|
||||
"Game/" + GLOBALS.context + "/GameObjects/Items/RubeDoll"
|
||||
|
||||
], function (Settings, Box2D, Nc, Abstract, CollisionDetector, Tile, Item, Skateboard, RagDoll, Rube) {
|
||||
], function (Settings, Box2D, Nc, Abstract, CollisionDetector, Tile, Item, Skateboard, RagDoll, RubeDoll) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
|
@ -50,8 +50,8 @@ define([
|
|||
return new Skateboard(this.engine, uid, options);
|
||||
case "ragdoll":
|
||||
return new RagDoll(this.engine, uid, options);
|
||||
case "rube":
|
||||
return new Rube(this.engine, uid, options);
|
||||
case "rubedoll":
|
||||
return new RubeDoll(this.engine, uid, options);
|
||||
default:
|
||||
return new Item(this.engine, uid, options);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue