public void Update(GameTime gameTime)
{
PlayerBase.Update(gameTime);
if (IsDead)
{
if (UnitCollection.Destroy(PlayerNum) && TowerCollection.DestroyAll(PlayerNum))
{
PlayerBase.Destroy();
Vector3 nv = new Vector3();
if (this.Type != PlayerType.AI)
{
nv.X = avatar.Position.X;
nv.Y = avatar.Position.Y + 5;
nv.Z = avatar.Position.Z;
ProjectileManager.AddParticle(avatar.Position, nv);
}
PlayerCollection.SetPlayerInactive(PlayerNum);
}
return;
}
//HumanPlayer
if (Type == PlayerType.Human)
{
avatar.Update(gameTime);
if (avatarMoved)
{
avatarMoved = false;
avatarFollowingTile.Position = TileMap.GetTilePosFromPos(avatar.Position);
}
avatarFollowingTile.Update(gameTime);
}
else
{
if (PlayScreen.GameType == PlayerScreenType.Scenario)
{
aIDeployScenarioTotal += gameTime.ElapsedGameTime;
if (aIDeployScenarioTotal >= aIDeployScenario)
{
UnitCollection.Build(PlayerNum, TeamNum, UnitType.SpeedBoat);
UnitCollection.Build(PlayerNum, TeamNum, UnitType.SpeedBoat);
UnitCollection.Deploy(PlayerNum, TeamNum, TargetPlayerNum, UnitType.SpeedBoat);
aIDeployScenarioTotal = TimeSpan.Zero;
}
}
}
elapsedHighlightUpdateTime += gameTime.ElapsedGameTime.Milliseconds;
if (elapsedHighlightUpdateTime > maxHighlightUpdateTime)
{
elapsedHighlightUpdateTime = 0;
if (currentHighlightRotation + 1 >= maxHighlightRotations)
{
currentHighlightRotation = 0;
}
else
{
currentHighlightRotation++;
}
}
if (queuedUnits > 0)
{
elapsedUnitDeployTime += gameTime.ElapsedGameTime.Milliseconds;
if (elapsedUnitDeployTime >= maxUnitDeployTime)
{
elapsedUnitDeployTime = 0;
UnitCollection.Deploy(PlayerNum, TeamNum, TargetPlayerNum, unitInformation[queuedUnitType].type);
queuedUnits--;
unitsDeployed++;
}
//elapsedUnitMeterUpdateTime += gameTime.ElapsedGameTime.Milliseconds;
//if (elapsedUnitMeterUpdateTime >= maxUnitMeterUpdateDate)
//{
// elapsedUnitMeterUpdateTime = 0;
// unitMeterHightlightSource.Y += 2;
// if (unitMeterHightlightSource.Y >= unitMeterHighlightTexture.Height)
// unitMeterHightlightSource.Y = 0;
//}
}
else
{
queuedUnitsToDeploy = 0;
}
if (pickEnemyTargetPressed)
{
elapsedPlayerToAttackChange += gameTime.ElapsedGameTime.Milliseconds;
if (elapsedPlayerToAttackChange >= maxPlayerToAttackChange)
{
pickEnemyTargetPressed = false;
elapsedPlayerToAttackChange = 0;
}
}
if (enemyTargetOpacity.A > 0)
{
if (enemyTargetOpacity.A <= 4)
enemyTargetOpacity.A = 0;
else
enemyTargetOpacity.A -= 4;
}
}