dynamic loading of gate prefabs

This commit is contained in:
klemek
2020-12-19 20:02:15 +01:00
parent 205a663e07
commit 972a689d9c
61 changed files with 5685 additions and 7662 deletions
+16 -2
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VectorGraphics;
using UnityEngine;
using UntitledLogicGame.Workspace;
@@ -26,6 +27,9 @@ namespace UntitledLogicGame
[Header("Prefabs")]
public Cable CablePrefab;
public Gate GatePrefab;
public Anchor AnchorPrefab;
public Anchor BigAnchorPrefab;
[Header("Groups")]
public Transform GatesGroup;
@@ -36,12 +40,14 @@ namespace UntitledLogicGame
public Color ActivatedColor;
[Header("Gates")]
public List<Gate> GatePrefabs;
public TextAsset GateBook;
public List<Sprite> GateSprites;
#endregion
#region Public Properties
public List<Gate> GatePrefabs { get; set; }
public Anchor CurrentAnchor { get; set; }
public Gate CurrentGate { get; set; }
public PointerManager PointerManager
@@ -64,6 +70,13 @@ namespace UntitledLogicGame
#region Unity Methods
private void Start()
{
var factory = gameObject.AddComponent<GatePrefabFactory>();
factory.Init(GatePrefab, AnchorPrefab, BigAnchorPrefab, GateSprites);
GatePrefabs = factory.GeneratePrefabs(GateBook);
}
#endregion
#region Public Methods
@@ -71,6 +84,7 @@ namespace UntitledLogicGame
public void CreateGate(Gate gatePrefab)
{
var gate = Instantiate(gatePrefab, GatesGroup);
gate.gameObject.SetActive(true);
gate.transform.position = PointerManager.MousePos - gate.Box.transform.position;
PointerManager.DragGate(gate, true);
}