Skip to content

Commit

Permalink
Tested, minor tweaks made. Client needs handler code in ViewControlle…
Browse files Browse the repository at this point in the history
…r and then client is ready
  • Loading branch information
dragagon committed Oct 13, 2011
1 parent d81e586 commit be35c94
Show file tree
Hide file tree
Showing 133 changed files with 168 additions and 61 deletions.
Binary file modified AegisBornClient/AegisBornClient-csharp.suo
Binary file not shown.
30 changes: 17 additions & 13 deletions AegisBornClient/Assembly-CSharp-vs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_3_4_0;UNITY_3_4;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_3_4_1;UNITY_3_4;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand All @@ -44,18 +44,22 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\_Scripts\Controllers\IViewController.cs" />
<Compile Include="Assets\_Scripts\Controllers\LoginController.cs" />
<Compile Include="Assets\_Scripts\Controllers\ViewController.cs" />
<Compile Include="Assets\_Scripts\GameStates\Connected.cs" />
<Compile Include="Assets\_Scripts\GameStates\Disconnected.cs" />
<Compile Include="Assets\_Scripts\GameStates\GameState.cs" />
<Compile Include="Assets\_Scripts\GameStates\IGameState.cs" />
<Compile Include="Assets\_Scripts\GameStates\WaitingForConnection.cs" />
<Compile Include="Assets\_Scripts\Login.cs" />
<Compile Include="Assets\_Scripts\PhotonEngine.cs" />
<Compile Include="Assets\_Scripts\Views\IView.cs" />
<Compile Include="Assets\_Scripts\Views\View.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\PhotonEngine.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Controllers\IViewController.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Controllers\ViewController.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\Connected.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\Disconnected.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\GameState.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\IGameState.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\WaitingForConnection.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\IPhotonEventHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\IPhotonOperationHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\PhotonEventHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\PhotonOperationHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Views\IView.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Views\View.cs" />
<Compile Include="Assets\_Scripts\Login\Login.cs" />
<Compile Include="Assets\_Scripts\Login\LoginController.cs" />
<Reference Include="CJRGaming.MMO.Common">
<HintPath>Assets\_Plugins\CJRGaming.MMO.Common.dll</HintPath>
</Reference>
Expand Down
30 changes: 17 additions & 13 deletions AegisBornClient/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_3_4_0;UNITY_3_4;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_3_4_1;UNITY_3_4;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand All @@ -44,18 +44,22 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\_Scripts\Controllers\IViewController.cs" />
<Compile Include="Assets\_Scripts\Controllers\LoginController.cs" />
<Compile Include="Assets\_Scripts\Controllers\ViewController.cs" />
<Compile Include="Assets\_Scripts\GameStates\Connected.cs" />
<Compile Include="Assets\_Scripts\GameStates\Disconnected.cs" />
<Compile Include="Assets\_Scripts\GameStates\GameState.cs" />
<Compile Include="Assets\_Scripts\GameStates\IGameState.cs" />
<Compile Include="Assets\_Scripts\GameStates\WaitingForConnection.cs" />
<Compile Include="Assets\_Scripts\Login.cs" />
<Compile Include="Assets\_Scripts\PhotonEngine.cs" />
<Compile Include="Assets\_Scripts\Views\IView.cs" />
<Compile Include="Assets\_Scripts\Views\View.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\PhotonEngine.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Controllers\IViewController.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Controllers\ViewController.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\Connected.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\Disconnected.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\GameState.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\IGameState.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_GameStates\WaitingForConnection.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\IPhotonEventHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\IPhotonOperationHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\PhotonEventHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Handlers\PhotonOperationHandler.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Views\IView.cs" />
<Compile Include="Assets\PhotonEngine\_Scripts\_Views\View.cs" />
<Compile Include="Assets\_Scripts\Login\Login.cs" />
<Compile Include="Assets\_Scripts\Login\LoginController.cs" />
<Reference Include="CJRGaming.MMO.Common">
<HintPath>Assets\_Plugins\CJRGaming.MMO.Common.dll</HintPath>
</Reference>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@ public class PhotonEngine : MonoBehaviour, IPhotonPeerListener

