private void CheckClick() { hitObject = GetHitObject(); if (hitObject) { clickedPusher = hitObject.GetComponent <JumpPoint>(); if (clickedPusher) { readInput = false; if (!clickedOnce) //клик { action = PlayerAction.climb; firstClickTime = Time.time; firstClickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); //для свайпа clickedOnce = true; } else //даблклик { action = PlayerAction.jump; clickedOnce = false; } } } }
// Use this for initialization new void Start() { base.Start(); jumpPoint = new JumpPoint(GameObject.FindGameObjectWithTag("GapStart").transform.position, GameObject.FindGameObjectWithTag("GapEnd").transform.position); jumpTarget.position = jumpPoint.jumpLocation; }
private void DrawJumpTrajectory(JumpPoint jumpPointA, JumpPoint jumpPointB, float speed) { float distance = jumpPointA.Distance; float height = jumpPointA.HeightDifference; float angle = Physics.GetAngle(speed, distance, height); float totalTime = Physics.GetTotalTime(distance, speed, angle); int steps = 20; float timeStep = totalTime / steps; for (int j = 0; j < steps; j++) { float t = j * timeStep; float t2 = (j + 1.0f) * timeStep; float startSegmentDistance = Physics.GetDistanceAtTime(t, totalTime, distance); float endSegmentDistance = Physics.GetDistanceAtTime(t2, totalTime, distance); float startH = jumpPointA.Position.y + Physics.GetHeightAtDistance(0, angle, startSegmentDistance, speed); float endH = jumpPointA.Position.y + Physics.GetHeightAtDistance(0, angle, endSegmentDistance, speed); Vector3 startLine = jumpPointA.Position + jumpPointA.Direction * startSegmentDistance; Vector3 endLine = jumpPointA.Position + jumpPointA.Direction * endSegmentDistance; startLine.y = startH; endLine.y = endH; Debug.DrawLine(startLine, endLine, Color.red); } }
void JumpToNext(GameInput.PlayerAction action) //Когда в эфире PlayerInputAction что-то "прозвучит", запускается JumpToNext { if (LerpCoroutine == null) { this.hitObject = GameInput.Instance.HitObject; this.hitJumpPoint = hitObject != null?hitObject.GetComponent <JumpPoint>() : null; if (!isPlayerFall && onPlatformAfterFall) { if (hitObject && hitJumpPoint)// && LevelGenerator.Instance.IsRunLevel)//если есть объект на который нажали мышкой { lastPusher = hitObject; if (hitJumpPoint.Line - 1 == idLine) { if (action == hitJumpPoint.Action) { speedPusher = LevelGenerator.Instance.SpeedPusher; LerpCoroutine = StartCoroutine("Lerp"); animController.SetJump(action); } else if (hitJumpPoint.Action == GameInput.PlayerAction.question) { GameInput.PlayerAction questionPusherAction = GetQuestionPusherType(hitJumpPoint); if (questionPusherAction == action) { speedPusher = LevelGenerator.Instance.SpeedPusher; LerpCoroutine = StartCoroutine("Lerp"); animController.SetJump(action); } else { PlayerFall(); } } else { PlayerFall(); } } else { PlayerFall(); } } } else if (action == GameInput.PlayerAction.climbAfterFall) { GrabAfterFall(); } } JumpPoint jumpPoint = GameInput.Instance.HitObject != null?hitObject.GetComponent <JumpPoint>() : null; if (!jumpPoint) { PlayerFall(); } }
void Start() { //Player.Create(spawnPoint.position); _grid = Grid.Instance; _grid.AStar = AStar; jp = GetComponent <JumpPoint>(); jp.InitializeGrid(); EventHandler.Instance.Subscribe <PathTimerEvent>(_UpdateTime); }
// Use this for initialization void Start() { velocity = Vector3.zero; steering = new Steering(); groups = new Dictionary <int, List <Steering> >(); jump = false; initialScale = transform.localScale; jumpPoint = null; }
void Start() { JumpPoint firstPoint = JumpPointManager.instance.GetRandomJumpPoint(); JumpPoint secondPoint = JumpPointManager.instance.GetRandomJumpPoint(); JumpPointBeat firstBeatPoint = new JumpPointBeat(firstPoint, -1); JumpPointBeat secondBeatPoint = new JumpPointBeat(secondPoint, 0); _beatPair = new JumpPointBeatPair(firstBeatPoint, secondBeatPoint); }
void GetNewBeatPoint() { JumpPoint newJumpPoint = null; while (newJumpPoint == null || newJumpPoint == _beatPair.point1.jumpPoint) { newJumpPoint = JumpPointManager.instance.GetRandomJumpPoint(); } _beatPair.point0 = _beatPair.point1; _beatPair.point1 = new JumpPointBeat(newJumpPoint, _beatPair.point0.beat + 1); }
public Agent() { position = Vector3.zero; velocity = Vector3.zero; rotation = 0; jp = new JumpPoint(); steering = null; maxSpeed = 0; jump = false; col = false; }
public void JumpAfterLanding() { m_speed = m_landingSpeed; SegmentAngle = m_landingAngle; m_beginJumpPoint = new JumpPoint(transform.position, m_beginJumpPoint.Direction, 3.0f, 0); m_endJumpPoint = new JumpPoint(transform.position + m_beginJumpPoint.Direction * 3.0f, m_beginJumpPoint.Direction, 3.0f, 0); SegmentTime = 0.0f; SegmentTotalTime = Physics.GetTotalTime(m_beginJumpPoint.Distance, m_speed, SegmentAngle); m_lookTarget = transform.position + transform.forward * 1000.0f; }
public Track Generate(Platform platformPrefab, int seed) { var jumpPointPosition = new Vector3(0, 0, 0); List <Vector3> jumpPointPositions = new List <Vector3>(); int pointCount = 20; Random.InitState(seed); for (int i = 0; i < pointCount; i++) { jumpPointPositions.Add(jumpPointPosition); //jumpPointPosition.x += 2 * i * ((i % 2 == 0) ? -1 : 1); //jumpPointPosition.z += 20.0f; //jumpPointPosition.y += 5.0f; jumpPointPosition.x += Random.Range(-5.0f, 5.0f); jumpPointPosition.z += Random.Range(20.0f, 40.0f); jumpPointPosition.y += Random.Range(-5.0f, 5.0f); } Track track = new Track(); for (int i = 0; i < pointCount; i++) { Vector3?prevPosition = null; if (i > 0) { prevPosition = jumpPointPositions[i - 1]; } Vector3 position = jumpPointPositions[i]; Vector3?nextPosition = null; if (i < pointCount - 1) { nextPosition = jumpPointPositions[i + 1]; } var jumpPoint = new JumpPoint(position, prevPosition, nextPosition); track.AddJumpPoint(jumpPoint); } CreateVisualTrack(track, platformPrefab); return(track); }
// TODO: These are defined in the parent so don't need redefining in any page class.... //public event PropertyChangedEventHandler PropertyChanged; //protected virtual void OnPropertyChanged(string propertyName) //{ // var handler = this.PropertyChanged; // if (handler != null) // handler(this, new PropertyChangedEventArgs(propertyName)); //} #endregion ------------ Implement INotifyPropertyChanged ------------ #region ------------ Event handlers that are specific to this GUI implementation, so are not implemented as ICommand objects ------------ private async void lstJumpPoints_ItemTap(object sender, ItemTappedEventArgs e) { JumpPoint jp = e.Item as JumpPoint; if (jp == null) { return; } ColorOption colorOption = jp.ColorOption; ((ListView)sender).SelectedItem = null; // de-select the row lstColors.ScrollTo(colorOption, ScrollToPosition.Center, false);; }
public void JumpPointsImportWithValidValues() { var test = new [] { "1", "test", "2", "1000", "2000", "3000", "180", "test", "22", "222", }; var obj = new JumpPoint(test); Assert.AreEqual(1, obj.ID); Assert.AreEqual("test", obj.Name); Assert.AreEqual(2, obj.ZoneID); Assert.AreEqual(1000, obj.X); Assert.AreEqual(2000, obj.Y); Assert.AreEqual(3000, obj.Z); Assert.AreEqual(180, obj.HeadingDegrees); Assert.AreEqual(2, obj.AlsoInZoneID.Length); Assert.IsTrue(obj.AlsoInZoneID.Any(z => z == 22)); Assert.IsTrue(obj.AlsoInZoneID.Any(z => z == 222)); }
private void CheckSwipe() { readInput = false; secondClickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); playerPos = playerBeh.transform.position; GameObject[] pushers = GameObject.FindGameObjectsWithTag("Pusher"); List <GameObject> swipePushers = new List <GameObject>(); float prevSwipeAngle = 180f; if (Vector2.Distance(firstClickPosition, secondClickPosition) > 1f) //если длина больше 1 { foreach (GameObject pusher in pushers) //находим все доступные для свайпа пушеры { PlayerAction pusherAction = pusher.GetComponent <JumpPoint>().Action; if (pusherAction == PlayerAction.doubleJump || pusherAction == PlayerAction.question) { JumpPoint doubleJunmpPusher = pusher.GetComponent <JumpPoint>(); int diffV = Mathf.Abs(doubleJunmpPusher.Collumn - playerBeh.IdCollumn); int diffH = doubleJunmpPusher.Line - playerBeh.IdLine; if (diffH == 1 && diffV == 2) { swipePushers.Add(pusher); } } } foreach (GameObject pusher in swipePushers) //находим пушер к которому свайпнули { Vector2 pusherPos = pusher.transform.position; Vector2 normal = (pusherPos - playerPos).normalized; //по направлению к камню(не значку) Vector2 projection = new Vector3(playerPos.x, playerPos.y) + Vector3.Project(firstClickPosition - playerPos, normal); //Debug.DrawLine(playerPos, pusherPos); if (Vector2.Distance(projection, firstClickPosition) < 2.5f) //если расстояние меньше 2.5 { float angle = Vector2.Angle(normal, (secondClickPosition - firstClickPosition).normalized); if (angle < 35f && angle < prevSwipeAngle) //если угол меньше 35 и меньше предыдущего { prevSwipeAngle = angle; hitObject = pusher; //устанавливаем пушер к которому свайпнули action = PlayerAction.doubleJump; } } } } }
// Update is called once per frame void Update() { if ((Market.Instance.Health > 0 || LevelGenerator.Instance.IsRunLevel) && playerBeh) { if (Input.GetMouseButtonDown(0)) { if (EventSystem.current.IsPointerOverGameObject() || (Input.touchCount == 1 && EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))) { clickOverUI = true; } else { clickOverUI = false; } CheckClick(); } if (Input.GetMouseButtonUp(0)) { readInput = false; //CheckSwipe(); } if (Time.time > firstClickTime + waitTime && !readInput) //если истекло время ожидания и ввод не прочитан { if (hitObject != null && hitObject.GetComponent <Enemy>()) { if (Market.Instance.Bomb > 0) { hitObject.GetComponent <Enemy>().DestroyEnemy(); } } else if (!clickOverUI && Time.timeScale > 0f) { CheckDoubleClick(); CheckClimbAfterFall(); //Debug.Log("Do: " + action); PlayerInputAction.Invoke(action); } clickedPusher = null; clickedOnce = false; //сбрасываем первый клик readInput = true; } } }
private void JumpPoints_ListChanged(object sender, ListChangedEventArgs e) { BindingList <JumpPoint> list = sender as BindingList <JumpPoint>; if (e.ListChangedType == ListChangedType.ItemAdded) { JumpPoint jp = list[e.NewIndex]; foreach (SceenElement element in Elements) { if (element.SceenEntity as Star == jp.Parent) { CreateJumpPoint(element, jp); break; } } } }
public GameInput.PlayerAction GetQuestionPusherType(JumpPoint pusher) { var diffV = Mathf.Abs(pusher.Collumn - idCollumn); var diffH = Mathf.Abs(pusher.Line - idLine); GameInput.PlayerAction pusherType = GameInput.PlayerAction.climb; if (diffV == 0 && diffH == 1) { //подтягивание pusherType = GameInput.PlayerAction.climb; } else if ((diffV == 1 && diffH == 1) || (diffV == 1 && diffH == 0)) { //прыжок pusherType = pusher.Action = GameInput.PlayerAction.jump; } else if (diffV == 2 || diffH == 2) { //двойной прыжок pusherType = pusher.Action = GameInput.PlayerAction.doubleJump; } return(pusherType); }
private void CreateJumpPoint(SceenElement parent, JumpPoint oJumpPoint) { SceenElement oJumpPointElement = new JumpPointElement(oJumpPoint); oJumpPointElement.EntityID = oJumpPoint.Id; Vector3 v3JPPos = new Vector3((float)oJumpPoint.Position.X, (float)oJumpPoint.Position.Y, 0.0f); GLQuad oJPQuad = new GLUtilities.GLQuad(SceenDefaultEffect, v3JPPos, new Vector2(0.0001f, 0.0001f), // what size is a jump point anyway??? Color.Cyan, UIConstants.Textures.DEFAULT_JUMPPOINT_ICON); GLUtilities.GLFont oNameLable = new GLUtilities.GLFont(SceenDefaultEffect, v3JPPos, UIConstants.DEFAULT_TEXT_SIZE, Color.Cyan, UIConstants.Textures.DEFAULT_GLFONT2, oJumpPoint.Name); oJumpPointElement.Lable = oNameLable; oJumpPointElement.PrimaryPrimitive = oJPQuad; oJumpPointElement.AddPrimitive(oJPQuad); oJumpPointElement.RealSize = new Vector2(0.0001f, 0.0001f); parent.AddChildElement(oJumpPointElement); }
public void SetJumpPoint(Transform jumpPad, Transform landingPad) { jumpPoint = new JumpPoint(jumpPad.position, landingPad.position); }
IEnumerator GeneratorLines() { //Генератор линий и объектов на них GameObject objNewRock = null; //здесь будет наш новый пушер JumpPoint jumpPointRock = null; //компонент JumpPoint объекта _obj Vector3 pusherPos; //рандомная позиция JumpPoint newRock; //пушер GameObject parentLine; //линия для пушеров int posNewRock = 0; //позиция для нового пушера while (!GameController.Instance.OnBonusLevel) { yield return(null); } while (GameController.Instance.OnBonusLevel) //пока не создадим нужное кол-во линий { while ((transform.position.y - lastLinePusher.transform.position.y) < lineSpacing) //ждем пeред тем как построить новую линию { yield return(null); } bool[] SetCol = new bool[m_StartPositions.Length];; //флаги занятых колонок, для избежания создания пушеров в одной колонке int countPushersInLine = Random.Range(1, MaxItemsInLine + 1); //кол-во пушеров на линии //countPushersInLine = Mathf.Clamp(countPushersInLine, 1, Market.Instance.Seeds); parentLine = new GameObject(); //новая линия, будет родителем пушера/ов parentLine.transform.parent = pushersParent.transform; parentLine.name = idLine.ToString(); //даём ему имя for (int _pushId = 0; _pushId < countPushersInLine; _pushId++) //создаем необходимое кол-во пушеров на линию { posNewRock = Random.Range(0, m_StartPositions.Length); //получаем рандомную позицию из списка возможных //смотриим чтобы эта позиция не совпала с другим пушером var isSetPos = false; while (!isSetPos) { if (!SetCol[posNewRock]) { isSetPos = true; SetCol[posNewRock] = true; break; } else { posNewRock = Random.Range(0, m_StartPositions.Length); //иначе берём новую } } JumpPoint[] tempArray = identifyTypeOfJumpPoint(countPushersInLine, posNewRock); //определяем тип пушера newRock = tempArray[Random.Range(0, tempArray.Length)]; //выбираем внешний вид пушера prevCountJumpPoint = countPushersInLine; pusherPos = m_StartPositions[posNewRock].position; //выбираем позицию pusherPos += RandomizePos(0.25f, 0.25f); //немного изменяем позицию objNewRock = Instantiate(newRock.gameObject, pusherPos, newRock.transform.rotation) as GameObject; //рандомный lastLinePusher = objNewRock; if (!objNewRock.activeSelf) { objNewRock.SetActive(true); } jumpPointRock = objNewRock.GetComponent <JumpPoint>(); jumpPointRock.Line = idLine; //задаём пушеру линию, на которой он находится jumpPointRock.Collumn = posNewRock; //задаём пушеру колонку в которой он находится jumpPointRock.PrefBonus = GetBonus(); //задаём пушеру бонус posPrevJumpPoint = posNewRock; //запоминаем где создали jumpPointRock.Speed = m_SpeedJumpPoint; //задаём скорость пушера objNewRock.transform.parent = parentLine.transform; //делаем новый пушер "ребёнком" нового родителя newRock = null; jumpPointRock = null; tempArray = null; yield return(null); } CreateDecorations(SetCol); parentLine = null; currentLinesCount++; idLine++; //прикидываем имя для следующего родителя yield return(null); } }
public void AddJumpPoint(JumpPoint jumpPoint) { m_jumpPoints.Add(jumpPoint); }
public JumpPointElement(JumpPoint jp) : base() { m_oJumpPoint = jp; }
public void JumpToNextSegment() { if (m_endJumpPoint != null) { JumpAccuracy = Vector3.Distance(nextPlatformPosition, transform.position); JumpAccuracy *= difficulty; float old_speed = m_jumpSpeed; if (JumpAccuracy < 0.3f) { m_jumpSpeed += 2.0f; } else if (JumpAccuracy < 0.5f) { m_jumpSpeed += 1.0f; } else if (JumpAccuracy < 0.7f) { m_jumpSpeed -= 0.0f; } else if (JumpAccuracy < 1.0f) { m_jumpSpeed -= 1.0f; } else if (JumpAccuracy >= 1.5f) { m_jumpSpeed -= 3.0f; } SpeedChange = m_jumpSpeed - old_speed; } m_speed = m_jumpSpeed; m_beginJumpPoint = m_track.GetJumpPoint(m_nextPlatformIndex); m_endJumpPoint = m_track.GetJumpPoint(m_nextPlatformIndex + 1); m_beginJumpPoint = new JumpPoint(transform.position, null, m_endJumpPoint.Position); if (m_nextPlatformIndex < m_track.GetJumpPointCount() - 2) { m_endendJumpPoint = m_track.GetJumpPoint(m_nextPlatformIndex + 2); nextPlatformPosition = m_endJumpPoint.Position; } else { m_endendJumpPoint = m_endJumpPoint; } m_nextPlatformIndex++; SegmentTime = 0.0f; SegmentAngle = Physics.GetAngle(m_speed, m_beginJumpPoint.Distance, m_beginJumpPoint.HeightDifference); if (float.IsNaN(SegmentAngle)) { SegmentAngle = 45 * Mathf.Deg2Rad; } SegmentTotalTime = Physics.GetTotalTime(m_beginJumpPoint.Distance, m_speed, SegmentAngle); m_lookTarget = m_endJumpPoint.Position; }
public JumpPointBeat(JumpPoint inJumpPoint, int inBeat) { jumpPoint = inJumpPoint; beat = inBeat; }