Beispiel #1
0
    public void SpawnPlayer(Graph graph, GameObject player, int xIndex, int yIndex, string name)
    {
        ItemDatabase itemDatabase = FindObjectOfType <ItemDatabase>();

        itemDatabase.BuildDatabase();
        Node       node     = graph.GetNodeAt(xIndex, yIndex);
        Unit       newUnit  = new Unit(xIndex, yIndex, node, UnitType.player, name);
        GameObject instance = Instantiate(player, node.position, Quaternion.identity, this.transform);

        SetUnitWeapons(newUnit);
        playerUnitView.Init(newUnit);
        OnUnitSpawned?.Invoke(this, new OnUnitSpawnedEventArgs {
            newUnit = newUnit, instance = instance, node = node
        });
    }