mirror of
https://github.com/evgen-app/steampunk-quest.git
synced 2025-02-08 02:10:32 +03:00
88 lines
2.9 KiB
C#
88 lines
2.9 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using System;
|
||
using UnityEngine.SceneManagement;
|
||
|
||
public class blohaManager : MonoBehaviour
|
||
{
|
||
|
||
[SerializeField] private GameObject dialog;
|
||
[SerializeField] private GameObject WinDialog;
|
||
|
||
[SerializeField] private GameObject filter;
|
||
[SerializeField] private float speed;
|
||
[SerializeField] private VariableJoystick variableJoystick;
|
||
[SerializeField] private List<GameObject> labirints;
|
||
private Rigidbody2D rb;
|
||
private Vector3 startPosition;
|
||
private bool showDialog = false;
|
||
|
||
private void Start()
|
||
{
|
||
rb = gameObject.GetComponent<Rigidbody2D>();
|
||
startPosition = gameObject.transform.position;
|
||
Instantiate(labirints[PlayerPrefs.GetInt("chestNumber")], gameObject.transform.parent);
|
||
}
|
||
public void FixedUpdate()
|
||
{
|
||
Vector2 direction = Vector2.up * variableJoystick.Vertical + Vector2.right * variableJoystick.Horizontal;
|
||
|
||
if(direction.x != 0 && direction.y != 0)
|
||
{
|
||
if (direction.x > 0)
|
||
{
|
||
gameObject.transform.rotation = Quaternion.Euler(0f, 0f, -Convert.ToSingle(180 / Math.PI * (Math.Acos(direction.y / (Math.Sqrt(direction.x * direction.x + direction.y * direction.y))))));
|
||
|
||
}
|
||
else
|
||
{
|
||
gameObject.transform.rotation = Quaternion.Euler(0f, 0f, Convert.ToSingle(180 / Math.PI * (Math.Acos(direction.y / (Math.Sqrt(direction.x * direction.x + direction.y * direction.y))))));
|
||
|
||
}
|
||
}
|
||
|
||
rb.AddForce(direction * speed * Time.fixedDeltaTime);
|
||
if (showDialog && (Input.touchCount > 0 || Input.anyKeyDown))
|
||
{
|
||
dialog.SetActive(false);
|
||
filter.SetActive(false);
|
||
showDialog = false;
|
||
gameObject.transform.position = startPosition;
|
||
gameObject.transform.rotation = new Quaternion();
|
||
rb.angularVelocity = 0f;
|
||
|
||
}
|
||
}
|
||
private void OnCollisionEnter2D(Collision2D collision)
|
||
{
|
||
if (collision.gameObject.tag == "aim")
|
||
{
|
||
Debug.Log("<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
Destroy(collision.gameObject);
|
||
WinDialog.SetActive(true);
|
||
filter.SetActive(true);
|
||
|
||
}
|
||
else
|
||
{
|
||
dialog.SetActive(true);
|
||
filter.SetActive(true);
|
||
showDialog = true;
|
||
rb.velocity = new Vector2(0f, 0f);
|
||
gameObject.transform.position = startPosition;
|
||
}
|
||
}
|
||
public void chestOpen()
|
||
{
|
||
PlayerPrefs.SetInt("chest" + PlayerPrefs.GetInt("chestNumber").ToString(), 1);
|
||
Debug.Log(PlayerPrefs.GetInt("chest" + PlayerPrefs.GetInt("chestNumber").ToString()));
|
||
Debug.Log("chest" + PlayerPrefs.GetInt("chestNumber").ToString());
|
||
SceneManager.UnloadScene("BlohaGame");
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
|
||
}
|
||
|
||
|