Ejemplo n.º 1
0
    public Player(int row, int col, MainSystem sys, GameObject root)
    {
        IsMoving = false;
        const float size = Stage.SpriteSize;
        var spriteTypes = new[] { SpriteType.PlayerN,
                                  SpriteType.PlayerS,
                                  SpriteType.PlayerE,
                                  SpriteType.PlayerW };
        foreach (var stype in spriteTypes) {
            var obj = sys.Bless("Player", stype);
            obj.GetComponent<SpriteRenderer>().sortingLayerName = "Player";
            obj.transform.SetParent(root.transform);
            obj.transform.position = new Vector3(size * col, -size * row, 0);
            obj.SetActive(false);

            _spriteMap[stype] = obj;
        }
        Row = row;
        Col = col;
        Sprite = _spriteMap[SpriteType.PlayerN];
        UpdateDirection(-1, 0);
    }