public bool Drop(GameObject sender) { _data.grabbed = false; transform.parent = null; transform.localRotation = Quaternion.identity; if (_playerGrabbing.closeWindows.Any() && _data.npcState == NPCState.Drunk) { _data.falling = true; OnFall?.Invoke(gameObject, this); transform.position += _playerGrabbing.closeWindows.First().transform.up * 2; GameHelper.GameManager.data.score += 100; return(true); } _playerGrabbing = null; _collider.enabled = true; _body.isKinematic = false; // Add the dancer to nbrDancer (if dancer) if (_data.drunkType == DrunkType.Dancer) { GameHelper.GameManager.data.dancerCount++; } return(true); }
public void EmitOnFall() { if (OnFall != null) { OnFall.Invoke(this, EventArgs.Empty); } }
public void Fall() { var isFalling = _lastVerticalPosition > YPosition && IsOnAir; if (isFalling && !IsOnTask && LastAction != Action.FALL) { LastAction = Action.FALL; IsFalling = true; OnFall?.Invoke(this, null); } else { IsFalling = false; } }
private void CameraMovement_Thread() { while (true) { if (render.isActive()) { try { if (player.Y > 650) { OnFall?.Invoke(); } //because of gravity being in a diffrent thread it checks if it has to move the camera to keep focus in case of falling etc. if (Math.Abs(player.Y - Y * -1) > 425 && player.Y <= 470) { Y -= 0.7f; } if (Up) { //check if collision is present otherwise move player to given direction if (lvl.Tiles.Count(o => o.Y <= player.Y && player.Collide(o) && o.Collidable) == 0) { if (Math.Abs(player.Y - Y * -1) < 125) { Y += 0.8f; } player.Y -= 0.75f; } else { player.Y += 1; Up = false; } } if (Left) { //check if collision is present otherwise move player to given direction if (lvl.Tiles.Count(o => o.X <= player.X && player.Collide(o) && o.Collidable) == 0) { if (X + player.X < 250) { X += 0.45f; } player.X -= 0.45f; } else { player.X += 1; Left = false; } } if (Right) { //check if collision is present otherwise move player to given direction if (lvl.Tiles.Count(o => o.X >= player.X && player.Collide(o) && o.Collidable) == 0) { if (X + player.X > 350) { X -= 0.45f; } player.X += 0.45f; } else { player.X -= 1; Right = false; } } } catch { } Thread.Sleep(1); } } }