Inheritance: MonoBehaviour
Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        Cursor.visible = false;
        cc             = GetComponent <CharacterController>();
        animator       = GetComponent <Animator>();

        if (camScript != null)
        {
            cam = camScript.gameObject.GetComponent <Camera>();
        }
        else
        {
            cam = Camera.main;
        }

        //moveDirection = Vector3.zero;
        health      = maxHealth;
        maxCrystals = GameObject.FindGameObjectsWithTag("Crystal").Length;
        RespawnPoint startPoint = new RespawnPoint(transform.position, transform.localRotation);

        checkpoints.Add(startPoint);
        healthSlider.value = health / maxHealth;
        WriteCrystals();
        syphonCollider = GetComponentInChildren <SphereCollider>();
        audioSource    = GetComponent <AudioSource>();

        camLookOffsetStart = camScript.Lookoffset;

        idleCounterTarget = Random.Range(2, 4);
    }
Exemplo n.º 2
0
 private void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Stand on a respawn point to activate it. You could play a particle effect of something here.
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         currentRespawnPoint = this;
     }
 }
Exemplo n.º 4
0
    // Use this for initialization
    public void Start()
    {
        // Get some of the objects we need later
        _emitterActive   = transform.Find("RSParticlesActive").GetComponent <ParticleSystem>();
        _emitterInactive = transform.Find("RSParticlesInactive").GetComponent <ParticleSystem>();
        _emitterRespawn1 = transform.Find("RSParticlesRespawn1").GetComponent <ParticleSystem>();
        _emitterRespawn2 = transform.Find("RSParticlesRespawn2").GetComponent <ParticleSystem>();
        _emitterRespawn3 = transform.Find("RSParticlesRespawn3").GetComponent <ParticleSystem>();

        _respawnLight = transform.Find("RSSpotlight").GetComponent <Light>();

        CurrentState = RespawnState.Inactive;

        // Set up the looping RespawnActive but leave it switched off for now
        if (SFXPlayerActiveLoop)
        {
            audio.clip        = SFXPlayerActiveLoop;
            audio.loop        = true;
            audio.playOnAwake = false;
        }

        // Assign the respawn point to be this one - Since the player is positioned on top of a respawn point,
        // it will come in and overwrite it, this is just to make sure there is always one active
        if (InitalRespawn != null)
        {
            CurrentRespawn = InitalRespawn;
        }
        if (CurrentRespawn == this)
        {
            SetActive();
        }
    }
Exemplo n.º 5
0
 public void Respawn()
 {
     UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("GameOver");
     Time.timeScale = 1f;
     RespawnPoint.Respawn();
     PlayerControler.instance.GetComponent <Entity>().SetHp(PlayerControler.instance.GetComponent <Entity>().GetMaxHp());
 }
Exemplo n.º 6
0
    public void OnTriggerEnter()
    {
        if (CurrentRespawn != this) // Make sure we're not respawning or re-activing an already active point
        {
            // Turn the old respawn off
            if (CurrentRespawn)
            {
                CurrentRespawn.SetInactive();
            }
            else
            {
                Debug.LogWarning("No intial respawn point set for this level.");
            }

            // Play the "Activated" one-shot sound effect
            if (SFXPlayerActivate)
            {
                AudioSource.PlayClipAtPoint(SFXPlayerActivate, transform.position, SFXVolume);
            }

            // Set the current respawn point to this one
            CurrentRespawn = this;

            SetActive();
        }
    }
Exemplo n.º 7
0
 private void BUGGED_RESET()
 {
     if (Input.GetKeyDown(KeyCode.Escape) || transform.position.z < -50)
     {
         RespawnPoint.Respawn();
     }
 }
Exemplo n.º 8
0
 public static void RegisterRespawnPoint(RespawnPoint newRespawn)
 {
     if (!Instance.Respawns.Contains(newRespawn))
     {
         Instance.Respawns.Add(newRespawn);
     }
 }
Exemplo n.º 9
0
        public void OnPlayerRevive(CM_PLAYER_REVIVE p)
        {
            if (chara.Status.Dead && !chara.Status.Recovering && !chara.Status.ShouldRespawn)
            {
                chara.Status.ShouldRespawn = true;
                chara.Status.ShouldLoadMap = true;

                var points = from point in map.RespawnPoints
                             orderby chara.DistanceToPoint(point.X, point.Y, point.Z)
                             select point;

                RespawnPoint res = points.FirstOrDefault();
                if (res.MapID == 0)
                {
                    map.SendActorToMap(chara, map, chara.X, chara.Y, chara.Z);
                }
                else
                {
                    Map.Map tMap = MapManager.Instance.GetMap(res.MapID, chara.CharID, chara.PartyID);
                    if (map != null)
                    {
                        chara.Dir = res.Dir;
                        map.SendActorToMap(chara, tMap, res.X, res.Y, res.Z);
                    }
                    else
                    {
                        map.SendActorToMap(chara, map, chara.X, chara.Y, chara.Z);
                    }
                }
            }
        }
