This page provides an overview of all the code used in the game Harmony Last Stand. You can copy and paste the code snippets as needed.
Folder / File | Description |
---|---|
Assets | The root folder for all your project assets. |
Scripts | Place all your scripts here for easy access. Keep them organized by function or type. |
PlayerController.cs | Player movement and basic actions |
BasicAttackScript.cs | Charging and releasing the basic attack |
HeavyAttackScript.cs | Heavy attack actions |
InspireTroopsScript.cs | Inspiring and commanding troops |
DodgeRollScript.cs | Player's dodging/rolling actions |
LaserBeamScript.cs | Laser beam projectile actions |
ElementalRelicScript.cs | Elemental relic behavior and abilities |
EnemyScript.cs | Enemy movement, attacks, and abilities |
EnemySpawnManagerScript.cs | Enemy wave management and spawning logic |
BossScript.cs | Final boss battle mechanics |
ObjectiveManagerScript.cs | Game objectives and progression logic |
UIManagerScript.cs | User interface management |
GameControllerScript.cs | Game session management and scoring |
Prefabs | Store reusable GameObjects, including player characters, enemies, elemental relics, and UI elements. |
PlayerPrefab | Player character prefab |
EnemyPrefabs | Enemy prefabs |
ElementalRelicPrefabs | Elemental relic prefabs |
UIPrefabs | UI element prefabs |
Folder / File | Description |
Assets | The root folder for all your project assets. |
Scripts | Place all your scripts here for easy access. Keep them organized by function or type. |
Prefabs | Store reusable GameObjects, including player characters, enemies, elemental relics, and UI elements. |
Materials, Textures, Audio | Organize your project's graphical and audio assets here. |
Scenes | Keep your game scenes separate for clarity. Each scene corresponds to a different part of the game (e.g., MainMenu, Gameplay, Victory, GameOver). |
Animations | Store animation assets if you have any character or object animations. |
Shaders, Fonts, Plugins, StreamingAssets, Editor, Resources | Use these folders as needed for special assets, custom editor scripts, third-party plugins, streaming data, etc. |
... (Continue the rest of the hierarchy) | ... (Add descriptions for the other folders and files) |
Script Name | Description | Attached To | Responsible For |
---|---|---|---|
PlayerController | Player movement and basic actions | Player GameObject | Player movement and basic actions |
BasicAttackScript | Charging and releasing the basic attack | Player GameObject | Basic attack logic |
HeavyAttackScript | Heavy attack actions | Player GameObject | Heavy attack logic |
InspireTroopsScript | Inspiring and commanding troops | Player GameObject | Troop management and inspiration |
DodgeRollScript | Player's dodging/rolling actions | Player GameObject | Dodging and rolling behavior |
LaserBeamScript | Laser beam projectile actions | Laser Beam GameObject | Laser beam projectile behavior |
ElementalRelicScript | Elemental relic behavior and abilities | Elemental Relic GameObjects | Elemental relic interactions |
EnemyScript | Enemy movement, attacks, and abilities | Enemy GameObjects | Enemy behavior and interactions |
EnemySpawnManagerScript | Enemy wave management and spawning logic | Spawn Manager GameObject | Enemy wave spawning |
BossScript | Final boss battle mechanics | Boss GameObject | Final boss behavior and abilities |
ObjectiveManagerScript | Game objectives and progression logic | Objective Manager GameObject | Game objectives and progression |
UIManagerScript | User interface management | UI elements | User interface elements management |
GameControllerScript | Game session management and scoring | Game Controller GameObject | Overall game flow and scoring |
This site map provides an overview of the key scripts and their responsibilities in the "Harmony's Last Stand" project. You can use this as a reference when planning and organizing your project's development.
using UnityEngine;
public class PlayerController : MonoBehaviour
{
// Reference to the VR camera rig or player's head
public Transform vrCamera;
// Buttons and triggers
public OVRInput.Button basicAttackButton = OVRInput.Button.One;
public OVRInput.Button heavyAttackButton = OVRInput.Button.Two;
public OVRInput.Button inspireTroopsButton = OVRInput.Button.PrimaryHandTrigger;
// Movement
public float moveSpeed = 3.0f;
// Dodge/Roll
public float dodgeSpeed = 5.0f;
// Basic Attack
private bool isChargingBasicAttack = false;
private float basicAttackChargeTime = 5.0f; // 5 seconds charge time
private float basicAttackChargeTimer = 0.0f;
void Update()
{
// Get input from Oculus Quest 2 controller
Vector2 stickInput = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
// Move the player in the direction of the controller
Vector3 moveDirection = vrCamera.TransformDirection(new Vector3(stickInput.x, 0, stickInput.y)) * moveSpeed * Time.deltaTime;
transform.Translate(moveDirection);
// Check for basic attack (A Button for Oculus Quest 2)
if (OVRInput.GetDown(basicAttackButton))
{
StartChargingBasicAttack();
}
if (isChargingBasicAttack)
{
basicAttackChargeTimer += Time.deltaTime;
// Check if the player has charged for the specified time
if (basicAttackChargeTimer >= basicAttackChargeTime)
{
ReleaseBasicAttack();
}
}
// Check for heavy attack
if (OVRInput.GetDown(heavyAttackButton))
{
HeavyAttack();
}
// Check for inspire troops button
if (OVRInput.GetDown(inspireTroopsButton))
{
InspireTroops();
}
// Check for dodge/roll
if (OVRInput.Get(heavyAttackButton) && !Mathf.Approximately(stickInput.magnitude, 0))
{
DodgeRoll(stickInput);
}
}
void StartChargingBasicAttack()
{
// Implement logic to start charging the basic attack
isChargingBasicAttack = true;
basicAttackChargeTimer = 0.0f;
// Play charging animation or effects
Debug.Log("Charging Basic Attack...");
}
void ReleaseBasicAttack()
{
// Implement logic to release the basic attack (fire the laser beam)
isChargingBasicAttack = false;
// Play the laser beam effect and sound
FireLaserBeam();
// Reset the charge timer
basicAttackChargeTimer = 0.0f;
}
void FireLaserBeam()
{
// Implement logic to create and fire the laser beam
Debug.Log("Firing Laser Beam!");
// Create the laser beam GameObject and position it at the player's hand
GameObject laserBeam = Instantiate(laserBeamPrefab, handTransform.position, handTransform.rotation);
// Add force or velocity to the laser beam to make it move forward
Rigidbody laserBeamRigidbody = laserBeam.GetComponent();
laserBeamRigidbody.velocity = laserBeam.transform.forward * laserBeamSpeed;
// Set a timer to destroy the laser beam after a certain time
Destroy(laserBeam, laserBeamDuration);
}
void HeavyAttack()
{
// Implement heavy attack logic here
Debug.Log("Heavy Attack");
}
void InspireTroops()
{
// Implement inspire troops logic here
Debug.Log("Inspire Troops");
}
void DodgeRoll(Vector2 dodgeDirection)
{
// Implement dodge/roll logic here
Vector3 moveDirection = vrCamera.TransformDirection(new Vector3(dodgeDirection.x, 0, dodgeDirection.y)) * dodgeSpeed * Time.deltaTime;
transform.Translate(moveDirection);
}
}
using UnityEngine;
public class EntwinedSprites : MonoBehaviour
{
public int health = 100; // Adjust as needed
public Transform target; // The player or VR companion
public float moveSpeed = 2f; // Movement speed of the enemy
public float attackRange = 2f; // Attack range of the enemy
public int damage = 10; // Damage dealt to the player or companion
private bool isAttacking = false;
void Update()
{
if (!isAttacking)
{
// Move towards the target (player or companion)
if (target != null)
{
Vector3 direction = (target.position - transform.position).normalized;
transform.Translate(direction * moveSpeed * Time.deltaTime);
}
}
}
public void TakeDamage(int damage)
{
health -= damage;
if (health <= 0)
{
Die();
}
}
void Die()
{
// Add death animation or logic here
Destroy(gameObject);
}
// Attack the player or companion
public void Attack()
{
if (Vector3.Distance(transform.position, target.position) <= attackRange)
{
// Deal damage to the target
PlayerController playerController = target.GetComponent();
if (playerController != null)
{
playerController.TakeDamage(damage);
}
// Set a cooldown to prevent continuous attacks
isAttacking = true;
Invoke("ResetAttackCooldown", 1.0f);
}
}
void ResetAttackCooldown()
{
isAttacking = false;
}
// Add any other necessary functions for enemy behavior here
}
using UnityEngine;
public class MossyTreants : MonoBehaviour
{
public int health = 200; // Adjust as needed
public Transform target; // The player or VR companion
public void TakeDamage(int damage)
{
health -= damage;
if (health <= 0)
{
Die();
}
}
void Die()
{
// Add death animation or logic here
Destroy(gameObject);
}
// Add any other necessary functions for enemy behavior here
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class PlayerController : MonoBehaviour
{
public Transform vrCamera;
public float moveSpeed = 3.0f;
private bool isChargingBasicAttack = false;
private float basicAttackChargeTime = 5.0f;
private float basicAttackChargeTimer = 0.0f;
public GameObject laserBeamPrefab; // Assign this in the Unity Inspector
public Transform handTransform; // Assign this in the Unity Inspector
public float laserBeamSpeed = 10f; // Speed of the laser beam
public float laserBeamDuration = 5f;// Time to destroy the laser beam
// Initialize XR Node references
private List nodeStates = new List();
private Vector2 primary2DAxis;
void Update()
{
UpdateNodeStates();
// Get input from the controllers
UnityEngine.XR.InputDevice device = GetDevice(UnityEngine.XR.XRNode.RightHand);
if (device.TryGetFeatureValue(CommonUsages.primary2DAxis, out primary2DAxis))
{
// Your code for movement
Vector3 moveDirection = vrCamera.TransformDirection(new Vector3(primary2DAxis.x, 0, primary2DAxis.y)) * moveSpeed * Time.deltaTime;
transform.Translate(moveDirection);
}
// Your code for other functionalities
// For example, for a basic attack:
if (device.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonPressed) && primaryButtonPressed)
{
StartChargingBasicAttack();
}
if (isChargingBasicAttack)
{
basicAttackChargeTimer += Time.deltaTime;
if (basicAttackChargeTimer >= basicAttackChargeTime)
{
ReleaseBasicAttack();
}
}
// Implement the rest of your functionalities similarly
}
private void UpdateNodeStates()
{
UnityEngine.XR.InputTracking.GetNodeStates(nodeStates);
}
private UnityEngine.XR.InputDevice GetDevice(UnityEngine.XR.XRNode node)
{
UnityEngine.XR.InputDevice device = new UnityEngine.XR.InputDevice();
foreach (var item in nodeStates)
{
if (item.nodeType == node)
{
device = UnityEngine.XR.InputDevices.GetDeviceAtXRNode(node);
break;
}
}
return device;
}
void StartChargingBasicAttack()
{
isChargingBasicAttack = true;
basicAttackChargeTimer = 0.0f;
Debug.Log("Charging Basic Attack...");
}
void ReleaseBasicAttack()
{
isChargingBasicAttack = false;
Debug.Log("Released Basic Attack!");
basicAttackChargeTimer = 0.0f;
}
void FireLaserBeam()
{
// Implement logic to create and fire the laser beam
Debug.Log("Firing Laser Beam!");
// Create the laser beam GameObject and position it at the player's hand
GameObject laserBeam = Instantiate(laserBeamPrefab, handTransform.position, handTransform.rotation);
// Add force or velocity to the laser beam to make it move forward
Rigidbody laserBeamRigidbody = laserBeam.GetComponent();
laserBeamRigidbody.velocity = laserBeam.transform.forward * laserBeamSpeed;
// Set a timer to destroy the laser beam after a certain time
Destroy(laserBeam, laserBeamDuration);
}
void HeavyAttack()
{
// Implement heavy attack logic here
Debug.Log("Heavy Attack");
}
void InspireTroops()
{
// Implement inspire troops logic here
Debug.Log("Inspire Troops");
}
void DodgeRoll(Vector2 dodgeDirection)
{
// Implement dodge/roll logic here
Vector3 moveDirection = vrCamera.TransformDirection(new Vector3(dodgeDirection.x, 0, dodgeDirection.y)) * dodgeSpeed * Time.deltaTime;
transform.Translate(moveDirection);
}
}