public void PutToPool(BaseObjectScene target) { _poolsDictionary[target.name].AddFirst(target); target.transform.parent = _deactivatedObjectsParent; target.SetActive(false); // Debug.Log($"PoolController.PutToPool; pool.Count: {_poolsDictionary[target.name].Count}"); }
public BaseObjectScene GetFromPool(BaseObjectScene prefab) { // Debug.Log($"_poolsDictionary: {_poolsDictionary.Count}"); if (!_poolsDictionary.ContainsKey(prefab.name)) { // Debug.Log($"Create new LinkedList<BaseObjectScene>"); _poolsDictionary[prefab.name] = new LinkedList <BaseObjectScene>(); } BaseObjectScene result; if (_poolsDictionary[prefab.name].Count > 0) { // Debug.Log($"_poolsDictionary[{prefab.name}].Count = {_poolsDictionary.Count}"); result = _poolsDictionary[prefab.name].First.Value; _poolsDictionary[prefab.name].RemoveFirst(); result.SetDefault(); result.SetActive(true); // Debug.Log($"return {result.name}"); return(result); } // Debug.Log($"Create new BaseObjectScene.Instantiate(prefab): {prefab.name}"); result = BaseObjectScene.Instantiate(prefab); result.name = prefab.name; return(result); }
public override void On(BaseObjectScene weapon) { if (IsActive) { return; } base.On(weapon); _weapon = weapon as Weapon; if (_weapon == null) { return; } _weapon.IsVisible = true; UiInterface.WeaponUiText.SetActive(true); UiInterface.WeaponUiText.ShowData(_weapon.Clip.CountAmmunition, _weapon.CountClip); }
public virtual void On(BaseObjectScene obj) { IsActive = true; }
public virtual void On(BaseObjectScene obj = null) { isActive = true; }
private void ParseObj(XmlNode node, string nameObj) { BaseObjectScene obj = null; string name = String.Empty; Vector3 position = new Vector3(); Quaternion rotation = new Quaternion(); Vector3 scale = new Vector3(); foreach (XmlAttribute attribute in node.Attributes) { switch (attribute.Name) { case "Name": name = attribute.Value; break; case "PosX": position.x = float.Parse(attribute.Value); break; case "PosY": position.y = float.Parse(attribute.Value); break; case "PosZ": position.z = float.Parse(attribute.Value); break; case "RotX": rotation.x = float.Parse(attribute.Value); break; case "RotY": rotation.y = float.Parse(attribute.Value); break; case "RotZ": rotation.z = float.Parse(attribute.Value); break; case "ScalX": scale.x = float.Parse(attribute.Value); break; case "ScalY": scale.y = float.Parse(attribute.Value); break; case "ScalZ": scale.z = float.Parse(attribute.Value); break; } } if (nameObj == "Wall") { //Create objects with parameters } obj.Position = position; obj.Roration = rotation; obj.Scale = scale; obj.Name = name; }