Beispiel #1
0
        protected override void RpcRespawn()
        {
//            StartCoroutine(Respawn());

            isDead = true;
            inRange.Clear();
            agent.Stop();

            if (explosionFX)
            {
                //spawn death particles locally using pooling and colorize them in the player's team color
                GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                if (pColor)
                {
                    pColor.SetColor(GameManager.GetInstance().teams[GetView().GetTeam()].material.color);
                }
            }

            //play sound clip on player death
            if (explosionClip)
            {
                AudioManager.Play3D(explosionClip, transform.position);
            }

            FindObjectOfType <BotSpawner>().Despawn(this.gameObject);

            targetPoint        = GameManager.GetInstance().GetSpawnPosition(GetView().GetTeam());
            transform.position = targetPoint;
            agent.Warp(targetPoint);
            agent.Resume();
            isDead = false;
        }
Beispiel #2
0
        //the actual respawn routine
        IEnumerator Respawn(short senderId)
        {
            //stop AI updates
            isDead = true;
            inRange.Clear();
            agent.isStopped = true;
            killedBy        = null;

            //find original sender game object (killedBy)
            PhotonView senderView = senderId > 0 ? PhotonView.Find(senderId) : null;

            if (senderView != null && senderView.gameObject != null)
            {
                killedBy = senderView.gameObject;
            }

            //detect whether the current user was responsible for the kill
            //yes, that's my kill: increase local kill counter
            if (killedBy == GameManager.GetInstance().localPlayer.gameObject)
            {
                GameManager.GetInstance().ui.killCounter[0].text = (int.Parse(GameManager.GetInstance().ui.killCounter[0].text) + 1).ToString();
                GameManager.GetInstance().ui.killCounter[0].GetComponent <Animator>().Play("Animation");
            }

            if (explosionFX)
            {
                //spawn death particles locally using pooling and colorize them in the player's team color
                GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                if (pColor)
                {
                    pColor.SetColor(GameManager.GetInstance().teams[GetView().GetTeam()].material.color);
                }
            }

            //play sound clip on player death
            if (explosionClip)
            {
                AudioManager.Play3D(explosionClip, transform.position);
            }

            //toggle visibility for all rendering parts (off)
            ToggleComponents(false);
            //wait global respawn delay until reactivation
            yield return(new WaitForSeconds(GameManager.GetInstance().respawnTime));

            //toggle visibility again (on)
            ToggleComponents(true);

            //respawn and continue with pathfinding
            targetPoint        = GameManager.GetInstance().GetSpawnPosition(GetView().GetTeam());
            transform.position = targetPoint;
            agent.Warp(targetPoint);
            agent.isStopped = false;
            isDead          = false;
        }
Beispiel #3
0
        /// <summary>
        /// This is when the respawn delay is over
        /// </summary>
        public virtual void Respawn()
        {
            //toggle visibility for player gameobject (on/off)
            gameObject.SetActive(!gameObject.activeInHierarchy);
            bool isActive = gameObject.activeInHierarchy;

            //the player has been killed
            if (!isActive)
            {
                //detect whether the current user was responsible for the kill
                //yes, that's my kill: increase local kill counter
                if (killedBy == GameManagerSinglePlayer.GetInstance().localPlayer.gameObject)
                {
                    GameManagerSinglePlayer.GetInstance().ui.killCounter[0].text = (int.Parse(GameManagerSinglePlayer.GetInstance().ui.killCounter[0].text) + 1).ToString();
                    GameManagerSinglePlayer.GetInstance().ui.killCounter[0].GetComponent <Animator>().Play("Animation");
                }

                if (explosionFX)
                {
                    //spawn death particles locally using pooling and colorize them in the player's team color
                    GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                    ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                    if (pColor)
                    {
                        pColor.SetColor(GameManagerSinglePlayer.GetInstance().teamsForSinglePlayer[teamIndex].material.color);
                    }
                }

                //play sound clip on player death
                if (explosionClip)
                {
                    AudioManager.Play3D(explosionClip, transform.position);
                }
            }

            //further changes only affect the local player
            if (!isLocalPlayer)
            {
                return;
            }

            //local player got respawned so reset states
            if (isActive == true)
            {
                ResetPosition();
            }
            else
            {
                //local player was killed, set camera to follow the killer
                camFollow.target = killedBy.transform;
                //disable input
                disableInput = true;
                //display respawn window (only for local player)
                GameManagerSinglePlayer.GetInstance().DisplayDeath();
            }
        }
