Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions src/client/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ React = require 'React'

PrismGeometry = require './PrismGeometry'
Hex = require '../lib/Hex'
# Skill = require './skill'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<

# SkillBarrier = require './skill'

Colors =
purple: "#9b59b6"
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
Expand All @@ -187,6 +212,7 @@ class GameView
@currentTeamTurn = 0
@turn++
@movesRemaining = @movesPerTurn
@actionPointsRemaining = @actionPointsPerTurn
renderUI(this)

getTeamName: ->
Expand Down Expand Up @@ -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 )

Expand All @@ -269,6 +319,28 @@ onMouseMove = (e) ->
mouseVector.y = 1 - 2 * ( e.clientY / window.innerHeight )


canCast = (skill) ->
if gameView.actionPointsRemaining >= SkillBarrier.cost
return true
Copy link
Owner

Choose a reason for hiding this comment

The 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
Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Owner

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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()
Expand All @@ -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)"
Expand All @@ -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>
Expand Down
26 changes: 26 additions & 0 deletions src/client/skill.coffee
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