Exemplo n.º 1
0
    protected override bool CanPush(RaycastHit2D hit, Vector3 direction)
    {
        if (moving)
        {
            switch (hit.collider.tag)
            {
            case "Pushable":
                var trolley = hit.collider.GetComponent <Trolley>();
                if (trolley != null)
                {
                    trolley.Push(direction, false);
                    break;
                }
                break;

            case "Switchable":
                Switchable switchable = hit.collider.GetComponent <Switchable>();
                switchable.Switch(false);

                /*if (!GameWorld.dialogueOff && LevelManager.instance.Level == 5 && switchable.name.StartsWith("Mirror") && DialogueManager.CurrentDialogue == (DialogueManager.dialogueIndex[LevelManager.instance.Level] + 1))
                 * {
                 *  DialogueManager.DialogueComplete = GameWorld.GoBackToLevel;
                 *  GroupManager.main.activeGroup = GroupManager.main.group["Dialogue"];
                 *
                 *  return false;
                 * }*/
                break;
            }
        }

        return(false);
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     isOn           = false;
     spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
     onSprite       = spriteRenderer.sprite;
     parent         = this.transform.parent.gameObject.GetComponent <Switchable>();
 }
Exemplo n.º 3
0
 public static ISorterEval FullTest(this ISorter sorter)
 {
     return(sorter.Sort(Switchable.AllSwitchablesForKeyCount(sorter.KeyCount)
                        .ToSwitchableGroup(
                            guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(sorter.KeyCount),
                            keyCount: sorter.KeyCount)));
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     _myRenderer        = GetComponent <SpriteRenderer> ();
     _myRenderer.sprite = _sprites [0];
     _subjectScript     = _mySubject.GetComponent <Switchable> ();
     _isOn = true;
 }
Exemplo n.º 5
0
 private void Awake()
 {
     _renderer    = GetComponent <SpriteRenderer>();
     _switchable  = GetComponent <Switchable>();
     _collider    = GetComponent <BoxCollider2D>();
     _audioSource = GetComponent <AudioSource>();
 }
Exemplo n.º 6
0
    IEnumerator LightsCoroutine(Switchable item)
    {
        actualCamera.transform.GetChild(0).gameObject.SetActive(false);
        pickUpDestinationLocal.gameObject.SetActive(false);

        GameObject[] spinningLights = GameObject.FindGameObjectsWithTag("SpinningLight");
        ObjectToSeeTheLights.SetActive(true);
        yield return(new WaitForSeconds(3));

        foreach (var light in spinningLights)
        {
            photonView.RPC(nameof(TurnOffLight), RpcTarget.All, light.transform.GetComponent <PhotonView>().ViewID, item.transform.GetComponent <PhotonView>().ViewID);
        }
        yield return(new WaitForSeconds(1));

        ObjectToSeeTheLights.SetActive(false);
        camera.transform.GetChild(1).gameObject.SetActive(true);
        Debug.Log(camera.transform.GetChild(1).gameObject);
        yield return(new WaitForSeconds(2));

        camera.transform.GetChild(1).gameObject.SetActive(false);
        //camera.transform.GetChild(0).GetComponent<CinemachineVirtualCamera>().MoveToTopOfPrioritySubqueue();

        if (pickUpDestinationLocal.childCount > 0)
        {
            if (pickUpDestinationLocal.GetChild(0).GetComponent <Throwable>() != null)
            {
                actualCamera.transform.GetChild(0).gameObject.SetActive(true);
            }
        }
        pickUpDestinationLocal.gameObject.SetActive(true);

        yield break;
    }
Exemplo n.º 7
0
    void changeObjective(bool der)
    {
        print((-5) % 4);
        bool encontrado = false;
        int  i          = 0;

        while (i < allSwitchs.Length)
        {
            //print((allSwitchs[i].order) % allSwitchs.Length);
            if (!encontrado && der && (actual.order + 1) % allSwitchs.Length == (allSwitchs[i].order))
            {
                encontrado = true;
                actual     = allSwitchs[i];
                actual.changeColor(false);
            }
            else if (!encontrado && !der && actual.order == 0 && allSwitchs[i].order == allSwitchs.Length - 1)
            {
                encontrado = true;
                actual     = allSwitchs[i];
                actual.changeColor(false);
            }
            else if (!encontrado && !der && Mathf.Abs(actual.order - 1) % allSwitchs.Length == (allSwitchs[i].order))
            {
                encontrado = true;
                actual     = allSwitchs[i];
                actual.changeColor(false);
            }
            else
            {
                allSwitchs[i].changeColor(true);
            }
            i++;
        }
    }
Exemplo n.º 8
0
 // used to turn off lights
 public void SwitchOff(Switchable item)
 {
     if (!PlayerPrefs.HasKey("Hackerman"))
     {
         GetComponent <Achievements>()?.HackermanCompleted();
     }
     StartCoroutine(LightsCoroutine(item));
 }
Exemplo n.º 9
0
    private void Awake()
    {
        _switchable    = GetComponent <Switchable>();
        _colorReplacer = GetComponent <ColorReplacer>();

        // Start in disabled state, color sprite accordingly
        _colorReplacer.ReplacementColor = disabledColor;
        // Remember the current position of the platform in the Awake phase as position to return to
        _platformReturnPoint = platformToReturn.transform.position;
    }
Exemplo n.º 10
0
 private void notifyListeners()
 {
     if (listeners != null)
     {
         foreach (GameObject listener in listeners)
         {
             Switchable switchable = listener.GetComponent <Switchable>();
             switchable.turnOnOff(!currentlyInteracting);
         }
     }
 }
Exemplo n.º 11
0
        public IEnumerable <IEnumerable <ISorterEval> > RandomSorterTests(int seed, int keyCount,
                                                                          int switchLength)
        {
            KeyPairSwitchSet.Make <uint>(keyCount);
            var testSet = Switchable.AllSwitchablesForKeyCount(keyCount).ToSwitchableGroup(
                guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(keyCount),
                keyCount: keyCount);

            foreach (var chunk in RandomSorters(seed, keyCount, switchLength).Chunk(16))
            {
                yield return(chunk.AsParallel().Select(s => s.Sort(testSet)));
            }
        }
Exemplo n.º 12
0
 public void Update(IAtlas atlas)
 {
     if (m_isActive)
     {
         Switchable?.SwitchOn(null, atlas);
         m_isActive      = false;
         m_wasActive     = true;
         NextUpdateAfter = DELAY;
         return;
     }
     Switchable?.SwitchOff(null, atlas);
     NextUpdateAfter = 0;
     m_wasActive     = false;
 }
Exemplo n.º 13
0
        //public static ICompPool ToCompPoolParallel(
        //    this IEnumerable<ISorter> sorters
        //)
        //{
        //    var sortersList = sorters.ToList();
        //    var keyCount = sortersList[0].KeyCount;
        //    KeyPairSwitchSet.Make<uint>(keyCount);
        //    var switchables = Switchable.AllSwitchablesForKeyCount(keyCount).ToSwitchableGroup
        //        (
        //            guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(keyCount),
        //            keyCount: keyCount
        //        );

        //    return new CompPoolImpl(
        //            sorterEvals: sortersList.AsParallel().Select(s => s.Sort(switchables)),
        //            keyCount: keyCount
        //        );
        //}

        public static ICompPool AddSorterEvalsParallel(this ICompPool compPool,
                                                       IEnumerable <ISorter> sorters)
        {
            KeyPairSwitchSet.Make <uint>(compPool.KeyCount);
            var switchables = Switchable.AllSwitchablesForKeyCount(compPool.KeyCount).ToSwitchableGroup
                              (
                guid: SwitchableGroup.GuidOfAllSwitchableGroupsForKeyCount(compPool.KeyCount),
                keyCount: compPool.KeyCount
                              );

            return(new CompPoolImpl(
                       sorterEvals: compPool.SorterEvals.Concat(sorters.AsParallel().Select(s => s.Sort(switchables))),
                       keyCount: compPool.KeyCount
                       ));
        }
Exemplo n.º 14
0
    private void Awake()
    {
        _switchable = GetComponent <Switchable>();

        objectsToSave = autoDiscoveredTags
                        .SelectMany(GameObject.FindGameObjectsWithTag)
                        .Select(gameObject => gameObject.GetComponent <Guid>())
                        .Where(maybeGuid =>
        {
            if (maybeGuid is null)
            {
                Debug.LogError(
                    "All objects for which a position shall be saved must have a Guid component. However, while searching for objects to save by the given tags, there was one included without a Guid component");
                return(false);
            }

            return(true);
        })
                        .Concat(objectsToSave)
                        .ToArray();
    }
Exemplo n.º 15
0
    private Color _beforeActivationColor; // Color used by the ColorReplacer before applying this effect

    private void Awake()
    {
        _colorReplacer = GetComponent <ColorReplacer>();
        _switchable    = GetComponent <Switchable>();
    }
Exemplo n.º 16
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas)
 {
     Switchable = Switchable.Switch(null, atlas);
 }
Exemplo n.º 17
0
 public Switch(Switchable switchable)
 {
     this.switchable = switchable;
 }
Exemplo n.º 18
0
 private int Index(Switchable token)
 {
     converter.index = -1;
     token.Apply(converter);
     return converter.index;
 }
Exemplo n.º 19
0
 // Start is called before the first frame update
 void Awake()
 {
     _switchable = this.GetComponent <Switchable>();
 }
Exemplo n.º 20
0
 public SwitchOffCommand(Switchable switchableItem) : base(switchableItem)
 {
 }
Exemplo n.º 21
0
 public SwitchCommand(Switchable switchableItem)
 {
     this.SwitchableItem = switchableItem;
 }
Exemplo n.º 22
0
    private bool CanMove()
    {
        objectPushing = null;

        movement = nextMovement;

        // Get the next position
        var nextPosition = previousPosition + nextMovement;

        // Check collisions
        var hit = Physics2D.Raycast(nextPosition, nextMovement, 0.0f);

        if (hit.collider == null)
        {
            return(true);
        }

        //Debug.Log("Collided with " + hit.collider.name + " [" + hit.collider.tag + "].");

        switch (hit.collider.tag)
        {
        case "Wall":
            return(false);

        case "Pushable":
            var pushable = hit.collider.GetComponent <Pushable>();
            var canPush  = pushable.Push(nextMovement);

            if (canPush && hit.transform.name.StartsWith("Trolley"))
            {
                StartAction();
            }

            canMove = canPush && pushable.MovingWithPlayer;
            if (canMove)
            {
                objectPushing            = pushable.transform;
                previousPushablePosition = objectPushing.position;
            }

            return(canMove);

        case "Collectible":
            var collectible = hit.collider.GetComponent <Collectible>();
            collectible.Collect();

            return(true);

        case "Accessible":
            var accessible = hit.collider.GetComponent <Accessible>();

            return(accessible.Enter());

        case "Switchable":
            if (canSwitch)
            {
                Switchable switchable = hit.collider.GetComponent <Switchable>();
                switchable.Switch(true);
                Debug.Log("Switchy!");

                canSwitch           = false;
                lastSwitchDirection = nextMovement;

                if (!switchable.name.StartsWith("Patient"))
                {
                    StartAction();
                }
            }
            return(false);

        default:
            return(true);
        }
    }
Exemplo n.º 23
0
 // Start is called before the first frame update
 void Start()
 {
     allSwitchs = GameObject.FindObjectsOfType <Switchable>();
     actual     = allSwitchs[0];
     actual.changeColor(false);
 }
Exemplo n.º 24
0
 void Start()
 {
     target         = targetObj.GetComponent <Switchable>();
     spriteRenderer = GetComponentInChildren <SpriteRenderer>();
     audioSource    = GetComponent <AudioSource>();
 }
Exemplo n.º 25
0
 private int Index(Switchable token)
 {
     converter.index = -1;
     token.Apply(converter);
     return(converter.index);
 }
Exemplo n.º 26
0
 void Awake()
 {
     _audioSource = GetComponent <AudioSource>();
     _switchable  = GetComponent <Switchable>();
     _switch      = GetComponent <Switch>();
 }
Exemplo n.º 27
0
 public ExplosionTask(Switchable switchable)
 {
     Switchable = switchable;
     Delay      = 0;
 }
Exemplo n.º 28
0
 // Adds a switchable type (trap) to the list
 public void AddSwitchable(Switchable switchable)
 {
     traps.Add(switchable);
 }
Exemplo n.º 29
0
 public void Awake()
 {
     _switchable  = GetComponent <Switchable>();
     _renderer    = GetComponent <SpriteRenderer>();
     _audioSource = GetComponent <AudioSource>();
 }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        if (cinemachineBrain.ActiveVirtualCamera as CinemachineVirtualCamera != Camera.GetComponent <CinemachineVirtualCamera>())
        {
            return;
        }

        bool canInteract = interactableInRange && !character.HasItem();

        if (canInteract)
        {
            Interactable newInteractable = null;

            try
            {
                newInteractable = interactableObject.GetComponent <Interactable>();
            }
            catch
            {
                //Debug.Log("Interactable is null");
            }


            //currentInteractable = newInteractable;

            if (newInteractable != null)
            {
                //Debug.Log("current interactable has a pick up script");
                if (((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0)))
                {
                    if (newInteractable.GetComponent <Breakable>() != null)
                    {
                        //photonView.RPC("SetBreakHandsInactive", GetComponent<PhotonView>().Owner);
                        SetBreakHandsInactive();
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }
                //d is for opening
                //u is closing

                if (Input.GetKeyDown(KeyCode.E))
                {
                    if (newInteractable.GetComponent <Openable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if (PoseParser.GETGestureAsString().CompareTo("D") == 0)
                {
                    if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == false)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if (PoseParser.GETGestureAsString().CompareTo("U") == 0)
                {
                    if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == true)
                    {
                        newInteractable.PrimaryInteraction(character);
                        return;
                    }
                }

                if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newInteractable.GetComponent <Breakable>() == null && newInteractable.GetComponent <Openable>() == null)
                {
                    if (newInteractable.GetComponent <Switchable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                    }
                    else if (newInteractable.GetComponent <Droppable>() != null)
                    {
                        newInteractable.PrimaryInteraction(character);
                        //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner);
                        SetPressDropToNotActive();
                    }
                    else
                    {
                        currentInteractable = newInteractable;
                        currentInteractable.GetComponent <Outline>().enabled = false;
                        // Debug.Log("F was pressed");

                        currentInteractable.PrimaryInteraction(character);
                    }
                }
            }
        }
        // if we are holding something, we are limited to the possible interactions
        else if (currentInteractable != null)
        {
            // check if there is a bag nearby as we can still pickup bags if we are holding an item
            Grabbable  newBag          = null;
            Switchable newSwitch       = null;
            Droppable  dropBag         = null;
            Breakable  breakableObject = null;
            Openable   openableObject  = null;
            try
            {
                newBag = interactableObject.GetComponent <Grabbable>();
            }
            catch
            {
                //Debug.Log("rock is null");
            }

            try
            {
                newSwitch = interactableObject.GetComponent <Switchable>();
            }
            catch
            {
                //Debug.Log("switch is null");
            }

            try
            {
                dropBag = interactableObject.GetComponent <Droppable>();
            }
            catch
            {
                //Debug.Log("switch is null");
            }

            try
            {
                breakableObject = interactableObject.GetComponent <Breakable>();
            }
            catch
            {
                //Debug.Log("breakable is null");
            }

            try
            {
                openableObject = interactableObject.GetComponent <Openable>();
            }
            catch
            {
                //Debug.Log("Opanable is null");
            }
            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0) && openableObject != null)
            {
                openableObject.PrimaryInteraction(character);
            }

            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newBag != null)
            {
                newBag.PrimaryInteraction(character);
            }

            if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newSwitch != null)
            {
                newSwitch.PrimaryInteraction(character);
            }

            if (Input.GetKeyDown(KeyCode.E) && dropBag != null)
            {
                dropBag.PrimaryInteraction(character);
                //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner);
                SetPressDropToNotActive();
            }

            if (Input.GetKeyDown(KeyCode.E) && breakableObject != null)
            {
                breakableObject.PrimaryInteraction(character);
            }
            // press G to drop/throw item
            if (Input.GetKeyDown(KeyCode.G))
            {
                // we drop/throw item and turn off its outline
                currentInteractable.SecondaryInteraction(character);
                currentInteractable.GetComponent <Outline>().enabled = true;
                currentInteractable = null;
            }
            else

            if ((Input.GetMouseButtonDown(0) || PoseParser.GETGestureAsString().CompareTo("R") == 0) && currentInteractable.GetComponent <Throwable>() != null)
            {
                currentInteractable.GetComponent <Throwable>().ThrowRock(character);
                currentInteractable.GetComponent <Outline>().enabled = true;
                currentInteractable = null;
            }
            else
            // if item is shootable
            if (Input.GetMouseButtonDown(0) && currentInteractable.GetComponent <Shootable>() != null)
            {
                //Debug.Log(currentInteractable);
                currentInteractable.GetComponent <Shootable>().ShootGun(character);
            }
        }
    }
Exemplo n.º 31
0
        public void AllSwitchablesForKeyCount()
        {
            const int keyCountSize = 8;

            Assert.AreEqual(Switchable.AllSwitchablesForKeyCount(keyCountSize).ToArray().Length, Math.Pow(2, keyCountSize));
        }