public override void Update()
{
base.Update ();
if (InventoryReady==false)
{
if (!LevelSerializer.IsDeserializing)
{
if ((playerInventory!=null))
{
if (playerInventory.GetCurrentContainer()!=null)
{
playerInventory.Refresh();
InventoryReady=true;
}
}
}
}
if ((WindowDetectUW.WaitingForInput==true) && (Instrument.PlayingInstrument==false))//TODO:Make this cleaner!!
{//TODO: This should be in window detect
//UWHUD.instance.MessageScroll.gameObject.GetComponent<UIInput>().selected=true;
//UWHUD.instance.MessageScroll.gameObject.GetComponent<UIInput>().selected=true;
//UWHUD.instance.InputControl.selected=true;
UWHUD.instance.InputControl.Select();
}
if ((CurVIT<=0) && (mus.Death==false))
{
PlayerDeath();
return;
}
if(mus.Death==true)
{
//Still processing death.
return;
}
if (playerCam.enabled==true)
{
if (isSwimming==true)
{
playerCam.transform.localPosition=new Vector3(playerCam.transform.localPosition.x,-0.8f,playerCam.transform.localPosition.z);
swimSpeedMultiplier= Mathf.Max((float)(PlayerSkills.Swimming/30.0f),0.1f);
SwimTimer = SwimTimer += Time.deltaTime;
//Not sure of what UW does here but for the moment 45seconds of damage gree swimming then 15s per skill point
if (SwimTimer>=05.0f + PlayerSkills.Swimming*15.0f)
{
SwimDamageTimer+=Time.deltaTime;
if (SwimDamageTimer>=10.0f)//Take Damage every 10 seconds.
{
ApplyDamage (1);
SwimDamageTimer=0.0f;
}
}
else
{
SwimDamageTimer=0.0f;
}
}
else
{
playerCam.transform.localPosition=new Vector3(playerCam.transform.localPosition.x,0.9198418f,playerCam.transform.localPosition.z);
swimSpeedMultiplier=1.0f;
SwimTimer=0.0f;
}
}
playerMotor.enabled=((!Paralyzed) && (!GameWorldController.instance.AtMainMenu) && (!Conversation.InConversation));
if (isFlying)
{//Flying spell
playerMotor.movement.maxFallSpeed=0.0f;
playerMotor.movement.maxForwardSpeed=flySpeed*speedMultiplier;
if (((Input.GetKeyDown(KeyCode.R)) || (Input.GetKey(KeyCode.R))) && (WindowDetectUW.WaitingForInput==false))
{//Fly up
this.GetComponent<CharacterController>().Move(new Vector3(0,0.2f * Time.deltaTime,0));
}
else if (((Input.GetKeyDown(KeyCode.V)) || (Input.GetKey(KeyCode.V))) && (WindowDetectUW.WaitingForInput==false))
{//Fly down
this.GetComponent<CharacterController>().Move(new Vector3(0,-0.2f * Time.deltaTime,0));
}
}
else
{
if (isFloating)
{
playerMotor.movement.maxFallSpeed=0.1f;//Default
}
else
{
playerMotor.movement.maxFallSpeed=20.0f;//Default
playerMotor.movement.maxForwardSpeed=walkSpeed*speedMultiplier*swimSpeedMultiplier;
}
}
if (isLeaping)
{//Jump spell
playerMotor.jumping.baseHeight=1.2f;
}
else
{
playerMotor.jumping.baseHeight=0.6f;
}
if (isRoaming)
{
playerMotor.movement.maxFallSpeed=0.0f;
}
mus.WeaponDrawn=(InteractionMode==UWCharacter.InteractionModeAttack);
if (PlayerMagic.ReadiedSpell!="")
{//Player has a spell thats about to be cast. All other activity is ignored.
SpellMode ();
return;
}
if (UWHUD.instance.window.JustClicked==false)
{
if(Paralyzed==false)
{
PlayerCombat.PlayerCombatIdle();
}
}
if (TileMap.OnLava==true)
{
if(!FireProof)
{
lavaDamageTimer+=Time.deltaTime;
if (lavaDamageTimer>=1.0f)//Take Damage every 1 second.
{
ApplyDamage (10);
lavaDamageTimer=0.0f;
}
}
}
else
{
lavaDamageTimer=0;
}
//Calculate how visible the player is.
if (LightActive)//The player has a light and is therefore visible at max range.
{
DetectionRange=BaseDetectionRange;
}
else
{//=MinRange+( (MaxRange-MinRange) * ((30-B4)/30))
DetectionRange= MinDetectionRange+ ( ( BaseDetectionRange-MinDetectionRange) * ((30.0f - (GetBaseStealthLevel()+StealthLevel))/30.0f));
}
}