Skip to content

Instantly share code, notes, and snippets.

Andrew Weston AndrewWeston9

  • Victoria, Australia
View GitHub Profile
@AndrewWeston9
AndrewWeston9 / PlayerMove.cs
Created Oct 6, 2017
PlayerMove.cs Snippet: Flag placing and removal checks and sending of network messages for flag related functions.
View PlayerMove.cs
if(Input.GetKey(KeyCode.E) && playerFlagPlaced == true)
{
/*if(Physics.Raycast(ray, out hit, 50))
{
pickup = true;
}
}
else
{
pickup = false;*/
@AndrewWeston9
AndrewWeston9 / PlayerMove.cs
Created Oct 6, 2017
PlayerMove.cs Snippet: Adjustment of currently accessed block type for placing by the player.
View PlayerMove.cs
/// Change the currentBlockType
if (Input.GetKey (KeyCode.Alpha1))
{
currentBlockType = 1;
}
if (Input.GetKey (KeyCode.Alpha2))
{
currentBlockType = 2;
}
@AndrewWeston9
AndrewWeston9 / PlayerMove.cs
Created Oct 6, 2017
PlayerMove.cs Snippet: functions for resource changes, communicating with PlayerState class.
View PlayerMove.cs
// Current block type selected by the player to be placed.
int currentBlockType = 1;
/// Is the player flag placed in the world.
public bool playerFlagPlaced = false;
bool inTrigger = false;
GameObject flagShortest;
@AndrewWeston9
AndrewWeston9 / PlayerState.cs
Created Oct 6, 2017
PlayerState.cs Snippet: Resource system that tracks the amount of resource for the player and controls the gain and reduction in resource.
View PlayerState.cs
private bool inTrigger;
private string ResourceName;
private Vector3 ResourcePosition;
PlayerMove pmove;
//GameObject playerObject;
@AndrewWeston9
AndrewWeston9 / LocalWorld.cs
Last active Oct 6, 2017
LocalWorld.cs Snippet: Created by another team member, I took their code and changed it to work in a network environment, sending the emotes between clients through the server.
View LocalWorld.cs
void Start () {
emoteDisplayer = new EmoteDisplayClass();
}
public void displayEmote(int emoteType, NetworkInstanceId netId)
{
emoteDisplayer.displayEmote (emoteType, netId);
}
public class EmoteDisplayClass : ScriptableObject
@AndrewWeston9
AndrewWeston9 / PlayMove.cs
Last active Oct 6, 2017
PlayMove.cs Snippet: Camera pause function when GUI is in use. Created by myself and another team member.
View PlayMove.cs
bool setUIToFalse = true;
public void SetUIOpenTrue()
{
UIOpen = true;
}
public void SetUIOpenFalse()
{
UIOpen = false;
@AndrewWeston9
AndrewWeston9 / PlayerAnimator.cs
Created Oct 6, 2017
Animation controller for the player character. Controls walking and gathering animations.
View PlayerAnimator.cs
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
using System;
public class PlayerAnimator : NetworkBehaviour {
public Animator anim;
public float speed = 2.0f;
@AndrewWeston9
AndrewWeston9 / EmoteWheel.cs
Last active Oct 6, 2017
EmoteWheel.cs Snippet: Camera pause function when GUI is in use. Created by myself and another team member.
View EmoteWheel.cs
if(menuon == true)
{
setUIToFalse = false;
PCamera = this.transform.parent.gameObject;
netIDC = PCamera.GetComponent<NetworkIdentity>().netId;
PCamera = ClientScene.FindLocalObject(netIDC);
pmove = PCamera.GetComponent<PlayerMove>();
pmove.SetUIOpenTrue();
}
else if (setUIToFalse == false)
@AndrewWeston9
AndrewWeston9 / EmoteWheel.cs
Last active Oct 6, 2017
EmoteWheel.cs Snippet: Created by another team member, I took their code and changed it to work in a network environment, sending the emotes between clients through the server.
View EmoteWheel.cs
public void ButtonAction()
{
buttons[CurMenuItem].sceneimage.color = buttons[CurMenuItem].PressedColor;
GameObject Player = this.transform.parent.gameObject;
NetworkInstanceId netID = Player.GetComponent<NetworkIdentity>().netId;
Debug.Log ("Sending emote with networkID: " + netID.ToString());
Vector3 offset = new Vector3(0.0f, 2.5f, 0.0f);
//IconObject DisplayEmote;
if (CurMenuItem == 0)
{
@AndrewWeston9
AndrewWeston9 / LocalWorld.cs
Last active Oct 6, 2017
LocalWorld.cs Snippet: Message handling, client side.
View LocalWorld.cs
NetworkClient.allClients[0].RegisterHandler (LevelMsgType.EmoteSingleSender, ServerCommandHandler); // Handle incoming emotes from server
NetworkClient.allClients[0].RegisterHandler (LevelMsgType.PlayerFlagRequest, ServerCommandHandler);
case LevelMsgType.EmoteSingleSender:
/// Handle incoming emotes from server
{
SendEmoteMessageAndClientID m = netMsg.ReadMessage<SendEmoteMessageAndClientID> ();
displayEmote(m.emoteType, m.netId);
Debug.Log ("Incoming emote to client from server from network id: " + m.netId);
}
You can’t perform that action at this time.