1 decade ago
by Gamma
I have a couple of weapons that the player can choose from, and they can switch them off using a specific key, but I wanted to tie a strategy to it, by making it so that they can only switch off to an existing weapon only with a certain number of kills (i.e killing enemy entities). I use cases and breaks to make the weapon system.
1 decade ago
by Joncom
When you say "lock a weapon", do you mean prevent the player from using it, or force player to use nothing but it?
When you say "switch off to an existing weapon only with a certain number of kills", do you mean unlock the ability to use a weapon after so many kills?
Perhaps let's see some of the code you are using for managing weapons.
1 decade ago
by Gamma
Yes, I'd like to have my weapons be unlocked at certain amounts of kills. And yes, I'd like to prevent the player from switching to "that" locked weapon until they have the right number of kills. And maybe I should add a message indicating that they have unlocked a weapon.
Here's my weapon system:
type: ig.Entity.TYPE.A,
checkAgainst: ig.Entity.TYPE.NONE,
collides: ig.Entity.COLLIDES.PASSIVE,
weapon: 0, //<----
totalWeapons: 2, //<------
activeWeapon: "EntityPistol", //<------
--
[Update function]
if( ig.input.pressed('switch') ) {
this.weapon ++;
if(this.weapon >= this.totalWeapons)
this.weapon = 0;
switch(this.weapon){
case(0):
this.activeWeapon = "EntityPistol";
break;
case(1):
this.activeWeapon = "EntityDouble";
break;
}
this.setupAnimation(this.weapon);
}
--
Below the update function I have my separate weapon entities.
Page 1 of 1
« first
« previous
next ›
last »