// ************************* private void HandleOnDragBegin(Model.Gun.Part part) { if (OnDragBegin != null) { OnDragBegin(part); } }
private void HandleOnDragEnd(Model.Gun.Part part) { if (OnDragEnd != null) { OnDragEnd(part); } }
private void Start() { if (_partToPickup == null) { var rand = Random.Range(0, _partPrefabs.Count); var prefab = Instantiate(_partPrefabs[rand]); _partToPickup = prefab.GetPart(); } ; }
// ************************* private void AddRow(Model.Gun.Part part) { var row = Instantiate(_gunPartRowPrefab); row.transform.SetParent(_content, false); row.SetPart(part); row.OnDragBegin += HandleOnDragBegin; row.OnDragEnd += HandleOnDragEnd; }
public void AddPartToGraph(Model.Gun.Part part, bool moving = false) { // create an instance based on the model name var prefab = Resources.Load(part.PrefabName) as GameObject; var instance = Instantiate(prefab); // set transform of new part controller instance.transform.SetParent(_content, false); instance.transform.rotation = Quaternion.Euler(part.Rotation); instance.transform.position = part.Position; // add new part to the object graph var component = instance.GetComponent <Elements.GunCrafting.Part>(); _partsOnGraph.Add(component); // inject ((IPartGraphSubpanel)component).Inject(this); // set actions component.Stats = part.Stats; component.HasBeenSet += SetPart; component.HasBeenUnset += UnsetPart; // if moving start if (moving) { component.InitMoving(); } else { component.InitAtLocation(); } // calculate new path SetNeedToRecalulatePath(); }