Skip to content

Commit

Permalink
Cleaning code & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Prown0 committed Nov 26, 2024
1 parent 04c4098 commit 98aba1c
Show file tree
Hide file tree
Showing 25 changed files with 726 additions and 723 deletions.
4 changes: 2 additions & 2 deletions 302/Assets/Prefabs/Anomaly20/Anomaly20InteractableBack.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e3abf5127f1fd514eafeb2411741d79a, type: 3}
m_Name:
m_EditorClassIdentifier:
promptMessage: "\uD074\uB9AD\uD558\uC5EC \uC0C1\uD638\uC791\uC6A9"
interactionRange: 1
prompt:
distanceInteractionMax: 1.8
namePlayer: Player
nameBoard: BoardBack
zMin: -15.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fa6dee73251e9a04e8d20560af1f1997, type: 3}
m_Name:
m_EditorClassIdentifier:
promptMessage: "\uD074\uB9AD\uD558\uC5EC \uC0C1\uD638\uC791\uC6A9"
interactionRange: 1
prompt:
distanceInteractionMax: 1.8
namePlayer: Player
nameBoard: BoardFront
zMin: -11.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5c14879ba6f660e4196accbcc95dfe7a, type: 3}
m_Name:
m_EditorClassIdentifier:
promptMessage: "\uD074\uB9AD\uD558\uC5EC \uC0C1\uD638\uC791\uC6A9"
interactionRange: 1
prompt:
distanceInteractionMax: 1.8
namePlayer: Player
nameBoard: BoardRight (1)
x1Min: -25.2
Expand Down
1 change: 1 addition & 0 deletions 302/Assets/Prefabs/Anomaly20/PlayerAnomaly.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
namePlayer: Player
duration: 2
--- !u!1 &3565635857044313825
GameObject:
m_ObjectHideFlags: 0
Expand Down
6 changes: 3 additions & 3 deletions 302/Assets/Prefabs/Anomaly23/ghost.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,9 @@ MonoBehaviour:
namePlayer: Player
nameCamera: Main Camera
position: {x: 24, y: 2, z: 0}
speedInit: 2
speedDelta: 4
durationChase: 20
speedInit: 1
speedDelta: 5
durationChase: 25
durationFade: 5
--- !u!1 &6612614341887459618
GameObject:
Expand Down
25 changes: 21 additions & 4 deletions 302/Assets/Scenes/DefaultGameScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4919,6 +4919,24 @@ Transform:
m_CorrespondingSourceObject: {fileID: 1809372938388778512, guid: 474138867ca9be144953fa0ca636b7c9, type: 3}
m_PrefabInstance: {fileID: 241118524}
m_PrefabAsset: {fileID: 0}
--- !u!1 &243047807 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6482429499626390066, guid: e98bfaaf0938845d098edce033f7e7a2, type: 3}
m_PrefabInstance: {fileID: 2208074503459508080}
m_PrefabAsset: {fileID: 0}
--- !u!114 &243047810
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 243047807}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d755543348868a045964c1da73713696, type: 3}
m_Name:
m_EditorClassIdentifier:
anomalyScreenIndex: 12
--- !u!1001 &245510671
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -22951,9 +22969,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2960778f4e9343349a587d3d39be1a05, type: 3}
m_Name:
m_EditorClassIdentifier:
promptMessage: "\uD074\uB9AD\uD558\uC5EC \uC0C1\uD638\uC791\uC6A9"
interactionRange: 2
nameCamera: Main Camera
prompt:
distanceInteractionMax: 0
objectCamera: {fileID: 0}
thresholdDistance: 10
--- !u!1001 &1027390622
PrefabInstance:
Expand Down Expand Up @@ -40988,7 +41006,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 18e2c46eaa68afe458ec364512f84534, type: 3}
m_Name:
m_EditorClassIdentifier:
nameCameraMain: Main Camera
prompt:
distanceInteractionMax: 5
--- !u!65 &1875637180
Expand Down
63 changes: 46 additions & 17 deletions 302/Assets/Scripts/LaptopFaceController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LaptopFaceController : LaptopScreenController
{
/**********
* fields *
**********/

public GameObject player;
/*************
* constants *
*************/

private int[] X0DATA = new int[] {
394, 391, 389, 387, 386, 385, 384, 383, 382, 381, 380, 379, 379, 378, 378, 377, 377,
Expand Down Expand Up @@ -36,6 +32,14 @@ public class LaptopFaceController : LaptopScreenController
306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322
};

/**********
* fields *
**********/

// 오브젝트
public GameObject player;

// 내부 수치
private int TANGENT_MAX = 25;
private float TANGENT_CONST = 12.5f;
private int ORIGIN_X = 38;
Expand All @@ -45,18 +49,14 @@ public class LaptopFaceController : LaptopScreenController
private bool _isGazing;
private int _tangent;

/**********************
* overridden methods *
**********************/
/************
* messages *
************/

// Start is called on the frame when a script is enabled just
// before any of the Update methods are called the first time.
void Start()
{
_colour = defaults[0].GetPixel(407, 297);
_isGazing = false;
_tangent = 0;

ResetScreen();
}

Expand All @@ -68,9 +68,34 @@ void Update()
}
}

