Created
August 24, 2017 20:05
-
-
Save nkallen/7e0c70ad25334837030290040db66a83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(gameBuilder) { | |
// MARK: - Bad Guy | |
var entityBad = gameBuilder.Entity("baddy_bad") | |
var agent = entityBad.Agent("Bad") | |
var chaseBehavior = agent.Behavior() | |
chaseBehavior.wander(1) | |
chaseBehavior.seekAgent("player") | |
entityBad.onLoad = function(self, scene) { | |
self.setBehaviorWeight(chaseBehavior, 1) | |
} | |
entityBad.onContact = onContact | |
// MARK: - Fearful Guy | |
var entityFearful = gameBuilder.Entity("baddy_fearful") | |
var agent = entityFearful.Agent("Bad") | |
var fleeBehavior = agent.Behavior() | |
fleeBehavior.wander(1) | |
fleeBehavior.fleeAgent("player") | |
entityFearful.onLoad = function(self, root) { | |
self.setBehaviorWeight(fleeBehavior, 1) | |
} | |
entityFearful.onContact = onContact | |
} | |
function onContact(self, other, scene) { | |
if (other.name == "Ark_Ball") { | |
scene.addParticles("enemy_explosion.scn", self.worldTransform) | |
scene.rootNode.playAudio("Explosion2.m4a") | |
self.removeFromParentNode() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment