added gaining shield on hit
This commit is contained in:
		
							parent
							
								
									a0271d7a97
								
							
						
					
					
						commit
						e6f1cbcf39
					
				| 
						 | 
					@ -212,11 +212,11 @@
 | 
				
			||||||
			"frames": [
 | 
								"frames": [
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"index": 0,
 | 
										"index": 0,
 | 
				
			||||||
					"duration": 50
 | 
										"duration": 500
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"index": 39,
 | 
										"index": 39,
 | 
				
			||||||
					"duration": 50
 | 
										"duration": 500
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			]
 | 
								]
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,27 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    "name": "Hiro",
 | 
					 | 
				
			||||||
    "spriteSheetImage": "Hiro.png",
 | 
					 | 
				
			||||||
    "spriteWidth": 32,
 | 
					 | 
				
			||||||
    "spriteHeight": 32,
 | 
					 | 
				
			||||||
    "columns": 1,
 | 
					 | 
				
			||||||
    "rows": 1,
 | 
					 | 
				
			||||||
    "durationType": "time",
 | 
					 | 
				
			||||||
    "animations": [
 | 
					 | 
				
			||||||
        { 
 | 
					 | 
				
			||||||
            "name": "IDLE",
 | 
					 | 
				
			||||||
            "frames": [ {"index": 0, "duration": 540} ]
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            "name": "JUMP",
 | 
					 | 
				
			||||||
            "frames":[ {"index": 0, "duration": 32}]
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        { 
 | 
					 | 
				
			||||||
            "name": "WALK",
 | 
					 | 
				
			||||||
            "frames": [ {"index": 0, "duration": 540} ]
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        { 
 | 
					 | 
				
			||||||
            "name": "FALL",
 | 
					 | 
				
			||||||
            "frames": [ {"index": 0, "duration": 540} ]
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								dist/shattered_sword_assets/spritesheets/Hiro1.png
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								dist/shattered_sword_assets/spritesheets/Hiro1.png
									
									
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 819 B  | 
| 
						 | 
					@ -23,7 +23,12 @@ export default class Patrol extends EnemyState {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onEnter(options: Record<string, any>): void {
 | 
					    onEnter(options: Record<string, any>): void {
 | 
				
			||||||
        //this.currentPath = this.getNextPath();
 | 
					        //this.currentPath = this.getNextPath();
 | 
				
			||||||
        (<AnimatedSprite>this.owner).animation.play("IDLE", true);
 | 
					        //if(!(<AnimatedSprite>this.owner).animation.isPlaying("DYING")){
 | 
				
			||||||
 | 
					            //(<AnimatedSprite>this.owner).animation.queue("IDLE", true);
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //else{
 | 
				
			||||||
 | 
					            (<AnimatedSprite>this.owner).animation.playIfNotAlready("IDLE", true);
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    handleInput(event: GameEvent): void { }
 | 
					    handleInput(event: GameEvent): void { }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,10 @@ export default class BattleManager {
 | 
				
			||||||
                    if (weapon.hits(enemy.owner)) {
 | 
					                    if (weapon.hits(enemy.owner)) {
 | 
				
			||||||
                        enemy.damage(weapon.type.damage + weapon.EXTRA_DAMAGE);
 | 
					                        enemy.damage(weapon.type.damage + weapon.EXTRA_DAMAGE);
 | 
				
			||||||
                        //console.log("enemy took dmg");
 | 
					                        //console.log("enemy took dmg");
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
 | 
					                        //TODO - test shield, 
 | 
				
			||||||
 | 
					                        //add checking for each onhit buff here
 | 
				
			||||||
 | 
					                        (<PlayerController>this.players[0]).addShield(1);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -28,6 +32,7 @@ export default class BattleManager {
 | 
				
			||||||
            for (let player of this.players) {
 | 
					            for (let player of this.players) {
 | 
				
			||||||
                if (weapon.hits(player.owner)) {
 | 
					                if (weapon.hits(player.owner)) {
 | 
				
			||||||
                    (<PlayerController>player).damage(weapon.type.damage, user);
 | 
					                    (<PlayerController>player).damage(weapon.type.damage, user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,10 +72,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA
 | 
				
			||||||
    CURRENT_DEF: number = 100;
 | 
					    CURRENT_DEF: number = 100;
 | 
				
			||||||
    CURRENT_EXP : number = 0;
 | 
					    CURRENT_EXP : number = 0;
 | 
				
			||||||
    MAX_EXP : number = 100;
 | 
					    MAX_EXP : number = 100;
 | 
				
			||||||
    //shield buff
 | 
					 | 
				
			||||||
    CURRENT_SHIELD : number =0;
 | 
					    CURRENT_SHIELD : number =0;
 | 
				
			||||||
    MAX_SHIELD : number = 20;
 | 
					    MAX_SHIELD : number = 20;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    invincible : boolean = false;
 | 
					    invincible : boolean = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tilemap: OrthogonalTilemap;
 | 
					    tilemap: OrthogonalTilemap;
 | 
				
			||||||
| 
						 | 
					@ -85,7 +83,6 @@ export default class PlayerController extends StateMachineAI implements BattlerA
 | 
				
			||||||
    airjumps:number = 0;
 | 
					    airjumps:number = 0;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private lookDirection: Vec2;
 | 
					    private lookDirection: Vec2;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** A list of items in the game world */
 | 
					    /** A list of items in the game world */
 | 
				
			||||||
    private items: Array<Item>;
 | 
					    private items: Array<Item>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,20 +107,21 @@ export default class PlayerController extends StateMachineAI implements BattlerA
 | 
				
			||||||
            //shield absorbs the damage and sends dmg back to attacker
 | 
					            //shield absorbs the damage and sends dmg back to attacker
 | 
				
			||||||
            if(this.CURRENT_SHIELD > 0){
 | 
					            if(this.CURRENT_SHIELD > 0){
 | 
				
			||||||
                let newshield = Math.max(0, this.CURRENT_SHIELD - damage ); //calculate the new shield value
 | 
					                let newshield = Math.max(0, this.CURRENT_SHIELD - damage ); //calculate the new shield value
 | 
				
			||||||
                (<EnemyAI>attacker._ai).damage(this.CURRENT_SHIELD - newshield); //damage the attacker the dmg taken to shield
 | 
					                if( attacker !== undefined){
 | 
				
			||||||
 | 
					                    (<EnemyAI>attacker._ai).damage(this.CURRENT_SHIELD - newshield); //damage the attacker the dmg taken to shield
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                this.CURRENT_SHIELD = newshield; //update shield value
 | 
					                this.CURRENT_SHIELD = newshield; //update shield value
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else{
 | 
					            else{
 | 
				
			||||||
                //i frame here
 | 
					                //i frame here
 | 
				
			||||||
                PlayerController.invincibilityTimer.start();
 | 
					                PlayerController.invincibilityTimer.start();
 | 
				
			||||||
                this.invincible = true;
 | 
					                this.invincible = true;
 | 
				
			||||||
 | 
					                //console.log("hurt anim");
 | 
				
			||||||
                (<AnimatedSprite>this.owner).animation.playIfNotAlready("HURT", false);
 | 
					                (<AnimatedSprite>this.owner).animation.play("HURT" );
 | 
				
			||||||
                this.CURRENT_HP -= damage;
 | 
					                this.CURRENT_HP -= damage;
 | 
				
			||||||
                if(this.CURRENT_HP <= 0){
 | 
					                if(this.CURRENT_HP <= 0){
 | 
				
			||||||
                    this.emitter.fireEvent(Player_Events.PLAYER_KILLED);
 | 
					                    (<AnimatedSprite>this.owner).animation.play("DYING");
 | 
				
			||||||
                    (<AnimatedSprite>this.owner).animation.playIfNotAlready("DYING", false);
 | 
					                    (<AnimatedSprite>this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED);
 | 
				
			||||||
                    (<AnimatedSprite>this.owner).animation.queue("DEAD", false);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
| 
						 | 
					@ -236,7 +234,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
 | 
				
			||||||
        //this.addBuff( {type:BuffType.HEALTH, value:1} );
 | 
					        //this.addBuff( {type:BuffType.HEALTH, value:1} );
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        //i frame timer
 | 
					        //i frame timer
 | 
				
			||||||
        PlayerController.invincibilityTimer = new Timer(400);
 | 
					        PlayerController.invincibilityTimer = new Timer(2000);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    initializePlatformer(): void {
 | 
					    initializePlatformer(): void {
 | 
				
			||||||
| 
						 | 
					@ -285,7 +283,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
 | 
				
			||||||
        //testing the attacks here, may be moved to another place later
 | 
					        //testing the attacks here, may be moved to another place later
 | 
				
			||||||
        if(InputWrapper.isAttackJustPressed()){
 | 
					        if(InputWrapper.isAttackJustPressed()){
 | 
				
			||||||
            let item = this.inventory.getItem();
 | 
					            let item = this.inventory.getItem();
 | 
				
			||||||
            (<AnimatedSprite>this.owner).animation.playIfNotAlready("ATTACK", true);
 | 
					            (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
 | 
				
			||||||
            //TODO - get proper look direction 
 | 
					            //TODO - get proper look direction 
 | 
				
			||||||
            this.lookDirection.x = (<Sprite>this.owner).invertX ? -1 : 1;
 | 
					            this.lookDirection.x = (<Sprite>this.owner).invertX ? -1 : 1;
 | 
				
			||||||
            // If there is an item in the current slot, use it
 | 
					            // If there is an item in the current slot, use it
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ export default class Walk extends OnGround {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	update(deltaT: number): void {
 | 
						update(deltaT: number): void {
 | 
				
			||||||
		//console.log("walking anim");
 | 
							console.log("walking anim");
 | 
				
			||||||
        this.owner.animation.playIfNotAlready("WALK", true);
 | 
					        this.owner.animation.playIfNotAlready("WALK", true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		let dir = this.getInputDirection();
 | 
							let dir = this.getInputDirection();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -718,7 +718,6 @@ export default class GameLevel extends Scene {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(typeof enemy != undefined && typeof player != undefined){
 | 
					        if(typeof enemy != undefined && typeof player != undefined){
 | 
				
			||||||
                //damage the player 
 | 
					                //damage the player 
 | 
				
			||||||
                console.log("player collision damage");
 | 
					 | 
				
			||||||
                (<PlayerController>this.player._ai).damage(10); //10 collision dmg for now
 | 
					                (<PlayerController>this.player._ai).damage(10); //10 collision dmg for now
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user