Beispiel #1
0
    // -ButtBehaviour API-

    protected override void Awake()
    {
        base.Awake();

        string characterName = m_DefaultCharacter;

        if (m_PlayerSlotToSpawn < PlayerDataSlots.Count)
        {
            PlayerData playerData = PlayerDataSlots.GetPlayer(m_PlayerSlotToSpawn);
            characterName = playerData.m_CharacterName;
        }

        CharacterConfig config = ExternalJson.LoadJSON <CharacterConfig>("Characters/" + characterName);

        SpawnCharacter(config);
    }
Beispiel #2
0
    // -Private API-

    private void SpawnCharacter(CharacterConfig config)
    {
        GameObject templateCharacter = Resources.Load <GameObject>("Characters/Templates/" + config.m_CharacterTemplate);
        GameObject spawnedCharacter  = Instantiate(templateCharacter);

        spawnedCharacter.transform.position = transform.position;
        spawnedCharacter.transform.rotation = transform.rotation;

        FighterController fighterController = spawnedCharacter.GetComponent <FighterController>();

        fighterController.SetCombos(config.m_ComboList.ToComboList());

        if (m_PlayerSlotToSpawn < PlayerDataSlots.Count)
        {
            PlayerData playerData = PlayerDataSlots.GetPlayer(m_PlayerSlotToSpawn);
            playerData.m_InputConverter.BindController(fighterController);
        }
    }
Beispiel #3
0
    // -Private API-

    private void OnInputReceived(IInputDevice device, InputEventType inputEvent)
    {
        if (inputEvent == InputEventType.Start)
        {
            if (m_IgnoredDevices.Contains(device))
            {
                return;
            }

            PlayerData playerData = PlayerDataSlots.AddPlayer();
            playerData.m_InputConverter = new CombatInputConverter();

            InputMapConfig inputMap = ExternalJson.LoadJSON <InputMapConfig>("Input/ConverterMap");
            playerData.m_InputConverter.SetConverterMap(inputMap.ToConverterMap());

            playerData.m_InputConverter.BindDevice(device);

            m_IgnoredDevices.Add(device);
        }
    }