protected override void Die() { base.Die(); int random = Random.Range(0, _elements.GetList().Count); GetSlimeFromPool(random, gameObject.transform.position + new Vector3(0, 3, 0)); }
private void Update() { _spawnTimer += Time.deltaTime; if (!_isActive) { return; } if (_spawnTimer > _spawnRate) { if ((ObjectManager.Instance.GetActiveObjects(_spawner.GetPrefab()) != null)) { if (ObjectManager.Instance.GetActiveObjects(_prefab) != null) { if (ObjectManager.Instance.GetActiveObjects(_prefab).Count < (_maxSpawnCount * ObjectManager.Instance.GetActiveObjects(_spawner.GetPrefab()).Count)) { int random = Random.Range(0, _elements.GetList().Count); GetSlimeFromPool(random, gameObject.transform.position); } } else { int random = Random.Range(0, _elements.GetList().Count); GetSlimeFromPool(random, gameObject.transform.position); } } _spawnTimer = 0; } }
void Start() { rb = this.GetComponent <Rigidbody> (); forward = characterObject.transform.forward; //生成するスライムの番号をランダムで決める _randomNumber = Random.Range(0, _elements.GetList().Count - 1); //色変え GetComponent <Renderer>().material = _mat[_randomNumber]; }
private void Update() { //Temporary if (Input.GetKeyDown(KeyCode.Space)) { //ObjectManager.Instance.InstantiateWithObjectPooling(_prefab, transform.position, transform.rotation).GetComponent<EnvironmentBase>(); int random = Random.Range(0, _elements.GetList().Count); GetSlimeFromPool(random, Vector3.one); } }
public GameObject GetSlimeFromPool(int type, Vector3 position = new Vector3()) { GameObject slime_obj = ObjectManager.Instance.InstantiateWithObjectPooling(_prefab, position); Stats temp = EnumHolder.Instance.GetStats(_prefab.name); SlimeBase temp_component = slime_obj.GetComponent <SlimeBase>(); slime_obj.transform.SetParent(gameObject.transform); if (temp_component != null) { Destroy(temp_component); } System.Type _MyScriptType = System.Type.GetType(((ElementType)_elements.GetList()[type]).GetSlimeScriptName()); SlimeBase temp_script = slime_obj.AddComponent(_MyScriptType) as SlimeBase; temp_script.Init(temp, ((((ElementType)_elements.GetList()[type]).name.Equals("Lightning")) ? 2 : 1), ((ElementType)_elements.GetList()[type]), _startingTier); slime_obj.SetActive(true); return(slime_obj); }
// スライムを選んでオーブリストに送る void SelectSlime() { Dictionary <KeyCode, ElementType> keyBind = new Dictionary <KeyCode, ElementType>(); keyBind.Add(KeyCode.Z, _ElementType.GetList() [0] as ElementType); keyBind.Add(KeyCode.X, _ElementType.GetList() [1] as ElementType); keyBind.Add(KeyCode.C, _ElementType.GetList() [2] as ElementType); keyBind.Add(KeyCode.Alpha1, _ElementType.GetList() [0] as ElementType); keyBind.Add(KeyCode.Alpha2, _ElementType.GetList() [1] as ElementType); keyBind.Add(KeyCode.Alpha3, _ElementType.GetList() [2] as ElementType); ElementType type = null; foreach (var key in keyBind) { if (Input.GetKeyDown(key.Key)) { // 溢れた分を仮ストックから抜く if (_tmpStock.Count >= _Orb_Slots) { ResetOrbSlots(); _tmpStock.Clear(); return; } type = key.Value; } } if (type == null) { return; } // 選んだ型のスライムの残数 int slimeRemain = 0; _SlimeStock.TryGetValue(type, out slimeRemain); // 選んだ方のオーブストックに送った分 int slot = CountSearchQueue(type, _tmpStock); // スライムがストックに1体以上残っていれば仮ストックに突っ込める if ((slimeRemain - slot) >= 1) { _tmpStock.Enqueue(type); StoreElementInOrb(type); AudioManager.Instance.PlaySE("OrbSet"); } }
public Stats GetStats(string InstanceName) { foreach (Stats s in _Stat.GetList()) { if (s.GetPrefabName().Equals(InstanceName)) { if (s.IsUseByMultiple) { return(Instantiate(s)); } else { return(s); } } } return(null); }
// オーブを送ってスキルを生成する public void StoreElementInOrb(ElementType type) { string debug = ""; if (_CurrentSkillOutcome != null) { Destroy(_CurrentSkillOutcome); _CurrentSkillOutcome = null; } _OrbSlot.Add(type); if (_OrbSlot.Count > _Orb_Slots) { _OrbSlot.RemoveAt(0); } bool HasUniqueCombination = true; if (_OrbSlot.Count >= _Orb_Slots) { for (int i = 0; i < _OrbSlot.Count; ++i) { for (int j = i + 1; j < _OrbSlot.Count; ++j) { if (_OrbSlot[i].Equals(_OrbSlot[j])) { HasUniqueCombination = false; break; } } } } else { HasUniqueCombination = false; } if (HasUniqueCombination) { foreach (Skill s in _combiSkill.GetList()) { var conbinationElements = s.GetCombinationElements(); if (conbinationElements.Length > _OrbSlot.Count) { continue; } bool found_skill = true; for (int i = 0; i < _OrbSlot.Count; ++i) { if (conbinationElements[i] != _OrbSlot[i]) { found_skill = false; break; } } if (found_skill) { _CurrentSkillOutcome = ScriptableObject.Instantiate(s); _CurrentSkillOutcome.name = s.name; debug += "------------------------------------------------\n"; debug += "[Created Skill] " + _CurrentSkillOutcome.name + "\n"; debug += "------------------------------------------------"; break; } else { _CurrentSkillOutcome = null; } } } else { foreach (Skill s in _baseSkill.GetList()) { if (_OrbSlot.Count <= 0) { break; } var baseElement = s.GetBaseElement(); if (baseElement.Equals(_OrbSlot[0])) { int temp_tier = _OrbSlot.Skip(1).Where(x => x.Equals(baseElement)).Count(); _CurrentSkillOutcome = ScriptableObject.Instantiate(s); _CurrentSkillOutcome.name = s.name; debug += "------------------------------------------------\n"; debug += "[Created Skill] " + _CurrentSkillOutcome.name + "\n"; // for (int i = 1; i < _OrbSlot.Count; ++i) // { // if (baseElement.Equals(_OrbSlot[i])) // ++temp_tier; // else // break; // } _CurrentSkillOutcome.SetSkillTier((SkillTier)_skillTier.GetList() [temp_tier]); debug += "[Setting Tier] " + _CurrentSkillOutcome.GetSkillTier() + "\n"; // List<ElementType> temp = new List<ElementType>(); // temp.AddRange(_OrbSlot); // temp.RemoveRange(0, temp_tier + 1); List <ElementType> temp = _OrbSlot.Skip(temp_tier + 1).ToList(); if (temp.Count > 0) { _CurrentSkillOutcome.SetElementType(temp); var statusEffects = _CurrentSkillOutcome.GetStatusEffects(); foreach (StatusEffect et in statusEffects) { debug += "[Skill (" + _CurrentSkillOutcome.name + ") Status Added] " + et.name + "\n"; } } debug += "------------------------------------------------"; break; } else { _CurrentSkillOutcome = null; } } } Debug.Log(debug); }