// Add a ball to the board, call from logic only! public void PlaceBall(BallData data) { if (this.ballTmp != null) { Destroy(this.ballTmp); this.ballTmp = null; } Debug.Log("add ball"); Debug.Log(data.stage); Debug.Log(data.x); Debug.Log(data.y); Vector3 ballPosition = GetSpot(data).transform.position; ballPosition += new Vector3(0, CELLSIZE / 2, 0); if (data.stage != 3) { ballPosition -= new Vector3(0, 0.3f, 0); } GameObject tmp = Instantiate(ballPrefab, ballPosition, Quaternion.identity); BallData d = tmp.GetComponent <BallData>(); d.x = data.x; d.y = data.y; d.stage = data.stage; d.player = game.ActualPlayer; if (d.player == 1) { tmp.GetComponent <MeshRenderer>().material.SetColor("_Color", new Color(210f / 255f, 105f / 255f, 30f / 255f, 255f / 255f)); } else { tmp.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.white); } HideConfirmationButton(); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); string json = File.ReadAllText(Application.dataPath + "/Resources/ball_path.json"); loadedData = JsonUtility.FromJson <BallData>(json); }
// What happens when we click the yes button private void OnYes() { HideCancelButton(); BallData d; if (this.ballToRemove != null) { // If we clicked on a red ball to remove d = this.ballToRemove.GetComponent <BallData>(); game.RemoveSquare(new Position(d.stage, d.x, d.y)); this.ballToRemove = null; } else if (this.ballToMove != null) { // If we clicked on a blue ball to move d = this.ballTmp.GetComponent <BallData>(); game.Jump( new Position(this.ballToMove.stage, this.ballToMove.x, this.ballToMove.y), new Position(d.stage, d.x, d.y)); this.ballToMove = null; } else { // If we clicked on a normal spot d = this.ballTmp.GetComponent <BallData>(); game.PlaceBall(new Position(d.stage, d.x, d.y)); } }
Color[] LoadBallColors() { TextAsset ballDataString = Resources.Load <TextAsset>("ballcolors"); BallData ballData = JsonUtility.FromJson <BallData>(ballDataString.ToString()); return(ballData.colors); }
void SetBallData(GameObject ballObj) { switch (GameManager.gamePlayMode) { case GameManager.GAMEPLAY_MODE.FREE_PLAY: BallData[] allBD = Resources.LoadAll <BallData> (dataPathBallData); ballData = allBD [UnityEngine.Random.Range(0, allBD.Length)]; ballObj.GetComponent <SpriteRenderer> ().sprite = ballData.defaultBallSprite; ballObj.GetComponent <SpriteRenderer> ().color = ballData.defaultBallColor; ballObj.GetComponent <Ball> ().SetSpeed = ballData.defaultBallSpeed; ballObj.GetComponent <Ball> ().typeMovement = ballData.defaultBallTypeMovement; break; case GameManager.GAMEPLAY_MODE.CUSTOM_PLAY: ballObj.GetComponent <SpriteRenderer> ().sprite = GameManager.customSprite; ballObj.GetComponent <SpriteRenderer> ().color = GameManager.customColor; ballObj.GetComponent <Ball> ().SetSpeed = GameManager.customSpeed; ballObj.GetComponent <Ball> ().typeMovement = GameManager.customTypeMovement; break; case GameManager.GAMEPLAY_MODE.RANDOM_PLAY: ballObj.GetComponent <SpriteRenderer> ().sprite = GameManager.customSprite; ballObj.GetComponent <SpriteRenderer> ().color = GameManager.customColor; ballObj.GetComponent <Ball> ().SetSpeed = GameManager.customSpeed; ballObj.GetComponent <Ball> ().typeMovement = GameManager.customTypeMovement; break; } }
public BallData GetNextBall() { progress = levelCurrentScore / levelTotalScore; BallData ball = new BallData(); float maxScorePerBall = levelTotalScore - levelCurrentScore; float ballChance = Random.Range(0f, 1f); ball.hitPoints = progress * progress * 10 * level + level; if (ballChance > 0.95f) { ball.size = 3; } else if (ballChance > 0.70f) { ball.size = 2; } else if (ballChance > 0.15f) { ball.size = 1; } else { ball.size = 0; } ball.hitPoints *= Mathf.Pow(2, ball.size); totalScoreSpent += ball.hitPoints; ball.coinWorth = (int)(ball.hitPoints / 10f); Debug.Log("Spent: " + ball.hitPoints + "Total Spent now: " + totalScoreSpent); return(ball); }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * TOOLBAR *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ void DrawToolBar() { GUIStyle b = new GUIStyle(GUI.skin.button); GUILayout.BeginArea(toolbarSection); GUILayout.BeginHorizontal(); // Create Simple Ball ChangeColor(Color.green); if (GUILayout.Button("+ Simple Ball", b, GUILayout.Width(100))) { BallData new_ball = SongEdit.CreateBall(typeof(SimpleBallData)); ballList.Add(new_ball); } ResetColor(); // Sort Balls ChangeColor(new Color(0.909f, 0.635f, 0.066f)); if (GUILayout.Button("Sort Balls", b, GUILayout.Width(80))) { game.SortBalls(); } ResetColor(); // Sort Notes ChangeColor(new Color(0.717f, 0.262f, 0.937f)); if (GUILayout.Button("Sort Notes", b, GUILayout.Width(80))) { game.SortNotes(); } ResetColor(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
/** * Spawns a ball as a child of BallDropper */ public Ball SpawnBall(BallData data) { if (!data.enabled) { return(null); // if the ball is disabled, don't spawn it } try{ Ball ball = Instantiate(data.prefab).GetComponent <Ball>(); ball.transform.parent = transform; // set BallDropper object to parent ball.Initialize(game, data, this); // This lets anyone who is subscribed to the onBallSpawned event subscribe to the ball's events if (onBallSpawned != null) { onBallSpawned(ball); } // Add to list of balls activeBallList.Add(ball); NextBall(); return(ball); } catch (Exception) { return(null); } }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ public override void Initialize(Game game, BallData data, BallDropper dropper) { base.Initialize(game, data, dropper); // downcast data to specific type BounceBallData bounceData = (data as BounceBallData); // COMPONENTS rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); // ATTRIBUTES radius = GetComponent <SphereCollider>().bounds.size.y / 2; InitializeRings(); // MOVEMENT fallAxisBounds = dropper.fallAxisBounds; speed = dropper.startSpeed; gravity = dropper.gravity; velocity = speed * axisVector * negative; baseHeight = dropper.bounceHeightBase; // OPTIONS bounceHeight = bounceData.GetOption("Bounce Height"); }
public void ResetBoard() { oldFaces = TileData.CreateEmptyFaceArray(new IntVector3(0, 0, 0)); oldBalls = BallData.CreateEmptyBallDataMatrix(new IntVector3(0, 0, 0)); CreateBoard(IntVector3.One * 3); UpdateModel(); }
public BallLabel(BallData data, float y) { this.y = y; height = line_h + (numNotes * line_h); height += padding + (padding * numNotes); yMax = y + height; }
private void Update() { if (mover.speed == 0 && ballData.type != -1) //Only still balls, and not center { Collider2D[] chainColliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), 1.1f); foreach (Collider2D collision in chainColliders) { GameObject colObject = collision.gameObject; if (colObject == gameObject) { break; //Don't collide with yourself } BallData colData = colObject.GetComponent <BallData>(); if (colData != null) { if (colData.type == ballData.type) { if (colData.type == ballData.type) { ballData.MergeChain(colData.chain); } } } } } }
public override void EnterState() { GameObject ground = GameStart.GetInstance().ResModuel.LoadResources <GameObject>(EResourceType.Ground, "Ground"); ground = CommonFunc.Instantiate(ground); m_ground = CommonFunc.AddSingleComponent <Ground>(ground); GroundData groundData = new GroundData(); m_ground.InitGround(groundData); PlayerData playerData = new PlayerData(); m_palyer = new Player(1, playerData); m_palyer.InitPlayerAction(HitBallDelegate); GameObject go = new GameObject("Controller"); m_playerController = go.AddComponent <PlayerController>(); m_playerController.InitController(m_palyer); BallMechineData mechineData = new BallMechineData(); BallData ballData = new BallData(); m_ballMechine = new BallMechine(mechineData, ballData, m_ground.GetLeftPoint(), m_ground.GetRightPoint()); CoroutineTool.GetInstance().StartGameCoroutine(StartCoroutine()); }
private void UpdateUi(bool requestBuy = false) { if (IsCurrentIndexValid) { BallData selected = balls[CurrentIndex]; bool isCurrentEquipped = IsBallEquipped(selected); if (selected && ui.ItemNotOwnedUi) { ui.ItemNotOwnedUi.SetActive(!selected.IsBought); } if (ui.BallEquippedSign) { ui.BallEquippedSign.SetActive(isCurrentEquipped); } if (requestBuy && selected && !selected.IsBought) { if (ui.BuyText.IsTextValid) { ui.BuyText.Text = ui.BuyText.Prefix + selected.Price.ToString() + ui.BuyText.Suffix; ui.BuyText.Ui.gameObject.SetActive(true); } if (ui.UnlockUi) { ui.UnlockUi.SetActive(true); } } } }
public Ball(Game game, BallData bData) : base(game) { Speed = 3f; ballData = bData; ballTexture = Game1.ballTexture; Position = new Vector2((Game1.ScreenWidth / 2) - (ballTexture.Width / 2), (Game1.ScreenHeight / 2) - (ballTexture.Height / 2)); }
private void Awake() { toSequence = new Rotator[balls.Length]; for (int i = 0; i < toSequence.Length; i++) { BallData ball = balls[i]; if (!ball) { Debug.LogErrorFormat("{0} of type {1} found a null reference in its ballsdata array index {2}!", this, this.GetType(), i); continue; } GameObject prefab = ball.GetBallPrefab(); if (!prefab) { Debug.LogErrorFormat("{0} of type {1} found a null reference while attempting to get ball prefab from ballsdata array index {2}!", this, this.GetType(), i); continue; } Rotator rotator = GameObject.Instantiate(prefab, spawnsParent).AddComponent <Rotator>(); rotator.gameObject.SetActive(false); rotator.SetValues(this.rotationSpeed, this.rotationAx); rotator.transform.localPosition = Vector3.zero; toSequence[i] = rotator; } if (!playerData || !currency) { Debug.LogErrorFormat("{0} of type {1} required PlayerData and CurrencyHolder valid references!", this, this.GetType()); gameObject.SetActive(false); } }
private BallData[,] GetPlaneBoardData(BallData[,,] model, int[] sizes, bool inverseZ, Func <BallData[, , ], int[], BallData> getter) { Assert.AreEqual(sizes.Length, 3); BallData[,] result = new BallData[sizes[0], sizes[1]]; for (int first = 0; first < sizes[0]; first++) { for (int second = 0; second < sizes[1]; second++) { int third = 0; while (third < sizes[2]) { int iThird = Functions.Inverse(third, sizes[2], inverseZ); BallData ball = getter(model, new int[3] { first, second, iThird }); if (ball.BallType != BallType.EMPTY) { result[first, second] = ball; break; } third++; } if (third >= sizes[2]) { result[first, second] = BallData.GetEmptyBall(); } } } return(result); }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * SPAWN *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ /** * Spawn balls before the song starts using the game time */ public void CheckPreSpawn() { bool spawning = false; BallData checkBall = ballDataList[currentBallIndex]; float dropBeat = checkBall.notes[0].hitBeat - fallTimeBeats; if (!isFinished && dropBeat <= song.ToBeat(game.GetGameTime()) - fallTimeBeats) { spawning = true; // Check other balls for spawn // Because we want balls with same hit time to spawn in same Update loop so their motions are synced while (spawning) { Ball ball = SpawnBall(checkBall); // if there are no balls left, exit the loop if (isFinished) { spawning = false; break; } else { checkBall = ballDataList[currentBallIndex]; dropBeat = checkBall.notes[0].hitBeat - fallTimeBeats; // If the next ball isn't ready to drop, continue if (!(dropBeat <= song.ToBeat(game.GetGameTime() - fallTimeBeats))) { spawning = false; } } } } }
public static void DeleteBall(BallData ball) { Game game = FindObjectOfType <Game>(); string path = game.GetEditorSong().dataPath + "/Balls/" + ball.name + ".asset"; AssetDatabase.DeleteAsset(path); }
public static void DeleteNote(BallData ball, NoteData note) { Game game = FindObjectOfType <Game>(); ball.notes.Remove(note); AssetDatabase.DeleteAsset(game.GetEditorSong().dataPath + "/Notes/" + note.name + ".asset"); }
public GameObject CreateBall() { var obj = Instantiate(_ballPrefab); var bdata = new BallData(obj.transform); _ballDetaList.Add(bdata); return(obj); }
private static void PrintBallData(StringBuilder sb, string indention, BallData data) { sb.AppendLine(indention + "[Data]"); sb.AppendLine(indention + Indention + "[Velocity: " + data.Velocity + "]"); sb.AppendLine(indention + Indention + "[MaxVelocity: " + data.MaxVelocity + "]"); sb.AppendLine(indention + Indention + "[SpeedFraction: " + data.SpeedFraction + "]"); sb.AppendLine(indention + Indention + "[Unk03: " + data.Unk03 + "]"); }
public Player(float xPos, float yPos) : base(xPos, yPos) { vertVbo = BallData.GetVertexBufferID(); indVbo = BallData.GetIndexBufferID(); indCount = BallData.GetIndexCount(); tex = Resources.Textures["ball.png"]; }
private void Awake() { if (instance != null) { Destroy(instance.gameObject); } instance = this; }
internal static IBallController GetBall(BallData ballData, float sizeRatio, bool floating = true) { GameObject mesh = null; GameObject gameObject; IBallController ballController; switch (ballData.BallType) { case BallType.EMPTY: //gameObject = new GameObject("EmptyBall"); ballController = new EmptyBallController(); break; case BallType.NORMAL: case BallType.WALL: gameObject = new GameObject(); if (ballData.BallType == BallType.NORMAL) { switch (ballData.ObjectiveType) { case ObjectiveType.NONE: mesh = Object.Instantiate(NoObjectiveBallPrefab); break; case ObjectiveType.OBJECTIVE1: mesh = Object.Instantiate(Objective1BallPrefab); break; case ObjectiveType.OBJECTIVE2: mesh = Object.Instantiate(Objective2BallPrefab); break; default: throw new UnhandledSwitchCaseException(ballData.ObjectiveType); } //FloatingAnimation.AddFloatingAnimation(mesh, 1, 0.4f); ballController = gameObject.AddComponent <ObjectiveBallController>(); } else { mesh = Object.Instantiate(WallPrefab); ballController = gameObject.AddComponent <WallController>(); } Assert.IsNotNull(mesh); ballController.SetMesh(mesh); break; default: throw new UnhandledSwitchCaseException(ballData.BallType); } if (mesh != null) { mesh.transform.localScale *= sizeRatio; } ballController.InitObjectiveType(ballData.ObjectiveType); return(ballController); }
/// <summary> /// Додавання данних /// </summary> /// <param name="dbContext">Контекст БД</param> /// <param name="isDevelopment">Режим роботи</param> /// <returns></returns> public static async Task EnsureSeededAsync(this ApplicationDbContext dbContext, bool isDevelopment) { dbContext.LoggingDisable = true; try { if (!dbContext.TournamentTypes.IgnoreQueryFilters().Any()) { await TournamentTypeData.Seed(dbContext); } if (!dbContext.Countries.IgnoreQueryFilters().Any()) { await CountryData.Seed(dbContext); } if (!dbContext.Configurations.Any()) { await ConfigurationData.Seed(dbContext); } if (!dbContext.Players.Any()) { await PlayerData.Seed(dbContext); } if (isDevelopment) { if (!dbContext.Trainings.IgnoreQueryFilters().Any()) { await TrainingData.Seed(dbContext); } if (!dbContext.Matches.IgnoreQueryFilters().Any()) { await MatchData.Seed(dbContext); } if (!dbContext.MatchToPlayers.IgnoreQueryFilters().Any()) { await MatchToPlayerData.Seed(dbContext); } if (!dbContext.Stages.IgnoreQueryFilters().Any()) { await StageData.Seed(dbContext); } if (!dbContext.StageToPlayers.IgnoreQueryFilters().Any()) { await StageToPlayerData.Seed(dbContext); } if (!dbContext.Balls.IgnoreQueryFilters().Any()) { await BallData.Seed(dbContext); } } } catch (Exception ex) { Log.Error("{SeedError}", ex.Message); } dbContext.LoggingDisable = false; }
void Start() { ballData = GetComponent <BallData>(); mover = GetComponent <MoveToCenter>(); center = GameObject.FindGameObjectWithTag("Player"); cCollider = GetComponent <CircleCollider2D>(); diagonalDistance = 1.2f; straightDistance = 1.2f; }
public void SetBall(BallData ball) { _stats = ball; _density = _stats.GetDensity(); _maxVelocity = _stats.GetMaxVelocity(); _weight = _stats.GetWeight(); _hardness = _stats.GetHardness(); }
public void Initialize(BallData data) { spriteRenderer.sprite = data.sprite; transform.localScale = data.scale; movementController.SetConfiguration(data); movementController.ResetState(); }
// Create a free spot object at given location private void CreateFreeSpot(Vector3 p, int x, int y, int stage) { GameObject tmp = Instantiate(freeSpot, p, Quaternion.identity); BallData d = tmp.AddComponent <BallData>() as BallData; d.x = x; d.y = y; d.stage = stage; }
public BallData GetBallDataByType(int key) { BallData value = null; if (!_ballDataDic.TryGetValue(key, out value)) { Debug.LogErrorFormat("BallData.xls中不存在key为{0}的数据", key); } return(value); }
private void Awake(){ startColor = targetColor = GetComponent<Renderer>().material.GetColor("_SpecColor"); //let's not render the GUI on the cubemap if(cubemap != null) { Camera.main.GetComponent<GUILayer>().enabled = false; Camera.main.RenderToCubemap(cubemap); Camera.main.GetComponent<GUILayer>().enabled = true; } gameObject.name = "Ball"; Data = new BallData(); }
public void Reset() { _hsyncCnt = 0; _capChargeStart = 0; _capCharging = false; _vblankEnabled = false; vblank_delay = 0; vblank_value = 0; _vsyncEnabled = false; _CurrentScanLine = 0; _audioClocks = 0; bus_state = 0; pf0_update = 0; pf1_update = 0; pf2_update = 0; pf0_updater = false; pf1_updater = false; pf2_updater = false; pf0_delay_clock = 0; pf1_delay_clock = 0; pf2_delay_clock = 0; pf0_max_delay = 0; pf1_max_delay = 0; pf2_max_delay = 0; enam0_delay = 0; enam1_delay = 0; enamb_delay = 0; enam0_val = false; enam1_val = false; enamb_val = false; p0_stuff = false; p1_stuff = false; m0_stuff = false; m1_stuff = false; b_stuff = false; HMP0_delay = 0; HMP0_val = 0; HMP1_delay = 0; HMP1_val = 0; prg0_delay = 0; prg1_delay = 0; prg0_val = 0; prg1_val = 0; do_ticks = false; _player0 = new PlayerData(); _player1 = new PlayerData(); _playField = new PlayfieldData(); _hmove = new HMoveData(); _ball = new BallData(); _player0.ScanCnt = 8; _player1.ScanCnt = 8; }
public void Reset() { _hsyncCnt = 0; _capChargeStart = 0; _capCharging = false; _vblankEnabled = false; _vsyncEnabled = false; _CurrentScanLine = 0; _audioClocks = 0; _player0 = new PlayerData(); _player1 = new PlayerData(); _playField = new PlayfieldData(); _hmove = new HMoveData(); _ball = new BallData(); _player0.ScanCnt = 8; _player1.ScanCnt = 8; }