public void OnPointerUp(PointerEventData eventData) { if (PlayerInstance.getInstance().IsOnPlatform) { // choosing next platform position if (PlayerInstance.getInstance().transform.position.y > PlatformsController.CurrentPlatform.transform.position.y) { PlayerInstance.getInstance().transform.SetParent(PlayerInstance.getInstance().MyParent); PlatformsController.CurrentPlatform.NextPos = PlatformsController.CurrentPlatform.Positions[rand.Next(PlatformsController.CurrentPlatform.Positions.Count)]; PlatformsController.CurrentPlatform.HasPlayerOn = false; PlatformsController.CurrentPlatform.IsOnJumpPos = false; PlatformsController.CurrentPlatform.Collider.isTrigger = true; } rulesPanel.SetActive(false); } touchLength.Stop(); PlayerInstance.getInstance().Jump(touchLength.ElapsedMilliseconds); touchLength.Reset(); if (PlatformsController.CurrentPlatform != null) { PlatformsController.CurrentPlatform.Collider.isTrigger = true; } }
// Start is called before the first frame update void Start() { if (PlayerPrefs.HasKey(StringConsts.CURRENT_CHARACTER)) { var characterTag = PlayerPrefs.GetString(StringConsts.CURRENT_CHARACTER); foreach (var character in charactersList) { if (character.tag == characterTag) { GameObject newCharacter = Instantiate(character, startPosition, Quaternion.identity); PlayerInstance.setInstance(newCharacter.GetComponent <PlayerBehaviour>()); EventsController.AddToFreezableItems(newCharacter.GetComponent <PlayerBehaviour>()); break; } } } else { PlayerPrefs.SetString(StringConsts.START_CHARACTER, StringConsts.EQUIPED); PlayerPrefs.SetString(StringConsts.CURRENT_CHARACTER, StringConsts.START_CHARACTER); foreach (var character in charactersList) { if (character.tag == StringConsts.START_CHARACTER) { GameObject newCharacter = Instantiate(character, startPosition, Quaternion.identity); PlayerInstance.setInstance(newCharacter.GetComponent <PlayerBehaviour>()); EventsController.AddToFreezableItems(newCharacter.GetComponent <PlayerBehaviour>()); } } } PlayerPrefs.Save(); }
void FixedUpdate() { if (!PlayerInstance.getInstance().IsOnGround&& rb.velocity == Vector2.zero) { rb.velocity = new Vector2(0f, MOVE_FORCE); } }
public static void ChangeCharacter(string newCharacterTag) { EventsController.RemoveFromFreezable(PlayerInstance.getInstance()); Destroy(PlayerInstance.getInstance().gameObject); foreach (var character in charactersList) { if (character.tag == newCharacterTag) { GameObject newCharacter = Instantiate(character, startPosition, Quaternion.identity); PlayerInstance.setInstance(newCharacter.GetComponent <PlayerBehaviour>()); EventsController.AddToFreezableItems(newCharacter.GetComponent <PlayerBehaviour>()); break; } } }