-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skills #15
base: master
Are you sure you want to change the base?
Skills #15
Changes from all commits
c60d90e
d86cadf
044bf19
a4e7951
3189cc9
fceddef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ React = require 'React' | |
|
||
PrismGeometry = require './PrismGeometry' | ||
Hex = require '../lib/Hex' | ||
# Skill = require './skill' | ||
# SkillBarrier = require './skill' | ||
|
||
Colors = | ||
purple: "#9b59b6" | ||
|
@@ -49,7 +51,7 @@ pointLight.position.x = 700 | |
pointLight.position.y = -250 | ||
pointLight.position.z = 500 | ||
|
||
scene.add(pointLight) | ||
# scene.add(pointLight) This is not doing anything atm | ||
|
||
TEAM_NAMES = ["Purple", "Red"] | ||
|
||
|
@@ -132,6 +134,27 @@ for hexX in [0..12] | |
scene.add hexagons | ||
|
||
|
||
|
||
class Barrier | ||
constructor: (player)-> | ||
@coneHeight = 80 | ||
@player = player | ||
@geometry = new THREE.CylinderGeometry(30, 30, @coneHeight, 30) | ||
@material = new THREE.MeshBasicMaterial( { color: "#2c3e50" } ) | ||
@mesh = new THREE.Mesh( @geometry, @material ) | ||
@mesh.rotation.x = Math.PI/2 | ||
@mesh.position.z = tileHeight + @coneHeight/2 | ||
@setPosition [0,0] | ||
|
||
setPosition: (hex) -> | ||
@hex = hex | ||
{@x, @y} = hexTo3d @hex | ||
@mesh.position.x = @x | ||
@mesh.position.y = @y | ||
scene.add @mesh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this add a new mesh to the scene each reposition? |
||
|
||
|
||
|
||
class Player | ||
constructor: -> | ||
@coneHeight = 80 | ||
|
@@ -174,11 +197,13 @@ class Player | |
class GameView | ||
constructor: -> | ||
@movesPerTurn = 4 | ||
@actionPointsPerTurn = 2 | ||
@players = [] | ||
@selectedPlayer = null | ||
@currentTeamTurn = 0 | ||
@turn = 1 | ||
@movesRemaining = @movesPerTurn | ||
@actionPointsRemaining = @actionPointsPerTurn | ||
|
||
nextTurn: -> | ||
if @currentTeamTurn is 0 | ||
|
@@ -187,6 +212,7 @@ class GameView | |
@currentTeamTurn = 0 | ||
@turn++ | ||
@movesRemaining = @movesPerTurn | ||
@actionPointsRemaining = @actionPointsPerTurn | ||
renderUI(this) | ||
|
||
getTeamName: -> | ||
|
@@ -252,6 +278,30 @@ mouseVector.x = 0 | |
mouseVector.y = 0 | ||
|
||
|
||
class Skill | ||
@cost = 0 | ||
constructor: -> | ||
console.log("load") | ||
|
||
cast: -> | ||
|
||
|
||
class SkillBarrier extends Skill | ||
@cost = 1 | ||
constructor: -> | ||
super() | ||
|
||
cast: (hex)-> | ||
super() | ||
barrier = new Barrier() | ||
barrier.setPosition(hex) | ||
|
||
|
||
|
||
castSkill = (hex, skill) -> | ||
skill.cast(hex) | ||
|
||
|
||
onClick = (e) -> | ||
raycaster.setFromCamera( mouseVector, camera ) | ||
|
||
|
@@ -269,6 +319,28 @@ onMouseMove = (e) -> | |
mouseVector.y = 1 - 2 * ( e.clientY / window.innerHeight ) | ||
|
||
|
||
canCast = (skill) -> | ||
if gameView.actionPointsRemaining >= SkillBarrier.cost | ||
return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return true return false? |
||
else | ||
return false | ||
|
||
onKeyPress = (e) -> | ||
console.log("KEY: ", e.keyCode) | ||
|
||
if e.keyCode == 98 #B | ||
if canCast(SkillBarrier) | ||
raycaster.setFromCamera( mouseVector, camera ) | ||
|
||
intersects = raycaster.intersectObjects(hexagons.children) | ||
if intersects.length > 0 | ||
hexUuid = intersects[0].object.uuid | ||
clickedHex = uuidToHex.get hexUuid | ||
barrierSkill = new SkillBarrier() | ||
castSkill(clickedHex, barrierSkill) | ||
gameView.actionPointsRemaining -= SkillBarrier.cost | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be in game view so you can actually check if you are going over the cost There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at least part of castSkill? |
||
renderUI(gameView) | ||
|
||
update = -> | ||
gameView.update() | ||
setTimeout update, 20 | ||
|
@@ -318,6 +390,7 @@ onResize = -> | |
window.addEventListener 'resize', onResize, false | ||
window.addEventListener 'mousemove', onMouseMove, false | ||
window.addEventListener 'click', onClick, false | ||
window.addEventListener 'keypress', onKeyPress, false | ||
|
||
update() | ||
render() | ||
|
@@ -326,7 +399,7 @@ PlayerUI = React.createClass | |
render: -> | ||
style = | ||
width: 220 | ||
height: 140 | ||
height: 160 | ||
backgroundColor: [Colors.purple, Colors.red][@props.gameView.currentTeamTurn] | ||
borderTopRightRadius: 200 | ||
boxShadow: "4px -4px 12px 12px rgba(0, 0, 0, 0.2)" | ||
|
@@ -341,6 +414,7 @@ PlayerUI = React.createClass | |
{ @props.gameView.getTeamName() } turn<br /> | ||
Turn {@props.gameView.turn} / 60 <br /> | ||
{("O" for x in [[email protected]]).join(" ")} <br /> | ||
{("X" for x in [[email protected]]).join(" ")} <br /> | ||
84 s <br /> | ||
19 tiles | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Skill | ||
constructor: -> | ||
console.log("load") | ||
|
||
|
||
cast: -> | ||
|
||
|
||
|
||
|
||
class SkillBarrier extends Skill | ||
constructor: -> | ||
super() | ||
|
||
cast: (hex)-> | ||
super() | ||
barrier = new Barrier() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
module.exports = Skill | ||
module.exports = SkillBarrier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<