-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &3985983561988511089 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 1225662013474792832} | ||
- component: {fileID: 4203500173424713874} | ||
- component: {fileID: 196829886972534681} | ||
- component: {fileID: 2749458525383876187} | ||
- component: {fileID: 3979177335964750275} | ||
m_Layer: 5 | ||
m_Name: SpamWindow | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!224 &1225662013474792832 | ||
RectTransform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3985983561988511089} | ||
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} | ||
m_AnchorMin: {x: 0.5, y: 0.5} | ||
m_AnchorMax: {x: 0.5, y: 0.5} | ||
m_AnchoredPosition: {x: 27.8552, y: 3.3161} | ||
m_SizeDelta: {x: 360, y: 264} | ||
m_Pivot: {x: 0.5, y: 0.5} | ||
--- !u!222 &4203500173424713874 | ||
CanvasRenderer: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3985983561988511089} | ||
m_CullTransparentMesh: 1 | ||
--- !u!114 &196829886972534681 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3985983561988511089} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_Material: {fileID: 0} | ||
m_Color: {r: 1, g: 1, b: 1, a: 1} | ||
m_RaycastTarget: 1 | ||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} | ||
m_Maskable: 1 | ||
m_OnCullStateChanged: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_Sprite: {fileID: 21300000, guid: 1208c49ff8294ce498efcc7be814bca7, type: 3} | ||
m_Type: 0 | ||
m_PreserveAspect: 0 | ||
m_FillCenter: 1 | ||
m_FillMethod: 4 | ||
m_FillAmount: 1 | ||
m_FillClockwise: 1 | ||
m_FillOrigin: 0 | ||
m_UseSpriteMesh: 0 | ||
m_PixelsPerUnitMultiplier: 1 | ||
--- !u!114 &2749458525383876187 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3985983561988511089} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: bf36c31efc151dc4b96cecf0ef7f1f29, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
minTimeout: 2 | ||
maxTimeout: 4 | ||
--- !u!114 &3979177335964750275 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 3985983561988511089} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: bf39a137c20631044b50258ded7b8ed2, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
baseWaitTime: 0 | ||
additionalWaitTime: 0 | ||
repeat: 0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using UnityEngine; | ||
using Random = UnityEngine.Random; | ||
|
||
public class Popup : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private float minTimeout = 2; | ||
|
||
[SerializeField] | ||
private float maxTimeout = 4; | ||
|
||
private Timer timer; | ||
|
||
private void Start() | ||
{ | ||
timer = GetComponent<Timer>(); | ||
timer.StartTimer(Random.Range(minTimeout, maxTimeout)); | ||
timer.OnTimerRunCompleted += Disappear; | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
timer.OnTimerRunCompleted -= Disappear; | ||
} | ||
|
||
private void Disappear() => Destroy(gameObject); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections; | ||
using CollectionExtensions; | ||
using UnityEngine; | ||
|
||
public class PopupSpammer : MonoBehaviour | ||
{ | ||
[SerializeField] private Popup[] popups; | ||
|
||
[SerializeField] private RectTransform spamTarget; | ||
[SerializeField] private RectTransform hud; | ||
|
||
[SerializeField] private float minSpamDelay = .1f; | ||
[SerializeField] private float maxSpamDelay = .3f; | ||
|
||
private int spamRemaining = 0; | ||
|
||
private Coroutine spamRoutine = null; | ||
|
||
private void OpenPopup() | ||
{ | ||
var halfWidth = hud.sizeDelta.x / 2; | ||
var halfHeight = hud.sizeDelta.y / 2; | ||
var position = new Vector2( | ||
Random.Range(-halfWidth, halfWidth), | ||
Random.Range(-halfHeight, halfHeight)); | ||
|
||
var popup = popups.RandomElement(); | ||
var instance = Instantiate(popup, spamTarget.transform.position, spamTarget.transform.rotation, spamTarget); | ||
instance.GetComponent<RectTransform>().anchoredPosition = position; | ||
} | ||
|
||
private IEnumerator SpamPeriodically() | ||
{ | ||
while (spamRemaining > 0) | ||
{ | ||
OpenPopup(); | ||
spamRemaining--; | ||
yield return new WaitForSeconds(Random.Range(minSpamDelay, maxSpamDelay)); | ||
} | ||
|
||
spamRoutine = null; | ||
} | ||
|
||
public void Spam(int amount) | ||
{ | ||
spamRemaining += amount; | ||
|
||
if (spamRoutine == null) | ||
{ | ||
spamRoutine = StartCoroutine(SpamPeriodically()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.