thing or bing bong

This commit is contained in:
c0repwn3r 2023-05-02 11:29:39 -04:00
parent 0cd3b3227e
commit 051b8de84c
Signed by: core
GPG Key ID: FDBF740DADDCEECF
11 changed files with 458 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.Petite Post.iml
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -202,7 +202,112 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10} m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1447796513
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1447796515}
- component: {fileID: 1447796514}
m_Layer: 0
m_Name: House 01
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1447796514
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1447796513}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef9f1f87684e67e6da7888d486a6bcea, type: 3}
m_Name:
m_EditorClassIdentifier:
mailCycleTime: 1
mailChance: 0.5
maxMail: 10
mailAmountAdjustment: 0.10000000149011612
mailAdjustment: 1
address: 0
manager: {fileID: 1967804166}
maxMailLifetime: 5
currentMail: 0
cycleTime: 0
lastRandomMail: 0
lastRandomCutoff: 0
lastMailAmountAdjustment: 0
lastMailAmountAdjustedBy: 0
--- !u!4 &1447796515
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1447796513}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1967804165
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1967804167}
- component: {fileID: 1967804166}
m_Layer: 0
m_Name: BuildingManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1967804166
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1967804165}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 32aa227b448de9c55a47a29b4d0ac546, type: 3}
m_Name:
m_EditorClassIdentifier:
gameOver: 0
gameOverAddress: -1
--- !u!4 &1967804167
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1967804165}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

8
Assets/Scripts.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8a7f71fd8aaf32134b5ff17d8e44a131
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = System.Random;
public class BuildingManager : MonoBehaviour {
[SerializeField] private bool gameOver = false;
[SerializeField] private int gameOverAddress = -1;
private Dictionary<int, MailGenerator> _mailGenerators;
// Start is called before the first frame update
private void Start() {
_mailGenerators = new Dictionary<int, MailGenerator>();
}
// Update is called once per frame
private void Update() { }
public void RegisterMailGenerator(int atAddress, MailGenerator generator) {
_mailGenerators[atAddress] = generator;
}
public void GameOver(int byAddress) {
gameOver = true;
gameOverAddress = byAddress;
}
public int RandomMailGenerator() {
return new Random().Next(0, _mailGenerators.Count);
}
public int RandomMailGeneratorNot(int address) {
var generator = 0;
do {
generator = RandomMailGenerator();
} while (generator != address);
return generator;
}
public MailGenerator GetMailGenerator(int address) {
return _mailGenerators[address];
}
}

View File

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

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Serialization;
using Random = System.Random;
public class Mail {
public int FromAddress;
public int ToAddress;
public double TimeExisted;
}
public class MailGenerator : MonoBehaviour {
[FormerlySerializedAs("MailCycleTime")] [SerializeField] private int mailCycleTime = 5;
[FormerlySerializedAs("MailChance")] [SerializeField, Range(0, 1)] private double mailChance = 0.2;
[FormerlySerializedAs("MaxMail")] [SerializeField] private int maxMail = 10;
[SerializeField, Range(0, 1)] private double mailAmountAdjustment = 0.3;
[SerializeField] private bool mailAdjustment = true;
[SerializeField] private int address;
[SerializeField] private BuildingManager manager;
[SerializeField] private double maxMailLifetime = 30;
[FormerlySerializedAs("CurrentMail")] [SerializeField, ReadOnly] private int currentMail = 0;
[FormerlySerializedAs("CycleTime")] [SerializeField, ReadOnly] private double cycleTime = 0.0;
[FormerlySerializedAs("LastRandomMail")] [SerializeField, ReadOnly] private double lastRandomMail = 0.0;
[FormerlySerializedAs("LastRandomCutoff")] [SerializeField, ReadOnly] private double lastRandomCutoff = 0.0;
[SerializeField, ReadOnly] private double lastMailAmountAdjustment = 0.0;
[SerializeField, ReadOnly] private double lastMailAmountAdjustedBy = 0.0;
private Random _rng;
private Dictionary<int, Mail> _mail;
// Start is called before the first frame update
private void Start() {
_rng = new Random();
_mail = new Dictionary<int, Mail>();
manager.RegisterMailGenerator(address, this);
}
// Update is called once per frame
private void Update() {
cycleTime += Time.deltaTime;
foreach (var mail in _mail) {
mail.Value.TimeExisted += Time.deltaTime;
if (mail.Value.TimeExisted > maxMailLifetime) {
manager.GameOver(mail.Value.ToAddress);
}
}
if (cycleTime > mailCycleTime) {
cycleTime = 0;
lastRandomMail = _rng.NextDouble();
lastRandomCutoff = 1 - mailChance;
if (currentMail < maxMail && lastRandomMail > lastRandomCutoff) {
currentMail++;
var newMail = new Mail {
FromAddress = address,
ToAddress = manager.RandomMailGeneratorNot(address),
TimeExisted = 0.0
};
_mail[currentMail] = newMail;
}
if (mailAdjustment) {
lastMailAmountAdjustment = _rng.NextDouble() - 0.5;
lastMailAmountAdjustedBy = lastMailAmountAdjustment * mailAmountAdjustment;
mailChance += lastMailAmountAdjustedBy;
}
if (mailChance > 1) mailChance = 1;
if (mailChance < 0) mailChance = 0;
}
}
}

View File

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

View File

@ -0,0 +1,167 @@
{
"templatePinStates": [],
"dependencyTypeInfos": [
{
"userAdded": false,
"type": "UnityEngine.AnimationClip",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEditor.Animations.AnimatorController",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.AnimatorOverrideController",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEditor.Audio.AudioMixerController",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.ComputeShader",
"ignore": true,
"defaultInstantiationMode": 1,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Cubemap",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.GameObject",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEditor.LightingDataAsset",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": false
},
{
"userAdded": false,
"type": "UnityEngine.LightingSettings",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Material",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEditor.MonoScript",
"ignore": true,
"defaultInstantiationMode": 1,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.PhysicMaterial",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.PhysicsMaterial2D",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.VolumeProfile",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEditor.SceneAsset",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": false
},
{
"userAdded": false,
"type": "UnityEngine.Shader",
"ignore": true,
"defaultInstantiationMode": 1,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.ShaderVariantCollection",
"ignore": true,
"defaultInstantiationMode": 1,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Texture",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Texture2D",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
},
{
"userAdded": false,
"type": "UnityEngine.Timeline.TimelineAsset",
"ignore": false,
"defaultInstantiationMode": 0,
"supportsModification": true
}
],
"defaultDependencyTypeInfo": {
"userAdded": false,
"type": "<default_scene_template_dependencies>",
"ignore": false,
"defaultInstantiationMode": 1,
"supportsModification": true
},
"newSceneOverride": 0
}