Commit e996ef41 authored by Andrew Conn's avatar Andrew Conn

Merge branch 'master' into 'EnemyMovementHopefullyNotBrokenThisTimeIDK'

# Conflicts:
#   Assets/Scenes/SampleScene.unity
parents 026923b7 8d7d0d54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//We 'aquired' some code from our awesome director Andrew Conn, thanks buddy!
public class AutoGunScript : MonoBehaviour
{
public float damage = 7f; // this used to be 10f from GunScript
public float range = 100f; // this used to be 100f from GunScript
public float fireRate = 20f; // this used to be 15f from GunScript
public Camera fpsCam;
public ParticleSystem muzzleFlash;
private float nextTimeToFire = 0f;
// Update is called once per frame
void Update()
{
if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire)
{
nextTimeToFire = Time.time + 1f / fireRate;
Shoot();
}
}
// This makes sure that the gun is shot! (Unchanged from GunScript)
void Shoot()
{
muzzleFlash.Play();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Enemy enemy = hit.transform.GetComponent<Enemy>();
if (enemy != null)
{
enemy.TakeDamage(damage);
}
}
}
}
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5973112910024538586
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4003412051476802904}
- component: {fileID: 3841182838796132650}
- component: {fileID: 9177195043485479130}
- component: {fileID: 2889560094775934912}
- component: {fileID: 2173676895223364385}
- component: {fileID: 1242980841338303331}
m_Layer: 0
m_Name: AmmoDrop
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4003412051476802904
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.325, y: 1.017, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &3841182838796132650
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &9177195043485479130
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &2889560094775934912
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &2173676895223364385
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 57db7a228bc6f094ca39899316548198, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!54 &1242980841338303331
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5973112910024538586}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
fileFormatVersion: 2
guid: 7602c407d81c06748a00708b4f7de678
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
using System;
using UnityEngine;
//We 'aquired' some code from our awsome director Andrew Conn, thanks buddy!
public class SemiAutoGunScript : MonoBehaviour
{
public float damage = 15f; // this used to be 10f from GunScript
public float range = 100f; // this used to be 100f from GunScript
public float fireRate = 10f; // this used to be 15f from GunScript
public Camera fpsCam;
public ParticleSystem muzzleFlash;
private float nextTimeToFire = 0f;
// Update is called once per frame
void Update()
{
if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire)
{
nextTimeToFire = Time.time + 1f / fireRate;
Shoot();
}
}
// This makes sure the gun shoots! (Unchaged from GunScript)
void Shoot()
{
muzzleFlash.Play();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Enemy enemy = hit.transform.GetComponent<Enemy>();
if (enemy != null)
{
enemy.TakeDamage(damage);
}
}
}
}
using System;
using UnityEngine;
/*
* This WeaponSwapScript makes sure that, if the player wants to swap weapons,
* they can swap weapons!
*
* WARNING: If we want to add more weapons, we have to modify this script to
* accomodate for swapping weapons with the number buttons. Currently, it can
* swap through 3 weapons.
*/
public class WeaponSwapScript : MonoBehaviour
{
public int selectedWeapon = 0;
// Start makes sure a weapon is selected at the start of a level
void Start()
{
SelectWeapon();
}
// Update is called once per frame.
// Update checks to see if either:
// -the scroll wheel is changing what weapon is active
// -the number buttons (not the num pad) are changing what weapon is active
void Update()
{
//This is used at the bottom of Update to check and make sure that the
//current weapon is the same as the newly selected weapon.
//If they're different, then the current weapon will update.
int previousSelectedWeapon = selectedWeapon;
//When the scroll wheel goes up.
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
//If the selected weapon is already at the top of list,
//then it'll wrap around to the bottom of the list. Else, keep
//going up the list of weapons.
if (selectedWeapon >= transform.childCount - 1)
selectedWeapon = 0;
else
selectedWeapon++;
}
//When the scroll wheel goes down.
if (Input.GetAxis("Mouse ScrollWheel") < 0)
{
//If the selected weaopn is already at the bottom of the list,
//then it'll wrap around to the top of the list. Else, keep
//going down the list of weapons.
if (selectedWeapon <= 0)
selectedWeapon = transform.childCount - 1;
else
selectedWeapon--;
}
//These will alllow the nubmer buttons to change what weapon you're using.
//WARNING: If we plan to add more weapons and want them to be able to swap with them
//in game, then we must add to this!!!!
if (Input.GetKeyDown(KeyCode.Alpha1))
{
selectedWeapon = 0;
}
if (Input.GetKeyDown(KeyCode.Alpha2) && transform.childCount >= 2)
{
selectedWeapon = 1;
}
if (Input.GetKeyDown(KeyCode.Alpha3) && transform.childCount >= 3)
{
selectedWeapon = 2;
}
//This calls SelectWeapon to change weapons
if (previousSelectedWeapon != selectedWeapon)
{
SelectWeapon();
AddAmmo(selectedWeapon, 22);
}
}
//This is what actually changes the weapons. It loops through all of the weapons
//and either toggles the weapon active or not active
void SelectWeapon()
{
int x = 0; //the 'iterator' of the foreach loop
foreach (Transform weapon in transform)
{
if (x == selectedWeapon)//if this is the weapon the player wants, then it becomes true.
weapon.gameObject.SetActive(true);
else //if this weapon is NOT what the player wants, then it becomes false.
weapon.gameObject.SetActive(false);
x++;
}
}
public void AddAmmo(int ammoType, int ammoToGivePlayer)
{
int x = 0;
foreach (Transform weapon in transform)
{
if(x == ammoType)
{
weapon.GetComponent<GunScript>().ammo+=ammoToGivePlayer;
}
x++;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment