public void Init(ChessPieceComponent comp) { var parent = gameObject.transform; var iconObj = new GameObject("icon"); m_icon = iconObj.AddComponent <SpriteRenderer>(); iconObj.transform.SetParent(parent, false); iconObj.transform.localPosition = Vector3.zero; var selObj = new GameObject("selected"); m_selectedIcon = selObj.AddComponent <SpriteRenderer>(); selObj.transform.SetParent(parent, false); selObj.transform.localPosition = Vector3.zero; m_icon.sprite = (Sprite)Resources.Load("Images/chess", typeof(Sprite)); m_icon.sortingOrder = 1; m_selectedIcon.sprite = (Sprite)Resources.Load("Images/selected", typeof(Sprite)); if (comp.isWhite) { m_icon.color = Color.white; } else { m_icon.color = Color.black; } selObj.SetActive(false); }
public void ReplaceLayChessPiece(ChessPieceComponent newChessPiece, GameEntity newChessPieceEntity) { var index = GameComponentsLookup.LayChessPiece; var component = CreateComponent <LayChessPieceComponent>(index); component.chessPiece = newChessPiece; component.chessPieceEntity = newChessPieceEntity; ReplaceComponent(index, component); }