Exemplo n.º 10
0
    /// <summary>
    /// Triggers the death actions.
    /// </summary>
    /// <returns>The zero health action.</returns>
    protected IEnumerator DoZeroHealthAction()
    {
        if (zeroHealthAction == ZeroHealthAction.SEND_MESSAGE_DIED)
        {
            SendMessage("Died", SendMessageOptions.DontRequireReceiver);
        }
        else
        {
            controller.Stun(dieDelay * 1.25f);
            controller.Velocity = new Vector2(0.0f, 10.0f);
            int tmpBackgroundLayer  = controller.backgroundLayer;
            int tmpPassThroughLayer = controller.passThroughLayer;
            int tmpClimableLayer    = controller.climableLayer;
            controller.backgroundLayer  = 999;
            controller.passThroughLayer = 999;
            controller.climableLayer    = 999;
            yield return(new WaitForSeconds(dieDelay));

            controller.backgroundLayer  = tmpBackgroundLayer;
            controller.passThroughLayer = tmpPassThroughLayer;
            controller.climableLayer    = tmpClimableLayer;
            controller.Velocity         = Vector2.zero;
            switch (zeroHealthAction)
            {
            case ZeroHealthAction.RELOAD_SCENE: Application.LoadLevel(Application.loadedLevel); break;

            case ZeroHealthAction.RESPAWN: health = maxHealth; RespawnPoint.Respawn(controller); break;
            }
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Moves the <see cref="Rigidbody2D"/> of the parent <see cref="GameObject"/> to the best <see cref="RespawnPoint"/>
    /// </summary>
    private void Respawn()
    {
        var point        = RespawnPoint.FindBestPoint().transform;
        var rigidBody    = GetComponent <Rigidbody2D>();
        var playerHeight = GetComponent <Renderer>().bounds.size.y;

        rigidBody.position = point.position + 0.5f * playerHeight * Vector3.up;
    }
Exemplo n.º 12
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject == PlayerControler.instance.gameObject)
     {
         lastRespawnPoint = this;
         lastPlayerData.UpdateCurrentData();
     }
 }
 public void SetCurrentRespawnPoint(RespawnPoint point)
 {
     _lastRespawnPosition = point.transform.position;
     if (_respawnParticlesInstance == null)
     {
         _respawnParticlesInstance = Director.GetManager <ParticlesManager>().SpawnParticles(respawnParticles.Value, point.transform.position);
     }
     _respawnParticlesInstance.transform.position = point.transform.position;
 }
Exemplo n.º 14
0
    private void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.blue;
        Gizmos.DrawWireSphere(transform.position, m_Threshold.AsFloat());

        if (m_RespawnPoints != null)
        {
            for (int respawnPointIndex = 0; respawnPointIndex < m_RespawnPoints.Length; ++respawnPointIndex)
            {
                RespawnPoint respawnPoint = m_RespawnPoints[respawnPointIndex];

                if (respawnPoint == null)
                {
                    continue;
                }

                TSVector2 normalizedDir = respawnPoint.forceDirection.normalized;

                // Draw main direction.

                if (respawnPoint.transform != null)
                {
                    Gizmos.color = Color.yellow;

                    Vector3 from = respawnPoint.transform.position.ToVector();
                    Vector3 to   = from + new Vector3(normalizedDir.x.AsFloat(), normalizedDir.y.AsFloat(), 0f);
                    Gizmos.DrawLine(from, to);
                }

                if (MathFP.Abs(respawnPoint.errorAngle) > FP.Zero)
                {
                    // Draw error range.

                    {
                        Gizmos.color = Color.red;

                        TSVector2 normalizedDirLeft = normalizedDir.Rotate(-respawnPoint.errorAngle);

                        Vector3 from = respawnPoint.transform.position.ToVector();
                        Vector3 to   = from + new Vector3(normalizedDirLeft.x.AsFloat(), normalizedDirLeft.y.AsFloat(), 0f);
                        Gizmos.DrawLine(from, to);
                    }

                    {
                        Gizmos.color = Color.red;

                        TSVector2 normalizedDirRight = normalizedDir.Rotate(respawnPoint.errorAngle);

                        Vector3 from = respawnPoint.transform.position.ToVector();
                        Vector3 to   = from + new Vector3(normalizedDirRight.x.AsFloat(), normalizedDirRight.y.AsFloat(), 0f);
                        Gizmos.DrawLine(from, to);
                    }
                }
            }
        }
    }
