Ejemplo n.º 1
0
        private void AddDistractionToRandomStranger(DistractionComponent component, TouristBrainComponent brain)
        {
            if (!brain || !component)
            {
                return;
            }

            brain.States.GoToState(new PickingInterest());

            switch (component.DistractionType)
            {
            case DistractionType.Tiger:
                var comp = brain.AddComponent <TigerDistractionTouristComponent>();
                comp.CreatedFrom = component;
                comp.LastDistractionProgressTime = component.DistractionInteractionDuration;
                return;

            case DistractionType.Butterfly:
                var butterflyComp = brain.AddComponent <ButterflyDistractionTouristComponent>();
                butterflyComp.CreatedFrom = component;
                butterflyComp.LastDistractionProgressTime = component.DistractionInteractionDuration;
                return;

            case DistractionType.Spider:
                var spiderComp = brain.AddComponent <SpiderDistractionTouristComponent>();
                spiderComp.CreatedFrom = component;
                spiderComp.LastDistractionProgressTime = component.DistractionInteractionDuration;
                return;

            case DistractionType.Money:
                var moneyComp = brain.AddComponent <MoneyDistractionTouristComponent>();
                moneyComp.CreatedFrom = component;
                moneyComp.LastDistractionProgressTime = component.DistractionInteractionDuration;
                return;

            case DistractionType.Bus:
                var busComp = brain.AddComponent <BusDistractionTouristComponent>();
                busComp.CreatedFrom = component;
                busComp.LastDistractionProgressTime = component.DistractionInteractionDuration;
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
        private static void DriveAway(BusDistractionTouristComponent component, TouristBrainComponent touristBrain)
        {
            component.LastDistractionProgressTime -= Time.deltaTime;

            var bus               = GameObject.FindGameObjectWithTag("bus");
            var busComponent      = bus.GetComponent <BusComponent>();
            var movementComponent = bus.GetComponent <MovementComponent>();

            touristBrain.transform.parent = bus.transform;

            if (component.LastDistractionProgressTime <= 0)
            {
                component.DistractionProgress.Value = 1;
                movementComponent.Direction.Value   = busComponent.EndPosititon - (Vector2)component.transform.position;
            }

            component.DistractionProgress.Value = 1 - component.LastDistractionProgressTime / component.MaxProgressTime;
        }
Ejemplo n.º 3
0
 private static void StartInteracting(BusDistractionTouristComponent component, TouristBrainComponent touristBrain)
 {
     component.UpdateAsObservable()
     .Where(_ => component)
     .Subscribe(_ => DriveAway(component, touristBrain))
     .AddToLifecycleOf(component);
 }