function onMouseClick(event){
        var mouse3D = getYMouse3D(event, renderer, camera);
        //trace('clicked: ' + mouse3D.x + " " + mouse3D.y);
        if(!battle && !setting && !endGame) { // phase 1: construction of board
            if(communication && isStartOnMousePosition(mouse3D)){
                scene.remove(startButton);
                battle = true;
                if(receivedId){
                    if(myTurn){
                        scene.add(myTurnMsg);
                    }else{
                        scene.add(oppTurnMsg);
                    }
                } else{
                    waitMsg = new THREE.Mesh(geometries.textGeom, materials.waitMaterial);
                    waitMsg.position.set(-50, 50, 0);
                    scene.add(waitMsg);
                }
                if(callbacks.sendId){
                    callbacks.sendId();
                }
            }
        }else{ // phase 2: game
            if(isMouseOnOppBoard(mouse3D) && myTurn && !endGame){
                target = [ Math.floor(mouse3D.x / squareSize) , Math.floor((squareSize * 11 - mouse3D.y) / squareSize)] ;
                if(oppBoard[target[0]][target[1]] === 0){
                    if(callbacks.selectTarget){
                        callbacks.selectTarget(target);
                        trace('Sending targets: ' + target);
                        myTurn = false;
                        //renderer.domElement.removeEventListener('click', onMouseClick, false);
                    }
                }
                
            }

        }
    }
/**
     * Listener for click event.
     * Starts the game if start button is clicked
     */
Listener for click event.
Starts the game if start button is clicked
Listener for click event . Starts the game if start button is clicked
function onMouseClick(event){
        var mouse3D = getYMouse3D(event, renderer, camera);
        if(!battle && !setting && !endGame) { 
            if(communication && isStartOnMousePosition(mouse3D)){
                scene.remove(startButton);
                battle = true;
                if(receivedId){
                    if(myTurn){
                        scene.add(myTurnMsg);
                    }else{
                        scene.add(oppTurnMsg);
                    }
                } else{
                    waitMsg = new THREE.Mesh(geometries.textGeom, materials.waitMaterial);
                    waitMsg.position.set(-50, 50, 0);
                    scene.add(waitMsg);
                }
                if(callbacks.sendId){
                    callbacks.sendId();
                }
            }
        }else{ 
            if(isMouseOnOppBoard(mouse3D) && myTurn && !endGame){
                target = [ Math.floor(mouse3D.x / squareSize) , Math.floor((squareSize * 11 - mouse3D.y) / squareSize)] ;
                if(oppBoard[target[0]][target[1]] === 0){
                    if(callbacks.selectTarget){
                        callbacks.selectTarget(target);
                        trace('Sending targets: ' + target);
                        myTurn = false;
                    }
                }
            }
        }
    }
function onMouseClick ( event ) { var mouse3D = getYMouse3D ( event , renderer , camera ) ; if ( ! battle && ! setting && ! endGame ) { if ( communication && isStartOnMousePosition ( mouse3D ) ) { scene . remove ( startButton ) ; battle = true ; if ( receivedId ) { if ( myTurn ) { scene . add ( myTurnMsg ) ; } else { scene . add ( oppTurnMsg ) ; } } else { waitMsg = new THREE . Mesh ( geometries . textGeom , materials . waitMaterial ) ; waitMsg . position . set ( - 50 , 50 , 0 ) ; scene . add ( waitMsg ) ; } if ( callbacks . sendId ) { callbacks . sendId ( ) ; } } } else { if ( isMouseOnOppBoard ( mouse3D ) && myTurn && ! endGame ) { target = [ Math . floor ( mouse3D . x / squareSize ) , Math . floor ( ( squareSize * 11 - mouse3D . y ) / squareSize ) ] ; if ( oppBoard [ target [ 0 ] ] [ target [ 1 ] ] === 0 ) { if ( callbacks . selectTarget ) { callbacks . selectTarget ( target ) ; trace ( 'Sending targets: ' + target ) ; myTurn = false ; } } } } }
Listener for click event.
Listener for click event .
//trace('clicked: ' + mouse3D.x + " " + mouse3D.y); // phase 1: construction of board // phase 2: game //renderer.domElement.removeEventListener('click', onMouseClick, false);