Skip to content

Instantly share code, notes, and snippets.

View SocketWeaver's full-sized avatar

SocketWeaver SocketWeaver

View GitHub Profile
@SocketWeaver
SocketWeaver / account.yaml
Created April 25, 2019 18:56
sample yaml to create ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: socketweaverSA
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: socketweaverSA
pipelines:
branches:
master:
- step:
name: Build for staging
script:
- docker login -u $DOCKER_ID -p $DOCKER_PW
- docker build -t <your_dockerid>/<image_name>:latest -t <your_dockerid>/<image_name>:$BITBUCKET_COMMIT .
- docker push <your_dockerid>/<image_name>:latest
- docker push <your_dockerid>/<image_name>:$BITBUCKET_COMMIT
@SocketWeaver
SocketWeaver / production-pipeline.yaml
Last active November 4, 2019 13:09
production pipeline
tags:
release-*:
- step:
name: Test for production
script:
- echo "run test"
- step:
name: Build for production
script:
- docker login -u $DOCKER_ID -p $DOCKER_PW
@SocketWeaver
SocketWeaver / Lobby.cs
Created April 26, 2019 04:22
basic matchmaking logic
using UnityEngine;
using SWNetwork;
using UnityEngine.SceneManagement;
public class Lobby : MonoBehaviour
{
void Start()
{
NetworkClient.Lobby.OnRoomReadyEvent += Lobby_OnRoomReadyEvent;
NetworkClient.Lobby.OnFailedToStartRoomEvent += Lobby_OnFailedToStartRoomEvent;
@SocketWeaver
SocketWeaver / prepare.yaml
Created May 10, 2019 01:38
prepare CA cert and token
# list all secrets
kubectl --kubeconfig="kubeconfig.yaml" -n kube-system get secret
# find the secret for the service account we created before and output its CA certificate
# In our case, its name should start with socketweaverSA-token-*
# Add the output of the follow command as the STAGING_LOBBY_CLUSTER_CA pipeline variable
kubectl -kubeconfig="kubeconfig.yaml" -n kube-system get secret socketweaverSA-token-xxxxx -o jsonpath="{['data']['ca\.crt']}"
# Add the output of the follow command as the STAGING_CLUSTER_SA_TOKEN pipeline variable
kubectl --kubeconfig="kubeconfig.yaml" -n kube-system get secret socketweaverSA-token-xxxxx -o jsonpath="{['data']['token']}" | base64 --decode
@SocketWeaver
SocketWeaver / CarMovement.cs
Last active May 11, 2019 21:37
CarMovement changes
NetworkID networkId;
private void Start()
{
Rigidbody rb = GetComponent<Rigidbody>();
rb.centerOfMass = centerOfMass.localPosition;
gameSceneManager = FindObjectOfType<GameSceneManager>();
// initialize networkId
networkId = GetComponent<NetworkID>();
@SocketWeaver
SocketWeaver / CarMovement.cs
Last active May 11, 2019 21:10
CarMovement change for wheel rotation
// expose wheel rotate for the generic tracker
public Quaternion frontWheelRot;
public Quaternion rearWheelRot;
void UpdateWheelTransforms()
{
if (networkId.IsMine)
{
Quaternion rotation;
Vector3 position;
@SocketWeaver
SocketWeaver / GameSceneManager.cs
Created May 11, 2019 20:28
GameSceneManager changes to handle the OnReady event of the SceneSpawner
public void OnSpawnerReady(bool finishedSceneSetup)
{
// scene has not been set up. spawn a car for the local player.
if (!finishedSceneSetup)
{
// assign different spawn point for the host player and the other players in the room
// This is okay for this tutorial as we only have 2 players in a room and we are not handling host migration.
// To properly assign spawn points, you should use GameDataManger or custom room data.
if (NetworkClient.Instance.IsHost)
{
@SocketWeaver
SocketWeaver / GameSceneManager.cs
Last active June 13, 2019 20:10
Handle PlayersPressedEnter's event
RemotePropertyAgent remotePropertyAgent;
const string PLAYER_PRESSED_ENTER = "PlayersPressedEnter";
private void Start()
{
guiManager.SetLapRecord(lap_, lapsToWin);
// get a reference of the gameDataManager component
remotePropertyAgent = GetComponent<RemotePropertyAgent>();
}
@SocketWeaver
SocketWeaver / GameSceneManager.cs
Last active June 13, 2019 20:09
Set the WinnerId SyncProperty to the player who completed the laps first
void OnTriggerEnter(Collider other)
{
GameObject go = other.gameObject;
NetworkID networkID = go.GetComponent<NetworkID>();
// check if the player is the local player
if (networkID.IsMine)
{
lap_ = lap_ + 1;
guiManager.SetLapRecord(lap_, lapsToWin);