Exemplo n.º 15
0
 public void CheckPointSet(RespawnPoint NewPoint)
 {
     //set last point as inactive (if there is one
     if (LastRespawn)
     {
         LastRespawn.SetOff();
     }
     //set our new respawn point
     LastRespawn = NewPoint;
 }
Exemplo n.º 16
0
    private void ChangeCurrentRespawn(RespawnPoint other)
    {
        if (currentRespawn == other)
        {
            return;
        }

        currentRespawn = other;
        Debug.Log("Respawn point has changed : " + other.transform.position);
    }
Exemplo n.º 17
0
    public void SetCurrentSpawner(RespawnPoint a_spawner)
    {
        var i = PlayerSpawnManager.instance.GetSpawnerIndex(a_spawner);

        if (i < 0)
        {
            return;
        }

        PlayerPrefs.SetInt("spawner index", i);
        PlayerPrefs.Save();
    }
Exemplo n.º 18
0
 private void Start()
 {
     UpdateSpeed(1 - PlayerPrefs.GetInt("playerSpeed") * 0.25f);
     Pools   = GameObject.Find("Pools").GetComponent <ObjectPooler>();
     mapData = VII.SceneDataManager.Instance.GetMapData();
     if (VII.SceneManager.instance.GetSave())
     {
         SavePlayerData data = SaveSystem.LoadPlayer();
         currentMapID   = data.saveMapId;
         currentLevelID = data.saveLevelId;
     }
     else
     {
         currentMapID   = VII.SceneManager.instance.GetStartMapID();
         currentLevelID = VII.SceneManager.instance.GetStartLevelID();
     }
     if (currentMapID > 0)
     {
         for (int i = 0; i < currentMapID; i++)
         {
             mapData[i].GetMapObject().SetActive(false);
         }
     }
     if (currentLevelID > 0)
     {
         mapData[currentMapID].GetLevelData()[currentLevelID - 1].GetCheckpoint().activated = true;
     }
     for (int i = 0; i < mapData[currentMapID].GetLevelData()[currentLevelID].GetLevelObject().transform.childCount; i++)
     {
         if (mapData[currentMapID].GetLevelData()[currentLevelID].GetLevelObject().transform.GetChild(i).name == "Level_blocker")
         {
             mapData[currentMapID].GetLevelData()[currentLevelID].GetLevelObject().transform.GetChild(i).GetComponent <Wall>().Move(new Vector3(0, 1, 0));
         }
         if (mapData[currentMapID].GetLevelData()[currentLevelID].GetLevelObject().transform.GetChild(i).name == "Level_blocker2")
         {
             mapData[currentMapID].GetLevelData()[currentLevelID].GetLevelObject().transform.GetChild(i).GetComponent <Wall>().Move(new Vector3(0, -1, 0));
         }
     }
     mapData[currentMapID].GetLevelData()[currentLevelID].SetTilesEnabledState(true);
     currentRespawnPoint = mapData[currentMapID].GetLevelData()[currentLevelID].GetRespawnPoint();
     bestLifeCost        = mapData[currentMapID].GetLevelData()[currentLevelID].GetBestLivesCost();
     transform.position  = currentRespawnPoint.transform.position + VII.GameData.PLAYER_RESPAWN_POSITION_OFFSET;
     currentRespawnPoint.playerInside = true;
     tilePlayerInside = currentRespawnPoint;
     VII.VIIEvents.PlayerRespawnEnd.Invoke(this);
     m_playerData.playerState = VII.PlayerState.IDLE;
     VII.SceneDataManager.Instance.GetCurrentLevelData().GetRespawnPoint().SetBaseAnimator(true);
     UIManager.UIInstance.UpdateUI();
     m_PlayerAnimationController.InitStepUI();
     VII.VIIEvents.PlayerRegisterEnd.Invoke(this);
 }
    void OnDrawGizmosSelected()
    {
        for (int respawnPointIndex = 0; respawnPointIndex < m_RespawnPoints.Length; ++respawnPointIndex)
        {
            RespawnPoint respawnPoint = m_RespawnPoints[respawnPointIndex];

            if (respawnPoint == null)
            {
                continue;
            }

            Vector2 normalizedDir = respawnPoint.forceDirection.normalized;

            // Draw main direction.

            {
                Gizmos.color = Color.yellow;

                Vector3 from = respawnPoint.transform.position;
                Vector3 to   = from + new Vector3(normalizedDir.x, normalizedDir.y, 0f);
                Gizmos.DrawLine(from, to);
            }

            if (Mathf.Abs(respawnPoint.errorAngle) > Mathf.Epsilon)
            {
                // Draw error range.

                {
                    Gizmos.color = Color.red;

                    Vector2 normalizedDirLeft = normalizedDir.Rotate(-respawnPoint.errorAngle);

                    Vector3 from = respawnPoint.transform.position;
                    Vector3 to   = from + new Vector3(normalizedDirLeft.x, normalizedDirLeft.y, 0f);
                    Gizmos.DrawLine(from, to);
                }

                {
                    Gizmos.color = Color.red;

                    Vector2 normalizedDirRight = normalizedDir.Rotate(respawnPoint.errorAngle);

                    Vector3 from = respawnPoint.transform.position;
                    Vector3 to   = from + new Vector3(normalizedDirRight.x, normalizedDirRight.y, 0f);
                    Gizmos.DrawLine(from, to);
                }
            }
        }
    }
