// Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player"); st = player.GetComponent <SceneTimer>(); this.time = st.time; p = new Vector3(-2.14f, 8.09f, 0f); }
private void Start() { // Creates audio source for player GameObject child = new GameObject("Player"); child.transform.parent = gameObject.transform; audioSource = child.AddComponent<AudioSource>(); sceneTimer = (SceneTimer) timerGameObject.GetComponent("SceneTimer"); }
void Start() { //VFX projectile = GetComponent <MeshRenderer>(); sparks.SetActive(false); //AUDIO source = GetComponent <AudioSource>(); //SCORE scenetimer = GameObject.Find("GameManager").GetComponent <SceneTimer>(); }
void Start() { sparks.SetActive(false); targetPos = new Vector3(transform.position.x, Random.Range(0.2f, 1.8f), Random.Range(-1f, 1f)); player = GameObject.FindGameObjectWithTag("MainCamera"); source = GetComponent <AudioSource> (); if (SceneManager.GetActiveScene().name == "Parry" || SceneManager.GetActiveScene().name == "Throwing") { scenetimer = GameObject.Find("GameManager").GetComponent <SceneTimer> (); } }
public void ShowFinishLine() { if (Road.RouteDistance <= 0) { Road.FinishLine.Visible = true; SpeedGame = 0; Road.Auto.Top -= ((int)StaticValues.carStep / 2); } if ((Road.Auto.Bounds.IntersectsWith(Road.FinishLine.Bounds)) && (Road.FinishLine.Visible == true)) { SceneTimer.Stop(); GameTimer.Stop(); FinishGame.Start(); } }
public void PauseGame() { if (SceneTimer.Enabled == true) { SceneTimer.Stop(); GameTimer.Stop(); Road.Pause.Enabled = true; Road.Pause.Visible = true; } else { SceneTimer.Start(); GameTimer.Start(); Road.Pause.Enabled = false; Road.Pause.Visible = false; } }
public void Start() { SceneTimer.RunSetup(new List <Tuple <int, Action> > { new Tuple <int, Action>(500, () => { AddFigure(() => new CircleFigure(_worldLoop.World, 75, 600, 400, 40)); }), new Tuple <int, Action>(1000, () => { AddFigure(() => new CircleFigure(_worldLoop.World, 75, 600, 400, 40)); }), new Tuple <int, Action>(2000, () => { AddFigure(() => new CircleFigure(_worldLoop.World, 75, 600, 600, 40)); }), new Tuple <int, Action>(3000, () => { AddFigure(() => new CircleFigure(_worldLoop.World, 75, 400, 600, 40)); }), new Tuple <int, Action>(4000, () => { AddFigure(() => new Rectangle(_worldLoop.World, 600, 20, 0.2f, 500, 500)); }), new Tuple <int, Action>(10000, () => { AddFigure(() => new Rectangle(_worldLoop.World, 600, 20, 0.2f, 500, 500) { Static = true }); }), new Tuple <int, Action>(20000, () => { AddFigure(() => new Rectangle(_worldLoop.World, 600, 20, -0.2f, 1500, 500) { Static = true }); }), }); while (_worldLoop != null) { //Do something/wait for something/ react to stuff as long as the scene is active Thread.Sleep(1000); } }
public void Start() { InitializeScene(); int lastId = -1; int countId = 0; int countDown = 10; while (_worldLoop != null) { //Do something/wait for something/ react to stuff as long as the scene is active if (_rollRectangle != null) { if (countDown > 0) { var testAABB = new AABB(); testAABB.UpperBound = new Vector2(ConvertUnits.ToSimUnits(325), ConvertUnits.ToSimUnits(415)); testAABB.LowerBound = new Vector2(ConvertUnits.ToSimUnits(325), ConvertUnits.ToSimUnits(415)); _worldLoop.BeginInvoke(() => { _worldLoop.World.QueryAABB((fixture) => { var figure = fixture.Tag as IFigure; if (!figure.Static && figure.Position.Y >= 430) //320 { if (lastId != figure.Id) { lastId = figure.Id; countId = 0; } countId++; Debug.WriteLine($"Touching goal: {figure.Id} - {figure.HtmlColor} - #{countId} - {figure.Position.X},{figure.Position.Y}"); if (countId >= 5) { lastId = -1; MoveBallToNextPart(figure); var str = (--countDown).ToString(); if (_countDownInfo == null) { _countDownInfo = new Info() { F = "Arial", P = new Vector2(1125, 85), S = 60, T = str }; _worldLoop.TextInfos.Add(_countDownInfo); _worldLoop.TextInfos.Add(new Info() { F = "Arial", P = new Vector2(775, 85), S = 60, T = "Baller igjen:" }); } else { _countDownInfo.T = str; _countDownInfo.S += 5; } } } return(true); }, ref testAABB); }); } else { if (_waitRectangle != null) { _worldLoop.TextInfos.Clear(); foreach (var roundOneBall in _roundOneBalls) { _worldLoop.BeginInvoke(() => { roundOneBall.Static = true; }); } _worldLoop.BeginInvoke(() => _worldLoop.World.Gravity = new Vector2(0, -1)); var rect = _waitRectangle; _waitRectangle = null; _worldLoop.BeginInvoke(() => _wofObject.RotationPerSecond = 0f); int cdown = 5; _countDownInfo = new Info() { F = "Arial", P = new Vector2(900, 75), S = 60, T = $"Countdown: {cdown}" }; _worldLoop.TextInfos.Add(_countDownInfo); SceneTimer.RunSetup(new List <Tuple <int, Action> > { new Tuple <int, Action>(1000, () => { _countDownInfo.T = $"Countdown: {--cdown}"; }), new Tuple <int, Action>(2000, () => { _countDownInfo.T = $"Countdown: {--cdown}"; }), new Tuple <int, Action>(2500, () => { StartZigZaggers(); }), new Tuple <int, Action>(3000, () => { _countDownInfo.T = $"Countdown: {--cdown}"; }), new Tuple <int, Action>(4000, () => { _countDownInfo.T = $"Countdown: {--cdown}"; }), new Tuple <int, Action>(5000, () => { _countDownInfo.T = $"Countdown: {--cdown}"; }), new Tuple <int, Action>(5500, () => { _worldLoop.BeginInvoke(() => _worldLoop.World.Gravity = new Vector2(0, 4)); }), new Tuple <int, Action>(6000, () => { _countDownInfo.T = $"GO"; _worldLoop.RemoveFigure(rect); foreach (var roundTwoBall in _roundTwoBalls) { _worldLoop.BeginInvoke(() => roundTwoBall.LinearVelocity = new Vector2(random.Next(25), random.Next(25))); } }), new Tuple <int, Action>(8000, () => { _worldLoop.TextInfos.Clear(); }), }); } else { var balls = _roundTwoBalls.ToList(); _worldLoop.BeginInvoke(() => { foreach (var ball in balls) { if (ball.Position.Y < 600 && Math.Abs(ball.LinearVelocity.X) < 100 && Math.Abs(ball.LinearVelocity.Y) < 100) { ball.LinearVelocity = new Vector2(random.Next(50), random.Next(50)); } } }); if (_info1 == null) { foreach (var ball in balls) { if (ball.Position.Y > 700) { _info1 = new Info() { F = "Arial", S = 20, P = new Vector2(800, 50), T = "" }; _info2 = new Info() { F = "Arial", S = 20, P = new Vector2(800, 80), T = "" }; _info3 = new Info() { F = "Arial", S = 20, P = new Vector2(800, 110), T = "" }; _worldLoop.TextInfos.Add(_info1); _worldLoop.TextInfos.Add(_info2); _worldLoop.TextInfos.Add(_info3); } break; } } if (_info1 != null) { _info1.T = ""; _info2.T = ""; _info3.T = ""; var scores = balls.OrderBy(o => Vector2.Distance(o.Position, new Vector2(1150, 775))).ToList(); if (scores.Count > 0) { _info1.T = "Førsteplass: " + scores[0].Id; } if (scores.Count > 1) { _info2.T = "Andreplas: " + scores[1].Id; } if (scores.Count > 2) { _info3.T = "Tredjeplass: " + scores[2].Id; } var movement = balls.Any(o => Vector2.Distance(o.LinearVelocity, Vector2.Zero) > 10); if (!movement) { _worldLoop.TextInfos.Remove(_info2); _worldLoop.TextInfos.Remove(_info3); Task.Run(() => { Thread.Sleep(200); _info1.T = "VINNER!!! " + scores[0].Id; Thread.Sleep(5000); //DEBUG RESTART: RenderingHub.Instance.Stop(); Thread.Sleep(1000); RenderingHub.Instance.SceneStart("WoF3Scene"); Thread.Sleep(2000); RenderingHub.Instance.SceneEvent("DropTheBalls"); }); return; } } } } } Thread.Sleep(200); } }
public void SendEvent(string eventString) { if (eventString == "SomeEvent") { for (int i = 0; i < 25; i++) { AddFigure(() => new Circle(_worldLoop.World, 15, 400, 400)); Thread.Sleep(100); } } if (eventString == "DropTheBalls") { for (int i = 0; i < 100; i++) { var ball = AddFigure(() => new Circle(_worldLoop.World, 15, 350 + random.Next(400) - 200, 350 + random.Next(400) - 200) { Restitution = 0.1f, Mass = 0.4f, Friction = 1f, SleepingAllowed = false }); _roundOneBalls.Add(ball); Thread.Sleep(25); } var rect = AddFigure(() => new HollowRectangle(_worldLoop.World, 800, 800, 20, 1150, 400, "blue", true) { Restitution = 0.8f, Friction = 1f }); SceneTimer.RunSetup(new List <Tuple <int, Action> > { new Tuple <int, Action>(1000, () => { _worldLoop.BeginInvoke(() => _wofObject.RotationPerSecond = 0.8f); }), new Tuple <int, Action>(3500, () => { CreateBallCourt(); }), new Tuple <int, Action>(4500, () => { AddFigure(() => new Rectangle(_worldLoop.World, 175, 10, 0.3f, 300, 330, "blue", true) { Restitution = 0f }); }), new Tuple <int, Action>(5500, () => { AddFigure(() => new Rectangle(_worldLoop.World, 175, 10, -0.3f, 430, 260, "blue", true) { Restitution = 0f }); }), new Tuple <int, Action>(6500, () => { AddFigure(() => new Rectangle(_worldLoop.World, 175, 10, 0.3f, 300, 150, "blue", true) { Restitution = 0f }); }), new Tuple <int, Action>(4000, () => { _waitRectangle = AddFigure(() => new Rectangle(_worldLoop.World, 800, 20, 0f, 1150, 150, "red", true) { Restitution = 0f }); }), }); } }
private void Start() { sceneTimer = (SceneTimer) timerGameObject.GetComponent("SceneTimer"); }