void Update() { if (Input.GetKeyDown(KeyCode.K)) { switch (mode) { case (Mode.none): break; case (Mode.server): { Vector3 pos = Vector3.left * 3f + Vector3.forward * 2f * count; CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new SpawnBox(pos)); count++; break; } case (Mode.client): { Vector3 pos = Vector3.right * 3f + Vector3.forward * 2f * count; CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new SpawnBox(pos)); count++; break; } } } if (Input.GetKeyDown(KeyCode.J)) { GameObject local = GameObject.CreatePrimitive(PrimitiveType.Sphere); local.name = "local"; local.transform.position = Random.insideUnitSphere * 5f; local.AddNetComponent <TestGUIDObjectLocal>(); } }
private void UpdateDebug() { if(Input.GetKeyDown(KeyCode.K)) { CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GrowEvent(10)); } }
private void OnGridCollision(GridTransform other) { if (other.GetComponent <Player>() != null) { CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameOverEvent()); } }
private void OnGridCollision(GridTransform other) { if (other.GetComponent <Player>() != null) { Destroy(gameObject); CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameState.WinLevelEvent()); } }
private void OnDestroy() { CEventSystem.RemoveEventHandler(EventChannel.input, EventSubChannel.player1, this); CEventSystem.RemoveEventHandler(EventChannel.gameState, EventSubChannel.none, this); SnakeDestroyer.Create(gameObject, tailPieces.Select(x => x.gameObject)); instance = null; }
/// <summary> /// Process a network event broadcast, and push it into the event system /// </summary> /// <param name="netEvent"></param> private static void ProcessNetworkEventBroadcast(NetworkEventBroadcast netEvent) { Enum channel = netEvent.channel, subchannel = netEvent.subchannel; NetworkedCEvent e = netEvent.e; e.sendToServer = false; CEventSystem.Broadcast(channel, subchannel, e); }
public void Fire(WeaponFireEvent fireEvent) { RaycastHit hit; if (Physics.Raycast(fireEvent.ray, out hit, Mathf.Infinity, layerMask)) { CEventSystem.Broadcast(Ship.ShipChannel.shipChannel, Ship.ShipChannel.shipSubchannel, new Ship.TargetEvent(hit.point)); } }
private void Start() { gameObject.AddComponent <NetworkServer>(); NetworkClient.Create(gameObject, IP); gameObject.AddComponent <ServerDebugListener>(); CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new ServerDebugListener.ServerDebugEvent("This is a server debug event")); CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new ServerDebugListener.ClientDebugEvent("This is a client debug event")); }
void Update() { //if (Input.GetKeyDown(KeyCode.Escape)) //{ // SceneManager.LoadScene(SceneManager.GetActiveScene().name); //} Vector2 input = Vector2.zero; if (Input.GetKey(KeyCode.W)) { input.y += 1f; } if (Input.GetKey(KeyCode.S)) { input.y -= 1f; } if (Input.GetKey(KeyCode.A)) { input.x -= 1f; } if (Input.GetKey(KeyCode.D)) { input.x += 1f; } if (input.sqrMagnitude > 1f) { input = input.normalized; } //Sets the target input for the movement controller that receive this event. CEventSystem.Broadcast(EventChannel.input, playerNumber, new SetTargetInputEvent(input)); //Adds an inpulse event to the movement controller that receives this event. if (Input.GetKeyDown(KeyCode.Space)) { CEventSystem.Broadcast(EventChannel.input, playerNumber, new InpulseEvent(Vector3.up * 10f)); } Vector2 viewInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")); CEventSystem.Broadcast(EventChannel.input, playerNumber, new LookInputEvent(viewInput)); if (Input.GetKeyDown(KeyCode.LeftShift)) { CEventSystem.Broadcast(EventChannel.input, playerNumber, new CrouchToggleEvent()); } }
private void Start() { childRight = MakeChild("childRight", Vector2.right); childUp = MakeChild("childUp", Vector2.up); childOne = MakeChild("childOne", Vector2.one); gridTransform = gameObject.GetComponent <GridTransform>(); gridRight = childRight.AddComponent <GridTransform>(); gridUp = childUp.AddComponent <GridTransform>(); gridOne = childOne.AddComponent <GridTransform>(); gridTransforms = new GridTransform[] { gridTransform, gridRight, gridUp, gridOne }; foreach (var gTransform in gridTransforms) { gTransform.Events = new GridEventHandlers(OnCollision: (x) => OnGridCollision(x)); } tweener = gameObject.AddComponent <LinearTweener>(); tweener.speed = 10f; tweener.autoTarget = () => gridTransform.Target; //gridTransform.Warp(GridSystem.GetNode((int)transform.position.x, (int)transform.position.y)); CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameState.EnemySpawnEvent()); animationParent = new GameObject("animationParent"); animationParent.transform.SetParent(transform, false); animationParent.transform.localPosition = new Vector3(0.5f, -0.5f, 0f); animationChild = GameObject.CreatePrimitive(PrimitiveType.Quad); animationChild.name = "AnimationChild"; animationChild.transform.SetParent(animationParent.transform, false); animationChild.transform.localPosition = Vector2.up; animationChild.transform.localScale = new Vector3(2f, 2f, 1f); Sprite[] sheet = Resources.LoadAll <Sprite>("Sprites/slime-sprite-sheet-FINAL-PNG"); front = textureFromSprite(sheet[8]); right = textureFromSprite(sheet[5]); left = textureFromSprite(sheet[2]); back = textureFromSprite(sheet[11]); mat = new Material(Shader.Find("Unlit/Transparent")); mat.SetTexture("_MainTex", front); animationChild.GetComponent <MeshRenderer>().material = mat; }
private void PrivateInit(int owner) { init = false; this.owner = owner; isOwner = owner == NetworkClient.ClientNumber; if (owner == NetworkClient.ClientNumber) { NetBehaviourTracker.AddNetBehaviour(this); var spawn = GetSpawn(); if (spawn != null) { CEventSystem.Broadcast(NetBehaviourSpawner.Channel.channel, NetBehaviourSpawner.Channel.subchannel, spawn); } } }
private void OnGridCollision(GridTransform other) { GreenSlime slime = other.GetComponentInParent <GreenSlime>(); if (slime == this) { return; } Player player = other.GetComponent <Player>(); if (player != null) { Destroy(gameObject); CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GrowEvent(GameState.SnakeGrowCount)); CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameState.EnemyDestroyedEvent()); } }
void Start() { movementController = GetComponent <MovementController>(); movementController.OnCoordinateSpaceDelta += OnCoordinateSpaceDelta; movementController.OnNewCoordinateSpace += OnNewCoordinateSpace; var springObject = new GameObject("Axial"); springObject.transform.parent = transform; springObject.transform.localPosition = Vector3.zero; springObject.transform.localRotation = Quaternion.identity; var spring = springObject.AddComponent <AxialSpring>(); spring.axis = Vector3.up; spring.dynamicStrength = 0.00000001f; var gyroObject = new GameObject("Gyro"); gyroObject.transform.parent = springObject.transform; gyroObject.transform.localPosition = Vector3.zero; gyroObject.transform.localRotation = Quaternion.identity; var gyro = gyroObject.AddComponent <GyroSpring>(); gyro.staticStrength = 10f; var camera = GetComponentInChildren <Camera>(); camera.transform.parent = gyroObject.transform; camera.transform.localPosition = Vector3.zero; camera.transform.localRotation = Quaternion.identity; root = SpringComponent.AutoLink(springObject); CEventSystem.AddEventListener(EventChannel.input, EventPlayerNumberChannel.player1, this); }
public void EventSystemBaseTestSimplePasses() { //Check that the event system is empty Assert.True(CEventSystem.Count == 0); //create an event, add it to the system, and check the count TestEventObject testEvent = new TestEventObject(); CEventSystem.AddEventHandler(category.category, category.subcategory, testEvent); Assert.True(CEventSystem.Count == 1); //Check the state of the test class after broadcasting a set true, set false, and foo event Assert.True(!testEvent.State); CEventSystem.BroadcastEvent(category.category, category.subcategory, new SetTrueEvent()); Assert.True(testEvent.State); CEventSystem.BroadcastEvent(category.category, category.subcategory, new SetFalseEvent()); Assert.True(!testEvent.State); CEventSystem.BroadcastEvent(category.category, category.subcategory, new FooEvent()); Assert.True(!testEvent.State); //remove the event, check the count of the system. CEventSystem.RemoveEventHandler(category.category, category.subcategory, testEvent); Assert.True(CEventSystem.Count == 0); }
void Awake() { CEventSystem.AddEventHandler(EventChannel.gameState, EventSubChannel.none, this); }
void Awake() { CEventSystem.AddEventHandler(EventChannel.gameState, EventSubChannel.none, this); //tween = gameObject.AddComponent<AsymtoticTweener>(); }
private void OnDestroy() { CEventSystem.RemoveEventHandler(EventChannel.gameState, EventSubChannel.none, this); }
void Awake() { statusLabel = gameObject.transform.Find("Status").GetComponentInChildren <UnityEngine.UI.Text>(); CEventSystem.AddEventListener(ServerEventChannel.channel, ServerEventChannel.subchannel, this); }
private void OnDestroy() { CEventSystem.RemoveEventListener(EventChannel.input, playerNumber, movementController); }
private void BroadcastDirectionEvent(Direction direction) { CEventSystem.BroadcastEvent(EventChannel.input, EventSubChannel.player1, new DirectionEvent(direction)); }
public void Start() { CEventSystem.AddEventListener(ShipChannel.channel, ShipChannel.subchannel, this); var plat = gameObject.AddComponent <Platform>(); }
private void OnGridCollision(GridTransform other) { CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GameOverEvent()); Destroy(gameObject); //CEventSystem.BroadcastEvent(EventChannel.gameState, EventSubChannel.none, new GrowEvent(1)); }
void OnDestroy() { CEventSystem.RemoveEventListener(EventChannel.input, EventPlayerNumberChannel.player1, this); }
void OnDestroy() { CEventSystem.RemoveEventListener(ServerEventChannel.channel, ServerEventChannel.subchannel, this); }
private void Awake() { movementController = GetComponent <MovementController>(); CEventSystem.AddEventListener(EventChannel.input, playerNumber, movementController); }
private void CreateEventSystem() { var eventSystem = new CEventSystem(); eventSystem.CreateEventSystem(); }
private void Awake() { CEventSystem.AddEventHandler(EventChannel.input, EventSubChannel.player1, this); CEventSystem.AddEventHandler(EventChannel.gameState, EventSubChannel.none, this); instance = this; }
public void Start() { CEventSystem.AddEventListener(Channel.channel, Channel.subchannel, this); }
void Start() { CEventSystem.AddEventListener(ServerEventChannel.channel, ServerEventChannel.subchannel, this); }
protected override void _OnDestroy() { CEventSystem.RemoveEventListener(ShipChannel.shipChannel, ShipChannel.shipSubchannel, this); }