Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        AbilityPickup pickup = other.gameObject.GetComponentInChildren <AbilityPickup>();

        if (pickup != null)
        {
            switch (pickup.ability)
            {
            case AbilityPickup.Ability.Jump:
                allowJump = true;
                break;

            case AbilityPickup.Ability.Pickup:
                Debug.Log("Enable pickup");
                allowPickup = true;
                break;

            case AbilityPickup.Ability.WalkLeft:
                allowLeftMovement = true;
                break;

            case AbilityPickup.Ability.WalkRight:
                allowRightMovement = true;
                break;
            }
            Destroy(pickup.gameObject);
        }
        InsertZone insert = other.gameObject.GetComponent <InsertZone>();

        if (insert != null)
        {
            Debug.Log("Add insert " + insert.name);
            inserts.Add(insert.insert);
        }
    }
Example #2
0
    private void OnTriggerExit(Collider other)
    {
        InsertZone insert = other.gameObject.GetComponent <InsertZone>();

        if (insert != null && interactable != null && insert == interactable)
        {
            interactable = null;
        }
    }
Example #3
0
    private void OnTriggerEnter(Collider other)
    {
        InsertZone insert = other.gameObject.GetComponent <InsertZone>();

        if (insert != null)
        {
            interactable = insert;
        }
    }
Example #4
0
    private void Update()
    {
        if (currentPlug && insertZone)
        {
            Plug temp = currentPlug;
            currentPlug = null;
            temp.InteractWithInsert(insertZone);
            insertZone = null;
        }

        if (currentPlug != null)
        {
            currentPlug.transform.position = plugPoint.transform.position;
            currentPlug.transform.rotation = Quaternion.Euler(-90, 0, 0);
        }

        bool hasPower = providesPower;

        if (!hasPower && currentPlug)
        {
            hasPower = currentPlug.HasPower();
        }

        if (hasPower != isPowered)
        {
            isPowered = hasPower;

            if (isPowered)
            {
                foreach (WirePowerAction action in powerActions)
                {
                    action.OnPowerEnabledInternal();
                }
            }
            else
            {
                foreach (WirePowerAction action in powerActions)
                {
                    action.OnPowerDisabledInternal();
                }
            }

            Color color = isPowered ? Color.green : Color.white;

            foreach (LineRenderer renderer in lineRenderers)
            {
                renderer.startColor = color;
                renderer.endColor   = color;
            }
        }
    }
Example #5
0
 public void InteractWithInsert(InsertZone insert)
 {
     interactable = insert;
     Interact();
 }