Beispiel #1
0
    public override void Load(string json)
    {
        var data = JsonUtility.FromJson <CharacterData>(json);

        CharacterPool.Register(data.characterId, player);
        player.data = data;
        player.characterController.enabled = false;
        transform.position      = data.position;
        player.graphic.rotation = data.rotation;

        for (int i = 0; i < player.inventory.slots; i++)
        {
            player.inventory.DestroyItem(i);
        }

        for (int i = 0; i < data.items.Count; i++)
        {
            for (int j = 0; j < data.quantities[i]; j++)
            {
                player.inventory.AddItem(data.items[i]);
            }

            player.inventory.items[i].Equipped = data.equipped[i];
        }


        player.GetComponent <CharacterEquipment>().CheckEquipment();
        player.characterController.enabled = true;
    }
Beispiel #2
0
 protected void Awake()
 {
     if (SaveGameManager.newGame)
     {
         data.characterId = CharacterPool.Register(this).ToString();
     }
     equipment = GetComponent <CharacterEquipment>();
 }
Beispiel #3
0
 public void UpdateData(CharacterData data)
 {
     this.data = data;
     SetHealth(data.health);
     transform.position = data.position;
     transform.rotation = data.rotation;
     CharacterPool.Register(data.characterId, this);
     ActivateRoutine(data.routine, true, true);
 }