public ViewController Controller { get; set; }

public string ServerAddress;
public string ApplicationName;

private static PhotonEngine _instance;

public PhotonEngine()
public void Awake()
{
_instance = this;
State = new Disconnected(this);
Initialize("localhost:5055", "AegisBorn");
Initialize();
}

public static PhotonEngine Instance
{
get
{
if(_instance == null)
{
_instance = new PhotonEngine();
}
return _instance;
}
get { return _instance; }
}

#region Implementation of IPhotonPeerListener
Expand Down Expand Up @@ -60,6 +56,7 @@ public void OnStatusChanged(StatusCode statusCode)
case StatusCode.DisconnectByServerUserLimit:
case StatusCode.TimeoutDisconnect:
case StatusCode.Exception:
case StatusCode.ExceptionOnConnect:
{
Controller.OnDisconnected("" + statusCode);
State = new Disconnected(this);
Expand All @@ -86,10 +83,10 @@ public void OnEvent(EventData eventData)

#endregion

public void Initialize(string serverAddress, string applicationName)
public void Initialize()
{
Peer = new PhotonPeer(this, false);
Peer.Connect(serverAddress, applicationName);
Peer.Connect(ServerAddress, ApplicationName);
State = new WaitingForConnection(this);
}

Expand All @@ -99,6 +96,7 @@ public void Disconnect()
{
Peer.Disconnect();
}
State = new Disconnected(this);
}

public void Update()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public interface IViewController

void ApplicationQuit();

bool IsConnected { get; }

void Connect();
#endregion

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
using System.Text;
using ExitGames.Client.Photon;

public abstract class ViewController : IViewController
public class ViewController : IViewController
{

private IView _controlledView;

protected ViewController(IView controlledView)
public ViewController(IView controlledView)
{
_controlledView = controlledView;
PhotonEngine.Instance.Controller = this;
}

#region Implementation of IViewController

public virtual void OnEvent(EventData eventData)
public void OnEvent(EventData eventData)
{
OnUnexpectedEvent(eventData);
}

public virtual void OnOperationResponse(OperationResponse operationResponse)
public void OnOperationResponse(OperationResponse operationResponse)
{
OnUnexpectedOperationResponse(operationResponse);
}
Expand Down Expand Up @@ -57,4 +57,17 @@ public void ApplicationQuit()
{
PhotonEngine.Instance.Disconnect();
}

public bool IsConnected
{
get { return PhotonEngine.Instance.State is Connected; }
}

public void Connect()
{
if(!IsConnected)
{
PhotonEngine.Instance.Initialize();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using ExitGames.Client.Photon;

public interface IPhotonEventHandler
{
void HandleEvent(EventData eventData);
void OnHandleEvent(EventData eventData);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using ExitGames.Client.Photon;

public interface IPhotonOperationHandler
{
void HandleResponse(OperationResponse response);
void OnHandleResponse(OperationResponse response);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExitGames.Client.Photon;

public abstract class PhotonEventHandler : IPhotonEventHandler
{
delegate void BeforeEventRecieved();
BeforeEventRecieved beforeEventRecieved;

delegate void AfterEventRecieved();
AfterEventRecieved afterEventRecieved;

public void HandleEvent(EventData eventData)
{
if (beforeEventRecieved != null)
{
beforeEventRecieved();
}
OnHandleEvent(eventData);
if (afterEventRecieved != null)
{
afterEventRecieved();
}
}

public abstract void OnHandleEvent(EventData eventData);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExitGames.Client.Photon;

public abstract class PhotonOperationHandler : IPhotonOperationHandler
{
delegate void BeforeResponseRecieved();
BeforeResponseRecieved beforeResponseRecieved;

delegate void AfterResponseRecieved();
AfterResponseRecieved afterResponseRecieved;

public void HandleResponse(OperationResponse response)
{
if (beforeResponseRecieved != null)
{
beforeResponseRecieved();
}
OnHandleResponse(response);
if (afterResponseRecieved != null)
{
afterResponseRecieved();
}
}

public abstract void OnHandleResponse(OperationResponse response);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using System.Collections.Generic;
using UnityEngine;

public abstract class View : MonoBehaviour, IView
public class View : MonoBehaviour, IView
{
#region Implementation of IView

private IViewController _controller;

void Awake()
{
Controller = new ViewController(this);
}

public IViewController Controller
{
get { return _controller; }
Expand Down
Binary file modified AegisBornClient/Assets/_Scenes/Login.unity
Binary file not shown.
11 changes: 0 additions & 11 deletions AegisBornClient/Assets/_Scripts/Controllers/LoginController.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using System.Collections.Generic;
using CJRGaming.MMO.Common;
using ExitGames.Client.Photon;
using UnityEditor;
using UnityEngine;
using System.Collections;

public class Login : View {

public class Login : View
{
public string _username;
public string _password;

Expand All @@ -26,12 +27,13 @@ public void OnGUI()
_username = GUI.TextField(new Rect(100, 116, 200, 20), _username, 25);
GUI.Label(new Rect(10, 141, 100, 100), "Password: ");
_password = GUI.PasswordField(new Rect(100, 141, 200, 20), _password, '*', 25);
if (GUI.Button(new Rect(100, 60, 100, 30), "Logout"))
if (Controller.IsConnected && GUI.Button(new Rect(100, 60, 100, 30), "Logout"))
{
Controller.ApplicationQuit();
}
if (GUI.Button(new Rect(210, 60, 100, 30), "Send login"))
{
}
GUI.Label(new Rect(10, 180, 100, 100), "" +PhotonEngine.Instance.State);
}
}
6 changes: 6 additions & 0 deletions AegisBornClient/Assets/_Scripts/Login/LoginController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class LoginController :ViewController
{
public LoginController(IView controlledView) : base(controlledView)
{
}
}
Binary file modified AegisBornClient/Library/InspectorExpandedItems.asset
Binary file not shown.
Binary file modified AegisBornClient/Library/ScriptAssemblies/Assembly-CSharp.dll
Binary file not shown.
Binary file modified AegisBornClient/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file modified AegisBornClient/Library/ScriptMapper
Binary file not shown.
Binary file modified AegisBornClient/Library/assetDatabase3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified AegisBornClient/Library/expandedItems
Binary file not shown.
Binary file modified AegisBornClient/Library/guidmapper
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
K9d
�΋
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
θ�
�J
Binary file not shown.
Binary file not shown.
Binary file modified AegisBornClient/_ReSharper.AegisBornClient-csharp/SymbolCache.bin
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C
��
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1��$
̬u1
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
D:\development\photon\AegisBornClient\obj\Debug\ResolveAssemblyReference.cache
C:\development\photon\AegisBornClient\Temp\bin\Debug\Assembly-CSharp.dll
C:\development\photon\AegisBornClient\Temp\bin\Debug\Assembly-CSharp.pdb
C:\development\photon\AegisBornClient\Temp\bin\Debug\CJRGaming.MMO.Common.dll
C:\development\photon\AegisBornClient\Temp\bin\Debug\Photon3Unity3D.dll
C:\development\photon\AegisBornClient\Temp\bin\Debug\UnityEditor.dll
C:\development\photon\AegisBornClient\Temp\bin\Debug\UnityEngine.dll
C:\development\photon\AegisBornClient\Temp\bin\Debug\nunit.framework.dll
C:\development\photon\AegisBornClient\obj\Debug\ResolveAssemblyReference.cache
C:\development\photon\AegisBornClient\obj\Debug\Assembly-CSharp.dll
C:\development\photon\AegisBornClient\obj\Debug\Assembly-CSharp.pdb
Binary file added AegisBornClient/obj/Debug/Assembly-CSharp.dll
Binary file not shown.
Binary file added AegisBornClient/obj/Debug/Assembly-CSharp.pdb
Binary file not shown.
Binary file not shown.
Binary file modified AegisBornClient/obj/Debug/ResolveAssemblyReference.cache
Binary file not shown.
Binary file modified CJRGaming.MMO/CJRGaming.MMO.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit be35c94

Please sign in to comment.