《文法》

【Nullじゃないなら実行】

// :: Callback
Callback_CompletedFX?.Invoke();
// :: Same the above
/*if (Callback_CompletedFX != null)
{
	Callback_CompletedFX();
}*/

《EASY to USE》

【EnumのDescriptionを取得して使用】

// :: Enums : Animation Key
private enum eAnimation
{
  [Description("idle@loop")]
  IDLE,
  [Description("run@loop")]
  RUN,
  [Description("walk@loop")]
  WALK
}

// :: for use enum Description
// ::: Ref : http://kawakawa2000.jugem.jp/?eid=27
// ::: I don't understand perfectly yet.
private string GetEnumDescription(eAnimation value)
{
	FieldInfo fi = value.GetType().GetField(value.ToString());
	var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

	var descriptionString = attributes.Select(ele => ele.Description).FirstOrDefault();

	if(descriptionString != null)
	{
		return descriptionString;
	}
	return value.ToString();
}

void Update() 
{
	anim.Play(this.GetEnumDescription(eAnimation.RUN));
}

【Unity Editorにツールを登録

// :: for Using
using UnityEditor;

// :: Easy to use
public class MenuTest : MonoBehaviour
{
    // :: Location
    [MenuItem("MyMenu/Delete All PlayerPrefs")]
    // :: Program : Delete All PlayerPrefs
    static void DeleteAllPlayerPrefs()
    {
        PlayerPrefs.DeleteAll();
        Debug.Log("deleted all player prefs");
    }
}

《イベント》

【ボタンにイベントリスナーを追加】

>>クリックすると動くように

// :: Add Event Listener
btn.onClick.AddListener(this.ClickedButton);

【数秒後に実行】
>>Singletonに定義してそれを持ってきて使うのも可能

<<CT_Ruler>>
// :: Do Action after Waiting
UIController.WaitForSecondsAndDo(10f, (() => { UIController.FadeIn(GOHolder.SPRITE_handRight); }));

<<Sing_UIController>>
// :: Do Action after Waiting
public void WaitForSecondsAndDo(float time, System.Action action)
{
	this.StartCoroutine(WaitForSecondsAndDoImplement(time, action));
}
private IEnumerator WaitForSecondsAndDoImplement(float time, System.Action action)
{
	yield return new WaitForSeconds(time);
	action();
}

【ゲーム停止】

// :: Pause Game
Time.timeScale = 0;
// :: RePlay Game
Time.timeScale = 1;

《出力》

【PrefabをベースにGameObjectの複製を作ってそれを画面に出力】

// :: Make GameObject & Render
GameObject prefab =  Resources.Load<GameObject>("ch_03_01");
GameObject clone =  Instantiate<GameObject>(prefab);

【出力する際に親(Parent)と位置を設定】

// :: Render Chest Closed and Set Position
// ::: Use Transform Parent
// ::: 1. GameObject
// ::: 2. Position
// ::: 3. Rotation
// ::: 4. Parent transform
chestClosed = Object.Instantiate<GameObject>(chestPrefabA, // 1
            lastTarget.transform.position + new Vector3(0, 0, 0.5f), // 2 
            Quaternion.Euler(-90, -90, 0), // 3
            lastTarget.transform); // 4

【出力してから親(Parent)を設定】

// :: Create Weapon and Set Parent
GameObject spear = Object.Instantiate<GameObject>(Resources.Load<GameObject>("Spear_7"));
spear.transform.SetParent(dummyRHand);
// :: Change Position
spear.transform.localPosition = new Vector3(0, 0, 0);
spear.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));

【画面にいるGameObjectの出力を消す】

// :: Destroy Game Object
Destroy(itm);

【3Dのキャラ位置に合わせて2DキャンバスにHUDを出力】

// :: When Button Clicked : Show HUD
this.BUTTON_test.onClick.AddListener(() =>
{
	// :: Instantiate with Canvas
	var go = Instantiate<GameObject>(this.hudPrefab, this.canvas.transform);

	// :: Check Where do you want set the position
	// ::: Main Camera World Point => Screen Point
	var screenPoint = Camera.main.WorldToScreenPoint(playerGO.transform.position);

	// ::: Screen Point => Local(Canvas) Point
	Vector2 localPoint;
	// ::: ((RectTransform) Canvas Transform, Screen Point, Camera which you will set HUD, out local Point)
	RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)canvas.transform, screenPoint, this.uiCam, out localPoint);

	// :: Change HUD Local position
	go.transform.localPosition = localPoint;

	// :: Play and Destroy
	var hud = go.GetComponent<HUDText>();
	hud.Init(992);
	hud.Play();
	hud.Callback_Play = () => {
		Destroy(hud.gameObject);
	};
});

《方向と移動》

【1歩前に動く:マップ基準】

// :: Map Position
hero.transform.position += Vector3.forward;
//this.gameObject.transform.Translate(Vector3.forward, Space.Self);

1歩前に動く:自分基準】

// :: Self Position
hero.transform.position += hero.transform.forward;
//this.gameObject.transform.Translate(this.transform.forward, Space.World);

【目標の方向を見るように角度を修正】

// :: Look target Direction
Vector3 target = new Vector3(1, 0.49f, -2) - itm.transform.position;
itm.transform.rotation = Quaternion.LookRotation(target);

【目標を見てその方向に走る(結果:目標を通って走る)】

// :: Look at Target
this.transform.LookAt(target.transform);
// :: Move There with Translate
this.transform.Translate(this.transform.forward * 0.1f * Time.deltaTime, Space.World);

⇒まだ完全に理解していない。

【目標まで行く】

