You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
2 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using D2D;
|
||
|
using Sirenix.OdinInspector;
|
||
|
using UnityEngine;
|
||
2 months ago
|
using static D2D.Utilities.CommonGameplayFacade;
|
||
|
|
||
2 months ago
|
|
||
|
public class MemberInitializer : Unit
|
||
|
{
|
||
|
[SerializeField] private List<SquadMember> listOfCharacters;
|
||
2 months ago
|
[SerializeField] private List<NeutralMember> listOfNeutralCharacters;
|
||
2 months ago
|
[SerializeField] private SquadMember squadMember;
|
||
|
private SquadComponent squadComponent;
|
||
2 months ago
|
[SerializeField] private NeutralsSpawn neutralsSpawn;
|
||
2 months ago
|
public List<PoolMember> bulletParticleSystems;
|
||
2 months ago
|
private void Awake()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
2 months ago
|
squadComponent = Get<SquadComponent>();
|
||
|
squadMember = GetInitialSquadMember();
|
||
|
neutralsSpawn.neutralMember = GetInitialNeutralMember();
|
||
|
AddMember();
|
||
2 months ago
|
BulletPrefabSetter();
|
||
|
}
|
||
|
void BulletPrefabSetter()
|
||
|
{
|
||
|
_gameData.pistolProjectile.prefab = bulletParticleSystems[GetIDFromPlayerPrefs()];
|
||
2 months ago
|
}
|
||
|
private SquadMember GetInitialSquadMember()
|
||
|
{
|
||
|
int selectedPlayerId = GetIDFromPlayerPrefs();
|
||
|
return listOfCharacters[selectedPlayerId];
|
||
|
}
|
||
|
|
||
2 months ago
|
private NeutralMember GetInitialNeutralMember()
|
||
|
{
|
||
|
int selectedPlayerId = GetIDFromPlayerPrefs();
|
||
|
return listOfNeutralCharacters[selectedPlayerId];
|
||
|
}
|
||
|
|
||
2 months ago
|
private int GetIDFromPlayerPrefs()
|
||
|
{
|
||
|
return PlayerPrefs.GetInt(Constants.PlayerSelectionKey, 0);
|
||
|
}
|
||
|
|
||
|
|
||
|
[Button]
|
||
|
public void AddMember()
|
||
|
{
|
||
|
var newMember = Instantiate(squadMember.gameObject, Vector3.forward, Quaternion.identity, transform).GetComponent<SquadMember>();
|
||
|
|
||
|
squadComponent.AddMember(newMember);
|
||
|
}
|
||
|
}
|