This commit is contained in:
2022-04-27 19:12:09 +02:00
parent c547e9768d
commit 136fb8978a
51 changed files with 13771 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dragoncontrols : MonoBehaviour
{
public float speed = 300;
float xinput = 0;
float yinput = 0;
float zinput = 0;
float xrot = 0;
float yrot = 0;
public float rotspeed = 360;
bool flamethrover = false;
Rigidbody rb;
ParticleSystem flames;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
flames = GetComponentInChildren<ParticleSystem>();
speed *= rb.mass;
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
zinput = Input.GetAxis("Horizontal") * speed;
xinput = Input.GetAxis("Vertical") * speed;
yinput = Input.GetAxis("Jump") * speed;
xrot = Input.GetAxis("Rot") * speed;
yrot = Input.GetAxis("Yrot") * speed;
flamethrover = Input.GetButton("Fire1");
//control flames
if (flamethrover)
{
flames.Play();
}
else
{
flames.Stop();
}
//move relative to camera
//transform.Translate(xinput * Time.deltaTime * 4, yinput * Time.deltaTime * 4, zinput * Time.deltaTime);
//move relative to camera addforce
//rb.AddForce(xinput * Time.fixedDeltaTime * 2, yinput * Time.fixedDeltaTime * 4, zinput * Time.fixedDeltaTime);
//add force relative to rotation
Vector3 inputs = new Vector3(xinput * Time.fixedDeltaTime * 2, yinput * Time.fixedDeltaTime * 4, zinput * Time.fixedDeltaTime);
rb.AddForce(transform.TransformDirection(inputs));
//add rotation from ziput
//transform.Rotate(0, zinput * Time.deltaTime * rotspeed, xrot * Time.deltaTime / 2 * rotspeed);
//set rotation from ziput addforce
Vector3 m_EulerAngleVelocity = new Vector3(0, yrot * Time.fixedDeltaTime * rotspeed, xrot * Time.fixedDeltaTime / 2 * rotspeed);
Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.fixedDeltaTime);
rb.MoveRotation(deltaRotation);
}
}

View File

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

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemykiller : MonoBehaviour
{
// Start is called before the first frame update
public ParticleSystem part;
public List<ParticleCollisionEvent> collisionEvents;
void Start()
{
part = GetComponent<ParticleSystem>();
collisionEvents = new List<ParticleCollisionEvent>();
}
// Update is called once per frame
void Update()
{
}
//on particle coolision
void OnParticleCollision(GameObject otherx)
{
int numCollisionEvents = part.GetCollisionEvents(otherx, collisionEvents);
int i = 0;
while (i < numCollisionEvents)
{
GameObject other = collisionEvents[i].colliderComponent.gameObject;
if (other.tag == "enemy")
{
Destroy(other);
Debug.Log("enemy killed");
}
if (other.tag == "king")
{
Destroy(other);
Debug.Log("killed king");
}
i++;
}
}
}

View File

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

41
Assets/scripts/spawner.cs Normal file
View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class spawner : MonoBehaviour
{
//get enemy and king prefab
public GameObject enemy;
public GameObject king;
public int numkings = 3;
public int numenemies = 30;
// Start is called before the first frame update
void Start()
{
//spawn enemies
for (int i = 0; i < numenemies; i++)
{
//spawn enemy
GameObject enemyclone = Instantiate(enemy, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
//set enemy name
enemyclone.name = "enemy" + i;
enemyclone.tag = "enemy";
}
//spawn kings
for (int i = 0; i < numkings; i++)
{
//spawn king
GameObject kingclone = Instantiate(king, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
//set king name
kingclone.name = "king" + i;
kingclone.tag = "king";
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8dc30419ebf6a3930be5b997ed5bacde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- enemy: {fileID: 919132149155446097, guid: ded7e10a6d22af0d0924281aa81fd2e4, type: 3}
- king: {fileID: 919132149155446097, guid: 7bc1f8d1241626c1c92334fafd723ce8, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: