Пример #1
0
 /// <summary>
 /// Spawns the players.
 /// </summary>
 public void SpawnPlayers()
 {
     Debug.Log("Spawning all the players");
     _playerSpawned++;
     CreatePlayer();
     NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.SPAWN_PLAYER);
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        TimeSinceLastExplosion += Time.deltaTime;
        TimeSinceLastGrip      += Time.deltaTime;
        if (Constants.BAZOOKA_CD - TimeSinceLastExplosion <= 0)
        {
            if (Input.GetMouseButtonDown(0) || Input.GetKey(KeyCode.Joystick1Button5))
            {
                TimeSinceLastExplosion = 0;
                //NetworkEventHandlers.SendEvent(new BazookaEvent(Launcher.transform.position, Launcher.transform.rotation, Camera.transform.forward * Constants.PROJECTILE_FORCE));
                NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.BAZOOKA_SHOT, new object[]
                {
                    (object)Launcher.transform.position,
                    (object)Launcher.transform.rotation,
                    (object)(Camera.transform.forward * Constants.PROJECTILE_FORCE)
                });
                _network.Engine.BazookaShoot(Launcher.transform.position, Launcher.transform.rotation, Camera.transform.forward * Constants.PROJECTILE_FORCE);
            }
        }

        if (Constants.GRIP_CD - TimeSinceLastGrip <= 0)
        {
            if (Input.GetMouseButtonDown(1) || Input.GetKey(KeyCode.Joystick1Button4))
            {
                TimeSinceLastGrip = 0;
                GameObject temp_projectile;
                temp_projectile = Instantiate(grip, Launcher.transform.position, Launcher.transform.rotation, PlayerBody.transform) as GameObject;
                Rigidbody projectile_body;
                projectile_body = temp_projectile.GetComponent <Rigidbody>();
                projectile_body.AddForce(Camera.transform.forward * Constants.PROJECTILE_FORCE);
                Destroy(temp_projectile, 10.0f);
            }
        }
    }
Пример #3
0
 public void RefreshCooldowns()
 {
     NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.COOLDOWN_REFRESH_PARTICLES, transform.FindChild("bottom").transform.position);
     Debug.LogWarning("REFRESHING");
     RefreshCooldownsParticles(transform.FindChild("bottom").transform.position, true);
     TimeSinceLastExplosion = Constants.BAZOOKA_CD;
     TimeSinceLastGrip      = Constants.GRIP_CD;
 }
Пример #4
0
    public void ImpairedVision(GameObject c)
    {
        NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.IMPAIR_VISION_EFFECT);
        NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.VISION_IMPAIRED_PARTICLES, transform.position);
        GameObject g = c.transform.parent.gameObject;

        g.transform.Find("Canvas/PowerCanvas/ImpairedVision").gameObject.GetComponent <Image>().enabled = false;
        ImpairedVisionParticles(transform.position, true);
    }
Пример #5
0
    private int spawnRandomPowerup(Vector3 position)
    {
        //Debug.LogWarning ("Spawning a powerup");
        // This is pretty bad and should be changed.
        // Remember to change the value when adding new powerups.
        int id = Random.Range(0, 4);

        NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.SPAWN_POWERUP,
                                       new object[] { (object)position, id });
        return(id);
    }
Пример #6
0
 public void SendChatMessage(string username, string message)
 {
     _isWriting  = false;
     _input.text = "";
     NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.CHAT_MESSAGE,
                                    new object[]
     {
         (object)username,
         (object)message
     }
                                    );
     ReceiveMessage(username, message);
 }
Пример #7
0
 /// <summary>
 /// To be called when a player has collided with the bottom of the map.
 /// </summary>
 /// <param name="p">The player that collided</param>
 public void PlayerLost(GameObject p)
 {
     Debug.Log("A player lost");
     _lostList.Push(p.GetComponent <PhotonView>().owner.NickName);
     if (_lostList.Count >= _playerCount)
     {
         string[] arr = _lostList.ToArray();
         foreach (string a in arr)
         {
             Debug.Log(a);
         }
         NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.END_GAME, arr);
         _network.EndGame(arr);
     }
 }
Пример #8
0
    /// <summary>
    /// Creates the player.
    /// </summary>
    public void CreatePlayer()
    {
        if (_hasAlreadySpawned)
        {
            Debug.Log("Trying to create a player I already had");
            return;
        }
        Cursor.visible     = false;
        _chat              = GameObject.Find("ChatManager").GetComponent <Chat>();
        _chat.InMenu       = false;
        _hasAlreadySpawned = true;
        GameObject.Find("ChatManager").GetComponent <Chat>().enabled = true;
        updateReferences();
        Vector3 spawnPosition = _map.transform.Find("BoxPrefab").transform.position + Vector3.up * 15;

        spawnPosition.x = UnityEngine.Random.Range(-9f, 9f);
        spawnPosition.z = UnityEngine.Random.Range(-9f, 9f);
        _localPlayer    = PhotonNetwork.Instantiate(Constants.ROBOT_NAMES[(int)_robotID], spawnPosition, Quaternion.identity, 0);
        _localPlayer.transform.Find("Canvas").gameObject.SetActive(true);
        _localPlayer.GetComponent <CrosshairUI>().enabled = true;
        _localPhotonView = _localPlayer.GetComponent <PhotonView>();
// _localPlayer.transform.Find("bottom").Find("Canvas").Find("Text").GetComponent<Text>().text = PhotonNetwork.playerName;
        _localPlayer.GetComponentInChildren <PlayerController>().enabled = true;
        _localPlayer.GetComponent <ShooterB>().enabled = true;
        _shooterB = _localPlayer.GetComponent <ShooterB>();
        _localPlayer.GetComponent <UI>().enabled = true;
        _localPlayer.GetComponentInChildren <LookTowardCamera>().enabled = true;
        _localPlayer.GetComponentInChildren <CameraControl>().enabled    = true;
        _flyingCamera.gameObject.SetActive(false);
        _camera = _localPlayer.transform.Find("TPScamera/firstCamera").gameObject;
        _camera.GetComponent <AudioListener>().enabled = true;

        if (!PhotonNetwork.isMasterClient)
        {
            NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.PLAYER_SPAWNED);
        }
        else
        {
            GameObject.Instantiate(Resources.Load("PowerupManager"));
        }

        if (!GameObject.Find("SettingsManager").GetComponent <Settings>().OnlineMode)
        {
            spawnAI(Constants.NUMBER_OF_AI);
        }
    }
Пример #9
0
    void Start()
    {
        Debug.Log("ARENA MANAGER START");
        var e = GameObject.Find("NetworkManager").GetComponent <Networking>().Engine;

        e.ReadyMap();
        if (PhotonNetwork.offlineMode)
        {
            e.SpawnPlayers();
            e.Network.RemoveWalls();
            return;
        }
        else if (!PhotonNetwork.isMasterClient)
        {
            NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.SCENE_LOADED);
            return;
        }
        else
        {
            NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.LOAD_SCENE, e.MapID);
        }
    }
Пример #10
0
 /// <summary>
 /// Removes the walls and sends the event to all the players.
 /// </summary>
 private void doRemove()
 {
     NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.REMOVE_WALLS);
     _engine.RemoveWalls();
 }
Пример #11
0
 public void Swap()
 {
     NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.SWAP_PARTICLES, transform.position);
     SpawnSwapParticles(transform.position);
     transform.position = _spawn.transform.position;
 }