using System;
using UnityEngine;
using UnityEngine.UI;
public class Console_Input : MonoBehaviour
{
public bool Enabled;
private Vector3 PosConsole;
private Vector3 PosInfo;
private int input_Num;
private string[] input_list;
private GameObject inputField;
private global::GameManager GM;
private global::Player_Control PC;
private void Start()
{
this.GM = GameObject.Find("GameManager").GetComponent<global::GameManager>();
this.PC = GameObject.Find("Player").GetComponent<global::Player_Control>();
this.input_list = new string[10];
this.inputField = GameObject.Find("InputField");
this.PosConsole = GameObject.Find("Console").GetComponent<RectTransform>().localPosition;
this.PosInfo = GameObject.Find("Text_Info").GetComponent<RectTransform>().localPosition;
this.Console_Off();
}
private void Update()
{
if (this.GM.Paused)
{
if (this.Enabled)
{
this.Console_Off();
}
}
else
{
if (this.Enabled)
{
this.Info_Text();
this.Console_Text_List();
if (GameObject.Find("InputField").GetComponent<InputField>().isFocused)
{
if (!this.GM.onConsole)
{
this.GM.onConsole = true;
GameObject.Find("InputField").GetComponent<Image>().color = new Color(0.2f, 0.1f, 1f, 0.6f);
}
}
else if (this.GM.onConsole)
{
this.GM.onConsole = false;
GameObject.Find("InputField").GetComponent<Image>().color = new Color(1f, 1f, 1f, 0.25f);
}
}
if (Input.GetKeyDown(KeyCode.F4))
{
if (this.Enabled)
{
this.Console_Off();
}
else
{
this.Console_ON();
}
}
}
}
private void Console_ON()
{
this.Enabled = true;
GameObject.Find("Console_BG").GetComponent<SpriteRenderer>().enabled = true;
GameObject.Find("Console").GetComponent<RectTransform>().localPosition = this.PosConsole;
GameObject.Find("Text_Info").GetComponent<RectTransform>().localPosition = this.PosInfo;
GameObject.Find("InputField").GetComponent<InputField>().Select();
GameObject.Find("InputField").GetComponent<InputField>().ActivateInputField();
GameObject.Find("InputField").GetComponent<InputField>().text = string.Empty;
}
private void Console_Off()
{
this.Enabled = false;
this.GM.onConsole = false;
GameObject.Find("Text_Info").GetComponent<Text>().text = string.Empty;
GameObject.Find("Console_BG").GetComponent<SpriteRenderer>().enabled = false;
GameObject.Find("Console").GetComponent<RectTransform>().localPosition = new Vector3(-3500f, 2500f, 0f);
GameObject.Find("Text_Info").GetComponent<RectTransform>().localPosition = new Vector3(-3500f, 2500f, 0f);
}
private void Console_Text_List()
{
string text = string.Empty;
if (this.input_Num > 0)
{
for (int i = this.input_Num - 1; i >= 0; i--)
{
text += this.input_list[i];
if (i > 0)
{
text += "\n";
}
}
}
if (GameObject.Find("Text_Console_List") != null)
{
GameObject.Find("Text_Console_List").GetComponent<Text>().text = text;
}
}
private void CharacterField(string inputFieldString)
{
if (inputFieldString != string.Empty)
{
int num;
if (this.input_Num < 10)
{
this.input_Num++;
num = this.input_Num - 1;
}
else
{
num = 9;
}
if (num > 0)
{
for (int i = num; i > 0; i--)
{
this.input_list[i] = this.input_list[i - 1];
}
}
this.input_list[0] = inputFieldString;
GameObject.Find("InputField").GetComponent<InputField>().Select();
GameObject.Find("InputField").GetComponent<InputField>().ActivateInputField();
GameObject.Find("InputField").GetComponent<InputField>().text = string.Empty;
this.Console_Text_List();
global::StageManager component = GameObject.Find("StageManager").GetComponent<global::StageManager>();
int num2 = -1;
if (int.TryParse(inputFieldString, out num2))
{
Debug.Log(num2);
if (num2 < component.Room.Length)
{
GameObject.Find("Player").GetComponent<global::Player_Control>().Lock_GameLoad();
component.Go_Room(num2, 0, 0f, 0f, true);
}
}
else
{
Debug.Log("Can't Parse to int...");
}
}
}
private void Info_Text()
{
if (GameObject.Find("Player") != null)
{
string text = " State: " + this.PC.State;
string text2 = text;
text = string.Concat(new object[]
{
text2,
"\n HP: ",
this.GM.HP,
" / ",
this.GM.HP_Max.ToString()
});
text2 = text;
text = string.Concat(new object[]
{
text2,
"\n MP: ",
this.GM.MP,
" / ",
this.GM.MP_Max
});
text = text + "\n\n Vel: " + this.GM.Velcocity;
text = text + "\nrgVel: " + GameObject.Find("Player").rigidbody2D.velocity;
text = text + "\n\n Jump: " + this.PC.Jump_Num;
text = text + "\n HJump: " + this.PC.onHighJump;
text = text + "\n Ground: " + this.PC.grounded_Now;
text = text + "\n onDrop: " + this.PC.onJumpDrop;
text = text + "\n\n Cam: " + GameObject.Find("Main Camera").camera.orthographicSize.ToString("f2");
GameObject.Find("Text_Info").GetComponent<Text>().text = text;
}
}
}