Fixed small visual bugs

This commit is contained in:
weedmjac000
2026-01-21 10:56:26 -07:00
parent fc5efd89bf
commit 649345ec01
814 changed files with 1649 additions and 8 deletions

View File

@@ -0,0 +1,211 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//Designed by Jacob Weedman
//Component of the "MainCamera" game object
public class CameraMovement : MonoBehaviour
{
GameObject target;
GameObject player;
GameObject TempPos;
GameObject query;
public bool TargetingPlayer = true;
float CameraTweenAmmount = 0.005f;
float CameraTweenRateX;
float CameraTweenRateY;
float MaxCameraTweenRate = 50f;
float MinCameraTweenRate = 0.01f;
public float MaxCameraDistance = 15f;
public List<GameObject> InitialPanDestinations;
Vector3 StartLocation;
public float shakeDuration;
public float shakeAmount;
public float shakeInterval = 0.01f; //sec
public float currentShakeInterval = 0.01f; // sec
public float MinZoom = 10;
public float MaxZoom = 7;
public float PlayerVelocity;
public float ZoomAmmount;
public float TargetZoom;
void Start()
{
InitialPanDestinations = GameObject.FindGameObjectsWithTag("PanDestinations").ToList();
target = GameObject.Find("CameraTarget");
player = GameObject.FindWithTag("Player");
transform.position = new Vector3(target.transform.position.x, target.transform.position.y, -10);
float distance = 1000000;
foreach (GameObject query in InitialPanDestinations)
{
if (Vector2.Distance(query.transform.position, target.transform.position) < distance)
{
distance = Vector2.Distance(query.transform.position, target.transform.position);
TempPos = query;
}
}
if (TempPos == null)
{
TempPos = target;
}
target.transform.position = TempPos.transform.position;
TargetZoom = 0;
}
void Update()
{
// Zoom based on player velocity
if (GameObject.Find("Player"))
{
if (ZoomAmmount < TargetZoom)
{
TargetZoom -= Time.deltaTime * 2;
}
if (ZoomAmmount > TargetZoom)
{
TargetZoom += Time.deltaTime * 2;
}
PlayerVelocity = Math.Abs(GameObject.Find("Player").GetComponent<Rigidbody2D>().linearVelocity.x + GameObject.Find("Player").GetComponent<Rigidbody2D>().linearVelocity.y);
ZoomAmmount = MinZoom - PlayerVelocity / 10;
if (ZoomAmmount > MinZoom)
{
ZoomAmmount = MinZoom;
}
// Fix this later
//gameObject.GetComponent<UnityEngine.Rendering.Universal.PixelPerfectCamera>().assetsPPU = DOTween.To(()=> gameObject.GetComponent<UnityEngine.Rendering.Universal.PixelPerfectCamera>().assetsPPU, CameraTweenRateX=> gameObject.GetComponent<UnityEngine.Rendering.Universal.PixelPerfectCamera>().assetsPPU = CameraTweenRateX, Mathf.RoundToInt(TargetZoom));
}
// Difference between camera and target; abs()
CameraTweenRateX = (Math.Abs(target.transform.position.x - transform.position.x));
CameraTweenRateY = (Math.Abs(target.transform.position.y - transform.position.y));
// Ensure the Tween Rate stays between the Max and Min values
if (CameraTweenRateX > MaxCameraTweenRate)
{
CameraTweenRateX = MaxCameraTweenRate;
}
if (CameraTweenRateX < MinCameraTweenRate)
{
transform.position = new Vector3(target.transform.position.x, transform.position.y, transform.position.z);
}
if (CameraTweenRateY > MaxCameraTweenRate)
{
CameraTweenRateY = MaxCameraTweenRate;
}
if (CameraTweenRateY < MinCameraTweenRate)
{
transform.position = new Vector3(transform.position.x, target.transform.position.y, transform.position.z);
}
// Camera Shake
if (shakeDuration > 0) {
if (currentShakeInterval <= 0)
{
currentShakeInterval = shakeInterval;
transform.localPosition = new Vector3(UnityEngine.Random.Range(-shakeAmount, shakeAmount) + StartLocation.x, UnityEngine.Random.Range(-shakeAmount, shakeAmount) + StartLocation.y, -10);
}
else
{
currentShakeInterval -= Time.deltaTime;
}
shakeInterval += 0.15f * Time.deltaTime;
shakeAmount -= 0.15f * Time.deltaTime;
shakeDuration -= Time.deltaTime;
}
else
{
StartLocation = transform.position;
shakeDuration = 0.0f;
shakeAmount= 0.0f;
shakeInterval = 0.01f;
// Move Camera
transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10), Vector2.Distance(transform.position, target.transform.position) / 100);
}
//Initial Pan
if (InitialPanDestinations.Count > 0)
{
// Lock player movement
if (Vector2.Distance(transform.position, TempPos.transform.position) < 0.5) // Camera at destination
{
InitialPanDestinations.Remove(TempPos);
TempPos = player;
float distance = 1000000;
foreach (GameObject query in InitialPanDestinations)
{
if (Vector2.Distance(query.transform.position, target.transform.position) < distance)
{
distance = Vector2.Distance(query.transform.position, target.transform.position);
TempPos = query;
}
}
target.transform.position = TempPos.transform.position;
}
else
{
target.transform.position = TempPos.transform.position;
}
}
else
{
// Hide Level Start UI
if (GameObject.Find("LevelName"))
{
Destroy(GameObject.Find("LevelName"));
}
if (GameObject.Find("BEGIN!"))
{
GameObject.Find("BEGIN!").transform.localScale = new Vector3(1, 1, 1);
}
if (Vector2.Distance(target.transform.position, transform.position) <= 0.5)
{
Destroy(GameObject.Find("BEGIN!"));
}
// Unlock player movement
// Look ahead feature based on right click
if (TargetingPlayer == true && Input.GetMouseButton(1) == true)
{
Vector3 pointer;
int speed = 10;
pointer = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pointer.z = transform.position.z;
target.transform.position = Vector3.MoveTowards(new Vector2(player.transform.position.x, player.transform.position.y + 5), pointer, MaxCameraDistance);
}
// Reset target to player position
else if (TargetingPlayer == true && Input.GetMouseButton(1) == false)
{
target.transform.position = new Vector2(player.transform.position.x, player.transform.position.y + 5);
}
}
}
public void shakeCamera(float duration, float intensity)
{
shakeDuration = duration;
shakeAmount = intensity;
shakeInterval = 0.01f;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2bdbfad5ec190e4488be58c471118030

View File

@@ -0,0 +1 @@
uid://duskgoh8vpaqv

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Designed by Jacob Weedman
//Belongs to the "CurrentSector" GameObject in the "LevelSelector" scene
//V 0.0.1
public class CurrentSector : MonoBehaviour
{
void Update()
{
if (GameObject.Find("GameData").GetComponent<GameData>().CurrentSector != "0")
{
tag = GameObject.Find("GameData").GetComponent<GameData>().CurrentSector;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7b9028922fb64154ca926e86537eac14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1 @@
uid://d1ii7t7s6p85a

View File

@@ -0,0 +1,69 @@
using UnityEngine;
public class GenericDamager : MonoBehaviour
{
// Designed by Jacob Weedman
// Attatch to any game object you want to damage something
public bool DamagePlayer = true;
public bool DamageEnemy;
public float Damage = 10;
public float InitialDamageInterval = 0.5f; // sec
public float DamageInterval;
public bool CurrentlyColliding = false;
public bool CanDamage = true;
public bool LockDamage = false;
// Update is called once per frame
void FixedUpdate()
{
if (CurrentlyColliding)
{
if (DamageInterval >= InitialDamageInterval)
{
CanDamage = true;
DamageInterval = 0;
}
else
{
DamageInterval += Time.deltaTime;
}
}
}
void OnTriggerStay2D(Collider2D collision)
{
if (CanDamage == true && LockDamage == false)
{
if (collision.GetComponent<MasterEnemyAI>() && DamageEnemy == true)
{
CanDamage = false;
collision.GetComponent<MasterEnemyAI>().Health -= Damage;
}
if (collision.gameObject.tag == "Player" && DamagePlayer == true)
{
CanDamage = false;
GameObject.Find("GameData").GetComponent<GameData>().CurrentHealth -= Damage;
}
}
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.GetComponent<MasterEnemyAI>() && DamageEnemy == true || collision.gameObject.tag == "Player" && DamagePlayer == true)
{
CurrentlyColliding = true;
}
}
void OnTriggerExit2D(Collider2D collision)
{
if (collision.GetComponent<MasterEnemyAI>() && DamageEnemy == true || collision.gameObject.tag == "Player" && DamagePlayer == true)
{
CurrentlyColliding = false;
DamageInterval = 0;
CanDamage = true;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 36e33107b86d6a6409607ac152ef21a3

View File

@@ -0,0 +1 @@
uid://u0ykaldd82e2

View File

@@ -0,0 +1,31 @@
using UnityEngine;
public class GenericDestructable : MonoBehaviour
{
// Designed by Jacob Weedman
public string mode = "DESTROY"; // "DESTROY". "DISABLE"
public bool AttackableByPlayer = true;
public float Health = 100;
// Update is called once per frame
void Update()
{
if (Health <= 0)
{
switch (mode)
{
case "DESTROY":
Destroy(gameObject);
break;
case "DISABLE":
gameObject.tag = "Destroyed";
GetComponent<GenericDestructable>().enabled = false;
break;
default:
break;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0b7225176776f6e42846d398232f7ea0

View File

@@ -0,0 +1 @@
uid://cw6hq63xt4tdx

View File

@@ -0,0 +1,77 @@
using UnityEngine;
using UnityEngine.UI;
public class HealthBarManager : MonoBehaviour
{
private float playerHealth;
public float sliderValue = 100.0f;
public GameObject centerBar;
private Transform centerBarTransform;
public GameObject rightBar;
private Transform rightBarTransform;
public Image centerBarSprite;
public Image rightBarSprite;
// public Image leftBarSprite;
private float shownHealth;
public Image skullSprite;
private Transform centerBarPosition;
private float centerBarOriginalHeight;
private float centerBarOriginalWidth;
private Vector2 originalSizeDelta;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
centerBarOriginalWidth = centerBarSprite.sprite.rect.width;
centerBarOriginalHeight = centerBarSprite.sprite.rect.height;
skullSprite.enabled = false;
originalSizeDelta = centerBarSprite.rectTransform.sizeDelta;
}
// Update is called once per frame
void FixedUpdate()
{
playerHealth = GameObject.Find("GameData").GetComponent<GameData>().CurrentHealth;
if (playerHealth > 0)
{
centerBarSprite.enabled = true;
rightBarSprite.enabled = true;
// leftBarSprite.enabled = true;
skullSprite.enabled = false;
shownHealth = playerHealth;
}
else
{
shownHealth = 0;
centerBarSprite.enabled = false;
rightBarSprite.enabled = false;
// leftBarSprite.enabled = false;
skullSprite.enabled = true;
}
// add lerp function for health
float healthIncrement = (shownHealth - sliderValue) * 0.1f;
sliderValue += healthIncrement;
centerBarSprite.rectTransform.sizeDelta = new Vector2(originalSizeDelta.x * sliderValue / 100.0f, originalSizeDelta.y);
// centerBarPosition = centerBar.GetComponent<Transform>();
centerBarTransform = centerBar.GetComponent<Transform>();
centerBarTransform.position += Vector3.right * healthIncrement * 1.1f;
rightBarTransform = rightBar.GetComponent<Transform>();
rightBarTransform.position += Vector3.right * healthIncrement * 2f * 1.1f;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4f40028be8d216449b6baf8d5a30f7f7

View File

@@ -0,0 +1 @@
uid://djmba654n8wny

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Designed by Jacob Weedman
//Place this script on any of the background elements you want paralax to apply to
public class Background : MonoBehaviour
{
float length;
float startposX;
float startposY;
GameObject camera;
float LAYER_MODULATOR;
float ParalaxStrength = 0.3f;
float yOffset = 1f;
public bool FixedOnCamera = false;
public bool looping = false;
void Awake()
{
startposX = transform.position.x;
startposY = transform.position.y;
length = GetComponentInChildren<SpriteRenderer>().bounds.size.x;
LAYER_MODULATOR = transform.position.z;
camera = GameObject.FindWithTag("MainCamera");
}
void Update()
{
float temp = (camera.transform.position.x * (1 - (LAYER_MODULATOR * ParalaxStrength * 0.1f)));
float distanceX = (camera.transform.position.x * ParalaxStrength) / LAYER_MODULATOR;
//float distanceY = (camera.transform.position.y * LAYER_MODULATOR * ParalaxStrength * 0.1f);
if (FixedOnCamera)
{
transform.position = new Vector3(camera.transform.position.x, camera.transform.position.y, transform.position.z);
}
else
{
transform.position = new Vector3((startposX + distanceX), transform.position.y, transform.position.z);
}
if (looping == true)
{
if (temp > startposX + length)
{
startposX += length;
}
else if (temp < startposX - length)
{
startposX -= length;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e4faa9b2b0de0ac43932ea144c9308a6

View File

@@ -0,0 +1 @@
uid://nr70h3am6fmd

View File

@@ -0,0 +1,19 @@
using UnityEngine;
public class Teleporter : MonoBehaviour
{
public GameObject destination;
void Awake()
{
destination = transform.Find("B").gameObject;
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player");
{
other.transform.position=destination.transform.position;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 67796b86bed7a104985247a66c8effc9

View File

@@ -0,0 +1 @@
uid://dtr8ivnai6ayg

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Designed by Jacob Weedman
//Belongs to "UpdateLevelInformation" GameObject within every single level
//V 0.0.1
public class UpdateLevelInformation : MonoBehaviour
{
public string SectorThisBelongsTo; //Change this in unity
public string LevelThisBelongsTo; //Change this in unity
void Start()
{
GameObject.Find("GameData").GetComponent<GameData>().CurrentSector = SectorThisBelongsTo;
GameObject.Find("GameData").GetComponent<GameData>().CurrentLevel = LevelThisBelongsTo;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 62f266dddc0a75a4b875623f4cd07c13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
//Designed by Jacob Weedman
//Belongs to the "WorldManager" GameObject in the "LevelSelector" scene
//V 0.0.1
public class WorldManager : MonoBehaviour
{
string[] LevelsCompleted;
string levelChosen;
public string currentSector;
void Update()
{
if (GameObject.Find("GameData").GetComponent<GameData>().CurrentSector == "0")
{
GameObject.Find("GameData").GetComponent<GameData>().CurrentSector = "1";
}
currentSector = GameObject.Find("CurrentSector").tag;
levelChosen = tag;
if ((currentSector != "Untagged") && (levelChosen != "Untagged"))
{
ChangeLevel();
}
}
void ChangeLevel()
{
if (levelChosen == "test") // Remove later when levels are put in place
{
//SceneManager.LoadScene("WorkingPathfindingTest");
//SceneManager.LoadScene("Sector1Boss");
SceneManager.LoadScene("BossFightSelector");
}
else
{
SceneManager.LoadScene("Sector" + currentSector + "Level" + levelChosen);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8ad668246b028344280a2f169a7ab4a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1 @@
uid://dmmic0yu2ogrh