示例#1
0
    // Reset the state of interactable with given siteID and spotID
    public static string resetInteractable(string input)
    {
        string[] stringInputs = input.Split(null);
        if (stringInputs.Length <= 2)
        {
            return("Invalid parameters: please enter a siteID and spotID.");
        }
        int[] intInput  = new int[2];
        bool  validInts = true;

        for (int i = 0; i < intInput.Length; i++)
        {
            validInts = int.TryParse(stringInputs[i], out intInput[i]) && validInts;
        }

        if (!validInts)
        {
            return("Invalid parameters: please use integers");
        }

        foreach (Interactable item in InteractableManager.InteractableList)
        {
            if (item.ID.siteID == intInput[0] && item.ID.spotID == intInput[1])
            {
                item.ActionIndex = 0;
                InteractableState state = item.stateData.states[item.ActionIndex];
                state.enterState(item);
                //item.HighlightInteractable(true, true);
                item.interactableUI.SetActionUI(item.ActionIndex);
                return("resetting interactable at site: " + intInput[0] + " and spot: " + intInput[1]);
            }
        }

        return("Could not find interactable at site: " + intInput[0] + " and spot: " + intInput[1]);
    }
示例#2
0
    protected void InitAudienceInteractable(AudienceInteractable audInt)
    {
        InteractableState state = Random.value > 0.5 ? InteractableState.negative : InteractableState.positive;

        audInt.InitializeInteractable(roomName, state, this);
        audienceInteractables.Add(audInt);
    }
示例#3
0
        private void onMouseMove(object sender, MouseMoveEventArgs e)
        {
            if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
            {
                if (_state == InteractableState.Normal)
                {
                    _state = InteractableState.Hover;
                    Entered?.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (_state == InteractableState.Hover)
                {
                    _state = InteractableState.Normal;
                    Exited?.Invoke(this, EventArgs.Empty);
                }
            }

            if (_state == InteractableState.Down)
            {
                tickX       = MathUtil.Clamp(GlobalX, GlobalX + barBitmap.Width, inputEngine.Mouse.X) - GlobalX - tickBitmap.Width / 2.0d;
                needsUpdate = true;
                ValueChanged?.Invoke(this, EventArgs.Empty);
            }
        }
示例#4
0
    public AudienceInteractable GetInteractableOfType(int ID, InteractableState state)
    {
        List <AudienceInteractable> interactablesToCheck;
        List <AudienceInteractable> interactableOptions = new List <AudienceInteractable>();

        // Start with current room
        Room roomToCheck = currentRoom;

        // Get Interactables from room
        interactablesToCheck = roomToCheck.GetInteractables();

        foreach (AudienceInteractable audInt in interactablesToCheck)
        {
            if (audInt.GetID() == ID && audInt.state == state)
            {
                interactableOptions.Add(audInt);
            }
        }

        if (interactableOptions.Count > 0)
        {
            // Pick one
            int randomIndex = Random.Range(0, interactableOptions.Count);

            return(interactableOptions[randomIndex]);
        }
        // We need to check all nearby rooms
        else
        {
            for (int i = currentRoom.X - 1; i < currentRoom.X + 2; i++)
            {
                for (int j = currentRoom.Z - 1; j < currentRoom.Z + 2; j++)
                {
                    // Make sure this spot is not out of bounds and not current room
                    if ((i > 0 && i < col) && (j > 0 && j < row) && roomLayout[i, j] != null && roomLayout[i, j] != currentRoom)
                    {
                        interactablesToCheck = roomLayout[i, j].GetInteractables();

                        foreach (AudienceInteractable audInt in interactablesToCheck)
                        {
                            if (audInt.GetID() == ID && audInt.state == state)
                            {
                                interactableOptions.Add(audInt);
                            }
                        }
                    }
                }
            }

            if (interactableOptions.Count > 0)
            {
                // Pick one
                int randomIndex = Random.Range(0, interactableOptions.Count);

                return(interactableOptions[randomIndex]);
            }
        }

        return(null);
    }
示例#5
0
 private void onMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
     {
         if (_state != InteractableState.Down)
         {
             if (_downTexture != null)
             {
                 /*bool update = false;
                  * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
                  *      update = true;
                  * }*/
                 Texture = atlas.GetTexture(_downTexture);
                 //if (update) {
                 _hitBox.X      = 0.0d;
                 _hitBox.Y      = 0.0d;
                 _hitBox.Width  = Width;
                 _hitBox.Height = Height;
                 //}
             }
             _state = InteractableState.Down;
             Pressed?.Invoke(this, EventArgs.Empty);
         }
     }
 }
示例#6
0
 public void FadeToDisabled()
 {
     if (state != InteractableState.DisabledVisible)
     {
         animationWrapper.StartNewAnimation(FadeToDisabledAnim());
         state = InteractableState.DisabledVisible;
     }
 }
示例#7
0
 public void FadeOut()
 {
     if (state != InteractableState.Invisible)
     {
         animationWrapper.StartNewAnimation(FadeOutAnim());
         state = InteractableState.Invisible;
     }
 }
示例#8
0
 protected override void OnStateChange(InteractableState state)
 {
     switch (state)
     {
     case InteractableState.clicked:
         _audioSource.Play();
         break;
     }
 }
        public void ForceResetButton()
        {
            var oldState = CurrentButtonState;

            CurrentButtonState = InteractableState.Default;
            InteractableStateChanged?.Invoke(new InteractableStateArgs(this, null,
                                                                       CurrentButtonState, oldState, new ColliderZoneArgs(ContactCollider, Time.frameCount,
                                                                                                                          null, InteractionType.Exit)));
        }
示例#10
0
 public void Enable()
 {
     if (State != InteractableState.Disabled)
     {
         return;
     }
     _registry.Register((TInteractable)this);
     State = InteractableState.Normal;
 }
示例#11
0
 public InteractableStateArgs(Interactable interactable, InteractableTool tool,
                              InteractableState newInteractableState, InteractableState oldState,
                              ColliderZoneArgs colliderArgs)
 {
     Interactable         = interactable;
     Tool                 = tool;
     NewInteractableState = newInteractableState;
     OldInteractableState = oldState;
     ColliderArgs         = colliderArgs;
 }
示例#12
0
 private void onMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
     {
         if (_state != InteractableState.Down)
         {
             _state = InteractableState.Down;
             Pressed?.Invoke(this, EventArgs.Empty);
         }
     }
 }
示例#13
0
 public virtual void Interact(PlayerController playerController)
 {
     if (_state == InteractableState.Activated)
     {
         AddPlayerToOperateMachine(playerController);
         if (CheckIfMachineCanBeStarted())
         {
             _state = InteractableState.Blocked;
             RunMinigame();
         }
     }
 }
示例#14
0
 public void FadeIn()
 {
     if (state != InteractableState.Enabled)
     {
         animationWrapper.StartNewAnimation(FadeInAnim());
         state = InteractableState.Enabled;
     }
     if (showKey)
     {
         return;
     }
     UpdateTutorial();
 }
示例#15
0
        public void InRange(InteractableState state)
        {
            switch (state)
            {
            case InteractableState.DisabledVisible:
                hideIndicator.FadeToDisabled();
                break;

            case InteractableState.Enabled:
                hideIndicator.FadeIn();
                break;
            }
        }
示例#16
0
 public void Lazer(float amount)
 {
     if (state != InteractableState.Ready)
     {
         return;
     }
     charge += amount;
     if (charge > maxCharge)
     {
         charge      = maxCharge;
         state       = InteractableState.Proccesing;
         actualColor = colorOverDisCharge;
     }
 }
示例#17
0
 private void UpdateState()
 {
     if (SelectingInteractorsCount > 0)
     {
         State = InteractableState.Select;
         return;
     }
     if (InteractorsCount > 0)
     {
         State = InteractableState.Hover;
         return;
     }
     State = InteractableState.Normal;
 }
示例#18
0
    public override void InitializeInteractable(string name, InteractableState state, Room room)
    {
        isMovingTripwire = mover.move;

        base.InitializeInteractable("Laser Grid " + name, state, room);

        if (mustStartOn)
        {
            state = InteractableState.negative;
        }

        if (state == InteractableState.positive)
        {
            for (int j = 0; j < tripwireLasers.Length; ++j)
            {
                tripwireLasers[j].gameObject.SetActive(false);
            }

            mover.move = false;

            p1.SetActive(true);
            p2.SetActive(true);
        }
        else
        {
            if (isMovingTripwire)
            {
                mover.move = true;
            }

            p1.SetActive(false);
            p2.SetActive(false);
        }

        int i = 0;

        foreach (TripwireLaser child in tripwireLasers)
        {
            TripwireLaser laser = tripwireLasers[i];

            if (laser)
            {
                laser.Initialize(this);
            }
            i++;
        }

        ID = 7;
    }
示例#19
0
    public void GotoState(InteractableStateType key)
    {
        if (!states.ContainsKey(key))
        {
            return;
        }

        currentState?.Exit();

        previousState    = currentState;
        CurrentStateType = key;
        currentState     = states[CurrentStateType];

        currentState.Enter();
    }
示例#20
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }
示例#21
0
        public void InRange(InteractableState state)
        {
            if (runningDialogue)
            {
                return;
            }

            switch (state)
            {
            case InteractableState.DisabledVisible:
                enterIndicator.FadeToDisabled();
                break;

            case InteractableState.Enabled:
                enterIndicator.FadeIn();
                break;
            }
        }
