protected void NotifyObstacleCollided(NetworkPlayer player , Type itemType) { C2Notification notification = new C2Notification("ObstacleCollided"); notification.putData("NetworkPlayer" , player); notification.MsgSrcType = itemType; this.SendNotification(notification); }
protected override void HandleNotification(C2Notification notification) { string type = notification.Type; switch (type){ case C2MessageType.Notification_CoinPicked: this.OnCoinPicked(); break; case C2MessageType.Notification_EnergyBlockPicked: this.OnEnergyBlockPicked(); break; case C2MessageType.Notification_AcceleratorPicked: this.OnAcceleratorPicked(); break; case C2MessageType.Notification_ShieldPicked: this.OnShieldPicked(); break; case C2MessageType.Notification_PlayerStatus: currentPlayer = (Player)notification.getData("Player"); break; case C2MessageType.Notification_EndGame: transform.FindChild("Explosion").gameObject.SetActive(true); break; default: break; } }
protected override void HandleRequest(C2Request request) { string type = request.Type; NetworkPlayer player = (NetworkPlayer)request.getData("NetworkPlayer"); switch (type){ case C2MessageType.Request_UpdateCoin: playerList[player].updatePlayerCoin(); break; case C2MessageType.Request_UpdateEnergy: playerList[player].updatePlayerEnergy(); break; case C2MessageType.Request_UpdateSpeed: playerList[player].updatePlayerSpeed(); break; case C2MessageType.Request_UpdateShield: playerList[player].updatePlayerShield(); break; case C2MessageType.Request_UpdateAlive: playerList[player].updatePlayerAlive(); break; case C2MessageType.Request_PlayerStatus: C2Notification notification = new C2Notification(C2MessageType.Notification_PlayerStatus); notification.putData("NetworkPlayer" , player); notification.putData("Player" , playerList[player]); this.SendNotification(notification); break; default: break; } }
private void NotifyInput(float VInput , float HInput) { C2Notification notification = new C2Notification(C2MessageType.Notification_Input); notification.putData("VInput",VInput); notification.putData("HInput",HInput); this.SendNotification(notification); }
protected override void HandleNotification(C2Notification notification) { foreach(C2Port bottomPort in this.bottoms) { bottomPort.PassNotification(notification); } }
public void EndGame() { if (Network.isClient){ C2Notification notification = new C2Notification(C2MessageType.Notification_EndGame); this.HandleNotification(notification); } }
public void GetPlayerStatus(NetworkPlayer player , int score , float distance , int coin , float energy , float speed , float shield, bool alive) { if (Network.player == player){ C2Notification notification = new C2Notification(C2MessageType.Notification_PlayerStatus); notification.putData("Player" , new Player(player , score , distance , coin , energy , speed , shield , alive)); this.HandleNotification(notification); } }
//send notification to lower brick through this port public bool PassNotification(C2Notification notification) { if (this.buttomBrick == null)return false; if(this.buttomBrick.AcceptNoti(notification.Type)) { this.buttomBrick.SendMessage("HandleNotification",notification); } return false; }
public void ItemPicked(string type , NetworkPlayer player) { if (player == Network.player){ C2Notification notification = new C2Notification(type); notification.putData("NetworkPlayer" , player); this.HandleNotification(notification); } }
protected override void HandleNotification(C2Notification notification) { string type = notification.Type; if(type.Equals(C2MessageType.Notification_Item_Collided)) { Type msgSrcType = notification.MsgSrcType; NetworkPlayer player = (NetworkPlayer)notification.getData("NetworkPlayer"); this.NotifyItemPicked(player , msgSrcType.ToString()); this.RequestUpdatePlayer(player , msgSrcType.ToString()); } }
protected override void HandleNotification(C2Notification notification) { string type = notification.Type; switch (type){ case C2MessageType.Notification_PlayerStatus: player = (Player)notification.getData("Player"); break; default: break; } }
protected override void HandleRequest(C2Request request) { if (request.Type.Equals(C2MessageType.Request_ClientAction)){ C2Notification notification = new C2Notification(C2MessageType.Notification_Input); notification.putData("VInput", (float)request.getData("VInput")); notification.putData("HInput", (float)request.getData("HInput")); notification.putData("NetworkPlayer" , (NetworkPlayer)request.getData("NetworkPlayer")); this.SendNotification(notification); } }
protected override void HandleNotification(C2Notification notification) { string type = notification.Type; if (type.Equals(C2MessageType.Notification_Input)) { float VInput = (float)notification.getData("VInput"); float HInput = (float)notification.getData("HInput"); this.RequestMovement(VInput, HInput); } }
protected override void HandleNotification(C2Notification notification) { string type = notification.Type; if(type.Equals(C2MessageType.Notification_Obstacle_Collided)) { Type msgSrcType = notification.MsgSrcType; NetworkPlayer player = (NetworkPlayer)notification.getData("NetworkPlayer"); Players players = (Players)(GameObject.Find("Players").GetComponent(typeof(Players))); if (players.playerList[player].Shield < Mathf.Epsilon){ this.NotifyCrash(player); this.RequestUpdatePlayer(player); } } }
protected void SendNotification(C2Notification notification) { foreach (C2Port port in this.bottoms){ if (testConnectionMode){ if (port.PassNotification(notification)){ Debug.Log(name + " successfully sent notification " + notification.Type + " to " + port.ButtomBrick.name); } else{ Debug.Log(name + " failed to sent notification " + notification.Type + " to " + port.ButtomBrick.name); } } else{ port.PassNotification(notification); } } }
protected override void HandleNotification(C2Notification notification) { foreach(C2Port bottomPort in this.bottoms) { if (testConnectionMode){ if (bottomPort.PassNotification(notification)){ Debug.Log(name + " successfully sent notification " + notification.Type + " to " + bottomPort.ButtomBrick.name); } else{ Debug.Log(name + " failed to sent notification " + notification.Type + " to " + bottomPort.ButtomBrick.name); } } else{ bottomPort.PassNotification(notification); } } }
private void NotifyItemPicked(NetworkPlayer player , string item) { C2Notification notification = new C2Notification(item + "Picked"); notification.putData("NetworkPlayer" , player); this.SendNotification(notification); }
protected override void HandleNotification(C2Notification notification) { if (notification.Type.Equals(C2MessageType.Notification_EndGame)){ show = true; } }
private void NotifyCrash(NetworkPlayer player) { C2Notification notification = new C2Notification(C2MessageType.Notification_EndGame); notification.putData("NetworkPlayer" , player); this.SendNotification(notification); }
protected abstract void HandleNotification(C2Notification notification);
protected override void HandleNotification(C2Notification notification) { foreach(C2Port bottomPort in this.bottoms) { bottomPort.PassNotification(notification); } string type = notification.Type; NetworkPlayer player = (NetworkPlayer)notification.getData("NetworkPlayer"); switch (type) { case C2MessageType.Notification_CoinPicked: case C2MessageType.Notification_EnergyBlockPicked: case C2MessageType.Notification_AcceleratorPicked: case C2MessageType.Notification_ShieldPicked: networkView.RPC ("ItemPicked" , player , notification.Type , player); break; case C2MessageType.Notification_PlayerStatus: Player playerStauts = (Player)notification.getData("Player"); networkView.RPC("GetPlayerStatus" , player, player, playerStauts.Score, playerStauts.Distance, playerStauts.Coin, playerStauts.Energy, playerStauts.Speed, playerStauts.Shield, playerStauts.Alive); break; case C2MessageType.Notification_EndGame: networkView.RPC ("EndGame" , player); break; default: break; } }
protected override void HandleNotification(C2Notification notification) { }