Esempio n. 1
0
 public void DamagePlayer(int damage)
 {
     current_health -= damage;
     if (current_health > 0)
     {
         health_bar.fillAmount = (float)current_health / (float)max_health;
         if (!currently_visible)
         {
             player.StartCoroutine(PeriodicallyShowHealthBar(SHOW_HEALTH_BAR_TIMER));
         }
     }
     else
     {
         respawner.KillPlayer(transform.gameObject, PlayerAnimations.Stand, true);
     }
 }
Esempio n. 2
0
 private void CheckPlatformType(Transform platform)
 {
     if ((platform.tag == "Snow") && (current_movement_type != PlayerMovementType.Snow))
     {
         current_movement_type = PlayerMovementType.Snow;
         last_movement_speed   = movement_speed;
         extra_movement_speed  = 0;
         ResetMovements(false, true, true);
         animations.SetAnimation(PlayerAnimations.Stand);
     }
     else if ((platform.tag == "Ice") && (current_movement_type != PlayerMovementType.Ice))
     {
         current_movement_type = PlayerMovementType.Ice;
         last_movement_speed   = ice_movement_speed;
         ResetMovements(true, false, true);
         animations.SetAnimation(PlayerAnimations.Ice);
     }
     else if ((platform.tag == "Reverse") && (current_movement_type != PlayerMovementType.Reverse))
     {
         current_movement_type = PlayerMovementType.Reverse;
         last_movement_speed   = ice_movement_speed;
         ResetMovements(true, false, true);
         animations.SetAnimation(PlayerAnimations.Ice);
     }
     else if ((platform.tag == "Straight") && (current_movement_type != PlayerMovementType.Straight))
     {
         current_movement_type = PlayerMovementType.Straight;
         last_movement_speed   = ice_movement_speed;
         ResetMovements(true, false, true);
         animations.SetAnimation(PlayerAnimations.Ice);
     }
     else if (platform.tag == "Water")
     {
         current_movement_type = PlayerMovementType.None;
         extra_movement_speed  = 0;
         ResetMovements(false, true, true);
         respawner.KillPlayer(gameObject, PlayerAnimations.Stand, false);
         SpawnPool general_pool = PoolManager.Pools[CurrentLevel.GetGeneralPoolName()];
         general_pool.Spawn(water_effect, transform.position, new Quaternion(90, 0, 0, 0));
     }
 }
Esempio n. 3
0
 public void OnCollision(GameObject player_object, Collider collider, PlayerRotate rotate)
 {
     if (collider.gameObject.tag == "Monster")
     {
         respawner.KillPlayer(player_object, PlayerAnimations.Death, true);
     }
     else if ((collider.gameObject.tag == "Arrow") && (rotating_with_arrow == false))
     {
         Quaternion collider_rotation = collider.transform.rotation;
         collider_rotation.x  = 0;
         collider_rotation.y  = 0;
         arrow_rotation_angle = collider_rotation.eulerAngles.z;
         CalculateRotationAngle();
         rotating_with_arrow = true;
     }
     else if (collider.gameObject.tag == "Checkpoint")
     {
         Vector3 respawn_position;
         respawn_position = collider.transform.position;
         if (collider.transform.parent != null)
         {
             if (collider.transform.parent.tag == "Checkpoint")
             {
                 respawn_position = collider.transform.parent.position;
             }
         }
         respawn_position.y -= 1;
         respawner.SetRespawnPosition(respawn_position);
     }
     else if (collider.gameObject.tag == "Teleporter")
     {
         player_object.transform.position = collider.gameObject.transform.GetChild(DESTINATION_INDEX).position;
         rotate.StopRotating();
         //SpawnPool general_pool = PoolManager.Pools[CurrentLevel.GetGeneralPoolName()];
         //general_pool.Spawn(checkpoint_effect, collider.transform.position, new Quaternion(90, 0, 0, 0));
     }
     else if (collider.gameObject.tag == "Lever")
     {
         collider.gameObject.tag = "LeverTriggered";
         bool open_door = true;
         foreach (Transform children in collider.gameObject.transform.parent)
         {
             if (children.tag == "Lever")
             {
                 open_door = false;
             }
         }
         if (open_door)
         {
             collider.gameObject.transform.parent.tag = "DoorOpen";
         }
     }
     else if (collider.gameObject.tag == "SpeedUp")
     {
         player_object.GetComponent <Player>().ActivateSpeedBoost(true);
     }
     else if (collider.gameObject.tag == "SpeedDown")
     {
         player_object.GetComponent <Player>().ActivateSpeedBoost(false);
     }
 }