control tabs, organism editor, code refactor
This commit is contained in:
53
src/Controllers/EditorController.js
Normal file
53
src/Controllers/EditorController.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const CanvasController = require("./CanvasController");
|
||||
const Modes = require("./ControlModes");
|
||||
const CellTypes = require("../Organism/Cell/CellTypes");
|
||||
|
||||
class EditorController extends CanvasController{
|
||||
constructor(env, canvas) {
|
||||
super(env, canvas);
|
||||
this.mode = Modes.None;
|
||||
this.edit_cell_type = null;
|
||||
this.highlight_org = false;
|
||||
this.defineCellTypeSelection();
|
||||
}
|
||||
|
||||
mouseMove() {
|
||||
|
||||
}
|
||||
|
||||
mouseDown() {
|
||||
if (this.edit_cell_type == null || this.mode != Modes.Edit)
|
||||
return;
|
||||
if (this.left_click)
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
if (this.right_click)
|
||||
this.env.removeCellFromOrg(this.mouse_c, this.mouse_r);
|
||||
}
|
||||
|
||||
defineCellTypeSelection() {
|
||||
var self = this;
|
||||
$('.cell-type').click( function() {
|
||||
switch(this.id){
|
||||
case "mouth":
|
||||
self.edit_cell_type = CellTypes.mouth;
|
||||
break;
|
||||
case "producer":
|
||||
self.edit_cell_type = CellTypes.producer;
|
||||
break;
|
||||
case "mover":
|
||||
self.edit_cell_type = CellTypes.mover;
|
||||
break;
|
||||
case "killer":
|
||||
self.edit_cell_type = CellTypes.killer;
|
||||
break;
|
||||
case "armor":
|
||||
self.edit_cell_type = CellTypes.armor;
|
||||
break;
|
||||
}
|
||||
$(".cell-type" ).css( "border-color", "black" );
|
||||
$("#"+this.id).css("border-color", "yellow");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = EditorController;
|
||||
Reference in New Issue
Block a user