private void DropInRoom(Worker worker, SnapTarget snapTarget) { SnapTarget openSnapTarget = GameController.FindOpenSnapTargetOfType( snapTarget.GetType() ); dragObject.EndDrag(openSnapTarget); }
public void EndDrag(SnapTarget snapTarget) { if(snapTarget != null) // Set pos to snapTarget { if(currentSnapTarget != null) { lastSnapTarget = currentSnapTarget; //Debug.Log("setting lastSnapTarget to " + currentSnapTarget.ToString()); } if(snapTarget.isEmpty()) currentSnapTarget = snapTarget; // If snapTarget is empty, snap to it else currentSnapTarget = GameController.FindOpenSnapTargetOfType( snapTarget.GetType() ); // else, find empty snapTarget of same type } else // Set pos to lastSnapTarget { if(lastSnapTarget == null || !lastSnapTarget.isEmpty()) // If lastSnapTarget is null or not empty, find empty snapTarget of same type lastSnapTarget = GameController.FindOpenSnapTargetOfType( SnapTargetType.Workstation ); currentSnapTarget = lastSnapTarget; } //Debug.Log("currentSnapTarget " + currentSnapTarget + " , lastSnapTarget " + lastSnapTarget); if(currentSnapTarget != null && lastSnapTarget != null) // Check For timeInRoom reset { //Debug.Log(""+currentSnapTarget.GetType() +", "+lastSnapTarget.GetType()); if(currentSnapTarget.GetType() != lastSnapTarget.GetType()) timeInRoom = 0f; // If switched room type, reset timeInRoom } Debug.Log("Worker.timeInRoom = " + timeInRoom); if(currentSnapTarget == null) return; currentSnapTarget.SetWorker(this); // Fill currentSnapTarget Vector3 pos = currentSnapTarget.GetPosition(); //pos.y = 0.5f; pos.y = 0.0f; SetPosition( pos ); gameObject.layer = 9; // Default Layer // Get Animation Name from currentSnapTarget Debug.Log ("Play animation " + currentSnapTarget.animation +", Stop animation "+ currentAnimation); anim.SetBool(currentAnimation, false); currentAnimation = currentSnapTarget.animation; anim.SetBool(currentAnimation, true); }