public Ball(BallTypes ballType, Vector2 startPosition, float radius = 20.0f, float mass = 1.0f, bool applyGravity = false, int ballSegments = 36) { BallType = ballType; Center = startPosition; Radius = radius; Mass = mass; ApplyGravity = applyGravity; this.ballSegments = ballSegments; ballsToIgnoreOnCurrentCollision = new List <Ball>(); }
public void Buy(BallTypes bt) { if (!CanBuy(bt)) { return; } int price = balls[bt].price; data.money -= price; data.unlockedBalls.Add(bt); data.currentBall = bt; SendDataChangedEvent(); Save(); }
public bool CanBuy(BallTypes bt) { if (IsUnlocked(bt)) { return(false); } Ball b = balls[bt]; if (data.money >= b.price) { return(true); } return(false); }
public PlayerItems() { money = 0; abilityLevels = new Dictionary <AbilityTypes, int> { { AbilityTypes.Null1, 1 }, { AbilityTypes.Null2, 1 }, { AbilityTypes.SlowDown, 0 }, { AbilityTypes.Freeze, 0 }, { AbilityTypes.Shield, 0 }, { AbilityTypes.DoubleMoney, 0 }, { AbilityTypes.DoubleScore, 0 }, { AbilityTypes.ExtraLife, 0 }, { AbilityTypes.Multiball, 0 }, { AbilityTypes.Bomb, 0 } }; //level=0 means that it hasn't been bought in the store yet unlockedBricks = new List <BrickTypes> { BrickTypes.Normal1, BrickTypes.Normal2 }; unlockedPaddles = new List <PaddleTypes> { PaddleTypes.Green }; currentPaddle = PaddleTypes.Green; unlockedBalls = new List <BallTypes> { BallTypes.White }; currentBall = BallTypes.White; unlockedBackgroundImages = new List <BackgroundImageTypes> { BackgroundImageTypes.Grey }; currentBackground = new Background(BackgroundImageTypes.Grey, BackgroundCircleTypes.SkyBlueEmpty); unlockedBackgrounds = new List <Background>() { currentBackground }; }
public static Ball CreateBall(RenderWindow rw, BallTypes type) { Ball b = new Ball(); float radius = 15; switch (type) { case BallTypes.Normal: b.Velocity = 5.0f; b.MoveVector = new Vector2f(-1, 0); b.BallObject = new CircleShape(radius); b.BallObject.Origin = new Vector2f(b.BallObject.Radius, b.BallObject.Radius); b.BallObject.Position = new Vector2f(rw.GetView().Size.X / 2, rw.GetView().Size.Y / 2); b.StatingPosition = b.BallObject.Position; break; } return(b); }
// Use this for initialization void Start() { Debug.Log("In box start"); // ballImage = gameObject.GetComponent (SpriteRenderer); int[] ballValues = { 0, 1, 2, 3 }; int selectedBall = ballValues [Random.Range(0, ballValues.Length)]; if (selectedBall == 0) { ballType = BallTypes.Yellow; Debug.Log("In yellow"); GetComponent <SpriteRenderer>().color = Color.yellow; gameObject.tag = "Yellow"; // ballImage.color = Color.green; // new Color (248f,251f,30f,255f); } else if (selectedBall == 1) { ballType = BallTypes.Green; Debug.Log("In green"); // GetComponent<SpriteRenderer>().color = new Color (97f,184f,81f,255f); GetComponent <SpriteRenderer>().color = Color.green; gameObject.tag = "Green"; // ballImage.color = new Color (97f,184f,81f,255f); } else if (selectedBall == 2) { ballType = BallTypes.Blue; Debug.Log("In blue"); GetComponent <SpriteRenderer>().color = Color.cyan; gameObject.tag = "Blue"; // ballImage.color = new Color (8f,195f,255f,255f); } else if (selectedBall == 3) { ballType = BallTypes.Red; Debug.Log("In red"); GetComponent <SpriteRenderer>().color = Color.red; gameObject.tag = "Red"; // ballImage.color = new Color (255f,9f,45f,255f); } }
public static BallData ChangeBallType(BallData ball, BallTypes type) { BallData new_ball = null; switch (type) { case BallTypes.simple: new_ball = CreateBall(typeof(SimpleBallData), ball.notes); break; case BallTypes.bounce: new_ball = CreateBall(typeof(BounceBallData), ball.notes); break; default: Debug.LogError("That ball type has not been created yet."); break; } return(new_ball); }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ public virtual void Initialize(Game game, BallData data, BallDropper dropper) { // REFERENCES this.ballData = data; this.dropper = dropper; this.song = game.songController; // COMPONENTS ball_collider = GetComponent <SphereCollider>(); ball_render = transform.Find("Render").gameObject; // DATA this.type = data.type; this.options = data.options; // APPEARANCE this.id = dropper.currentBallIndex; this.name = id.ToString() + "_" + type.ToString(); gameObject.layer = LayerMask.NameToLayer("Balls"); size = dropper.GetSize(); SetSize(); // NOTES this.notes = data.notes; currentNote = 0; numNotes = notes.Count; catchTimesBeats = new float[numNotes + 1]; // POSITION SetAxisVectors(); transform.position = GetNotePosition(currentNote); // START IN IDLE STATE SetState(new IdleState(this)); // TRIGGER SPAWN EVENT if (onBallSpawn != null) { onBallSpawn(this); } }
public bool IsUnlocked(BallTypes bt) { return(data.unlockedBalls.Contains(bt)); }
public void SetActive(BallTypes bt) { data.currentBall = bt; SendDataChangedEvent(); Save(); }
public bool IsActive(BallTypes bt) { return(data.currentBall == bt); }
void DrawBallDataList(Color color) { ballList = game.GetBallData(); GUIStyle s = new GUIStyle(GUI.skin.button); GUIStyle b = new GUIStyle(GUI.skin.button); s.alignment = TextAnchor.MiddleLeft; b.alignment = TextAnchor.MiddleCenter; var w = GUILayout.Width(100); var line_h = GUILayout.Height(20); float yPos = 0; List <BallLabel> labels = new List <BallLabel>(); newBalls.Clear(); deleteBalls.Clear(); typeChangeBalls.Clear(); //Ball Field foreach (BallData ball in ballList) { BallLabel ballLabel = new BallLabel(ball, yPos); if (isLabelVisible(ballLabel)) { DrawUILine(dividerLineColor); EditorGUILayout.BeginHorizontal(); yPos += ballLabel.height; //________Create New Ball___________________ ResetColor(); ChangeColor(Color.green); if (GUILayout.Button("+", b, GUILayout.Width(25), line_h)) { newBalls.Add(ball, ballList.IndexOf(ball)); } ResetColor(); //________Delete Ball___________________ ChangeColor(Color.red); if (GUILayout.Button("-", b, GUILayout.Width(25), line_h)) { deleteBalls.Add(ball); } ResetColor(); //________Refresh Ball___________________ ChangeColor(Color.yellow); if (GUILayout.Button("R", b, GUILayout.Width(25), line_h)) { //SongData.DeleteBall(ball); BallData repairedBall; if (ball.GetType() == typeof(SimpleBallData)) { repairedBall = SongEdit.CreateBall(typeof(SimpleBallData), ball.notes); } else { Debug.Log("its a bounce ball"); repairedBall = SongEdit.CreateBall(typeof(BounceBallData), ball.notes); } ballList.Add(repairedBall); SongEdit.DeleteBallAndNotes(ball); ballList.Remove(ball); game.SortBalls(); } ResetColor(); //________Ball Type___________________ GUILayout.Label("type:", GUILayout.Width(40), line_h); BallTypes ball_type = (BallTypes)EditorGUILayout.EnumPopup("", ball.type, s, w); if (ball_type != ball.type) { ball.type = ball_type; // if new type selected, set equal to type typeChangeBalls.Add(ball, ballList.IndexOf(ball)); EditorUtility.SetDirty(ball); } //________Enabled / Disabled Field___________________ //ball.enabled = GUILayout.Toggle(ball.enabled, "Enabled", s, w); if (Application.isPlaying) { float timeDiff = ball.notes[0].hitBeat - songController.GetSongTimeBeats(); if (Mathf.Abs(timeDiff) < 4.0f && timeDiff > 0.0f) { ChangeColor(Color.cyan); } else if (Mathf.Abs(timeDiff) < 2.0f) { ChangeColor(Color.yellow); } EditorGUILayout.ObjectField(ball, typeof(Object), true); ResetColor(); } EditorGUILayout.EndHorizontal(); DrawOptions(ball); if (ball.notes != null) { int numNotes = DrawNotes(ball); } } else { GUILayout.Space(60); yPos += 60; } } // --------- END BALL ITERATION -------------------------- foreach (KeyValuePair <BallData, int> pair in newBalls) { BallData new_ball = SongEdit.CreateBall(typeof(SimpleBallData)); ballList.Insert(pair.Value + 1, new_ball); } foreach (BallData ball in deleteBalls) { SongEdit.DeleteBallAndNotes(ball); ballList.Remove(ball); } foreach (KeyValuePair <BallData, int> pair in typeChangeBalls) { BallData ball = pair.Key; BallData new_ball = SongEdit.ChangeBallType(ball, ball.type); // create new ball and copy info ballList.Insert(pair.Value, new_ball); SongEdit.DeleteBallAndNotes(ball); ballList.Remove(ball); } }
public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight, BallGroupTypes ballGroupType) : this(ballType, cueBallGameType, weight) { BallGroupType = ballGroupType; }
public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight) : this(ballType) { CueBallGameType = cueBallGameType; Weight = weight; }
public Ball(BallTypes ballType) { BallType = ballType; }
public bool Is(BallTypes other) { return(this.BallType == other); }