void SpawnObstacle() { if (!Player_ControlerScript.isGameOver) { int obstaclesindex = Random.Range(0, obstacles.Length); //GameObject obstacle = Instantiate(obstacles[obstaclesindex], spawnPos, obstacles[obstaclesindex].transform.rotation); if (obstaclesindex == 2) { GameObject obstacle = Instantiate(obstacles[obstaclesindex], spawnPosBarrier, obstacles[obstaclesindex].transform.rotation); Move_Front obsSrcipt = obstacle.GetComponent <Move_Front>(); obsSrcipt.speed = obsSrcipt.speed + (float)obstacleDestroyedCount; } else { GameObject obstacle = Instantiate(obstacles[obstaclesindex], spawnPos, obstacles[obstaclesindex].transform.rotation); Move_Left obsSrcipt = obstacle.GetComponent <Move_Left>(); obsSrcipt.speed = obsSrcipt.speed + (float)obstacleDestroyedCount; } float randomDelay = Random.Range(repeatRateMin, repeatRateMax); Debug.Log("Random interval" + randomDelay); Invoke("SpawnObstacle", randomDelay); } }
private void Move_Airplane(bool con, int chk) { if (con == true) { if (chk == 1) { Move_Left.Begin(); } else { Move_Left.Resume(); } } else { Move_Left.Pause(); } //Move_Left.Begin(); //int left_from = -260; //int left_to = 440; //int top_from = 19; //int top_to = 100; //int Scale_from = 1; //int Scale_to = -1; ////for(int i = 1; i < 6; i++) ////{ // //if(i == 2) // //{ // // left_from = 400; // // left_to = -260; // // top_from = 19; // // top_to = 100; // // Scale_from = -1; // // Scale_to = 1; // //} // //else if(i == 3) // //{ // // left_from = 260; // // left_to = -440; // // top_from = 100; // // top_to = 200; // // Scale_from = 1; // // Scale_to = -1; // //} // //else if(i == 4) // //{ // // left_from = -260; // // left_to = 440; // // top_from = 200; // // top_to = 300; // // Scale_from = -1; // // Scale_to = 1; // //} // //else if(i == 5) // //{ // // left_from = -260; // // left_to = 440; // // top_from = 300; // // top_to = 400; // // Scale_from = 1; // // Scale_to = -1; // //} // DoubleAnimationUsingKeyFrames keyAnima1 = new DoubleAnimationUsingKeyFrames // { // EnableDependentAnimation = true, // KeyFrames = new DoubleKeyFrame(KeyTime(TimeSpan.FromSeconds(7))), // } // DoubleAnimation anima = new DoubleAnimation // { // EnableDependentAnimation = true, // From = -260, // To = 440, // Duration = new Duration((TimeSpan.FromSeconds(7)) // }; // DoubleAnimation anima2 = new DoubleAnimation // { // EnableDependentAnimation = true, // From = 19, // To = 100, // Duration = new Duration(TimeSpan.FromSeconds(0.5)), // BeginTime = TimeSpan.FromSeconds(7) // }; // Storyboard.SetTarget(anima, Img_Airplane); // Storyboard.SetTargetProperty(anima, "(Canvas.Left)"); // Storyboard.SetTarget(anima2, Img_Airplane); // Storyboard.SetTargetProperty(anima2, "(Canvas.Top)"); // Storyboard storyboard = new Storyboard(); // storyboard.Children.Add(anima); // storyboard.Children.Add(anima2); // storyboard.Begin(); //DoubleAnimation anima3 = new DoubleAnimation //{ // EnableDependentAnimation = true, // From = 440, // To = -260, // Duration = new Duration(TimeSpan.FromSeconds(7)), // BeginTime = TimeSpan.FromSeconds(7.5) //}; //DoubleAnimation anima4 = new DoubleAnimation //{ // EnableDependentAnimation = true, // From = 100, // To = 200, // Duration = new Duration(TimeSpan.FromSeconds(0.5)), // BeginTime = TimeSpan.FromSeconds(8) //}; //Storyboard.SetTarget(anima3, Img_Airplane); //Storyboard.SetTargetProperty(anima3, "(Canvas.Left)"); //Storyboard.SetTarget(anima4, Img_Airplane); //Storyboard.SetTargetProperty(anima4, "(Canvas.Top)"); //Storyboard storyboard2 = new Storyboard(); //storyboard.Children.Add(anima3); //storyboard.Children.Add(anima4); //storyboard2.BeginTime = TimeSpan.FromSeconds(7.5); //storyboard2.Begin(); //} }