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
|
|
@ -1,28 +0,0 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Items/Rube"
|
||||
],
|
||||
|
||||
function (Parent) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function Rube(physicsEngine, uid, options) {
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
}
|
||||
|
||||
Rube.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Rube.prototype.createMesh = function() {
|
||||
};
|
||||
|
||||
Rube.prototype.destroy = function() {
|
||||
};
|
||||
|
||||
Rube.prototype.render = function() {
|
||||
}
|
||||
|
||||
Rube.prototype.flip = function(direction) {
|
||||
};
|
||||
|
||||
return Rube;
|
||||
});
|
||||
187
app/Game/Client/GameObjects/Items/RubeDoll.js
Normal file
187
app/Game/Client/GameObjects/Items/RubeDoll.js
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Items/RubeDoll",
|
||||
"Game/Client/View/Abstract/Layer",
|
||||
"Game/Config/Settings",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
],
|
||||
|
||||
function (Parent, Layer, Settings, Nc) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function RubeDoll(physicsEngine, uid, options) {
|
||||
|
||||
this.primaryColor = 0x008800;
|
||||
|
||||
var limbOptions = {};
|
||||
|
||||
limbOptions.chest = {
|
||||
width: 6,
|
||||
height: 18,
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
limbOptions.head = {
|
||||
width: 10,
|
||||
height: 12,
|
||||
x: 0,
|
||||
y: - limbOptions.chest.height / 2 - 7
|
||||
};
|
||||
|
||||
limbOptions.upperLeftLeg = {
|
||||
width: 5,
|
||||
height: 8,
|
||||
x: -2,
|
||||
y: limbOptions.chest.height / 2
|
||||
};
|
||||
|
||||
limbOptions.upperRightLeg = {
|
||||
width: 4,
|
||||
height: 9,
|
||||
x: 2,
|
||||
y: limbOptions.chest.height / 2
|
||||
};
|
||||
|
||||
limbOptions.lowerLeftLeg = {
|
||||
width: 4,
|
||||
height: 4,
|
||||
x: -2,
|
||||
y: limbOptions.chest.height / 2 + limbOptions.upperLeftLeg.height
|
||||
};
|
||||
|
||||
limbOptions.lowerRightLeg = {
|
||||
width: 4,
|
||||
height: 4,
|
||||
x: 2,
|
||||
y: limbOptions.chest.height / 2 + limbOptions.upperRightLeg.height
|
||||
};
|
||||
|
||||
|
||||
|
||||
limbOptions.upperLeftArm = {
|
||||
width: 2,
|
||||
height: 8,
|
||||
x: -2,
|
||||
y: -limbOptions.chest.height / 2
|
||||
};
|
||||
|
||||
limbOptions.upperRightArm = {
|
||||
width: 3,
|
||||
height: 8,
|
||||
x: 2,
|
||||
y: -limbOptions.chest.height / 2
|
||||
};
|
||||
|
||||
limbOptions.lowerLeftArm = {
|
||||
width: 2,
|
||||
height: 5,
|
||||
x: -2,
|
||||
y: -limbOptions.chest.height / 2 + limbOptions.upperLeftArm.height
|
||||
};
|
||||
|
||||
limbOptions.lowerRightArm = {
|
||||
width: 2,
|
||||
height: 5,
|
||||
x: 2,
|
||||
y: -limbOptions.chest.height / 2 + limbOptions.upperRightArm.height
|
||||
};
|
||||
|
||||
this.limbOptions = limbOptions;
|
||||
|
||||
this.layerId = Layer.ID.SPAWN;
|
||||
this.limbMeshes = {};
|
||||
this.baseMeshName = "chest";
|
||||
this.characterName = "Chuck";
|
||||
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
}
|
||||
|
||||
RubeDoll.prototype = Object.create(Parent.prototype);
|
||||
|
||||
RubeDoll.prototype.createMesh = function() {
|
||||
|
||||
|
||||
this.createLimbMesh("lowerRightLeg");
|
||||
this.createLimbMesh("upperRightLeg");
|
||||
|
||||
this.createLimbMesh("lowerRightArm");
|
||||
this.createLimbMesh("upperRightArm");
|
||||
|
||||
this.createLimbMesh("chest");
|
||||
this.createLimbMesh("head");
|
||||
|
||||
this.createLimbMesh("lowerLeftLeg");
|
||||
this.createLimbMesh("upperLeftLeg");
|
||||
|
||||
this.createLimbMesh("lowerLeftArm");
|
||||
this.createLimbMesh("upperLeftArm");
|
||||
|
||||
};
|
||||
|
||||
RubeDoll.prototype.createLimbMesh = function(name) {
|
||||
var self = this;
|
||||
var texturePath = Settings.GRAPHICS_PATH
|
||||
+ Settings.GRAPHICS_SUBPATH_CHARACTERS + ""
|
||||
+ this.characterName + '/';
|
||||
|
||||
|
||||
var callback = function(mesh) {
|
||||
if(name == self.baseMeshName) {
|
||||
self.mesh = mesh;
|
||||
}
|
||||
|
||||
self.limbMeshes[name] = mesh;
|
||||
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
|
||||
|
||||
// setting shirt color
|
||||
Nc.trigger(Nc.ns.client.view.mesh.addFilter, self.layerId, mesh, "colorRangeReplace", {
|
||||
minColor: 0x3b4a31,
|
||||
maxColor: 0x6d855d,
|
||||
newColor: self.primaryColor,
|
||||
brightnessOffset: 0.56
|
||||
});
|
||||
};
|
||||
|
||||
Nc.trigger(Nc.ns.client.view.mesh.create,
|
||||
this.layerId,
|
||||
texturePath + name + ".png",
|
||||
callback,
|
||||
{
|
||||
width: this.limbOptions[name].width,
|
||||
height: this.limbOptions[name].height,
|
||||
pivot: {
|
||||
x: this.limbOptions[name].width / 2,
|
||||
y: this.limbOptions[name].height / 2
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
RubeDoll.prototype.destroy = function() {
|
||||
};
|
||||
|
||||
RubeDoll.prototype.render = function() {
|
||||
if(this.limbs) {
|
||||
for(var name in this.limbMeshes) {
|
||||
if(this.limbs[name]) {
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.layerId,
|
||||
this.limbMeshes[name],
|
||||
{
|
||||
x: this.limbs[name].GetPosition().x * Settings.RATIO,
|
||||
y: this.limbs[name].GetPosition().y * Settings.RATIO,
|
||||
rotation: this.limbs[name].GetAngle()
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RubeDoll.prototype.flip = function(direction) {
|
||||
};
|
||||
|
||||
return RubeDoll;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue