|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using D2D;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class MemberInitializer : Unit
|
|
|
|
{
|
|
|
|
[SerializeField] private List<SquadMember> listOfCharacters;
|
|
|
|
[SerializeField] private List<NeutralMember> listOfNeutralCharacters;
|
|
|
|
[SerializeField] private SquadMember squadMember;
|
|
|
|
private SquadComponent squadComponent;
|
|
|
|
[SerializeField] private NeutralsSpawn neutralsSpawn;
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
squadComponent = Get<SquadComponent>();
|
|
|
|
squadMember = GetInitialSquadMember();
|
|
|
|
neutralsSpawn.neutralMember = GetInitialNeutralMember();
|
|
|
|
AddMember();
|
|
|
|
}
|
|
|
|
|
|
|
|
private SquadMember GetInitialSquadMember()
|
|
|
|
{
|
|
|
|
int selectedPlayerId = GetIDFromPlayerPrefs();
|
|
|
|
return listOfCharacters[selectedPlayerId];
|
|
|
|
}
|
|
|
|
|
|
|
|
private NeutralMember GetInitialNeutralMember()
|
|
|
|
{
|
|
|
|
int selectedPlayerId = GetIDFromPlayerPrefs();
|
|
|
|
return listOfNeutralCharacters[selectedPlayerId];
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|