Newer
Older
HardPoint-Project-Abertay-University-Unity3D / Assets / Content / Developers / Miguel / MiguelToys / Cheats.cs
@Rackday Rackday on 18 Aug 2024 1 KB Project Added
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Cheats : MonoBehaviour
{
    bool noClip = false;
    [SerializeField] private int noClipLayer;
    [SerializeField] private int defaultLayer;

    HealthSystem healthSystem;
    StatusEffects statusEffects;
    float dmg = 0;
    void Start()
    {
        Physics.IgnoreLayerCollision(noClipLayer, defaultLayer);
        healthSystem= GetComponent<HealthSystem>();
        statusEffects= GetComponent<StatusEffects>();
        dmg = statusEffects.damage;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.anyKey)
        {
            if (Input.GetKeyDown(KeyCode.N))
            {
                if (!noClip)
                    gameObject.layer = noClipLayer;
                else gameObject.layer = defaultLayer;
                noClip = !noClip;
            }
            if (Input.GetKeyDown(KeyCode.I))
            {
                healthSystem.immortal = !healthSystem.immortal;
            }
            if (Input.GetKeyDown(KeyCode.K))
            {
                if (statusEffects.damage == dmg) statusEffects.damage = float.MaxValue;
                else statusEffects.damage = dmg;
            }
        }
    }
}