Beispiel #4
0
        protected virtual void RpcRespawn()
        {
            //toggle visibility for player gameobject (on/off)
            gameObject.SetActive(!gameObject.activeInHierarchy);
            bool isActive = gameObject.activeInHierarchy;

            //the player has been killed
            if (!isActive)
            {
                //detect whether the current user was responsible for the kill
                //yes, that's my kill: take thumbnail via EveryPlay
                if (killedBy == GameManager.GetInstance().localPlayer.gameObject)
                {
                    UnityEveryplayManager.TakeThumbnail();
                }

                if (explosionFX)
                {
                    //spawn death particles locally using pooling and colorize them in the player's team color
                    GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                    ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                    if (pColor)
                    {
                        pColor.SetColor(GameManager.GetInstance().teams[GetView().GetTeam()].material.color);
                    }
                }

                //play sound clip on player death
                if (explosionClip)
                {
                    AudioManager.Play3D(explosionClip, transform.position);
                }
            }

            //further changes only affect the local client
            if (!photonView.isMine)
            {
                return;
            }

            //local player got respawned so reset states
            if (isActive == true)
            {
                ResetPosition();
            }
            else
            {
                //local player was killed, set camera to follow the killer
                camFollow.target = killedBy.transform;
                //hide input controls and other HUD elements
                camFollow.HideMask(true);
                //display respawn window (only for local player)
                GameManager.GetInstance().DisplayDeath();
            }
        }
Beispiel #5
0
        public virtual void Rpc_Killed(GameObject killer)
        {
            Debug.Log("Run on client");
            Debug.Log("Client Killby:" + killer.ToString());

            killedBy = killer;

            Hide(true);

            Debug.Log(gameObject.activeInHierarchy);
            //detect whether the current user was responsible for the kill
            //yes, that's my kill: increase local kill counter
            //can't kill ourselves and add that to the kill counter
            if (!isLocalPlayer && killer == GameManager.GetInstance().localPlayer.gameObject)
            {
                GameManager.GetInstance().ui.killCounter[0].text = (int.Parse(GameManager.GetInstance().ui.killCounter[0].text) + 1).ToString();
                GameManager.GetInstance().ui.killCounter[0].GetComponent <Animator>().Play("Animation");
            }

            if (explosionFX)
            {
                //spawn death particles locally using pooling and colorize them in the player's team color
                GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                if (pColor)
                {
                    pColor.SetColor(GameManager.GetInstance().teams[teamIndex].material.color);
                }
            }

            //play sound clip on player death
            if (explosionClip)
            {
                AudioManager.Play3D(explosionClip, transform.position);
            }


            //further changes only affect the local player
            if (isLocalPlayer)
            {
                StartCoroutine(SpawnRoutine());
                //local player was killed, set camera to follow the killer
                camFollow.target = killedBy.transform;
                //disable input
                disableInput = true;
                //display respawn window (only for local player)
                GameManager.GetInstance().DisplayDeath();
            }
        }
Beispiel #6
0
        //the actual respawn routine
        IEnumerator Respawn()
        {
            //stop AI updates
            isDead = true;
            inRange.Clear();
            agent.Stop();

            if (explosionFX)
            {
                //spawn death particles locally using pooling and colorize them in the player's team color
                GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                if (pColor)
                {
                    pColor.SetColor(GameManager.GetInstance().teams[GetView().GetTeam()].material.color);
                }
            }

            //play sound clip on player death
            if (explosionClip)
            {
                AudioManager.Play3D(explosionClip, transform.position);
            }

            //toggle visibility for all rendering parts (off)
            ToggleComponents(false);
            //wait global respawn delay until reactivation

            yield return(new WaitForSeconds(GameManager.GetInstance().respawnTime));

            FindObjectOfType <BotSpawner>().Despawn(this.gameObject);


//            toggle visibility again (on)
            ToggleComponents(true);


            //respawn and continue with pathfinding
            targetPoint        = GameManager.GetInstance().GetSpawnPosition(GetView().GetTeam());
            transform.position = targetPoint;
            agent.Warp(targetPoint);
            agent.Resume();
            isDead = false;
        }
