void ScheduleRespawn() { _time = Time.time + Random.Range(1f, 5f); renderer.enabled = true; _state = RespawnState.Spawning; }
// 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(); } }
//############################################################################################## // Setup the player, and collect the different components that will get used. //############################################################################################## void Start() { player = this; respawnState = RespawnState.Alive; // Hide the cursor and lock it to screen Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; // Try to target 60 Application.targetFrameRate = 60; movementEnabled = true; lookingEnabled = true; gun = GetComponent <GunComponent>(); character = GetComponent <CharacterController>(); damage = GetComponent <DamageableComponent>(); damage.RegisterOnDamagedDelegate(OnDamaged); damage.RegisterOnKilledDelegate(OnKilled); respawnTimer = new Timer(respawnTime); shakeDecayTimer = new Timer(SHAKE_DECAY_TIME); safeTimer = new Timer(SAFE_TIME); recoilDecayTimer = new Timer(); jumpTimer = new Timer(jumpTime); sideJumpCooldownTimer = new Timer(SIDE_JUMP_COOLDOWN_TIME); }
void ScheduleRespawn() { _time = Time.time + Random.Range(1f, 5f); renderer.enabled = true; _state = RespawnState.Spawning; }
void Awake() { m_roundStart = true; m_renableCollisions = true; movementStates = gameObject.AddComponent <StateManager>(); driftState = gameObject.AddComponent <PlayerDriftState>(); jumpState = gameObject.AddComponent <PlayerJumpState>(); onPlanetState = gameObject.AddComponent <PlayerOnPlanetState>(); boostChargeState = gameObject.AddComponent <PlayerBoostChargeState>(); boostActiveState = gameObject.AddComponent <PlayerBoostActiveState>(); bigHitState = gameObject.AddComponent <PLayerBigHitState>(); respawnState = gameObject.AddComponent <RespawnState>(); }
void SpawnEnemy() { if (prefab != null) { _enemy = (GameObject) Instantiate(prefab); _enemy.transform.position = transform.position; _time = 0f; } _state = RespawnState.Idle; _time = 0f; renderer.enabled = false; }
void SpawnEnemy() { if (prefab != null) { _enemy = (GameObject)Instantiate(prefab); _enemy.transform.position = transform.position; _time = 0f; } _state = RespawnState.Idle; _time = 0f; renderer.enabled = false; }
//############################################################################################## // On killed, disable features and set state. //############################################################################################## public void OnKilled(DamageableComponent damage) { respawnState = RespawnState.Dying; respawnTimer.Start(); // Stop movement velocity = Vector3.zero; character.enabled = false; movementEnabled = false; lookingEnabled = false; // Log this for debugging and data Logger.Info("=== PLAYER DEATH === at position " + transform.position + " from " + damage.GetDamager()); }
public Bullet(Logic m, Unit owner) { _logic = m; Owner = owner; Speed = owner.Gun.BulletSpeed; MoveState moveState = new MoveState(this); RespawnState respawningState = new RespawnState(this, this, moveState); ExplodeState explodeState = new ExplodeState(this, this, _logic); MovingDirection = Owner.Gun.WeaponOpinion; CurrentPos = Owner.Gun.GunPos; CurrentPos = CurrentPos.Addition(MovingDirection.Multiplication(Speed * 4)); moveState.transitions.Add(5, explodeState); State = respawningState; State.Direct = Direction.Right; }
public RespawnResponse(RespawnState state, long time = 0L) { State = state; Time = time; }
private void RevSpawner() { _state = RespawnState.Revving; _time = Time.time + Random.Range(5f, 10f); }
// 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(); }
//############################################################################################## // Either fade out if dead, or teleport then fade in if respawning. //############################################################################################## void UpdateRespawn() { if (respawnState == RespawnState.Dying || respawnState == RespawnState.Respawning) { float t = respawnTimer.Parameterized(); if (fade != null) { if (respawnState == RespawnState.Dying) { fade.color = new Color(0.0f, 0.0f, 0.0f, t); } else { fade.color = new Color(0.0f, 0.0f, 0.0f, 1.0f - t); } } if (respawnTimer.Finished()) { if (respawnState == RespawnState.Dying) { respawnTimer.Start(); respawnState = RespawnState.Respawning; velocity = Vector3.zero; // Uncomment this to save on player respawn // SaveLoadManagerComponent.Instance().Save(); PlayerRespawnVolumeComponent currentRespawn = PlayerRespawnVolumeComponent.GetCurrentRespawn(); if (currentRespawn) { transform.position = currentRespawn.respawnPosition.transform.position; playerCamera.transform.localRotation = currentRespawn.transform.rotation; playerInputLookRotation = currentRespawn.transform.rotation; } else { // In case there's no respawn point, teleport the player up a bunch. transform.position = new Vector3(0.0f, transform.position.y + PLAYER_RESPAWN_HEIGHT_OFFSET, 0.0f); playerCamera.transform.localRotation = Quaternion.identity; playerInputLookRotation = Quaternion.identity; } transform.rotation = Quaternion.identity; // This is not ideal, but since CharacterController requires being grounded to set // velocity - something that can't be guaranteed on death - We have to destroy and // recreate the component to trigger a re-initialize, which zeroes out the velocity. Vector3 c_center = character.center; float c_height = character.height; float c_minMoveDistance = character.minMoveDistance; float c_radius = character.radius; float c_skinWidth = character.skinWidth; float c_slopeLimit = character.slopeLimit; float c_stepOffset = character.stepOffset; // Unity doesn't allow two of this component at once DestroyImmediate(character); character = gameObject.AddComponent <CharacterController>(); character.center = c_center; character.height = c_height; character.minMoveDistance = c_minMoveDistance; character.radius = c_radius; character.skinWidth = c_skinWidth; character.slopeLimit = c_slopeLimit; character.stepOffset = c_stepOffset; character.enabled = true; movementEnabled = true; lookingEnabled = true; damage.Respawn(); } else { respawnState = RespawnState.Alive; } } } }
private void RevSpawner() { _state = RespawnState.Revving; _time = Time.time + Random.Range(5f, 10f); }