public void OnWindowRemove() { if ((doAnimateOnDestroy && (WindowContent != null))) { WindowContent.MoveTo(EGTween.Hash("x", 600F, "easeType", EGTween.EaseType.easeInBack, "time", TransitionDuration, "islocal", true, "ignoretimescale", true)); if (doFadeOutBacklayOnDestroy) { BackLay.gameObject.ValueTo(EGTween.Hash("From", TransitionDuration, "To", 0F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate", "ignoretimescale", true)); } Invoke("OnRemoveTransitionComplete", 0.5F); } else { if (doFadeOutBacklayOnDestroy) { BackLay.gameObject.ValueTo(EGTween.Hash("From", TransitionDuration, "To", 0F, "Time", TransitionDuration, "onupdate", "OnOpacityUpdate")); Invoke("OnRemoveTransitionComplete", 0.5F); } else { OnRemoveTransitionComplete(); } } }
/// <summary> /// Обновления поведения после нажатия клавиш /// </summary> /// <param name="delta">Время между кадрами</param> protected override void AfterKeyProcess(float delta) { // обрабатываем мышь var inputController = InputController.GetInstance(); GameObject.RotateZ(_deltaAngle * inputController.MouseRelativePositionX * _rotSpeed); GameObject.RotateY(_deltaAngle * inputController.MouseRelativePositionY * _rotSpeed); // затем смещаем курсор мыши, чтоб он всегда был посередине, чтоб не вылететь за рамки экрана // нужно делать тут, так то код выше берет передвижение мыши по экрану var form = GameObject.Scene.Game.RenderForm; Cursor.Position = new System.Drawing.Point(form.Location.X + form.ClientSize.Width / 2, form.Location.Y + form.ClientSize.Height / 2); // применяем перемещние и вращение _moveDirection.Normalize(); Vector3 rotation = GameObject.Rotation; Matrix rotationMatrix = Matrix.RotationYawPitchRoll(rotation.Z, rotation.Y, rotation.X); var oldPosition = GameObject.Position; GameObject.MoveBy((Vector3)Vector3.Transform(_moveDirection * Speed * delta, rotationMatrix)); if (_colliderComponent.CheckIntersects(out _, "obstacle")) { GameObject.MoveTo(oldPosition); } }
/// <summary> /// Обновление поведения /// </summary> /// <param name="delta">Время между кадрами</param> public override void Update(float delta) { if (!_physics.IsGrounded && !_isCollided) { var oldPosition = GameObject.Position; GameObject.MoveBy(_direction * _speed * _arrowComponent.FiringForceCoef * delta); if (_colliderComponent.CheckIntersects(out Game3DObject enemy, "enemy")) { HandleHitEnemy(enemy); } if (_colliderComponent.CheckIntersects(out _, "obstacle")) { _isCollided = true; GameObject.MoveTo(oldPosition); } } _time += delta; if (_time >= _lifeTime) { GameObject.Scene.RemoveGameObject(GameObject); _colliderComponent.RemoveCollisionFromScene(); } }
public void GenerateGrid() { string holderName = "GeneratedGrid"; if (transform.Find(holderName)) { DestroyImmediate(transform.Find(holderName).gameObject); } Transform gridHolder = new GameObject(holderName).transform; // Temp holder for the grid at any given time gridHolder.parent = transform; for (int x = 0; x < mapSize.x; x++) { for (int y = 0; y < mapSize.y; y++) { Vector3 tilePosition = new Vector3(-mapSize.x / 2 + 0.5f + x, 0, -(-mapSize.y / 2 + 0.5f + y)); Transform newTile = Instantiate(TilePrefab, tilePosition, Quaternion.Euler(Vector3.right * 90)) as Transform; newTile.localScale = Vector3.one * (1 - outlinePercent); newTile.parent = gridHolder; Tiles[x, y] = newTile.gameObject; } } Tiles[1, 1].SetColor(Color.green); // Sets Tile 1,1 to green Tiles[9, 9].SetColor(Color.red); // Sets tile 9,9 to red Agent.MoveTo(Tiles[1, 1]); Agent.SetColor(Color.black); }
/// <summary> /// Обновление процесса натяжения /// </summary> /// <param name="delta">Время между кадрами</param> private void UpdateShootingProcess(float delta) { var inputController = InputController.GetInstance(); // если в этом кадре была нажата ЛКМ if (inputController.MouseButtons[0]) { // изменяем натяжение _process += delta; if (_process >= _maxProcess) { _process = _maxProcess; } // двигаем объект стрелы на луке var dest = new Vector3(0, 0, -_process / _processCoef); GameObject.MoveTo(_originalPosition + dest); // изменяем состояние прицеливания _playerComponent.IsAiming = true; } else { // если стрелу в прошлых кадрах НАТЯГИВАЛИ if (_process != 0) { GameObject.MoveTo(_originalPosition); _visibleComponent.MakeInvisible(_visibilityDuration); Shoot(); _process = 0; } // изменяем состояние прицеливания _playerComponent.IsAiming = false; } }
/// <summary> /// Движение к цели /// </summary> /// <param name="direction">Вектор движения</param> /// <param name="delta">Время между кадрами</param> private void MoveToTarget(Vector3 direction, float delta) { direction.Normalize(); // считаем угол поворота к цели float angle = (float)Math.Atan2(-direction.X, -direction.Z); // запоминаем старую позицию var oldPosition = GameObject.Position; // двигаем и крутит объект GameObject.SetRotationZ(angle); GameObject.MoveBy(direction * _enemyComponent.Speed * delta); // проверяем столкновение if (_colliderComponent.CheckIntersects(out _, "obstacle")) { // смещаем объект обратно GameObject.MoveTo(oldPosition); // угол для направления обхода препятствия if (direction.X < 0) { angle += MathUtil.Pi / 2; } else { angle -= MathUtil.Pi / 2; } // создаем новый вектор направления и двигаем Matrix rotationMatrix = Matrix.RotationYawPitchRoll(angle, 0, 0); direction = (Vector3)Vector3.Transform(direction, rotationMatrix); direction.Normalize(); GameObject.MoveBy(direction * _enemyComponent.Speed * delta); } }
public void Activate() { axe.GetComponent <SpriteRenderer>().enabled = true; axe.transform.localPosition = new Vector2(.3f, 1); // iTween.MoveTo(gameObject, iTween.Hash("position", new Vector2(-.5f, 0), "time", activeDuration, "easeType", EaseType.easeOutExpo, "isLocal", true)); axe.MoveTo((Vector2)transform.position + new Vector2(-.3f, 1), activeDuration / 5, activeDuration * 3 / 5, EaseType.easeOutExpo); Invoke("Deactivate", activeDuration); }
public static iTweener LobTo(this GameObject go, Vector3 begin, Vector3 end, float yOffset = 2.0f) { Vector3[] path = new Vector3[3]; path[0] = begin; path[2] = end; path[1] = Vector3.Lerp(path[0], path[2], .5f).yAdd(yOffset); return(go.MoveTo(path)); }
protected virtual int MakePortSequence(RegionTimer callingTimer) { if (m_portTeleportTimerQueue.Count > 0) { m_portTeleportTimerQueue.Dequeue(); GameObject gameObject = (GameObject)m_portObjectQueue.Dequeue(); GameLocation location = (GameLocation)m_portDestinationQueue.Dequeue(); gameObject.MoveTo(location.RegionID, location.X, location.Y, location.Z, location.Heading); } return(0); }
public void Update(GameTime gameTime) { ks = Keyboard.GetState(); if (ks.IsKeyDown(Keys.Escape)) { score = 0; } foreach (GameObject f in fragiles.Items.Values) { if (f.getRect().Intersects(kid.getRect())) { f.MoveTo(rand.Next(0, 700), rand.Next(0 - f.getRect().Height, 150)); score += 5; } if (f.getPosition().Y > 480 - f.getRect().Height) { f.MoveTo(rand.Next(0, 700), rand.Next(0 - f.getRect().Height, 150)); score--; } f.Move(0, 3); } if (kid.getPosition().X < 800 - kid.getRect().Width&& kid.getPosition().X >= 0) { if (ks.IsKeyDown(Keys.Left)) { kid.Move(-3, 0); } if (ks.IsKeyDown(Keys.Right)) { kid.Move(3, 0); } } if (kid.getPosition().X < 0) { kid.MoveTo(0, 480 - 159); } if (kid.getPosition().X > 800 - kid.getRect().Width) { kid.MoveTo(800 - kid.getRect().Width, 480 - 159); } }
public virtual void Move(GameObject obj, float toX, float toY) { Hashtable hashtable = new Hashtable(); hashtable.Add("time", 0.1f); hashtable.Add("x", toX); hashtable.Add("y", toY); hashtable.Add("easeType", iTween.EaseType.linear); hashtable.Add("isLocal", true); hashtable.Add("oncompletetarget", obj); obj.MoveTo(hashtable); }
public void LoadContent(ContentManager Content) { objects = ObjectFactory.MakeCollection("Content/CNature", "nature", Content); for (int i = 0; i < 20; i++) { objects.Items.Add(i.ToString(), new GameObject(new Vector2(r.Next(0, 400), r.Next(0, 250)), "yagmur", "nature", Content)); } Score = objects.Items["score"]; objects.Items.Remove("score"); Score.MoveTo(0, 480 - Score.rTexture.Height); font = Content.Load <SpriteFont>("Font1"); mRect = new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 0, 0); }
public void MoveToSimpleTest() { game.TestFunction = delegate { GameObject g = new GameObject(10, 10); game.Add(g); Vector pos = new Vector(50, 50); g.MoveTo(pos, 40, () => { Assert.AreEqual(g.Position, pos); Assert.Pass(); }); }; game.Run(); }
void liikkuvatausta() { Image bgImg = LoadImage("kenttatausta v1"); GameObject liikkuvaTausta = new GameObject(bgImg.Width * 10, bgImg.Height); liikkuvaTausta.Image = bgImg; liikkuvaTausta.TextureWrapSize = new Vector(10.0, 1.0); // 10 kertaa kuvan levyinen Add(liikkuvaTausta, -3); liikkuvaTausta.MoveTo(new Vector(-Screen.Width, 0), 100); }
public void MoveTo() { game.TestFunction = delegate { Vector delta = new Vector(10, 10); Vector posToMove = new Vector(20, 20); GameObject g = new GameObject(10, 10); g.Position = delta; parent.Add(g); game.Add(parent); parent.MoveTo(posToMove, 20, () => { Assert.That(parent.Position, Is.EqualTo(posToMove).Using(new VectorComparer(0.1))); Assert.That(g.Position, Is.EqualTo(posToMove + delta).Using(new VectorComparer(0.1))); Assert.Pass(); }); }; game.Run(); }
private void MoveTo(GameObject obj, Vector3 to, float duration, float delay, string comp) { iTween.Stop(obj); Hashtable hashtable = new Hashtable(); hashtable.Add("position", to); hashtable.Add("isLocal", true); hashtable.Add("delay", delay); hashtable.Add("time", duration); hashtable.Add("easeType", iTween.EaseType.linear); hashtable.Add("oncomplete", comp); hashtable.Add("oncompletetarget", base.gameObject); obj.MoveTo(hashtable); }
public virtual void Move(GameObject obj, float fromX, float fromY, float toX, float toY) { Vector3 localPosition = new Vector3(fromX, fromY); obj.transform.localPosition = localPosition; Hashtable hashtable = new Hashtable(); hashtable.Add("time", 0.1f); hashtable.Add("x", toX); hashtable.Add("y", toY); hashtable.Add("easeType", iTween.EaseType.linear); hashtable.Add("isLocal", true); hashtable.Add("oncompletetarget", base.gameObject); obj.MoveTo(hashtable); }
protected override void OnBegin(Vector2 targetPosition, Side side) { GameObject crossHair = Instantiate(crosshairPrefab) as GameObject; crossHair.transform.position = targetPosition; crossHair.transform.position = crossHair.transform.position.zAdd(Map.use.m_maxZ); Destroy(crossHair, instantiateDelay); GameObject supplyPackage = Instantiate(supplyPackagePrefab) as GameObject; float xOffset = Random.Range(-10, -2); if (side == Side.Right) { xOffset = Random.Range(2, 10); } supplyPackage.transform.position = targetPosition.yAdd(16); // 16 = roughly screen height supplyPackage.transform.position = supplyPackage.transform.position.zAdd(Map.use.GetDepthByPercentage(0.5f)); List <Vector3> path = new List <Vector3>(); Vector3 start = supplyPackage.transform.position; Vector3 end = targetPosition.ToVector3().zAdd((Map.use.GetDepthByPercentage(0.5f))); path.Add(supplyPackage.transform.position); //for (int i = 1; i <= 3; i++) //{ // Vector3 point = Vector3.Lerp(start, targetPosition, (float)i / 5.0f); // point = point.xAdd(Random.Range(-3.0f, 3.0f)); // path.Add(point); //} path.Add(Vector3.Lerp(start, end, 0.5f).xAdd(Random.Range(-1f, 1f) * 6)); path.Add(end); supplyPackage.MoveTo(path.ToArray()). Time(instantiateDelay). EaseType(iTween.EaseType.linear). Execute(); StartCoroutine(RemoveParachute(supplyPackage)); }
private IEnumerator ShowGameOverRoutine() { Balls.Active = false; OverallRankLoading.SetActive(false); DailyRankLoading.SetActive(false); WeeklyRankLoading.SetActive(false); UIManager.Gameplay.Hide(); MenuBtn.transform.position = new Vector3(-400f, -150f, 0f) * GameManager.NGUI_SCALE; RestartBtn.transform.position = new Vector3(400f, -150f, 0f) * GameManager.NGUI_SCALE; ShareBtn.transform.position = new Vector3(0f, -500f, 0f) * GameManager.NGUI_SCALE; yield return(new WaitForEndOfFrame()); yield return(StartCoroutine(ShowRanksRoutine())); // if (Balls.Score > GameData.DailyBest) { OverallRankLoading.SetActive(true); DailyRankLoading.SetActive(true); WeeklyRankLoading.SetActive(true); PlayGameServiceManager.ReportScore(Balls.Score); } yield return(new WaitForEndOfFrame()); ScoreText.text = string.Format("{0}", Balls.Score); BestScoreText.text = string.Format("{0}", GameData.OverallBest); yield return(new WaitForEndOfFrame()); if (Balls.Score > GameData.OverallBest) { GameData.OverallBest = Balls.Score; yield return(new WaitForSecondsRealtime(0.5f)); BestScoreText.text = string.Format("{0}", GameData.OverallBest); yield return(new WaitForSecondsRealtime(0.5f)); NewBestStamp.SetActive(true); NewBestStamp.ScaleTo(Vector3.one, 0.5f, 0f, EaseType.spring); } yield return(new WaitForSeconds(0.5f)); MenuBtn.MoveTo(new Vector3(-150f, -150f, 0f) * GameManager.NGUI_SCALE, 0.5f, 0f, EaseType.spring); ShareBtn.MoveTo(new Vector3(0f, -200f, 0f) * GameManager.NGUI_SCALE, 0.5f, 0f, EaseType.spring); RestartBtn.MoveTo(new Vector3(150f, -150f, 0f) * GameManager.NGUI_SCALE, 0.5f, 0f, EaseType.spring); yield return(new WaitForSeconds(0.5f)); }
public void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { score = 0; } ms = Mouse.GetState(); mRect.Location = new Point(ms.X, ms.Y); for (int i = 0; i < 20; i++) { GameObject rain = objects.Items[i.ToString()]; Point position = rain.getPosition(); if (position.X > boundaries.X && position.Y < boundaries.Y) { rain.Move(-Speed / 1.5F, Speed / 1.5F); } else { rain.MoveTo(r.Next(0, 800), 0); } } if (ms.LeftButton == ButtonState.Pressed && mPress == false) { mPress = true; for (int i = 0; i < 20; i++) { if (mRect.Intersects(objects.Items[i.ToString()].getRect())) { score += 25; objects.Items[i.ToString()].Move(r.Next(0, 400), -objects.Items[i.ToString()].getRect().Location.Y); } } if (mRect.Intersects(objects.Items["bulut"].getRect()) || mRect.Intersects(objects.Items["bulut1"].getRect())) { score += 1; } } if (ms.LeftButton == ButtonState.Released) { mPress = false; } }
void luotahti(Vector paikka, Color vari) { PhysicsObject matta = new PhysicsObject(35, 35); matta.Shape = Shape.Circle; matta.Position = paikka; matta.Color = vari; matta.IgnoresExplosions = true; Add(matta); matta.LifetimeLeft = TimeSpan.FromSeconds(TUHOUTUMINEN); matta.Destroying += () => voimaMittari.Value += 1; tahtilista.Add(matta); AddCollisionHandler(matta, pallo1, mittaritayttyy); piilari.MoveTo(matta.Position, KAMERANOPEUS); }
public static GameObject moveTo(GameObject gameObject, GameObject uiTarget, GameObject prefab, float time, float delay) { Camera gameCamera = NGUITools.FindCameraForLayer(gameObject.layer); Camera uiCamera = UICamera.mainCamera; GameObject guiObject = NGUITools.AddChild(uiTarget.transform.parent.gameObject, prefab); /* UILabel label = guiObject.GetComponentInChildren<UILabel>(); * label.text = amout.ToString();*/ /* MOVE TO CORRECT POSITION*/ // Get screen location of node Vector2 screenPos = Camera.main.WorldToScreenPoint(gameObject.transform.position); // Move to node guiObject.transform.position = uiCamera.ScreenToWorldPoint(screenPos); // радиус окружности на которой находятся точки начала и коца float r = (Vector3.Distance(guiObject.transform.position, uiTarget.transform.position) / 3); Vector3 middlePoint = 0.5f * Vector3.Normalize(uiTarget.transform.position - guiObject.transform.position) + guiObject.transform.position; Vector3 bezierPoint = middlePoint; bezierPoint.x += Random.Range(-r, r); bezierPoint.y += Random.Range(-r, r); //Vector3 bezierPoint = //new Vector3( Random.Range(-r, r), Random.Range(-r, r), 0); Vector3[] path = new Vector3[3] { guiObject.transform.position, bezierPoint, uiTarget.transform.position }; guiObject.MoveTo(path, time, delay, EaseType.easeInSine); guiObject.RotateBy(new Vector3(0, 0, 1f), 0.5f, 0, EaseType.easeInOutSine, LoopType.loop); return(guiObject); }
IEnumerator ShowGameOverMenu() { yield return(new WaitForEndOfFrame()); #region Game Over Animation int numRows = 11; float animationTotal = numRows * animationDuration / 2 + animationDuration; List <GameObject> gameOverRows = new List <GameObject>(); for (int i = 0; i < numRows; i++) { GameObject gameOverRow = Instantiate(gameOverRowPrefab) as GameObject; gameOverRow.transform.position = (Vector2)Camera.main.transform.position + Vector2.down * 6; if (GameManager.gotBurned) { gameOverRow.GetComponent <GameOverRow>().SetColor("Fire"); } else { gameOverRow.GetComponent <GameOverRow>().SetColor("Water"); } gameOverRows.Add(gameOverRow); } for (int i = 0; i < gameOverRows.Count; i++) { gameOverRows[i].MoveTo((Vector2)Camera.main.transform.position + new Vector2(0, -5 + i), animationDuration, i * animationDuration / 2, EaseType.easeOutBack); } yield return(new WaitForSeconds(animationTotal)); #endregion gameOverMenu.MoveTo(Camera.main.transform.position, animationDuration, 0, EaseType.easeInOutQuart); }
public static iTweener MoveTo(this GameObject go, Transform target) { return(go.MoveTo(target.position)); }
void OnMouseDown() { if (!GameObject.Find("GoButtonTrue").GetComponent<GameController>().move) { //If the player has confirmed their tiles, don't let them move. } else if(this.gameObject.tag.Equals("Respawn")){ GameObject cam = GameObject.FindWithTag("MainCamera"); cam.transform.position = new Vector3(0,0,-10); } else if (this.gameObject.tag.Equals ("Placeable")) { //Selecting a tile to move. if (selected != null) { selected.ScaleTo (new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); } selected = this.gameObject; selected.ScaleTo (new Vector3 (0.35f, 0.35f, 1), 0.5f, 0); } else if (gameObject.tag.Equals ("Spot")) { //Selecting a tile to move to. if(selected == null){ Debug.Log("Nothing selected"); } else{ if(selected.transform.position.x == 4.93f){ inQueue--; } selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 1.0f, 0); selected.MoveTo(new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, -0.2f), 2, 0); switch(this.gameObject.name){ case "Spot 1": GameObject.Find("GoButtonTrue").GetComponent<GameController>().spot1 = selected.name; break; case "Spot 2": GameObject.Find("GoButtonTrue").GetComponent<GameController>().spot2 = selected.name; break; case "Spot 3": GameObject.Find("GoButtonTrue").GetComponent<GameController>().spot3 = selected.name; break; case "Spot 4": GameObject.Find("GoButtonTrue").GetComponent<GameController>().spot4 = selected.name; break; } selected = null; if(inQueue == 0){ setGo(true); } } } else if(gameObject.tag.Equals("Respawn")){ //Selecting the tile queue to put them back. if(selected != null && selected.transform.position.x != 4.93f){ switch(selected.name){ case "1": selected.MoveTo (new Vector3 (4.93f, 3.73f, -1), 1.5f, 0); selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); selected = null; inQueue++; setGo(false); break; case "2": selected.MoveTo (new Vector3 (4.93f, 1.75f, -1), 1.0f, 0); selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); selected = null; inQueue++; setGo(false); break; case "3": selected.MoveTo (new Vector3 (4.93f, -0.23f, -1), 1.0f, 0); selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); selected = null; inQueue++; setGo(false); break; case "4": selected.MoveTo (new Vector3 (4.93f, -2.21f, -1), 1.0f, 0); selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); selected = null; inQueue++; setGo(false); break; } } else if(selected != null){ selected.ScaleTo(new Vector3 (0.29f, 0.29f, 1), 0.5f, 0); selected = null; } } }
public static void MoveToParrent(this GameObject spawnObject, GameObject gameObject) => spawnObject.MoveTo(gameObject.transform.parent);