Exemplo n.º 20
0
    private void NewSceneStart()
    {
        GameObject[] findObjects = GameObject.FindGameObjectsWithTag(TagAndLayer.Tag.Respawn);
        for (int i = 0; i < findObjects.Length; i++)
        {
            RespawnPoint respawnPoint = findObjects[i].GetComponent <RespawnPoint>();
            if (respawnPoint._isStartingPoint)
            {
                _currentRespawnPoint = respawnPoint;
                break;
            }
        }

        Instantiate(_playerPrefab, _currentRespawnPoint.transform.position, Quaternion.identity);
    }
Exemplo n.º 21
0
    public void TrySettingRespawnPoint()
    {
        SceneData sd = GetSceneData();

        if (sd == null)
        {
            return;
        }

        if (!sd.blockRespawning && !savedGameOnce && GetSceneData() != null)
        {
            this.savedGameOnce = true;
            this.respawnPoint  = new RespawnPoint(GlobalController.GetPlayerPos(), sd.sceneName);
        }
    }
Exemplo n.º 22
0
    private IEnumerator RespawnAfterSecond()
    {
        yield return(new WaitForSecondsRealtime(1f));

        Entity ent = PlayerControler.instance.gameObject.GetComponent <Entity>();

        if (ent.gameObject == PlayerControler.instance.gameObject)
        {
            if (!ent.Damage(1, default))
            {
                RespawnPoint.Respawn();
            }
        }
        Time.timeScale = 1f;
    }
Exemplo n.º 23
0
    public void Respawn(RespawnPoint spawn)
    {
        FreezeSimulation(false);
        manager.fuelLevel = spawnFuel;
        body.MovePosition(spawn.transform.position);
        body.MoveRotation(spawn.transform.rotation);
        body.velocity        = Vector3.zero;
        body.angularVelocity = Vector3.zero;
        GetComponent <Rigidbody>().AddForce(spawn.spawnInMotion ? transform.forward * manager.respawnVelocity : Vector3.zero, ForceMode.VelocityChange);

        foreach (AeroEngine engine in engines)
        {
            engine.Respawn();
        }
    }
Exemplo n.º 24
0
 // Update is called once per frame
 void Update()
 {
     timer -= Time.deltaTime;
     if (timer < 0 && count < max)
     {
         count++;
         timer = interval;
         RespawnPoint toRespawn = this.respawns[(int)Mathf.Floor(Random.Range(0.0f, (float)(this.respawns.Length)))];
         Enemy        newEnemy  = (Enemy)Instantiate(enemyBase, toRespawn.transform.position, toRespawn.transform.rotation);
         newEnemy.type = EnemyType.Bounder;
         Vector3    outsidePos = new Vector3(100.0f, 100.0f);
         GameObject newGhost   = (GameObject)Instantiate(enemyGhost, outsidePos, toRespawn.transform.rotation);
         newEnemy.GetComponent <Ghost>().target = newGhost;
     }
 }
Exemplo n.º 25
0
        public override void LightOn()
        {
            if (lampType == LampType.PROXIMITY)
            {
                StartCoroutine(PulseLight());
                return;
            }
            else if (lampType == LampType.RESPAWN)
            {
                RespawnPoint respawn = transform.parent.GetComponent <RespawnPoint>();
                respawn.UpdateRespawn();
            }

            base.LightOn();
            lampTrigger.OnLit();
        }
