Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

정효인_4.7_Unity3Cs 과제 제출 #14

Open
wants to merge 6 commits into
base: hyoin
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Assets/AvatarFaceControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class AvatarFaceControl : MonoBehaviour
{
[SerializeField] Material _avatarFace;
[SerializeField] Texture _defaultTexture;

bool _crRunning = false;
IEnumerator _coroutine;
// Start is called before the first frame update
void Start()
{
_avatarFace.SetTexture("_MainTex", _defaultTexture);
}

// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.Alpha1))
ShowFace(QuickSlotManager.s_quickSlots[0].fid);
if (Input.GetKey(KeyCode.Alpha2))
ShowFace(QuickSlotManager.s_quickSlots[1].fid);
if (Input.GetKey(KeyCode.Alpha3))
ShowFace(QuickSlotManager.s_quickSlots[2].fid);
if (Input.GetKey(KeyCode.Alpha4))
ShowFace(QuickSlotManager.s_quickSlots[3].fid);
}

public void ChangeFace(int faceIndex)
{
_avatarFace.SetTexture("_MainTex", QuickSlotManager.s_faceTextures[faceIndex]);
}

void ShowFace(int index)
{
if(_crRunning && _coroutine != null)
{
StopCoroutine(_coroutine);
}
_coroutine = ShowFaceCoroutine(index);
StartCoroutine(_coroutine);
}

IEnumerator ShowFaceCoroutine(int index)
{
_crRunning = true;

ChangeFace(index);

yield return new WaitForSeconds(10f);

ChangeFace(11);

_crRunning = true;
}
}
11 changes: 11 additions & 0 deletions Assets/AvatarFaceControl.cs.meta

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

80 changes: 80 additions & 0 deletions Assets/CamManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;