/***************
* new methods *
***************/
/*********************************
* implementation: SCH_Behaviour *
*********************************/

// 필드를 초기화하는 메서드
protected override bool InitFields()
{
bool res = base.InitFields();

// _colour
_colour = defaults[0].GetPixel(407, 297);
Log("Initialize `_colour`: success: "
+ $"Color({_colour.r}, {_colour.g}, {_colour.b}, {_colour.a})");

// _isGazing
_isGazing = false;
Log("Initialize `_isGazing`: success");

// _tangent
_tangent = 0;
Log("Initialize `_tangent`: success");

return res;
}

/******************************************
* implementation: LaptopScreenController *
******************************************/

// 화면을 초기화하는 메서드
public override void ResetScreen()
Expand All @@ -95,6 +120,10 @@ public override void ResetScreen()
screen.Apply();
}

/***********
* methods *
***********/

// 쳐다보기 시작하는 메서드
public void StartGazing()
{
Expand Down
25 changes: 13 additions & 12 deletions 302/Assets/Scripts/LaptopScreenController.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LaptopScreenController : MonoBehaviour
public class LaptopScreenController : SCH_Behaviour
{
/**********
* fields *
**********/

// 텍스처
public Texture2D screen;
public Texture2D[] defaults;

// 가변 수치
public int screenXMin;
public int screenXMax;
public int screenYMin;
Expand All @@ -21,12 +21,13 @@ public class LaptopScreenController : MonoBehaviour
public int defaultYMin;
public int defaultYMax;

public bool isFlipped;

/**************
* properties *
**************/

// 클래스 이름
public override string Name { get; } = "LaptopScreenController";

private int _index = 0;
public int Index {
get => _index;
Expand All @@ -39,9 +40,9 @@ public int Index {
}
}

/**********************
* overridden methods *
**********************/
/************
* messages *
************/

// Start is called on the frame when a script is enabled just
// before any of the Update methods are called the first time.
Expand All @@ -50,9 +51,9 @@ void Start()
ResetScreen();
}

/***************
* new methods *
***************/
/***********
* methods *
***********/

public virtual void ResetScreen()
{
Expand All @@ -79,4 +80,4 @@ public void ChangeScreen(int index)
Index = index;
ResetScreen();
}
}
}
2 changes: 1 addition & 1 deletion 302/Assets/Scripts/SCH_AnomalyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SCH_AnomalyObject : SCH_Behaviour
public SCH_AnomalyManager Manager { get; set; }

/************
* messeges *
* messages *
************/

// This function is called when the object becomes enabled and active.
Expand Down
2 changes: 1 addition & 1 deletion 302/Assets/Scripts/SCH_Behaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SCH_Behaviour : MonoBehaviour
public virtual string Name { get; } = "SCH_Behaviour";

/************
* messeges *
* messages *
************/

// This function is called when the object becomes enabled and active.
Expand Down
92 changes: 92 additions & 0 deletions 302/Assets/Scripts/SCH_Random.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;

// 일부 메서드는 Python의 구현을 참고해서 구현함
// https://github.com/python/cpython/blob/3.13/Lib/random.py
public class SCH_Random : Random
{
/*************
* constants *
*************/

// 4.0 * Math.Exp(-0.5) / Math.Sqrt(2.0)
private const double NORMAL_MAGICCONST = 1.7155277699214135367355993366800248622894287109375;

/***********
* methods *
***********/

// 조합
public int[] Combination(int n, int r)
{
int[] candidates = new int[n];
int[] result = new int[r];

for (int i = 0; i < n; i++) {
candidates[i] = i;
}

for (int i = 0; i < r; i++) {
int index = Next(i, n);

result[i] = candidates[index];
if (index != i) {
int tmp = candidates[i];

candidates[i] = candidates[index];
candidates[index] = tmp;
}
}

System.Array.Sort(result);

return result;
}

// 로그 정규 분포
public double LogNormalDist(double mu, double sigma)
{
return Math.Exp(NormalDist(mu, sigma));
}

// 정규 분포
public double NormalDist(double mu = 0.0, double sigma = 0.0)
{
double u1, u2, z, zz;

while (true) {
u1 = Sample();
u2 = 1.0 - Sample();
z = NORMAL_MAGICCONST * (u1 - 0.5) / u2;
zz = z * z / 4.0;
if (zz <= -Math.Log(u2)) {
break;
}
}

return mu + z * sigma;
}

// 삼각 분포
public double TriangularDist(double low = 0.0, double high = 1.0, double mode = 0.5)
{
double u, c;

if (high == low) {
return low;
}

u = Sample();
c = (mode - low) / (high - low);

if (u > c) {
double tmp = low;

u = 1.0 - u;
c = 1.0 - c;
low = high;
high = tmp;
}

return low + (high - low) * Math.Sqrt(u * c);
}
}
11 changes: 11 additions & 0 deletions 302/Assets/Scripts/SCH_Random.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98aba1c

Please sign in to comment.