Beispiel #1
0
    private void OnTriggerExit(Collider other)
    {
        var player = other.gameObject.GetComponent <CharacterController>();

        if (player != null)
        {
            ModificationSystem.MakeChange(parent, changeType);
        }
    }
Beispiel #2
0
    private void Update()
    {
        SightZone sightZone   = GlobalState.get().sightZone;
        bool      inSightZone = sightZone.GetComponent <Collider>().bounds.Intersects(GetComponent <Collider>().bounds);

        if (holder.held == null && inSightZone && !gameObject.GetComponent <Renderer>().isVisible)
        {
            ModificationSystem.MakeChange(this, sightZone.changeType);
        }
    }
Beispiel #3
0
    public override void OnInteract()
    {
        bool inFacesZone = GlobalState.get().facesZone.GetComponent <Collider>().bounds.Intersects(parent.GetComponent <Collider>().bounds);

        if (parent.holder.held == null && inFacesZone)
        {
            ModificationSystem.MakeChange(parent, changeType);
        }
        parent.OnFace();
    }
Beispiel #4
0
 private void Update()
 {
     foreach (var box in countdowns.Keys.ToList())
     {
         var state = countdowns[box];
         if (!state.changing)
         {
             countdowns.Remove(box);
             continue;
         }
         state.countdown -= Time.deltaTime;
         if (state.countdown <= 0)
         {
             countdowns.Remove(box);
             ModificationSystem.MakeChange(box, changeType);
         }
     }
 }
    public void OnTriggerExit(Collider other)
    {
        Triggerable triggerable = other.GetComponent <Triggerable>();

        if (triggerable == null || countdown > 0)
        {
            return;
        }
        if (Input.GetKey(KeyCode.W))
        {
            countdown = cooldownSeconds;
            ModificationSystem.MakeChange(triggerable, forwardChange);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            countdown = cooldownSeconds;
            ModificationSystem.MakeChange(triggerable, backwardChange);
        }
    }
Beispiel #6
0
    public void SetShape(ShapeType type)
    {
        if (shapeType == type)
        {
            return;
        }
        bool cube  = type == ShapeType.CUBE;
        var  faces = GetComponentsInChildren <PickableFace>();

        foreach (var face in faces)
        {
            face.GetComponent <BoxCollider>().enabled = cube;
        }
        isInteractable = !cube;
        shapeType      = type;
        var shape = ModificationSystem.get().getShape(type);

        gameObject.GetComponent <MeshFilter>().mesh         = shape.mesh;
        gameObject.GetComponent <MeshCollider>().sharedMesh = shape.mesh;
    }
Beispiel #7
0
    private void SetMaterialAndColor(MaterialType materialType, ColorType colorType)
    {
        ColorAndMaterialType?type = null;

        switch (materialType)
        {
        case MaterialType.ABSTRACT:
            switch (colorType)
            {
            case ColorType.BLUE:
                type = ColorAndMaterialType.ABSTRACT_BLUE;
                break;

            case ColorType.GREY:
                type = ColorAndMaterialType.ABSTRACT_GREY;
                break;

            case ColorType.RED:
                type = ColorAndMaterialType.ABSTRACT_RED;
                break;

            case ColorType.YELLOW:
                type = ColorAndMaterialType.ABSTRACT_YELLOW;
                break;
            }
            break;

        case MaterialType.CHECKERED:
            switch (colorType)
            {
            case ColorType.BLUE:
                type = ColorAndMaterialType.CHECKERED_BLUE;
                break;

            case ColorType.GREY:
                type = ColorAndMaterialType.CHECKERED_GREY;
                break;

            case ColorType.RED:
                type = ColorAndMaterialType.CHECKERED_RED;
                break;

            case ColorType.YELLOW:
                type = ColorAndMaterialType.CHECKERED_YELLOW;
                break;
            }
            break;

        case MaterialType.MATTE:
            switch (colorType)
            {
            case ColorType.BLUE:
                type = ColorAndMaterialType.MATTE_BLUE;
                break;

            case ColorType.GREY:
                type = ColorAndMaterialType.MATTE_GREY;
                break;

            case ColorType.RED:
                type = ColorAndMaterialType.MATTE_RED;
                break;

            case ColorType.YELLOW:
                type = ColorAndMaterialType.MATTE_YELLOW;
                break;
            }
            break;

        case MaterialType.METAL:
            switch (colorType)
            {
            case ColorType.BLUE:
                type = ColorAndMaterialType.METAL_BLUE;
                break;

            case ColorType.GREY:
                type = ColorAndMaterialType.METAL_GREY;
                break;

            case ColorType.RED:
                type = ColorAndMaterialType.METAL_RED;
                break;

            case ColorType.YELLOW:
                type = ColorAndMaterialType.METAL_YELLOW;
                break;
            }
            break;
        }
        if (type == null)
        {
            throw new System.Exception("missing combination for: " + colorType + ", " + materialType);
        }
        this.colorType    = colorType;
        this.materialType = materialType;
        GetComponent <MeshRenderer>().material = ModificationSystem.get().getMaterial(type.Value).material;
    }