public class CamManager : MonoBehaviour
{
private GameObject player;
private CinemachineFreeLook thirdPersonCam;
private bool _useMouseToRotateTp;

public GameObject lookAt;
public float xRotateSpeed;
public float yRotateSpeed;
public float zoomSpeed;
// Start is called before the first frame update
void Start()
{
player = GameObject.FindWithTag("Player").gameObject;
//lookAt = GameObject.Find("LookAt").gameObject;
thirdPersonCam = GameObject.Find("ThirdPersonCam").GetComponent<CinemachineFreeLook>();
thirdPersonCam.Follow = player.transform;
thirdPersonCam.LookAt = lookAt.transform;

}

// Update is called once per frame
void Update()
{
if(Input.GetMouseButtonDown(1))
{
_useMouseToRotateTp = true;
}
if (Input.GetMouseButtonUp(1))
{
_useMouseToRotateTp = false;
}
}

private void LateUpdate()
{
if (_useMouseToRotateTp)
{
RotateTp();
}
else
{
thirdPersonCam.m_XAxis.m_MaxSpeed = 0;
thirdPersonCam.m_YAxis.m_MaxSpeed = 0;
}
if (Input.mouseScrollDelta.y != 0)
Zoom();
}

private void RotateTp()
{
thirdPersonCam.m_XAxis.m_MaxSpeed = xRotateSpeed;
thirdPersonCam.m_YAxis.m_MaxSpeed = yRotateSpeed;
}

private void Zoom()
{
if(Input.mouseScrollDelta.y<0)
{
if(thirdPersonCam.m_Lens.FieldOfView < 80)
{
Debug.Log("Zoom out");
thirdPersonCam.m_Lens.FieldOfView += zoomSpeed;
}
}
if (Input.mouseScrollDelta.y > 0)
{
if (thirdPersonCam.m_Lens.FieldOfView > 5)
{
Debug.Log("Zoom in");
thirdPersonCam.m_Lens.FieldOfView -= zoomSpeed;
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/CamManager.cs.meta

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

36 changes: 36 additions & 0 deletions Assets/CharacterAnimation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class CharacterAnimation : MonoBehaviour
{
private Transform _objectPivot;
private Transform _spaceSuit;

// Start is called before the first frame update
void Start()
{
_objectPivot = transform.Find("ObjectPivot");
_spaceSuit = transform.Find("ObjectPivot/Space_Suit");
}

public void Teleport(CharacterController controller, Vector3 startPosition, Vector3 destination)
{
DOTween.Sequence()
.Join(transform.DOMove(new Vector3(startPosition.x, transform.position.y, startPosition.z), 1f).SetEase(Ease.OutSine))
.Join(_spaceSuit.DOLocalMoveX(0.8f, 0.8f)).SetEase(Ease.InOutSine)
.Join(_spaceSuit.DOLocalMoveY(2, 1.5f)).SetEase(Ease.InExpo)
.Join(_objectPivot.DOLocalRotate(new Vector3(0, 360 * 10, 0), 5f, RotateMode.FastBeyond360).SetEase(Ease.InOutSine))
.Insert(4.6f, _spaceSuit.DOLocalMoveY(1, 0.2f)).SetEase(Ease.OutQuart)
.Insert(4.4f, _spaceSuit.DOLocalMoveX(0, 0.4f)).SetEase(Ease.OutSine)
.Append(_spaceSuit.DOLocalMoveY(50, 0.2f)).SetEase(Ease.OutCubic)
.AppendCallback(() =>
{
transform.position = destination;
_spaceSuit.DOLocalMoveY(0, 0.2f).SetEase(Ease.OutCubic);
}
)
.OnComplete(() => controller.enabled = true);
}
}
11 changes: 11 additions & 0 deletions Assets/CharacterAnimation.cs.meta

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

71 changes: 71 additions & 0 deletions Assets/Portal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class Portal : MonoBehaviour
{
[SerializeField] private Portal _target;

private Transform _spawnPoint;
public Transform spawnPoint { get { return _spawnPoint; } }

public Transform _objectPivot;
private CharacterController _controller;
private bool _isActive;
private Sequence _portalSequence;


// Start is called before the first frame update
void Start()
{
_spawnPoint = transform.Find("ObjectPivot/SpawnPoint");
_objectPivot = transform.Find("ObjectPivot");

_portalSequence = DOTween.Sequence().SetAutoKill(false)
.Join(transform.DOLocalRotate(new Vector3(0, 360 * 30, 0), 5f, RotateMode.FastBeyond360).SetEase(Ease.InOutSine))
.Join(_objectPivot.DOLocalRotate(new Vector3(0, 0, 80), 1f).SetEase(Ease.InSine))
.Insert(3.5f, _objectPivot.DOLocalRotate(new Vector3(0, 0, 0), 1.5f).SetEase(Ease.OutSine))
.Pause();
}

// Update is called once per frame
void Update()
{
if(!_isActive)
{
return;
}

if(Input.GetKeyDown(KeyCode.X))
{
ActivatePortal();
}
}

private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player"))
{
_controller = other.GetComponent<CharacterController>();
_isActive = true;
}
}

private void OnTriggerExit(Collider other)
{
_isActive = false;
}
private void ActivatePortal()
{
_isActive = false;
_controller.enabled = false;

_portalSequence.Rewind();
_portalSequence.Play();

CharacterAnimation characterAnimation = _controller.GetComponent<CharacterAnimation>();
characterAnimation.Teleport(_controller,transform.position,_target.spawnPoint.position);
}
}
11 changes: 11 additions & 0 deletions Assets/Portal.cs.meta

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

31 changes: 31 additions & 0 deletions Assets/QuickSlotButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class QuickSlotButton : MonoBehaviour, ISelectHandler, IPointerClickHandler
{
public enum _Buttontype { Quickslot, Viewport }

public _Buttontype Buttontype;
public Image ButtonImage;
public Text ButtonText;
public int fid;

public void OnSelect(BaseEventData eventData)
{
if(Buttontype == _Buttontype.Viewport)
{
QuickSlotManager.CurrentlySelected = this;
}
}

public void OnPointerClick(PointerEventData eventData)
{
if(Buttontype == _Buttontype.Quickslot && QuickSlotManager.CurrentlySelected != null)
{
QuickSlotManager.AddToQuickSlot(this);
}
}
}
11 changes: 11 additions & 0 deletions Assets/QuickSlotButton.cs.meta

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

Loading