Skip to content

Commit

Permalink
gamemanageとcontactスクリプトの修正
Browse files Browse the repository at this point in the history
  • Loading branch information
maooz4426 committed Mar 25, 2024
1 parent 28ef117 commit 3e58091
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 65 deletions.
69 changes: 27 additions & 42 deletions Assets/Manager/GameManager/Script/GameManage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace PLATEAU.Samples
{
public class GameManage : MonoBehaviour, InputGameManage.IInputGameActions
public class GameManage : MonoBehaviour
{
public struct GoalInfo
{
Expand Down Expand Up @@ -52,27 +52,30 @@ public struct GoalInfo
private int goalNum;
private int getHintNum;
private bool isSetGMLdata;

//player
private GameObject player;
//サウンドエフェクト
[SerializeField] private AudioClip saveAudioClip;
private AudioSource saveSound;

// パーティクルエフェクト
[SerializeField] private GameObject saveParticle;
private GameObject saveParticleInstance;
private float particleDuration = 2f;
// -------------------------------------------------------------------------------------------------------------
private void Awake()
{
player = GameObject.Find("PlayerArmature");
inputActions = new InputGameManage();
targetParent = GameObject.Find("52385628_bldg_6697_op.gml").transform;

// 救出時
saveSound = gameObject.AddComponent<AudioSource>();
saveSound.clip = saveAudioClip;
saveSound.loop = false;
}
// InputSystemを有効化させる
// -------------------------------------------------------------------------------------------------------------
private void OnEnable()
{
inputActions.Enable();
}
private void OnDisable()
{
inputActions.Disable();
}
private void OnDestroy()
{
inputActions.Dispose();
}
// -------------------------------------------------------------------------------------------------------------

void Start()
{

Expand All @@ -81,7 +84,7 @@ void Start()
public void StartGame()
{
rnd = new System.Random();
inputActions.InputGame.AddCallbacks(this);


//thirdpersonController = GameObject.Find("PlayerArmature").GetComponent<ThirdPersonController>();

Expand Down Expand Up @@ -499,38 +502,20 @@ public void AddRescueNum()
{
rescuedNum++;
UIManageScript.DisplayRescuedNum();

// パーティクルエフェクト
saveParticleInstance = Instantiate(saveParticle, player.gameObject.transform.position, Quaternion.Euler(-90, 0, 0), player.gameObject.transform);
Destroy(saveParticleInstance, particleDuration);
// サウンドエフェクト
saveSound.Play();
}
//現在助けている人数を追加する関数
public void ContactHumanAction()
{
rescuingNum += 1;
UIManageScript.DisplayRescuingNum();
}
// InputSystemの入力に対する処理(OnSonar : F)
// -------------------------------------------------------------------------------------------------------------
/// <summary>
/// Sonarを使う時の処理
/// </summary>
public void OnSonar(InputAction.CallbackContext context)
{
if (context.performed)
{
string nearestBuildingName = "";
float distance = -1f;
if(sonarCount > 0)
{
nearestBuildingName = FindNearestGoal();

Vector3 playerPos = GameObject.Find("PlayerArmature").transform.position;
Vector3 buildingPos = GoalAttributeDict[nearestBuildingName].goalPosition;
distance = Cal2DDistance(playerPos,buildingPos);

sonarCount -= 1;

}
UIManageScript.DisplayDistance(distance,sonarCount);
}
}

private void ResetGoals()
{
// 建物の色を初期化
Expand Down
1 change: 1 addition & 0 deletions Assets/Manager/Scripts/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum State

private void Awake()
{
animator = GetComponent<Animator>();
thirdPersonController = GetComponent<StarterAssets.ThirdPersonController>();
attackHandler = GetComponent<attackHandler>();
state = State.Wait;
Expand Down
2 changes: 1 addition & 1 deletion Assets/NPC/Scripts/NPCController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void Start()
characterController = GetComponent<CharacterController>();
gameManage = GameObject.Find("GameManager").GetComponent<GameManage>();
pathManager = GameObject.Find("RoadObjects").GetComponent<PathManager>();
npcManage = GameObject.Find("NPCManage").GetComponent<NPCManage>();
npcManage = GameObject.Find("NPCManager").GetComponent<NPCManage>();

player = GameObject.FindGameObjectWithTag("Player");
animator = GetComponent<Animator>();
Expand Down
29 changes: 7 additions & 22 deletions Assets/Player/Script/Contact.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using StarterAssets;
Expand All @@ -7,30 +7,23 @@ namespace PLATEAU.Samples
{
public class Contact : MonoBehaviour
{
// パーティクルエフェクト
[SerializeField] private GameObject saveParticle;
[SerializeField] private GameObject getItemParticle;
private GameObject saveParticleInstance;
// パーティクルエフェクト
[SerializeField] private GameObject getItemParticle;
private GameObject getItemParticleInstance;
private float particleDuration = 2f;

//サウンドエフェクト
[SerializeField] private AudioClip getItemAudioClip;
private AudioSource getItemSound;
[SerializeField] private AudioClip saveAudioClip;
private AudioSource saveSound;

private GameManage GameManageScript;
private GameView GameViewScript;
private UIManage UIManageScript;
private GameView GameViewScript;
private ItemManage ItemManageScript;
private ThirdPersonController ThirdPersonControllerScript;
private ActionManager ActionManager;

void Start()
{
ThirdPersonControllerScript = this.GetComponent<ThirdPersonController>();
GameManageScript = GameObject.Find("GameManager").GetComponent<GameManage>();
UIManageScript = GameObject.Find("UIManager").GetComponent<UIManage>();
ItemManageScript = GameObject.Find("ItemManager").GetComponent<ItemManage>();
GameViewScript = GameObject.Find("GameView").GetComponent<GameView>();
ActionManager = GameObject.Find("PlayerArmature").GetComponent<ActionManager>();
Expand All @@ -40,15 +33,10 @@ void Start()
getItemSound = gameObject.AddComponent<AudioSource>();
getItemSound.clip = getItemAudioClip;
getItemSound.loop = false;
// 救出時
saveSound = gameObject.AddComponent<AudioSource>();
saveSound.clip = saveAudioClip;
saveSound.loop = false;
}
public void GameOverFunc()
{
ActionManager.state = ActionManager.State.Died;
//ThirdPersonControllerScript.DyingMotion();
//一番上の親(GameView)にゲームオーバーを通知
GameViewScript.isGameOver = true ;
}
Expand All @@ -70,11 +58,8 @@ private void OnControllerColliderHit(ControllerColliderHit hit)
{
//救助する
GameManageScript.SelectBuildingAction(hit.transform);
// パーティクルエフェクト
saveParticleInstance = Instantiate(saveParticle,this.gameObject.transform.position,Quaternion.Euler(-90,0,0),this.gameObject.transform);
Destroy(saveParticleInstance,particleDuration);
// サウンドエフェクト
saveSound.Play();


}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Resources/Prefabs/ViewPrefabs/GameView.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -6382,6 +6382,8 @@ MonoBehaviour:
sonarCount: 0
rescuedNum: 0
rescuingNum: 0
saveAudioClip: {fileID: 8300000, guid: 52785ce05b92af64a9ec36e40ef3d94c, type: 3}
saveParticle: {fileID: 1837947354677370815, guid: 789b77970a5135140b92a679131ceff2, type: 3}
--- !u!1 &7600826448228269314
GameObject:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit 3e58091

Please sign in to comment.