public void UpdateConnectedItems() { //add archers if it is a tower item if (this.itemData.name == "Tower") { BaseItemScript towerArcher = null; if (this.connectedItems.Count > 0) { towerArcher = this.connectedItems[0]; } if (towerArcher == null) { towerArcher = SceneManager.instance.AddItem(1502, true, ownedItem); this.connectedItems.Add(towerArcher); } towerArcher.SetPosition(this.GetCenterPosition() + new Vector3(0, 1.2f, 0)); towerArcher.SetState(state); towerArcher.SetDirection(direction); } //add builder to builder hut if (this.itemData.name == "BuilderHut" && SceneManager.instance.gameMode == Common.GameMode.NORMAL) { if (SceneManager.instance.selectedItem == this) { //that means the hut is on drag //builder comes to hut only after on stop drag return; } BaseItemScript builder = null; if (this.connectedItems.Count > 0) { builder = this.connectedItems[0]; } if (builder == null) { builder = SceneManager.instance.AddItem(3823, true, ownedItem); builder.SetPosition(this.GetRandomFrontCellPosition()); //connect builder item to the builder hut this.connectedItems.Add(builder); //connect this builder hut item to builder builder.connectedItems.Add(this); } builder.ReturnBuilder(); } }