This repository has been archived on 2026-05-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
CompuLogic/Assets/Scripts/GameManager.cs
T
2020-12-10 13:18:02 +01:00

86 lines
1.8 KiB
C#
Executable File

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
#region Static Properties
public static GameManager Instance { get; set; }
#endregion
#region Unity Properties
[Header("Prefabs")]
public Cable CablePrefab;
[Header("Groups")]
public Transform GatesGroup;
public Transform CablesGroup;
[Header("Colors")]
public Color DeadColor;
public Color ActivatedColor;
#endregion
#region Public Properties
public Anchor CurrentAnchor { get; set; }
#endregion
#region Private Properties
private Cable _currentCable;
#endregion
#region Unity Methods
// Start is called before the first frame update
private void Start()
{
if (Instance != null)
throw new InvalidOperationException("More than one GameManager in scene");
Instance = this;
}
// Update is called once per frame
private void Update()
{
if (Input.GetMouseButton(0))
{
if (CurrentAnchor != null && _currentCable == null)
{
_currentCable = Instantiate(CablePrefab, CablesGroup, true);
_currentCable.StartAnchor = CurrentAnchor;
}
}
else if (_currentCable != null)
{
if (CurrentAnchor == null || _currentCable.StartAnchor.IsInput == CurrentAnchor.IsInput)
{
Destroy(_currentCable.gameObject);
}
else
{
_currentCable.EndAnchor = CurrentAnchor;
}
_currentCable = null;
}
}
#endregion
#region Public Methods
#endregion
#region Private Methods
#endregion
}