Initial. Added files

This commit is contained in:
Andrey Gumirov
2022-04-12 11:54:05 +07:00
parent 19900f6446
commit 8aa8e3d79b
254 changed files with 44750 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using System;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class AmmoPickUp : MonoBehaviour, IPickable
{
public PickUpType type => PickUpType.Ammunition;
public void OnTriggerEnter(Collider other)
{
PickObject(other.gameObject);
}
public void PickObject(GameObject obj)
{
obj.GetComponent<CharacterCondition>()?.TakeAmmo(SettingsReader.Instance.GetSettings.ammunitionPickupAmount);
gameObject.SetActive(false);
}
}

11
Assets/Scripts/Pickups/AmmoPickUp.cs.meta generated Executable file
View File

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

View File

@ -0,0 +1,19 @@
using System;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class ArmourPickUp : MonoBehaviour, IPickable
{
public PickUpType type => PickUpType.Armour;
public void OnTriggerEnter(Collider other)
{
PickObject(other.gameObject);
}
public void PickObject(GameObject obj)
{
obj.GetComponent<CharacterCondition>()?.GiveArmour(SettingsReader.Instance.GetSettings.armourPickupAmount);
gameObject.SetActive(false);
}
}

11
Assets/Scripts/Pickups/ArmourPickUp.cs.meta generated Executable file
View File

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

View File

@ -0,0 +1,19 @@
using System;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class HealthPickUp : MonoBehaviour, IPickable
{
public PickUpType type => PickUpType.Health;
public void OnTriggerEnter(Collider other)
{
PickObject(other.gameObject);
}
public void PickObject(GameObject obj)
{
obj.GetComponent<CharacterCondition>()?.GiveHealth(SettingsReader.Instance.GetSettings.healthPickupAmount);
gameObject.SetActive(false);
}
}

11
Assets/Scripts/Pickups/HealthPickUp.cs.meta generated Executable file
View File

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

View File

@ -0,0 +1,7 @@
using System;
using UnityEngine;
public interface IPickable
{
PickUpType type { get; }
void PickObject(GameObject obj);
}

11
Assets/Scripts/Pickups/IPickable.cs.meta generated Executable file
View File

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

View File

@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class PickUpSpawner : MonoBehaviour
{
private PickUpSpawner instance;
public PickUpSpawner Instance { get { return instance; } }
private List<GameObject> pickups;
[SerializeField] private GameObject healthPrefab;
[SerializeField] private GameObject armourPrefab;
[SerializeField] private GameObject ammoPrefab;
[SerializeField] private List<NavPoint> spawnPoints;
private void Start()
{
pickups = new List<GameObject>();
var amount = SettingsReader.Instance.GetSettings.pickupsAmount;
for (int i = 0; i < amount; i++)
pickups.Add(GameObject.Instantiate(healthPrefab, spawnPoints[Random.Range(0, spawnPoints.Count)].transform.position, Quaternion.identity));
for (int i = 0; i < amount; i++)
pickups.Add(GameObject.Instantiate(armourPrefab, spawnPoints[Random.Range(0, spawnPoints.Count)].transform.position, Quaternion.identity));
for (int i = 0; i < amount; i++)
{
pickups.Add(GameObject.Instantiate(ammoPrefab, spawnPoints[Random.Range(0, spawnPoints.Count)].transform.position, Quaternion.identity));
}
foreach (var gameobj in pickups)
gameobj.SetActive(true);
StartCoroutine(SpawnNewPickUps());
}
private IEnumerator SpawnNewPickUps()
{
while(true)
{
GameObject item;
if(IsDisableCheck(out item))
{
yield return new WaitForSeconds(3);
if (item != null)
{
item.transform.position = spawnPoints[Random.Range(0, spawnPoints.Count)].position;
item.SetActive(true);
}
}
yield return new WaitForSeconds(2);
}
}
private bool IsDisableCheck(out GameObject gameobj)
{
foreach(var pick in pickups)
{
if (!pick.activeInHierarchy)
{
gameobj = pick;
return true;
}
}
gameobj = null;
return false;
}
}

11
Assets/Scripts/Pickups/PickUpSpawner.cs.meta generated Executable file
View File

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

View File

@ -0,0 +1,6 @@
public enum PickUpType
{
Health,
Armour,
Ammunition,
}

11
Assets/Scripts/Pickups/PickUpType.cs.meta generated Executable file
View File

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