/// <summary> /// Initialization logic which is execute only one time for this Entity (unless the Entity is pooled). /// This method is called when the Entity is added to managers. Entities which are instantiated but not /// added to managers will not have this method called. /// </summary> private void CustomInitialize() { #if DEBUG if (DebugVariables.ShowDebugShapes) { AxisAlignedRectangleInstance.Visible = true; RangeCircleInstance.Visible = true; MinimumRangeCircleInstance.Visible = true; } else #endif { AxisAlignedRectangleInstance.Visible = false; RangeCircleInstance.Visible = false; MinimumRangeCircleInstance.Visible = false; } CurrentOnOffState = OnOff.On; _spriteRelativeY = SpriteInstance.Height / 3; ProjectileAltitude = PivotPoint.RelativeY; SpriteInstance.RelativeY = _spriteRelativeY; AimSpriteInstance.RelativeY += _spriteRelativeY; PivotPoint.RelativeY += _spriteRelativeY; var yOffset = AimSpriteInstance.RelativeY - PivotPoint.RelativeY; var xOffset = AimSpriteInstance.RelativeX - PivotPoint.RelativeX; AimSpriteInstance.AttachTo(PivotPoint, true); AimSpriteInstance.RelativeRotationZ = MathHelper.ToRadians(90); AimSpriteInstance.RelativeY = yOffset; AimSpriteInstance.RelativeX = xOffset; PivotPoint.RelativeY -= yOffset; PivotPoint.RelativeX -= xOffset; AimSpriteInstance.ParentRotationChangesPosition = false; LightAimSpriteInstance.AttachTo(AimSpriteInstance); RangePreviewSprite.RelativeX = PivotPoint.RelativeX; RangePreviewSprite.RelativeY = SpriteInstance.RelativeY; RefreshRangePreviewTexture(); RangeCircleInstance.Visible = true; LastFiredTime = TimeManager.CurrentTime; AfterIsBeingPlacedSet += (not, used) => { RangeCircleInstance.Visible = false; }; SetUpgradeStatus(); }
public override void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; base.PostInitialize(); if (SpriteInstance.Parent == null) { SpriteInstance.CopyAbsoluteToRelative(); SpriteInstance.AttachTo(this, false); } base.SpriteInstance.Texture = AllParticles; base.SpriteInstance.LeftTexturePixel = 1949f; base.SpriteInstance.RightTexturePixel = 2037f; base.SpriteInstance.TopTexturePixel = 1724f; base.SpriteInstance.BottomTexturePixel = 1825f; base.SpriteInstance.TextureScale = 1f; base.SpriteInstance.UseAnimationRelativePosition = false; base.SpriteInstance.AnimationChains = BaseStructureAnimationChainListFile; base.SpriteInstance.CurrentChainName = "BombardingTower"; if (mAxisAlignedRectangleInstance.Parent == null) { mAxisAlignedRectangleInstance.CopyAbsoluteToRelative(); mAxisAlignedRectangleInstance.AttachTo(this, false); } base.AxisAlignedRectangleInstance.Width = 64f; base.AxisAlignedRectangleInstance.Height = 64f; if (LightSpriteInstance.Parent == null) { LightSpriteInstance.CopyAbsoluteToRelative(); LightSpriteInstance.AttachTo(this, false); } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.X = 0f; } else { base.LightSpriteInstance.RelativeX = 0f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Y = 30f; } else { base.LightSpriteInstance.RelativeY = 30f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Z = -1f; } else { base.LightSpriteInstance.RelativeZ = -1f; } base.LightSpriteInstance.LeftTexturePixel = 1792f; base.LightSpriteInstance.RightTexturePixel = 2048f; base.LightSpriteInstance.TopTexturePixel = 1792f; base.LightSpriteInstance.BottomTexturePixel = 2048f; base.LightSpriteInstance.TextureScale = 1f; #if FRB_MDX LightSpriteInstance.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Modulate; #else base.LightSpriteInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Modulate; #endif base.LightSpriteInstance.Blue = 0.5f; base.LightSpriteInstance.Alpha = 0.25f; if (AimSpriteInstance.Parent == null) { AimSpriteInstance.CopyAbsoluteToRelative(); AimSpriteInstance.AttachTo(this, false); } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.X = 0f; } else { base.AimSpriteInstance.RelativeX = 0f; } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.Y = 78f; } else { base.AimSpriteInstance.RelativeY = 78f; } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.Z = 1f; } else { base.AimSpriteInstance.RelativeZ = 1f; } base.AimSpriteInstance.Texture = AllParticles; base.AimSpriteInstance.LeftTexturePixel = 1939f; base.AimSpriteInstance.RightTexturePixel = 1986f; base.AimSpriteInstance.TopTexturePixel = 1846f; base.AimSpriteInstance.BottomTexturePixel = 2002f; base.AimSpriteInstance.TextureScale = 1f; if (PivotPoint.Parent == null) { PivotPoint.CopyAbsoluteToRelative(); PivotPoint.AttachTo(this, false); } if (PivotPoint.Parent == null) { base.PivotPoint.Y = 30f; } else { base.PivotPoint.RelativeY = 30f; } if (LightAimSpriteInstance.Parent == null) { LightAimSpriteInstance.CopyAbsoluteToRelative(); LightAimSpriteInstance.AttachTo(this, false); } if (LightAimSpriteInstance.Parent == null) { base.LightAimSpriteInstance.Y = 120f; } else { base.LightAimSpriteInstance.RelativeY = 120f; } base.LightAimSpriteInstance.Texture = AllParticles; base.LightAimSpriteInstance.LeftTexturePixel = 1060f; base.LightAimSpriteInstance.RightTexturePixel = 1122f; base.LightAimSpriteInstance.TopTexturePixel = 1269f; base.LightAimSpriteInstance.BottomTexturePixel = 1339f; base.LightAimSpriteInstance.TextureScale = 1f; base.LightAimSpriteInstance.Width = 91f; base.LightAimSpriteInstance.Height = 70f; base.LightAimSpriteInstance.Visible = true; #if FRB_MDX LightAimSpriteInstance.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Modulate; #else base.LightAimSpriteInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Modulate; #endif base.LightAimSpriteInstance.Red = 0.5f; base.LightAimSpriteInstance.Green = 0.23f; base.LightAimSpriteInstance.BlendOperation = FlatRedBall.Graphics.BlendOperation.Add; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
public override void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; base.PostInitialize(); if (SpriteInstance.Parent == null) { SpriteInstance.CopyAbsoluteToRelative(); SpriteInstance.AttachTo(this, false); } base.SpriteInstance.Texture = AllParticles; base.SpriteInstance.LeftTexturePixel = 1617f; base.SpriteInstance.RightTexturePixel = 1694f; base.SpriteInstance.TopTexturePixel = 1948f; base.SpriteInstance.BottomTexturePixel = 2031f; base.SpriteInstance.TextureScale = 1f; base.SpriteInstance.AnimationChains = BaseStructureAnimationChainListFile; base.SpriteInstance.CurrentChainName = "PiercingTower"; if (mAxisAlignedRectangleInstance.Parent == null) { mAxisAlignedRectangleInstance.CopyAbsoluteToRelative(); mAxisAlignedRectangleInstance.AttachTo(this, false); } base.AxisAlignedRectangleInstance.Width = 64f; base.AxisAlignedRectangleInstance.Height = 64f; if (LightSpriteInstance.Parent == null) { LightSpriteInstance.CopyAbsoluteToRelative(); LightSpriteInstance.AttachTo(this, false); } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.X = -2.5f; } else { base.LightSpriteInstance.RelativeX = -2.5f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Y = 36f; } else { base.LightSpriteInstance.RelativeY = 36f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Z = -1f; } else { base.LightSpriteInstance.RelativeZ = -1f; } base.LightSpriteInstance.Texture = AllParticles; base.LightSpriteInstance.LeftTexturePixel = 1792f; base.LightSpriteInstance.RightTexturePixel = 2048f; base.LightSpriteInstance.TopTexturePixel = 1792f; base.LightSpriteInstance.BottomTexturePixel = 2048f; base.LightSpriteInstance.TextureScale = 1f; base.LightSpriteInstance.Width = 1f; base.LightSpriteInstance.Height = 1f; #if FRB_MDX LightSpriteInstance.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Modulate; #else base.LightSpriteInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Modulate; #endif base.LightSpriteInstance.Blue = 0.5f; base.LightSpriteInstance.Alpha = 0.25f; if (AimSpriteInstance.Parent == null) { AimSpriteInstance.CopyAbsoluteToRelative(); AimSpriteInstance.AttachTo(this, false); } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.X = 2f; } else { base.AimSpriteInstance.RelativeX = 2f; } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.Y = 46.11102f; } else { base.AimSpriteInstance.RelativeY = 46.11102f; } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.Z = 0.1f; } else { base.AimSpriteInstance.RelativeZ = 0.1f; } base.AimSpriteInstance.Texture = AllParticles; base.AimSpriteInstance.LeftTexturePixel = 1598f; base.AimSpriteInstance.RightTexturePixel = 1782f; base.AimSpriteInstance.TopTexturePixel = 1827f; base.AimSpriteInstance.BottomTexturePixel = 1946f; base.AimSpriteInstance.TextureScale = 1f; if (ArrowSpriteInstance.Parent == null) { ArrowSpriteInstance.CopyAbsoluteToRelative(); ArrowSpriteInstance.AttachTo(this, false); } if (ArrowSpriteInstance.Parent == null) { ArrowSpriteInstance.X = 1f; } else { ArrowSpriteInstance.RelativeX = 1f; } if (ArrowSpriteInstance.Parent == null) { ArrowSpriteInstance.Y = 57.24112f; } else { ArrowSpriteInstance.RelativeY = 57.24112f; } if (ArrowSpriteInstance.Parent == null) { ArrowSpriteInstance.Z = 0f; } else { ArrowSpriteInstance.RelativeZ = 0f; } ArrowSpriteInstance.Texture = AllParticles; ArrowSpriteInstance.LeftTexturePixel = 2019f; ArrowSpriteInstance.RightTexturePixel = 2034f; ArrowSpriteInstance.TopTexturePixel = 1571f; ArrowSpriteInstance.BottomTexturePixel = 1712f; ArrowSpriteInstance.TextureScale = 1f; if (PivotPoint.Parent == null) { PivotPoint.CopyAbsoluteToRelative(); PivotPoint.AttachTo(this, false); } if (PivotPoint.Parent == null) { base.PivotPoint.X = -2.5f; } else { base.PivotPoint.RelativeX = -2.5f; } if (PivotPoint.Parent == null) { base.PivotPoint.Y = 36f; } else { base.PivotPoint.RelativeY = 36f; } if (LightAimSpriteInstance.Parent == null) { LightAimSpriteInstance.CopyAbsoluteToRelative(); LightAimSpriteInstance.AttachTo(this, false); } base.LightAimSpriteInstance.Texture = AllParticles; base.LightAimSpriteInstance.TextureScale = 1f; base.LightAimSpriteInstance.AnimationChains = StructureGlowAnimationChainList; base.LightAimSpriteInstance.Visible = false; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
public override void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; base.PostInitialize(); if (SpriteInstance.Parent == null) { SpriteInstance.CopyAbsoluteToRelative(); SpriteInstance.AttachTo(this, false); } base.SpriteInstance.Texture = AllParticles; base.SpriteInstance.LeftTexturePixel = 1622f; base.SpriteInstance.RightTexturePixel = 1746f; base.SpriteInstance.TopTexturePixel = 1568f; base.SpriteInstance.BottomTexturePixel = 1789f; base.SpriteInstance.TextureScale = 1f; base.SpriteInstance.AnimationChains = BaseStructureAnimationChainListFile; base.SpriteInstance.CurrentChainName = "ElectricTower"; if (mAxisAlignedRectangleInstance.Parent == null) { mAxisAlignedRectangleInstance.CopyAbsoluteToRelative(); mAxisAlignedRectangleInstance.AttachTo(this, false); } base.AxisAlignedRectangleInstance.Width = 64f; base.AxisAlignedRectangleInstance.Height = 64f; if (LightSpriteInstance.Parent == null) { LightSpriteInstance.CopyAbsoluteToRelative(); LightSpriteInstance.AttachTo(this, false); } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.X = 15f; } else { base.LightSpriteInstance.RelativeX = 15f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Y = 95f; } else { base.LightSpriteInstance.RelativeY = 95f; } if (LightSpriteInstance.Parent == null) { base.LightSpriteInstance.Z = -1f; } else { base.LightSpriteInstance.RelativeZ = -1f; } base.LightSpriteInstance.LeftTexturePixel = 1792f; base.LightSpriteInstance.RightTexturePixel = 2048f; base.LightSpriteInstance.TopTexturePixel = 1792f; base.LightSpriteInstance.BottomTexturePixel = 2048f; base.LightSpriteInstance.TextureScale = 1f; base.LightSpriteInstance.Width = 1f; base.LightSpriteInstance.Height = 1f; base.LightSpriteInstance.AnimationChains = StructureGlowAnimationChainList; base.LightSpriteInstance.CurrentChainName = "ElectricGlow"; #if FRB_MDX LightSpriteInstance.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Modulate; #else base.LightSpriteInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Modulate; #endif base.LightSpriteInstance.Blue = 0.5f; base.LightSpriteInstance.Alpha = 0.5f; if (AimSpriteInstance.Parent == null) { AimSpriteInstance.CopyAbsoluteToRelative(); AimSpriteInstance.AttachTo(this, false); } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.X = 16.07512f; } else { base.AimSpriteInstance.RelativeX = 16.07512f; } if (AimSpriteInstance.Parent == null) { base.AimSpriteInstance.Y = 97.46671f; } else { base.AimSpriteInstance.RelativeY = 97.46671f; } base.AimSpriteInstance.Texture = AllParticles; base.AimSpriteInstance.LeftTexturePixel = 1635f; base.AimSpriteInstance.RightTexturePixel = 1636f; base.AimSpriteInstance.TopTexturePixel = 1579f; base.AimSpriteInstance.BottomTexturePixel = 1580f; base.AimSpriteInstance.TextureScale = 1f; if (PivotPoint.Parent == null) { PivotPoint.CopyAbsoluteToRelative(); PivotPoint.AttachTo(this, false); } if (PivotPoint.Parent == null) { base.PivotPoint.X = 15f; } else { base.PivotPoint.RelativeX = 15f; } if (PivotPoint.Parent == null) { base.PivotPoint.Y = 95f; } else { base.PivotPoint.RelativeY = 95f; } if (LightAimSpriteInstance.Parent == null) { LightAimSpriteInstance.CopyAbsoluteToRelative(); LightAimSpriteInstance.AttachTo(this, false); } base.LightAimSpriteInstance.Texture = AllParticles; base.LightAimSpriteInstance.LeftTexturePixel = 0f; base.LightAimSpriteInstance.RightTexturePixel = 1f; base.LightAimSpriteInstance.TopTexturePixel = 0f; base.LightAimSpriteInstance.BottomTexturePixel = 1f; base.LightAimSpriteInstance.TextureScale = 1f; base.LightAimSpriteInstance.UseAnimationRelativePosition = false; base.LightAimSpriteInstance.Animate = false; base.LightAimSpriteInstance.Visible = false; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }