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
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Jump") && playerIsTouching)
     {
         switchable.Switch(true);
         spriteRenderer.color = Color.red;
     }
 }
Exemplo n.º 3
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.º 4
0
 public void Switch()
 {
     toSwitch.Switch();
     hasFlipped = true;
 }
Exemplo n.º 5
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas)
 {
     Switchable = Switchable.Switch(null, atlas);
 }
Exemplo n.º 6
0
 public void SwitchState()
 {
     audioSource.Play();
     target.Switch();
     UpdateSprite();
 }
Exemplo n.º 7
0
 public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table)
 {
     Switchable = Switchable.Switch(null, atlas, table);
 }