Example #1
0
 public void SelectTower()
 {
     if (PlayerObjectRegistry.GetPlayer().state.Gold >= Data.cost)
     {
         InteractionManager.Instance.SetInteraction(new GridInteraction(Data));
     }
 }
Example #2
0
    /*
     * // Callback triggered when this instance receives an incoming client connection
     * public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  //*Example:* Accepting an incoming connection with user credentials in the data token.
     *  //   UserCredentials creds = (UserCredentials)token);
     *  ///   if(Authenticate(creds.username, creds.password)) {
     *  ///     BoltNetwork.Accept(connection.remoteEndPoint);
     *  ///   }
     *
     *
     *  print("S ConnectRequest 2");
     *  BoltNetwork.Accept(endpoint);
     * }
     */


    /*
     * public override void ConnectRequest(UdpKit.UdpEndPoint endpoint)
     * {
     *  print("Connection request of type 1");
     *  BoltNetwork.Accept(endpoint);
     * }
     */

    /*public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  print("ACcept incoming connection");
     *  BoltNetwork.Accept(endpoint);
     * }*/

    /*public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
     * {
     *  print("Connection request ");
     *  CameraSpawnPoint csp = new CameraSpawnPoint(new Vector3(20, 20, 20));
     *  print("Connect request, setting spawn point: "+ csp.position);
     *  BoltNetwork.Accept(endpoint, csp, csp, csp);
     * }*/

    // Callback triggered when a client has become connected to this instance

    /*public override void Connected(BoltConnection connection)
     * {
     *  print("S Connected 1");
     *
     * }*/

    // Callback triggered when a client has become connected to this instance
    public override void Connected(BoltConnection c, Bolt.IProtocolToken acceptToken)
    {
        //*Example:* Using a protocol token with the Connected callback to pass a spawnpoint position to to new player entity.
        print("S Connected 2");
        print("AcceptToken: " + acceptToken);
        //Store this location along with the user's connection
        PlayerObjectRegistry.CreateClientPlayer(c, (CameraSpawnPoint)acceptToken);
    }
Example #3
0
    public void Die(GameObject killer)
    {
        EntityManager.Instance.DestroyEnemy(entity.gameObject);
        var player = PlayerObjectRegistry.GetPlayer(killer.GetComponent <TowerBehaviour>().entity.controller);

        player.behavior.state.Score += _data.score;
        player.behavior.state.Gold  += _data.gold;
    }
Example #4
0
    public override void Disconnected(BoltConnection connection)
    {
        PlayerObjectRegistry.DestroyClientPlayer(connection);

        GameManager.Instance.SetAllPlayerReadyState(false);

        var log = LogEvent.Create();

        log.Message = string.Format("{0} disconnected", connection.RemoteEndPoint);
        log.Send();
    }
Example #5
0
    // Callback triggered when this instance receives an incoming client connection
    public override void ConnectRequest(UdpKit.UdpEndPoint endpoint)
    {
        print("S ConnectRequest 1");
        Vector3 connectedPlayerStarting = PlayerObjectRegistry.PlayerConnect();

        print("Connected starting: " + connectedPlayerStarting);

        if (PlayerObjectRegistry.connectedPlayerCount > 4)
        {
            BoltNetwork.Refuse(endpoint, null);
        }
        else
        {
            CameraSpawnPoint csp = new CameraSpawnPoint(connectedPlayerStarting);
            //print("Connect request, setting spawn point: " + csp.position);
            BoltNetwork.Accept(endpoint, null, csp, null);
        }
    }
Example #6
0
    // Callback triggered before the new local scene has been completely loaded
    public override void SceneLoadLocalDone(string map)
    {
        ///   if(BoltNetwork.isClient && map.Equals("GameScene") {
        ///     SplashScreen.Hide();
        ///   }

        print("S SceneLoadLocalDone");
        PlayerObject p = PlayerObjectRegistry.CreateServerPlayer(new CameraSpawnPoint(new Vector3(0f, 0f, -20f)));
        //server done loading

        //Find camera
        Camera myCamera = PlayerCamera.instance.GetComponentInChildren <Camera>();

        //create potato
        potato = BoltNetwork.Instantiate(BoltPrefabs.Potato);

        //Map camera to potato script
        (potato.GetComponent <PotatoController>()).mainCamera = myCamera;

        //p.rightWall =
    }
Example #7
0
    public override void OnEvent(TeleportEvent evnt)
    {
        foreach (PlayerObject p in PlayerObjectRegistry.allPlayers)
        {
            if (p.connection == evnt.RaisedBy)
            {
                Vector3 newPosition;
                if (evnt.isRightWall)
                {
                    newPosition = PlayerObjectRegistry.getRightWallTeleport(p);
                }
                else
                {
                    newPosition = PlayerObjectRegistry.getLeftWallTeleport(p);
                }

                //TODO move potato
                potato.transform.position = newPosition;
                return;
            }
        }
    }
Example #8
0
 public override void OnEvent(IsReadyEvent evnt)
 {
     PlayerObjectRegistry.GetPlayer(evnt.RaisedBy).behavior.state.IsReady = !PlayerObjectRegistry.GetPlayer(evnt.RaisedBy).behavior.state.IsReady;
 }
Example #9
0
 void Awake()
 {
     PlayerObjectRegistry.CreateServerPlayer();
 }
Example #10
0
    public override void OnEvent(SpawnEvent evnt)
    {
        var player = PlayerObjectRegistry.GetPlayer(evnt.RaisedBy);

        EntityManager.Instance.SpawnTower((TowerType)evnt.TowerType, player, evnt.Position);
    }
Example #11
0
 public override void OnEvent(SetNameEvent evnt)
 {
     PlayerObjectRegistry.GetPlayer(evnt.RaisedBy).behavior.state.Name = evnt.Name;
 }
Example #12
0
 public override void OnEvent(SetColorEvent evnt)
 {
     PlayerObjectRegistry.GetPlayer(evnt.RaisedBy).behavior.state.Color = evnt.Color;
 }
Example #13
0
 public override void SceneLoadRemoteDone(BoltConnection connection)
 {
     PlayerObjectRegistry.GetPlayer(connection).Spawn();
 }
Example #14
0
 public override void Connected(BoltConnection connection)
 {
     PlayerObjectRegistry.CreateClientPlayer(connection);
 }
Example #15
0
 public override void OnEvent(SpawnPlayerEvent evnt)
 {
     // Spawn the player with this customisation token and assign control to the
     // connection /player who raised the event...
     PlayerObjectRegistry.GetPlayer(evnt.RaisedBy).Spawn((CustomisationToken)evnt.CustomisationToken);
 }
Example #16
0
 // Creates a client player when connecting to the server.
 public override void Connected(BoltConnection arg)
 {
     PlayerObjectRegistry.CreateClientPlayer(arg);
     Debug.Log(arg.ConnectionId + " Connected");
 }