소스 검색

Merge branch 'master' of http://git.onarbooks.com/LosPoulos/mafalda-web

Nikatlas 6 년 전
부모
커밋
d68709f334

+ 1 - 0
.gitignore

@@ -15,6 +15,7 @@
 .env.development.local
 .env.test.local
 .env.production.local
+.idea
 
 npm-debug.log*
 yarn-debug.log*

+ 7 - 0
src/Game/services/GameService.js

@@ -22,6 +22,7 @@ class GameService {
 
         if(this.onInit) this.onInit();
         SocketService.on('move', (data) => this.move(data));
+        SocketService.on('result', (data) => this.end(data));
     }
 
     move(data) {
@@ -41,6 +42,12 @@ class GameService {
         if(this.onUpdate) this.onUpdate(1);
     }
 
+    end(data) {
+
+
+
+        SocketService.close();
+    }
 
 }
 

+ 1 - 0
src/Game/services/SocketService.js

@@ -11,6 +11,7 @@ class SocketService {
         this.on = this.socket.on.bind(this.socket);
         this.once = this.socket.once.bind(this.socket);
         this.emit = this.socket.emit.bind(this.socket);
+        this.close = this.socket.close.bind(this.socket);
     }
 
 

+ 0 - 1
src/Game/services/UserService.js

@@ -2,7 +2,6 @@ import Net from './Net.js';
 
 
 class UserService {
-
     constructor() {
         this.__enablePeristence = true;
         this.__load();

+ 13 - 5
src/Game/views/demo/Login.js

@@ -12,9 +12,9 @@ class Login extends PIXI.Container{
         super();
         let {GameLayer, Gui} = props;
 
-        let email = new TextInput({GameLayer, width: 200});
+        let email = new TextInput({GameLayer, width: 250});
         this.addChild(email);
-        let password = new TextInput({GameLayer, width: 200});
+        let password = new TextInput({GameLayer, width: 250});
         this.addChild(password);
 
         let emailText = new Text({GameLayer, width: 200});
@@ -44,10 +44,13 @@ class Login extends PIXI.Container{
         loginBtn.position.set	(0,	100);
         registerBtn.position.set(0,	220);
 
+        email.setText(UserService.username || '');
+
         // Events
         this.email = email;
         this.password = password;
         loginBtn.onClick((e) => this.login(e));
+        this.onLogin(() => alert("Logged in succesfully ! ! !"));
         registerBtn.onClick((e) => this.register(e));
     }
 
@@ -70,6 +73,14 @@ class Login extends PIXI.Container{
     	});
     }
 
+    _onLogin() {
+        this._onLoginFn();
+    }
+
+    onLogin(fn) {
+        this._onLoginFn = fn;
+    }
+
     register() {
 		let e = this.email.getValue();
     	let p = this.password.getValue();
@@ -88,9 +99,6 @@ class Login extends PIXI.Container{
     	});
     }
 
-    onLogin = (fn) => {
-    	this._onLogin = fn;
-    }
 
     update = () => {
     	if(UserService.isLogged()) {

+ 53 - 0
src/Game/views/demo/Menu.js

@@ -0,0 +1,53 @@
+import * as PIXI from 'pixi.js';
+import Injector from '../../services/Injector';
+
+import UserService from '../../services/UserService';
+
+import TextInput from '../misc/TextInput';
+import Text from '../misc/Text';
+import Button from '../misc/Button';
+
+class Menu extends PIXI.Container{
+    constructor(props) {
+        super();
+        let {GameLayer, Gui} = props;
+
+        let Play = new Text({GameLayer, width: 250});
+        this.addChild(Play);
+        
+        let Market = new Text({GameLayer, width: 250});
+        this.addChild(Market);
+
+        let Collection = new Text({GameLayer, width: 250});
+        this.addChild(Collection);
+
+        let Logout = new Text({GameLayer, width: 200});
+        this.addChild(Logout);
+
+        // Set Properties
+        Play.setText("Play Game");
+        Market.setText("Market");
+        Collection.setText("Collection");
+        Logout.setText("Logout");
+
+        // Position It
+        Play.position.set	   (0, -150);
+        Market.position.set	   (0, -100)
+        Collection.position.set(0,-50);
+        Logout.position.set    (0,0);
+
+        Logout.onClick((e) => UserService.logout());
+        
+        Play.onClick(() => null);
+        Market.onClick(() => null);
+        Collection.onClick(() => null);
+    }
+
+    _kill = () => {
+
+    }
+
+    getAsJSON = () => {return {component: 'demo/Menu'}}
+}
+
+export default Menu;

+ 5 - 0
src/Game/views/misc/Text.js

@@ -27,6 +27,11 @@ class Text extends GuiableContainer {
 		this.construct();
 	}
 
+	onClick(fn) {
+		this.textNode.interactive = true;
+		this.textNode.click = fn;
+	}
+
 	construct() {
 		this.textNode = new PIXI.Text(this.text,TextStyles[this.style]);
 		this.textNode.anchor.set(0.5,0.5);