// :: Move Toward 
this.transform.position = Vector3.MoveTowards(this.transform.position, this.target.transform.position, 0.1f * Time.deltaTime);

《衝突》

【衝突無視】

// :: Find all BoxCollider2D
foreach (var itm in GameObject.FindObjectsOfType<BoxCollider2D>())
{
	// :: Player : Ignore it
	Physics2D.IgnoreCollision(playerRigidbody.gameObject.GetComponent<CircleCollider2D>(), itm, true);
}

【RayCastで衝突感知】

// :: Hit Checker
RaycastHit hit;
// :: When Racast Hit
// ::: (Start Position, Direction, Hit Object, Max Distance)
if (Physics.Raycast(this.player.transform.position, this.player.transform.forward, out hit, 1f))
{
	// :: Check Hit Object's Name
	Debug.Log(hit.transform.gameObject.name);
	// :: Show ray for Debug
	Debug.DrawRay(this.player.transform.position, this.player.transform.forward * 1f, Color.red);
}

《SCENE移動》

【SCENE移動時に完了をチェック、そしてその後に何かを実行】

// :: Load Scene with Done Checker
UnityEngine.AsyncOperation async = SceneManager.LoadSceneAsync(this.GetEnumDescription(sceneType));
// :: When Scene Load Completed
async.completed += Async_completed;

// :: Do Action
private void Async_completed(UnityEngine.AsyncOperation obj)
{
	if(obj.isDone)
	{
    	Debug.Log("Load Completed");
	}
}

 

블로그 이미지

RIsN

,

D3 : 1 Page Plan

_Dogma 2020. 10. 27. 09:24

프로젝트명 : Dogma 3
게임(가제) : Dogma / Letter
언어 : 영어

 

간단 설명 : 던전 RPG(: 세계수의 미궁)로써 Dogma 2에 이은 스토리형 게임
컨셉 : 아포칼립스(Fallout 4 스타일), 사막, (Damn Crab)
사용 툴 : 유니티(3D? 2D?) // 2D로 가능할 경우 2D를 선호
플레이타임 : 1시간

 

목표 다운로드 수 : 100
목표 수익 : $10
수익 창출 수단 : 광고(Admob), 후원(Patreon)
마케팅 수단 : Twitter(#indie)

 

<상세 스토리 설명>

레드 랍스터에게서 도망치다가 어디가로 떨어져버린 플레이어와 송, 유적인 듯 방공호인 듯한 이곳에서 나가기 위해 탐험을 시작하는데

<초기 개발 제한>
: 캠프(아이템 구매 및 회복 등) / 던전
캐릭터 수 : 2(플레이어는 이미지 없음)
: 12x12 2(튜토리얼 5x5 제외) // 동일 디자인
몬스터 수 : 1마리
보스 : 1마리

 

업데이트 : 2020-10-28

'_Dogma' 카테고리의 다른 글

Dogma / Coin Expansion 0.1 is decided  (0) 2021.03.14
Project D2 : Dogma / Coin is Release Now!  (0) 2020.12.12
블로그 이미지

RIsN

,

Study : Quick Sort

C# 2020. 10. 26. 22:56

<퀵 정렬>

  :: 간략 정보

    - 가장 빠른 정렬 알고리즘

    - 자기 자신을 불러 쪼개서 정렬을 함

    - 수학적으로 이해해야 해서 더럽게 어려움

  :: 구조

    - 완벽하게 이해 못해서 못쓰겠음

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Study33_QuickSort
{
    public class App
    {
        public App()
        {
            // :: Testing Value
            int[] arr = new int[10] { 4, 8, 7, 6, 9, 1, 3, 2, 0, 5 };
            this.ShowArray(arr);

            this.QuickSort(arr, 0, arr.Length - 1);

            this.ShowArray(arr);

        }

        public void QuickSort(int[] arr, int indexStart, int indexEnd)
        {
            // :: Null Break;
            if (indexStart >= arr.Length)
                return;

            int target = arr[indexStart];
            int left = indexStart + 1;
            int right = indexEnd;

            while(left <= right)
            {
                // :: When target is bigger than Left Value : Skip
                while(arr[left] < target)
                {
                    left += 1;

                    // :: Null Break;
                    if (left >= arr.Length)
                        break;
                }
                // :: When target is smaller than Right Value : Skip
                while (arr[right] > target)
                {
                    right -= 1;

                    // :: Null Break;
                    if (right < 0)
                        break;
                }

                // :: I didn't understand this yet.
                if(left <= right)
                {
                    SwapArray(arr, left, right);
                }
            }            

            // :: I didn't understand this yet.
            // :: Until Start index is same End index : It means dividing is one now.
            if(indexStart < indexEnd)
            {
                // :: Swap target and Right Value
                SwapArray(arr, indexStart, right);

                QuickSort(arr, indexStart, right - 1); // :: Front
                QuickSort(arr, right + 1, indexEnd); // :: End
            }

            return;
        }

        public void SwapArray(int[] arr, int a, int b)
        {
            int temp = arr[a];
            arr[a] = arr[b];
            arr[b] = temp;
        }

        public void ShowArray(int[] arr)
        {
            foreach(var itm in arr)
            {
                Console.Write("[{0}]", itm);
            }
            Console.WriteLine("");
        }

        public void Today()
        {
            DateTime today = new DateTime(2020, 10, 26);
            Console.WriteLine(today.ToString("yyyy-MM-dd") + " : THINK");
        }
    }
}

 

글 업데이트 : 2020-10-26

 

참고 사이트 :

blockdmask.tistory.com/177

블로그 이미지

RIsN

,