Exemplo n.º 26
0
    private void Start()
    {
        _levelTriggerLayer = 1 << LayerMask.NameToLayer(Layers.LevelTrigger);
        _player            = GameObject.FindGameObjectWithTag(Tags.Player).GetComponent <PlayerActor>();

        _respawnPoint = RespawnPoint.Instance;
        if (!_respawnPoint.HasSpawnInfo)
        {
            _respawnPoint.SetRespawn(_player.transform.position, _player.Mobile.Direction);
        }
        else
        {
            _player.transform.position = _respawnPoint.Position;
            _player.Mobile.Direction   = _respawnPoint.Direction;
        }
    }
Exemplo n.º 27
0
    private void SetRespawnPoint(RespawnPoint newRespawnPoint)
    {
        if (respawnPoint != null && respawnPoint == newRespawnPoint)
        {
            return;
        }

        if (respawnPoint != null)
        {
            respawnPoint.Deactivate();
        }

        newRespawnPoint.Activate();
        respawnPoint = newRespawnPoint;

        PlayFlagSound();
    }
        public static IEnumerator WaitThenMovePlayer(Player __instance, SubRoot lastValidSub)
        {
            while (!__instance.playerController.inputEnabled)
            {
                yield return(CoroutineUtils.waitForNextFrame);
            }

            RespawnPoint componentInChildren = lastValidSub.gameObject.GetComponentInChildren <RespawnPoint>();

            if (componentInChildren)
            {
                __instance.SetPosition(componentInChildren.GetSpawnPosition());
                __instance.SetCurrentSub(lastValidSub);
            }

            yield break;
        }
Exemplo n.º 29
0
    private static void EvaluateRespawnPoint(ref RespawnPoint point, Vector3[] enemies, Vector3[] allies)
    {
        for (int i = 0; i < enemies.Length; i++)
        {
            if ((enemies[i] - point.pos).sqrMagnitude < 10)
            {
                point.value += 100;
            }
        }

        for (int i = 0; i < allies.Length; i++)
        {
            if ((allies[i] - point.pos).sqrMagnitude < 6)
            {
                point.value += 49;
            }
        }
    }
Exemplo n.º 30
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //This is checking the collision for a gameObject that has the
        //Script 'KillPlayer' Attached to it
        GameObject checkCollision = collision.gameObject;
        KillPlayer canKill        = checkCollision.GetComponent <KillPlayer>();

        if (canKill != null)
        {
            respawnPlayer();
        }

        RespawnPoint respawnPoint = checkCollision.GetComponent <RespawnPoint>();

        if (respawnPoint != null)
        {
            restartPosition = transform.position;
        }
    }
Exemplo n.º 31
0
	/// <summary>
	/// Stand on a respawn point to activate it. You could play a particle effect of something here.
	/// </summary>
	override public void DoAction(RaycastCollider collider, RaycastCharacterController character) {
		if (collider.direction == RC_Direction.DOWN) currentRespawnPoint = this;
	}
Exemplo n.º 32
0
    public void OnTriggerEnter()
    {
        if (CurrentRespawn != this) // Make sure we're not respawning or re-activing an already active point
        {
            // Turn the old respawn off
            if (CurrentRespawn)
                CurrentRespawn.SetInactive();
            else
                Debug.LogWarning("No intial respawn point set for this level.");

            // Play the "Activated" one-shot sound effect
            if (SFXPlayerActivate)
                AudioSource.PlayClipAtPoint(SFXPlayerActivate, transform.position, SFXVolume);

            // Set the current respawn point to this one
            CurrentRespawn = this;

            SetActive();
        }
    }
Exemplo n.º 33
0
    // Use this for initialization
    public void Start()
    {
        // Get some of the objects we need later
        _emitterActive = transform.Find("RSParticlesActive").GetComponent<ParticleSystem>();
        _emitterInactive = transform.Find("RSParticlesInactive").GetComponent<ParticleSystem>();
        _emitterRespawn1 = transform.Find("RSParticlesRespawn1").GetComponent<ParticleSystem>();
        _emitterRespawn2 = transform.Find("RSParticlesRespawn2").GetComponent<ParticleSystem>();
        _emitterRespawn3 = transform.Find("RSParticlesRespawn3").GetComponent<ParticleSystem>();

        _respawnLight = transform.Find("RSSpotlight").GetComponent<Light>();

        CurrentState = RespawnState.Inactive;

        // Set up the looping RespawnActive but leave it switched off for now
        if (SFXPlayerActiveLoop)
        {
            audio.clip = SFXPlayerActiveLoop;
            audio.loop = true;
            audio.playOnAwake = false;
        }

        // Assign the respawn point to be this one - Since the player is positioned on top of a respawn point,
        // it will come in and overwrite it, this is just to make sure there is always one active
        if (InitalRespawn != null)
            CurrentRespawn = InitalRespawn;
        if (CurrentRespawn == this)
            SetActive();
    }