Skip to content

Commit

Permalink
HW1 Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
syedjawadakhtar committed Mar 1, 2023
1 parent 96e965c commit 7df7fd0
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
34 changes: 34 additions & 0 deletions HW1/Scripts/ChangeLight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class ChangeLight : MonoBehaviour
{
public InputActionReference changeLight;
Light chnglight;
// Start is called before the first frame update
void Start()
{
changeLight.action.Enable();
}

// Update is called once per frame
void Update()
{
chnglight = GetComponent<Light>();

if (chnglight.color == Color.white){
changeLight.action.performed += (ctx) =>
{
chnglight.color = Color.blue;
};
}
if (chnglight.color == Color.blue){
changeLight.action.performed += (ctx) =>
{
chnglight.color = Color.white;
};
}
}
}
19 changes: 19 additions & 0 deletions HW1/Scripts/MoonRotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoonRotation : MonoBehaviour
{
public float degreesPerSecond = 10.0f;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
transform.Rotate(0, 0, degreesPerSecond * Time.deltaTime);
}
}
38 changes: 38 additions & 0 deletions HW1/Scripts/PlayerTransform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;


public class PlayerTransform : MonoBehaviour
{
public InputActionReference tf;
private Vector3 InitialPosition = new Vector3(0.0f, 4.0f, -6.5f);
private Vector3 TransformPosition = new Vector3(-23.5f, 17.5f, -10f);

// tf = GetComponent<transform>();

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
tf.action.Enable();
if (transform.position == InitialPosition){
tf.action.performed += (ctx) =>
{
transform.position = TransformPosition;
};
}
if (transform.position == TransformPosition){
tf.action.performed += (ctx) =>
{
transform.position = InitialPosition;
};
}
}
}
27 changes: 27 additions & 0 deletions HW1/Scripts/Quit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class Quit : MonoBehaviour
{
public InputActionReference action;
// Start is called before the first frame update
void Start()
{

}

void Update()
{
action.action.Enable();
action.action.performed += (ctx) =>
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
};
}
}
19 changes: 19 additions & 0 deletions HW1/Scripts/RotateSphere.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateSphere : MonoBehaviour
{
public float degreesPerSecond = 10.0f;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
transform.Rotate(0, degreesPerSecond * Time.deltaTime, 0);
}
}

0 comments on commit 7df7fd0

Please sign in to comment.