using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
private Dictionary<string, Action<RaycastHit>> _commands;
private void Start()
{
_commands = new Dictionary<string, Action<RaycastHit>>();
_commands.Add("StartDoor", StartDoor);
_commands.Add("NidDoor", NidDoor);
_commands.Add("ClosedDoor", ClosedDoor);
_commands.Add("StartKey", StartKey);
_commands.Add("StartBook", StartBook);
_commands.Add("StartTurnOnLight", StartTurnOnLight);
_commands.Add("SecoundFloorTOL", SecoundFloorTOL);
_commands.Add("FirstFloorRestRoom", FirstFloorRestRoom);
_commands.Add("FlashLight", FlashLight);
_commands.Add("Battery", Battery);
_commands.Add("ShellR1", ShellR1);
_commands.Add("ShellL1", ShellL1);
}
private void Update()
{
RaycastHit hit;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
int mask = 1 << LayerMask.NameToLayer(nameOfMask) | layerMask.value;
if (Physics.Raycast(transform.position, fwd, out hit, rayLenght, mask))
{
string tag = hit.collider.tag;
if (_commands.ContainsKey(tag))
_commands[tag].Invoke(hit);
}
}
private void ShellL1(RaycastHit hit)
{
OpenShell("ShellLO", "ShellLC", hit);
}
private void ShellR1(RaycastHit hit)
{
OpenShell("ShellRO", "ShellRC", hit);
}
private void Battery(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
Destroy(hit.collider.gameObject);
scr_Torch.countBattery++;
}
}
private void FlashLight(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
Destroy(hit.collider.gameObject);
haveFlash = true;
}
}
private void FirstFloorRestRoom(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
scr_TurnOnLight.TurnOnLight(firstFloorRR, scr_TurnOnLight.firstRestRoom);
firstFloorRR = !firstFloorRR;
}
}
private void SecoundFloorTOL(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
scr_TurnOnLight.TurnOnLight(secoundF, scr_TurnOnLight.secoundF);
secoundF = !secoundF;
}
}
private void StartTurnOnLight(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
scr_TurnOnLight.TurnOnLight(startLight, scr_TurnOnLight.start);
startLight = !startLight;
}
//TurnOnLight(startLight, startLights);
}
private void StartBook(RaycastHit hit)
{
VisibleChrosshair();
BookOpening(0);
}
private void StartKey(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
haveStartKey = true;
Destroy(hit.collider.gameObject);
}
}
private void ClosedDoor(RaycastHit hit)
{
VisibleChrosshair();
if (Input.GetKeyDown(interactingKey))
{
subtitles.text = "Закрыто";
scr_Main.ShowSubtitles();
}
}
private void NidDoor(RaycastHit hit)
{
VisibleChrosshair();
scr_Door = hit.collider.gameObject.GetComponent<SCR_Door>();
if (Input.GetKeyDown(interactingKey))
scr_Door.PlayAnimation();
}
private void StartDoor(RaycastHit hit)
{
if (!doOnce)
{
scr_Door = hit.collider.gameObject.GetComponent<SCR_Door>();
isChrosshairChange(true);
}
if (haveStartKey)
{
if (Input.GetKeyDown(interactingKey))
scr_Door.PlayAnimation();
}
else
if (Input.GetKeyDown(interactingKey))
{
subtitles.text = "Закрыто";
scr_Main.ShowSubtitles();
}
}
}