Beispiel #7
0
        public void RpcDie(short senderId)
        {
            gameObject.SetActive(false);
            killedBy = senderId > 0 ? ClientScene.FindLocalObject(new NetworkInstanceId((uint)senderId)) : null;
            bIsAlive = false;
            // TODO: ScoreBegin
            if (explosionFX != null)
            {
                //spawn death particles locally using pooling and colorize them in the player's team color
                GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                if (pColor)
                {
                    pColor.SetColor(GameManager.GetInstance().teams[teamIndex].material.color);
                }
            }

            //play sound clip on player death
            if (explosionClip != null)
            {
                AudioManager.Play3D(explosionClip, transform.position);
            }

            if (isServer)
            {
                agent.Warp(GameManager.GetInstance().GetSpawnPosition(teamIndex));
            }

            if (controller != null)
            {
                controller.Stop();
            }

            if (isLocalPlayer)
            {
                if (killedBy != null)
                {
                    camFollow.target = killedBy.transform;
                }
                camFollow.HideMask(true);
                GameManager.GetInstance().DisplayDeath();
            }
        }
Beispiel #8
0
        protected virtual void RpcRespawn(short senderId)
        {
            //toggle visibility for player gameobject (on/off)
            gameObject.SetActive(!gameObject.activeInHierarchy);
            bool isActive = gameObject.activeInHierarchy;

            killedBy = null;

            //the player has been killed
            if (!isActive)
            {
                //find original sender game object (killedBy)
                PhotonView senderView = senderId > 0 ? PhotonView.Find(senderId) : null;
                if (senderView != null && senderView.gameObject != null)
                {
                    killedBy = senderView.gameObject;
                }

                //detect whether the current user was responsible for the kill, but not for suicide
                //yes, that's my kill: increase local kill counter
                if (this != GameManager.GetInstance().localPlayer&& killedBy == GameManager.GetInstance().localPlayer.gameObject)
                {
                    GameManager.GetInstance().ui.killCounter[0].text = (int.Parse(GameManager.GetInstance().ui.killCounter[0].text) + 1).ToString();
                    GameManager.GetInstance().ui.killCounter[0].GetComponent <Animator>().Play("Animation");
                }

                if (explosionFX)
                {
                    //spawn death particles locally using pooling and colorize them in the player's team color
                    GameObject    particle = PoolManager.Spawn(explosionFX, transform.position, transform.rotation);
                    ParticleColor pColor   = particle.GetComponent <ParticleColor>();
                    if (pColor)
                    {
                        pColor.SetColor(GameManager.GetInstance().teams[GetView().GetTeam()].material.color);
                    }
                }

                //play sound clip on player death
                if (explosionClip)
                {
                    AudioManager.Play3D(explosionClip, transform.position);
                }
            }

            if (PhotonNetwork.IsMasterClient)
            {
                //send player back to the team area, this will get overwritten by the exact position from the client itself later on
                //we just do this to avoid players "popping up" from the position they died and then teleporting to the team area instantly
                //this is manipulating the internal PhotonTransformView cache to update the networkPosition variable
                GetComponent <PhotonTransformView>().OnPhotonSerializeView(new PhotonStream(false, new object[] { GameManager.GetInstance().GetSpawnPosition(GetView().GetTeam()),
                                                                                                                  Vector3.zero, Quaternion.identity }), new PhotonMessageInfo());
            }

            //further changes only affect the local client
            if (!photonView.IsMine)
            {
                return;
            }

            //local player got respawned so reset states
            if (isActive == true)
            {
                ResetPosition();
            }
            else
            {
                //local player was killed, set camera to follow the killer
                if (killedBy != null)
                {
                    camFollow.target = killedBy.transform;
                }
                //hide input controls and other HUD elements
                camFollow.HideMask(true);
                //display respawn window (only for local player)
                GameManager.GetInstance().DisplayDeath();
            }
        }