public void UpdateBootsNumber(int newValue) { if (Boots.Count == newValue) { return; } if (Boots.Count < newValue) { while (Boots.Count < newValue) { M_Damagule newBoot = Instantiate(BootPrefab).GetComponent <M_Damagule>(); newBoot.gameObject.GetComponent <C_Boot>().SetMainPlayer(mainPlayerModel); newBoot.InitializeBoot(Boots.Count + 1); newBoot.gameObject.GetComponent <C_Boot>().SetDistanceFromMain(distanceBetweenBoots * newBoot.GetId()); Boots.Push(newBoot); } } else { while (Boots.Count > newValue) { M_Damagule bootToDestroy = Boots.Peek(); bootToDestroy.gameObject.GetComponent <C_Boot>().destroyBoot(); Boots.Pop(); } } }
// Use this for initialization void Start() { Boot = GetComponent <M_Damagule>(); Vector2 pos = MainPlayer.GetPosition(); pos.x -= distanceFromMain; Boot.SetNewPosition(pos); }
public void SetMainPlayer(M_Damagule mainPlayer) { MainPlayer = mainPlayer; }
float distanceBetweenBoots = 2f;//just for fun #endregion // Use this for initialization #region private_functions void Start() { mainPlayerModel = gameObject.GetComponent <M_Damagule>(); Boots = new Stack <M_Damagule>(); }