control tabs, organism editor, code refactor

This commit is contained in:
MaxRobinsonTheGreat
2020-07-18 00:31:46 -06:00
parent 2fc2ba7b80
commit ebb39df34a
21 changed files with 524 additions and 402 deletions

View 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;