added buff giving, took out fullscreen for now
bug with button location -> works with this.viewport.setZoomLevel(1);, but zoom level 2 doesnt change the click location, only the visual location
This commit is contained in:
parent
82eafede7e
commit
465404afda
|
@ -100,6 +100,9 @@
|
||||||
"width": 3,
|
"width": 3,
|
||||||
"alt_tile": [477, 479]
|
"alt_tile": [477, 479]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"sprites":[
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ export default class PlayerController extends ControllerAI {
|
||||||
if(velocity.x === 0){
|
if(velocity.x === 0){
|
||||||
this.owner.animation.playIfNotAlready("IDLE", true);
|
this.owner.animation.playIfNotAlready("IDLE", true);
|
||||||
} else {
|
} else {
|
||||||
console.log("walking anim");
|
|
||||||
this.owner.animation.playIfNotAlready("WALK", true);
|
this.owner.animation.playIfNotAlready("WALK", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ import WeaponTypeRegistry from "./shattered_sword/Registry/WeaponTypeRegistry";
|
||||||
|
|
||||||
// Set up options for our game
|
// Set up options for our game
|
||||||
let options = {
|
let options = {
|
||||||
canvasSize: {x: window.innerWidth, y: window.innerHeight}, // The size of the game
|
canvasSize: {x : 1200, y:1000},
|
||||||
|
//canvasSize: {x: window.innerWidth, y: window.innerHeight}, // The size of the game
|
||||||
clearColor: {r: 0, g: 0, b: 0}, // The color the game clears to
|
clearColor: {r: 0, g: 0, b: 0}, // The color the game clears to
|
||||||
inputs: [
|
inputs: [
|
||||||
{name: "left", keys: ["a", "arrowleft"]}, //TODO - add arrow keys
|
{name: "left", keys: ["a", "arrowleft"]}, //TODO - add arrow keys
|
||||||
|
|
|
@ -41,10 +41,10 @@ export enum BuffType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Buff = {
|
export class Buff {
|
||||||
"type": BuffType,
|
"type": BuffType;
|
||||||
"value": number,
|
"value": number;
|
||||||
"bonus": boolean,
|
//"bonus": boolean, //need to determine what bonus gives
|
||||||
}
|
}
|
||||||
|
|
||||||
type Buffs = [
|
type Buffs = [
|
||||||
|
@ -104,6 +104,31 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//generate array of 3 different buffs
|
||||||
|
/**
|
||||||
|
* generate array of 3 buffs
|
||||||
|
* @returns array of 3 differently typed buffs
|
||||||
|
*/
|
||||||
|
static generateBuffs() : Buff[]{
|
||||||
|
let num = Number(Math.random().toPrecision(1)) * 10; //number from 1 to 10
|
||||||
|
let array : Buff[] = [
|
||||||
|
{type:BuffType.ATK, value:num},
|
||||||
|
{type:BuffType.HEALTH, value:num},
|
||||||
|
{type:BuffType.DEF, value:num},
|
||||||
|
{type:BuffType.SPEED, value:num},
|
||||||
|
{type:BuffType.RANGE, value:num/10} //range is a multiplier percent
|
||||||
|
];
|
||||||
|
|
||||||
|
// Shuffle array
|
||||||
|
const shuffled = array.sort(() => 0.5 - Math.random());
|
||||||
|
|
||||||
|
// Get sub-array of first 3 elements after shuffled
|
||||||
|
let selected = shuffled.slice(0, 3);
|
||||||
|
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add given buff to the player
|
* Add given buff to the player
|
||||||
* @param buff Given buff
|
* @param buff Given buff
|
||||||
|
@ -156,7 +181,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
this.CURRENT_BUFFS = {hp:0, atk:0, def:0, speed:0, range:0};
|
this.CURRENT_BUFFS = {hp:0, atk:0, def:0, speed:0, range:0};
|
||||||
|
|
||||||
//to test the buffs
|
//to test the buffs
|
||||||
//this.addBuff( {type:BuffType.HEALTH, value:1, bonus:false} );
|
this.addBuff( {type:BuffType.HEALTH, value:1} );
|
||||||
//this.addBuff( {type:BuffType.RANGE, value:1, bonus:false} );
|
//this.addBuff( {type:BuffType.RANGE, value:1, bonus:false} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +223,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
Debug.log("playerstate", "Player State: Fall");
|
Debug.log("playerstate", "Player State: Fall");
|
||||||
}
|
}
|
||||||
Debug.log("playerspeed", "x: " + this.velocity.x + ", y:" + this.velocity.y);
|
Debug.log("playerspeed", "x: " + this.velocity.x + ", y:" + this.velocity.y);
|
||||||
|
Debug.log("player Coords:", this.owner.position );
|
||||||
|
|
||||||
//testing the attacks here, may be moved to another place latera
|
//testing the attacks here, may be moved to another place latera
|
||||||
if(Input.isJustPressed("attack")){
|
if(Input.isJustPressed("attack")){
|
||||||
|
|
|
@ -25,7 +25,9 @@ import EnemyAI from "../AI/EnemyAI";
|
||||||
import BattlerAI from "../AI/BattlerAI";
|
import BattlerAI from "../AI/BattlerAI";
|
||||||
import InventoryManager from "../GameSystems/InventoryManager";
|
import InventoryManager from "../GameSystems/InventoryManager";
|
||||||
import Item from "../GameSystems/items/Item";
|
import Item from "../GameSystems/items/Item";
|
||||||
|
import Layer from "../../Wolfie2D/Scene/Layer";
|
||||||
|
import Button from "../../Wolfie2D/Nodes/UIElements/Button";
|
||||||
|
import { Buff } from "../Player/PlayerController";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +62,8 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
// Health UI
|
// Health UI
|
||||||
protected healthLabel: Label;
|
protected healthLabel: Label;
|
||||||
|
//may need exp label
|
||||||
|
//may need mp label
|
||||||
|
|
||||||
//seed UI
|
//seed UI
|
||||||
protected seedLabel: Label;
|
protected seedLabel: Label;
|
||||||
|
@ -70,6 +74,13 @@ export default class GameLevel extends Scene {
|
||||||
// A list of enemies
|
// A list of enemies
|
||||||
private enemies: Array<AnimatedSprite>;
|
private enemies: Array<AnimatedSprite>;
|
||||||
|
|
||||||
|
//buffs layer
|
||||||
|
buffLayer: Layer;
|
||||||
|
buffButton1 : Button;
|
||||||
|
buffButton2 : Button;
|
||||||
|
buffButton3 : Button;
|
||||||
|
buffs: Array<Buff>;
|
||||||
|
|
||||||
randomSeed: number;
|
randomSeed: number;
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
//can load player sprite here
|
//can load player sprite here
|
||||||
|
@ -94,13 +105,12 @@ export default class GameLevel extends Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
startScene(): void {
|
startScene(): void {
|
||||||
|
//call super after extending story with scene
|
||||||
|
|
||||||
|
|
||||||
// Do the game level standard initializations
|
// Do the game level standard initializations
|
||||||
this.initLayers();
|
|
||||||
this.initViewport();
|
this.initViewport();
|
||||||
|
this.initLayers();
|
||||||
// Create the battle manager
|
// Create the battle manager
|
||||||
this.battleManager = new BattleManager();
|
this.battleManager = new BattleManager();
|
||||||
|
|
||||||
|
@ -109,22 +119,19 @@ export default class GameLevel extends Scene {
|
||||||
// Initialize the items array - this represents items that are in the game world
|
// Initialize the items array - this represents items that are in the game world
|
||||||
this.items = new Array();
|
this.items = new Array();
|
||||||
|
|
||||||
// Create an enemies array
|
|
||||||
this.enemies = new Array();
|
|
||||||
|
|
||||||
this.initPlayer();
|
this.initPlayer();
|
||||||
|
//subscribe to relevant events
|
||||||
this.subscribeToEvents();
|
this.subscribeToEvents();
|
||||||
this.addUI();
|
this.addUI();
|
||||||
|
|
||||||
|
// Create an enemies array
|
||||||
|
this.enemies = new Array();
|
||||||
// Send the player and enemies to the battle manager
|
// Send the player and enemies to the battle manager
|
||||||
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
||||||
// Initialize all enemies
|
// Initialize all enemies
|
||||||
//this.initializeEnemies();
|
//this.initializeEnemies();
|
||||||
this.battleManager.setEnemies(this.enemies.map(enemy => <BattlerAI>enemy._ai));
|
this.battleManager.setEnemies(this.enemies.map(enemy => <BattlerAI>enemy._ai));
|
||||||
|
|
||||||
// Subscribe to relevant events
|
|
||||||
//this.receiver.subscribe("");
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize the timers
|
// Initialize the timers
|
||||||
|
@ -137,16 +144,19 @@ export default class GameLevel extends Scene {
|
||||||
this.player.unfreeze();
|
this.player.unfreeze();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
this.levelTransitionTimer = new Timer(500);
|
this.levelTransitionTimer = new Timer(500);
|
||||||
this.levelEndTimer = new Timer(3000, () => {
|
this.levelEndTimer = new Timer(3000, () => {
|
||||||
// After the level end timer ends, fade to black and then go to the next scene
|
// After the level end timer ends, fade to black and then go to the next scene
|
||||||
this.levelTransitionScreen.tweens.play("fadeIn");
|
this.levelTransitionScreen.tweens.play("fadeIn");
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Start the black screen fade out
|
// Start the black screen fade out
|
||||||
|
/*
|
||||||
this.levelTransitionScreen.tweens.play("fadeOut");
|
this.levelTransitionScreen.tweens.play("fadeOut");
|
||||||
|
*/
|
||||||
|
|
||||||
//TODO - uncomment when done testing
|
//TODO - uncomment when done testing
|
||||||
// Initially disable player movement
|
// Initially disable player movement
|
||||||
|
@ -170,9 +180,33 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
console.log("enemy destroyed");
|
console.log("enemy destroyed");
|
||||||
node.destroy();
|
node.destroy();
|
||||||
|
//TODO - this is for testing, add some chance here later
|
||||||
|
this.emitter.fireEvent(Player_Events.GIVE_BUFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Player_Events.GIVE_BUFF:
|
||||||
|
this.buffs = PlayerController.generateBuffs();
|
||||||
|
this.buffButton1.text = "Increase "+this.buffs[0].type + "\n by "+this.buffs[0].value;
|
||||||
|
this.buffButton2.text = "Increase "+this.buffs[1].type + "\n by "+this.buffs[1].value;
|
||||||
|
this.buffButton3.text = "Increase "+this.buffs[2].type + "\n by "+this.buffs[2].value;
|
||||||
|
this.buffLayer.enable();
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "buff1":
|
||||||
|
console.log("button 1 pressed");
|
||||||
|
(<PlayerController>this.player._ai).addBuff(this.buffs[0]);
|
||||||
|
this.buffLayer.disable();
|
||||||
|
break;
|
||||||
|
case "buff2":
|
||||||
|
console.log("button 2 pressed");
|
||||||
|
(<PlayerController>this.player._ai).addBuff(this.buffs[1]);
|
||||||
|
this.buffLayer.disable();
|
||||||
|
break;
|
||||||
|
case "buff3":
|
||||||
|
console.log("button 3 pressed");
|
||||||
|
(<PlayerController>this.player._ai).addBuff(this.buffs[2]);
|
||||||
|
this.buffLayer.disable();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +237,6 @@ export default class GameLevel extends Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,6 +248,8 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
// Add a layer for players and enemies
|
// Add a layer for players and enemies
|
||||||
this.addLayer("primary", 1);
|
this.addLayer("primary", 1);
|
||||||
|
|
||||||
|
this.buffLayer = this.addUILayer("buffLayer"); //TODO - test depth later, may be just a regular Layer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,8 +268,12 @@ export default class GameLevel extends Scene {
|
||||||
Player_Events.ENEMY_KILLED,
|
Player_Events.ENEMY_KILLED,
|
||||||
Player_Events.LEVEL_START,
|
Player_Events.LEVEL_START,
|
||||||
Player_Events.LEVEL_END,
|
Player_Events.LEVEL_END,
|
||||||
Player_Events.PLAYER_KILLED
|
Player_Events.PLAYER_KILLED,
|
||||||
|
Player_Events.GIVE_BUFF,
|
||||||
]);
|
]);
|
||||||
|
this.receiver.subscribe("buff1");
|
||||||
|
this.receiver.subscribe("buff2");
|
||||||
|
this.receiver.subscribe("buff3");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO -
|
// TODO -
|
||||||
|
@ -248,14 +287,14 @@ export default class GameLevel extends Scene {
|
||||||
this.healthLabel.font = "PixelSimple";
|
this.healthLabel.font = "PixelSimple";
|
||||||
|
|
||||||
//seed label
|
//seed label
|
||||||
|
//worldsize.x doesnt work how i want it to
|
||||||
//this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(400, 30), text: "Seed: "+ this.randomSeed });
|
|
||||||
this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(this.worldSize.x - 50, 30), text: "Seed: "+ this.randomSeed });
|
this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(this.worldSize.x - 50, 30), text: "Seed: "+ this.randomSeed });
|
||||||
this.seedLabel.textColor = Color.WHITE;
|
this.seedLabel.textColor = Color.WHITE;
|
||||||
this.seedLabel.font = "PixelSimple";
|
this.seedLabel.font = "PixelSimple";
|
||||||
|
|
||||||
|
|
||||||
// End of level label (start off screen)
|
// End of level label (start off screen)
|
||||||
|
/*
|
||||||
this.levelEndLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(-300, 200), text: "Level Complete"});
|
this.levelEndLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(-300, 200), text: "Level Complete"});
|
||||||
this.levelEndLabel.size.set(1200, 60);
|
this.levelEndLabel.size.set(1200, 60);
|
||||||
this.levelEndLabel.borderRadius = 0;
|
this.levelEndLabel.borderRadius = 0;
|
||||||
|
@ -277,7 +316,9 @@ export default class GameLevel extends Scene {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
this.levelTransitionScreen = <Rect>this.add.graphic(GraphicType.RECT, "UI", {position: new Vec2(300, 200), size: new Vec2(600, 400)});
|
this.levelTransitionScreen = <Rect>this.add.graphic(GraphicType.RECT, "UI", {position: new Vec2(300, 200), size: new Vec2(600, 400)});
|
||||||
this.levelTransitionScreen.color = new Color(34, 32, 52);
|
this.levelTransitionScreen.color = new Color(34, 32, 52);
|
||||||
this.levelTransitionScreen.alpha = 1;
|
this.levelTransitionScreen.alpha = 1;
|
||||||
|
@ -309,8 +350,42 @@ export default class GameLevel extends Scene {
|
||||||
],
|
],
|
||||||
onEnd: Player_Events.LEVEL_START
|
onEnd: Player_Events.LEVEL_START
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//TODO -
|
||||||
|
//determine button location
|
||||||
|
this.buffButton1 = <Button>this.add.uiElement(UIElementType.BUTTON, "buffLayer", {position: new Vec2(100, 250),text:"buffButton1"});
|
||||||
|
this.buffButton1.size.set(180,200);
|
||||||
|
this.buffButton1.borderWidth = 2;
|
||||||
|
this.buffButton1.borderColor = Color.RED;
|
||||||
|
this.buffButton1.backgroundColor = Color.WHITE;
|
||||||
|
this.buffButton1.textColor = Color.BLACK;
|
||||||
|
this.buffButton1.onClickEventId = "buff1";
|
||||||
|
this.buffButton1.fontSize = 20;
|
||||||
|
|
||||||
|
this.buffButton2 = <Button>this.add.uiElement(UIElementType.BUTTON, "buffLayer", {position: new Vec2(300, 250),text:"buffButton1"});
|
||||||
|
this.buffButton2.size.set(180,200);
|
||||||
|
this.buffButton2.borderWidth = 2;
|
||||||
|
this.buffButton2.borderColor = Color.RED;
|
||||||
|
this.buffButton2.backgroundColor = Color.WHITE;
|
||||||
|
this.buffButton2.textColor = Color.BLACK;
|
||||||
|
this.buffButton2.onClickEventId = "buff2";
|
||||||
|
this.buffButton2.fontSize = 20;
|
||||||
|
|
||||||
|
this.buffButton3 = <Button>this.add.uiElement(UIElementType.BUTTON, "buffLayer", {position: new Vec2(500, 250),text:"buffButton1"});
|
||||||
|
this.buffButton3.size.set(180,200);
|
||||||
|
this.buffButton3.borderWidth = 2;
|
||||||
|
this.buffButton3.borderColor = Color.RED;
|
||||||
|
this.buffButton3.backgroundColor = Color.WHITE;
|
||||||
|
this.buffButton3.textColor = Color.BLACK;
|
||||||
|
this.buffButton3.onClickEventId = "buff3";
|
||||||
|
this.buffButton3.fontSize = 20;
|
||||||
|
|
||||||
|
this.buffs = this.buffs = PlayerController.generateBuffs();
|
||||||
|
|
||||||
|
this.buffLayer.disable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - determine whether we will have weapon datatype
|
//TODO - determine whether we will have weapon datatype
|
||||||
|
@ -447,7 +522,6 @@ export default class GameLevel extends Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* handles the player falling off the map
|
* handles the player falling off the map
|
||||||
|
|
|
@ -149,7 +149,6 @@ export default class MainMenu extends Scene {
|
||||||
back.backgroundColor = Color.TRANSPARENT;
|
back.backgroundColor = Color.TRANSPARENT;
|
||||||
back.onClickEventId = "menu";
|
back.onClickEventId = "menu";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadScene(): void {
|
unloadScene(): void {
|
||||||
|
|
|
@ -35,7 +35,8 @@ export default class Tutorial extends GameLevel{
|
||||||
startScene(): void {
|
startScene(): void {
|
||||||
// Add the level 1 tilemap
|
// Add the level 1 tilemap
|
||||||
this.add.tilemap("forest1", new Vec2(2, 2));
|
this.add.tilemap("forest1", new Vec2(2, 2));
|
||||||
this.viewport.setBounds(0, 0, this.map.width*32, this.map.height*32);
|
console.log("width,height:"+this.map.width,this.map.height);
|
||||||
|
this.viewport.setBounds(0, -500, this.map.width*32, this.map.height*32);
|
||||||
this.viewport.follow(this.player);
|
this.viewport.follow(this.player);
|
||||||
|
|
||||||
this.playerSpawn = new Vec2(5*32, 9*32);
|
this.playerSpawn = new Vec2(5*32, 9*32);
|
||||||
|
|
|
@ -10,6 +10,7 @@ export enum Player_Events {
|
||||||
ENEMY_KILLED = "EnemyKilled",
|
ENEMY_KILLED = "EnemyKilled",
|
||||||
PLAYER_HIT_ENEMY = "PlayerHitEnemy",
|
PLAYER_HIT_ENEMY = "PlayerHitEnemy",
|
||||||
BOSS_KILLED = "BossKilled",
|
BOSS_KILLED = "BossKilled",
|
||||||
|
GIVE_BUFF = "GiveBuff"
|
||||||
}
|
}
|
||||||
export enum Damage_Type {
|
export enum Damage_Type {
|
||||||
NORMAL_DAMAGE = "NormalDamage",
|
NORMAL_DAMAGE = "NormalDamage",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user