public override ShortAction ProduceShortAction() { var currentSubLocation = gameObject.transform.parent.parent; Debug.Assert (currentSubLocation != null, "Object should be child of Location/Characters"); if (!currentSubLocation.name.Equals (_targetSublocation)) { var nextSublocationName = SublocationUtils.GetNextSublocationInRoute(currentSubLocation.name, _targetSublocation); var action = new MoveToTheSublocationShortAction (nextSublocationName); action.actionSource = gameObject; action.actionTarget = gameObject; return action; } else { return null; } }
public void Move(string sublocationName) { var player = GameObject.Find ("Characters/Player"); var producerComponent = player.GetComponent<ShortActionsProducerComponent> (); var producer = producerComponent.actionsProducer as PlayerShortActionsProducer; var action = new MoveToTheSublocationShortAction (sublocationName); action.actionSource = player; action.actionTarget = player; producer.SetShortAction (action); TimeMachine.Instance.ExecuteShortActions (); Application.LoadLevel (sublocationName); }