示例#22
0
    public virtual void DeactivateMachine()
    {
        if (machine.gameType != GameType.TEA && machine.gameType != GameType.PERISCOPE)
        {
            ActiveMachines.RemoveActiveMachine();
        }

        _alarmController.TurnOff();
        _state = InteractableState.Deactivated;

        foreach (var playerController in _playerControllers)
        {
            playerController.SetPlayerStatus(PlayerStatus.Free);
        }

        _playerControllers.Clear();
        Invoke("ClearActivationStarted", Random.Range(0f, 5f));
    }
示例#23
0
 public void doAction(int actionIndex)
 {
     if (stateData == null)
     {
         Debug.Log(this.name + " Error: StateData is null");
         return;
     }
     else if (stateData.states.Count == 0)
     {
         Debug.Log(this.name + " Error: States is empty");
         return;
     }
     else
     {
         InteractableState state = stateData.states[actionIndex];
         state.enterState(this);
     }
 }
示例#24
0
 private void onMouseMove(object sender, MouseMoveEventArgs e)
 {
     if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
     {
         if (_state == InteractableState.Normal)
         {
             if (_hoverTexture != null)
             {
                 /*bool update = false;
                  * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
                  *      update = true;
                  * }*/
                 Texture = atlas.GetTexture(_hoverTexture);
                 //if (update) {
                 _hitBox.X      = 0.0d;
                 _hitBox.Y      = 0.0d;
                 _hitBox.Width  = Width;
                 _hitBox.Height = Height;
                 //}
             }
             _state = InteractableState.Hover;
             Entered?.Invoke(this, EventArgs.Empty);
         }
     }
     else
     {
         if (_state == InteractableState.Hover)
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Normal;
             Exited?.Invoke(this, EventArgs.Empty);
         }
     }
 }
示例#25
0
 private void UpdateInteractableState()
 {
     if (State == InteractableState.Disabled)
     {
         return;
     }
     if (SelectingInteractorsCount > 0)
     {
         State = InteractableState.Select;
     }
     else if (InteractorsCount > 0)
     {
         State = InteractableState.Hover;
     }
     else
     {
         State = InteractableState.Normal;
     }
 }
示例#26
0
    public override void InitializeInteractable(string name, InteractableState state, Room room)
    {
        base.InitializeInteractable("Door " + name, state, room);

        anim = transform.GetChild(0).GetComponent <Animator>();

        if (state == InteractableState.negative)
        {
            anim.SetBool("Open", false);
            state = InteractableState.negative;
        }
        else
        {
            anim.SetBool("Open", true);
            state = InteractableState.negative;
        }

        ID = 1;
    }
示例#27
0
 private void onMouseMove(object sender, MouseMoveEventArgs e)
 {
     if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
     {
         if (_state == InteractableState.Normal)
         {
             _state = InteractableState.Hover;
             Entered?.Invoke(this, EventArgs.Empty);
         }
     }
     else
     {
         if (_state == InteractableState.Hover)
         {
             _state = InteractableState.Normal;
             Exited?.Invoke(this, EventArgs.Empty);
         }
     }
 }
示例#28
0
    protected override void OnStateChange(InteractableState state)
    {
        switch (state)
        {
        case InteractableState.normalHover:
            SetMaterial(_hovered);
            break;

        case InteractableState.clicked:
            SetMaterial(_clicked);
            break;

        case InteractableState.clickedHover:
            SetMaterial(_clickedHovered);
            break;

        default:
        case InteractableState.normal:
            SetMaterial(_normal);
            break;
        }
    }
示例#29
0
    private void Update()
    {
        switch (state)
        {
        case InteractableState.Ready:
            charge = Mathf.Max(charge - dischargePerSecondAmount * Time.deltaTime, 0f);
            break;

        case InteractableState.Proccesing:
            charge = Mathf.Max(charge - dischargePerSecondAmount * 50f * Time.deltaTime, 0f);
            if (charge == 0f)
            {
                //launchPOWER
                state              = InteractableState.Cooling;
                actualColor        = colorOverCooldown;
                actualCooldownTime = 0f;
                StartCoroutine(LaunchZoneurEffect());
            }
            break;

        case InteractableState.Cooling:
            actualCooldownTime += Time.deltaTime;
            if (actualCooldownTime > coolDownTime)
            {
                state       = InteractableState.Ready;
                actualColor = colorOverCharge;
            }
            break;

        default:
            break;
        }
        foreach (Renderer renderer in visualChargeRenderers)
        {
            renderer.material.SetColor("_GlowColor", actualColor.Evaluate(charge / maxCharge));
            Vector3 localPosition = renderer.transform.localPosition;
            renderer.transform.localPosition = new Vector3(localPosition.x, initialVerticalChargePosition + chargeHigh * charge / maxCharge, localPosition.z);
        }
    }
示例#30
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = (_hoverTexture != null) ? atlas.GetTexture(_hoverTexture) : atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }