Skip to content

Commit

Permalink
Last mirror from SVN
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanahman committed Aug 17, 2014
1 parent 865971f commit 6128c9a
Show file tree
Hide file tree
Showing 315 changed files with 3,488 additions and 24 deletions.
Binary file modified Assets/Resources/Characters/Sportscar.prefab
Binary file not shown.

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

5 changes: 5 additions & 0 deletions Assets/Resources/SkillEffects/HammerTime.meta

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

File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions Assets/Resources/SkillEffects/RocketShot.meta

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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/Scripts/Client/HUD/Minimap/MapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Start() {
minimapCamera.clearFlags = CameraClearFlags.Depth;

minimapMask = GameObject.FindGameObjectWithTag (Constants.TAG_MINIMAP_MASK);
minimapMask.gameObject.active = true;
minimapMask.gameObject.SetActive(true);

minimapPosition.x = minimapCamera.pixelRect.x;
minimapPosition.y = minimapCamera.pixelRect.y;
Expand Down
59 changes: 59 additions & 0 deletions Assets/Scripts/Client/HUD/PlayerBar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using UnityEngine;
using System.Collections;

public class PlayerBar : HUDBase
{
private GameObject PlayerBarObject;
private Transform PlayerBarTransform;

private GUIText myName;
public Font TextFont;
public int FontSize = 20;
GUIStyle TextStyle;

private Transform target;
public Vector3 heightOffset = Vector3.up; // Put it to one unit above the player for now
public bool clampToScreen = false; // if true the label will be visible even when the player it out of the frame
public float clampBorderSize = 0.05f; // How much viewport space to leave at the borders when label is clamped

private Camera cam;
private Transform camTransform;

void Awake()
{
// Disable playerbar for our own car
if (Player.IsLocalPlayer)
this.enabled = false;
}

void Start()
{
PlayerBarObject = new GameObject("PlayerBar");
PlayerBarTransform = PlayerBarObject.transform;
myName = (GUIText)PlayerBarObject.AddComponent(typeof(GUIText));
myName.text = Player.Name;
myName.font = TextFont;
myName.fontSize = FontSize;

cam = Camera.main;
camTransform = cam.transform;

// our target is the transform of the car
target = transform.GetComponentInChildren<CarHandling> ().transform;
}

// Update is called once per frame
void Update ()
{
}


void OnGUI()
{
PlayerBarTransform.position = cam.WorldToViewportPoint (target.position + heightOffset);
if (PlayerBarTransform.position.z < 0)
PlayerBarObject.SetActive (false);
else
PlayerBarObject.SetActive (true);
}
}
8 changes: 8 additions & 0 deletions Assets/Scripts/Client/HUD/PlayerBar.cs.meta

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

34 changes: 34 additions & 0 deletions Assets/Scripts/Client/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

public class Player : PlayerBase
{
private string _name;
public string Name
{
get
{
return _name;
}
}

private float _health = 100.0f;
public float Health
{
Expand Down Expand Up @@ -30,9 +39,24 @@ public Team Team
}
}

public bool IsLocalPlayer
{
get
{
return PhotonView.isMine;
}
}

private Vector3 startPosition;
private Quaternion startRotation;

void Awake()
{
// Only read the properties for our own car
if (IsLocalPlayer)
readProperties();
}

void Start()
{
// PhotonNetwork.sendRate = 60;
Expand All @@ -42,6 +66,14 @@ void Start()
startRotation = transform.rotation;
}

// Read our name from the playerproperties and destroy it
private void readProperties()
{
GameObject go = GameObject.Find("PlayerProperties");
_name = go.GetComponent<PlayerProperties>().Name;
Destroy(go);
}

public void SetTeam(Team team)
{
//This method gets called right after a car is created
Expand Down Expand Up @@ -93,12 +125,14 @@ void SerializeState(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting == true)
{
stream.SendNext(_name);
stream.SendNext(_health);
stream.SendNext(_armor);
}
else
{
float oldHealth = _health;
_name = (string)stream.ReceiveNext();
_health = (float)stream.ReceiveNext();
_armor = (float)stream.ReceiveNext();

Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/Client/Skills.meta

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

5 changes: 5 additions & 0 deletions Assets/Scripts/Client/Skills/BaseClasses.meta

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

61 changes: 61 additions & 0 deletions Assets/Scripts/Client/Skills/BaseClasses/AimSkill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using UnityEngine;
using System.Collections;

public abstract class AimSkill : Skill {

private bool isAiming;

// Use this for initialization
void Start ()
{
isAiming = false;
}

// Update is called once per frame
void Update ()
{
listenForFire();
}

/// <summary>
/// Wrapper function around the abstract aim function to make sure that all skills follow the cooldown
/// </summary>
private void aim()
{
if (isReady)
{
isAiming = true;
_aim();
}
}

private void stopAiming()
{
isAiming = false;
_stopAiming();
}

private void listenForFire()
{
if (isAiming && Input.GetButtonUp(Constants.KEY_MAIN_FIRE))
{
applyCooldown();
stopAiming();
_fire();
}
}

protected override void ButtonPressed()
{
aim();
}

protected override void ButtonReleased()
{
stopAiming();
}

protected abstract void _aim();
protected abstract void _stopAiming();
protected abstract void _fire();
}
8 changes: 8 additions & 0 deletions Assets/Scripts/Client/Skills/BaseClasses/AimSkill.cs.meta

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

86 changes: 86 additions & 0 deletions Assets/Scripts/Client/Skills/BaseClasses/Skill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using UnityEngine;
using System.Collections;


public abstract class Skill : SkillBase
{
public float cooldown = 2F; // The time it takes the skill to recharge

public Button Button;

private float _currentCooldown;
public float CurrentCooldown
{
get
{
return _currentCooldown;
}
}

private bool _isReady;
public bool isReady
{
get
{
return _isReady;
}
}

//TODO:
// Add icon to draw in the HUD

protected void Start()
{
_isReady = true;
_currentCooldown = 0.0f;
}

/// <summary>
/// Each update we check if our button has been pressed
/// </summary>
protected void Update()
{
// Check if the button is being pressed OBS: DO THIS BETTER .TOSTRING IS EXPENSIVE!!!!!!!!!!!!!!!
if (Input.GetButtonDown(Button.ToString()))
{
Debug.Log("BUTTON DOWN");
ButtonPressed();
}
else if (Input.GetButtonUp(Button.ToString()))
{
Debug.Log("BUTTON UP");
ButtonReleased();
}
}

/// <summary>
/// Starts thte coroutine that performs the cooldown
/// </summary>
protected void applyCooldown()
{
Debug.Log("APPLYING CD");
_isReady = false;
_currentCooldown = cooldown;
StartCoroutine(countdown());
}

/// <summary>
/// Counts down until the cooldown has passed
/// </summary>
/// <returns></returns>
private IEnumerator countdown()
{
while (_currentCooldown > 0.0F)
{
Debug.Log("_currentCoolDown = " + _currentCooldown);
_currentCooldown -= Time.deltaTime;
yield return null;
}

Debug.Log("After While");
_isReady = true;
}

protected abstract void ButtonPressed();
protected abstract void ButtonReleased();
}
8 changes: 8 additions & 0 deletions Assets/Scripts/Client/Skills/BaseClasses/Skill.cs.meta

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

Loading

0 comments on commit 6128c9a

Please sign in to comment.