public bool amIYourOwner(MachineComponent askingComponent) { if (this.owner == askingComponent) return true; else return false; }
protected int ticks_to_die; //Ticks that remain until Money "dies" #endregion Fields #region Constructors public Money(Vector2 center, float radius = 5f, float weight = 1f) : base(center, radius) { owner = null; this.mass = weight; this.state = BallState.Hidden; this.RotateAngle = XNACS1Base.RandomFloat(0, 360); this.lifetime = XNACS1Base.World.TicksInASecond * 10 + XNACS1Base.RandomInt(0, 200); // sometimes be a gold coin. int randomTexture = XNACS1Base.RandomInt(1, 100); if (randomTexture > 90) this.Texture = "goldcoin"; else if( randomTexture > 35) this.Texture = "silvercoin"; else this.Texture = "coppercoin"; if (FinalGame.kelvinMode) this.Texture = "KelvinHead"; }
public void GetMoving() { this.AddToAutoDrawSet(); this.ShouldTravel = true; this.state = BallState.Moving; this.ticks_to_die = lifetime; this.owner = null; }
public void setNewOwner(MachineComponent newOwner) { this.state = BallState.BeingControlled; this.ShouldTravel = false; this.owner = newOwner; }
public void HandleSingleTap(Vector2 touchLocation) { this.currentSelected = null; touchLocation = HudBar.screenToWorld(touchLocation); // see if user touched a component. foreach (MachineComponent current in machineComponentList) { if (current != null) { if (current.selected(touchLocation)) { this.currentSelected = current; } } } }
public void AddComponent(MachineComponent newComponent) { machineComponentList.AddLast(newComponent); }
public ComponentType RemoveCurrentComponent() { ComponentType currentComponent = ComponentType.none; // user clicked remove button if ( this.currentSelected != null ) { // remove component from draw-set and list. //this.addMenu.ComponentRemovedFromStage(this.currentSelected.myComponentType()); currentComponent = currentSelected.myComponentType(); this.currentSelected.RemoveFromAutoDrawSet(); machineComponentList.Remove(this.currentSelected); } this.currentSelected = null; return currentComponent; }
public void ShowRemoveComponentMenu(MachineComponent current) { if (current != null) { this.currentState = InGameMenuState.removeComponentMenu; this.removeMenu.Show(current); } }
public void Show(MachineComponent current) { FinalGame.allowMovement = false; //FinalGame.isZoomed = false; // reset background and button positions. float screenWidth = XNACS1Base.World.WorldDimension.X; float screenHeight = XNACS1Base.World.WorldDimension.Y; Vector2 screenCenter = XNACS1Base.World.WorldDimension / 2 + XNACS1Base.World.WorldMin; this.background.Center = screenCenter; this.background.Width = screenWidth;// *0.8f; this.background.Height = screenHeight;// *0.8f; component = current; previousComponentCenter = current.Center; current.Center = screenCenter; float xOffset = 0; float yOffset = 0; #region Setup Remove Button xOffset = XNACS1Base.World.WorldMin.X + screenWidth * 0.5f; yOffset = XNACS1Base.World.WorldMin.Y + screenHeight * 0.8f; Vector2 buttonCenter = new Vector2(xOffset, yOffset); // + screenCenter this.remove.Center = buttonCenter; this.remove.Width = background.Width * 0.8f; this.remove.Height = background.Height * 0.1f; #endregion #region Setup Cancel Button yOffset = XNACS1Base.World.WorldMin.Y + screenHeight * 0.2f; buttonCenter = new Vector2(xOffset, yOffset); // + screenCenter this.cancel.Center = buttonCenter; this.cancel.Width = background.Width * 0.8f; this.cancel.Height = background.Height * 0.1f; #endregion #region Setup SpinLeft Button yOffset = XNACS1Base.World.WorldMin.Y + screenHeight * 0.5f; xOffset = XNACS1Base.World.WorldMin.X + screenWidth * 0.1f; buttonCenter = new Vector2(xOffset, yOffset); this.spinLeft.Center = buttonCenter; this.spinLeft.Width = background.Width * 0.2f; this.spinLeft.Height = background.Height * 0.2f; #endregion #region Setup SpinRight Button xOffset = XNACS1Base.World.WorldMin.X + screenWidth * 0.9f; buttonCenter = new Vector2(xOffset, yOffset); this.spinRight.Center = buttonCenter; this.spinRight.Width = background.Width * 0.2f; this.spinRight.Height = background.Height * 0.2f; #endregion #region Reset States this.cancelButtonState = false; this.cancel.Color = Color.White; this.removeButtonState = false; this.remove.Color = Color.White; this.spinLeftButtonState = false; this.spinLeft.Color = Color.White; this.spinRightButtonState = false; this.spinRight.Color = Color.White; this.background.Visible = this.remove.Visible = this.cancel.Visible = this.spinLeft.Visible = this.spinRight.Visible = true; #endregion #region Draw Buttons this.background.AddToAutoDrawSet(); this.remove.AddToAutoDrawSet(); this.cancel.AddToAutoDrawSet(); this.spinLeft.AddToAutoDrawSet(); this.spinRight.AddToAutoDrawSet(); this.background.TopOfAutoDrawSet(); this.remove.TopOfAutoDrawSet(); this.cancel.TopOfAutoDrawSet(); this.spinLeft.TopOfAutoDrawSet(); this.spinRight.TopOfAutoDrawSet(); current.TopOfAutoDrawSet(); #endregion }