Skip to content

Commit

Permalink
Added Photon Networking..
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasiyer14 committed Jul 26, 2017
1 parent 574e887 commit bbfdd2c
Show file tree
Hide file tree
Showing 833 changed files with 59,168 additions and 4,307 deletions.
1 change: 0 additions & 1 deletion Assets/GyroDroid-minimal-README.txt

This file was deleted.

2 changes: 0 additions & 2 deletions Assets/GyroDroid-minimal-README.txt.meta

This file was deleted.

Binary file removed Assets/GyroDroid-minimal.unitypackage
Binary file not shown.
9 changes: 9 additions & 0 deletions Assets/Photon Unity Networking.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Photon Unity Networking/Demos.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;
using System.Collections;

public class Demo2DJumpAndRun : MonoBehaviour
{
void OnJoinedRoom()
{
if( PhotonNetwork.isMasterClient == false )
{
return;
}

PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 5.5f, 0 ), Quaternion.identity, 0, null );
PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 4.5f, 0 ), Quaternion.identity, 0, null );
PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 3.5f, 0 ), Quaternion.identity, 0, null );

PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 5.5f, 0 ), Quaternion.identity, 0, null );
PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 4.5f, 0 ), Quaternion.identity, 0, null );
PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 3.5f, 0 ), Quaternion.identity, 0, null );
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using UnityEngine;
using System.Collections;

public class JumpAndRunMovement : MonoBehaviour
{
public float Speed;
public float JumpForce;

Animator m_Animator;
Rigidbody2D m_Body;
PhotonView m_PhotonView;

bool m_IsGrounded;

void Awake()
{
m_Animator = GetComponent<Animator>();
m_Body = GetComponent<Rigidbody2D>();
m_PhotonView = GetComponent<PhotonView>();
}

void Update()
{
UpdateIsGrounded();
UpdateIsRunning();
UpdateFacingDirection();
}

void FixedUpdate()
{
if( m_PhotonView.isMine == false )
{
return;
}

UpdateMovement();
UpdateJumping();
}

void UpdateFacingDirection()
{
if( m_Body.velocity.x > 0.2f )
{
transform.localScale = new Vector3( 1, 1, 1 );
}
else if( m_Body.velocity.x < -0.2f )
{
transform.localScale = new Vector3( -1, 1, 1 );
}
}

void UpdateJumping()
{
if (Input.GetButton("Jump") && m_IsGrounded)
{
m_Animator.SetTrigger("IsJumping");
m_Body.AddForce(Vector2.up * JumpForce);
m_PhotonView.RPC("DoJump", PhotonTargets.Others);
}
}

[PunRPC]
void DoJump()
{
m_Animator.SetTrigger( "IsJumping" );
}

void UpdateMovement()
{
Vector2 movementVelocity = m_Body.velocity;

if( Input.GetAxisRaw( "Horizontal" ) > 0.5f )
{
movementVelocity.x = Speed;

}
else if( Input.GetAxisRaw( "Horizontal" ) < -0.5f )
{
movementVelocity.x = -Speed;
}
else
{
movementVelocity.x = 0;
}

m_Body.velocity = movementVelocity;
}

void UpdateIsRunning()
{
m_Animator.SetBool( "IsRunning", Mathf.Abs( m_Body.velocity.x ) > 0.1f );
}

void UpdateIsGrounded()
{
Vector2 position = new Vector2( transform.position.x, transform.position.y );

//RaycastHit2D hit = Physics2D.Raycast( position, -Vector2.up, 0.1f, 1 << LayerMask.NameToLayer( "Ground" ) );
RaycastHit2D hit = Physics2D.Raycast(position, -Vector2.up, 0.1f);

m_IsGrounded = hit.collider != null;
m_Animator.SetBool( "IsGrounded", m_IsGrounded );
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit bbfdd2c

Please sign in to comment.