public void SetInstance(Vector3 mPos, MonsterActState mState, MonsterColor mColor, float mSpeed) { GameObject obj = Pool.BirthCell(); obj.transform.position = mPos; Monster monster = obj.GetComponent <Monster>(); monster.MonsterState = mState; monster.OnSetState(); monster.ColorType = mColor; monster.SetInitSpeed(mSpeed); }
// Update is called once per frame void FixedUpdate() { if (playerTrans == null) { return; } if (Mathf.Abs(collection[pCollection].Key - pTime) < 0.02f) { var currentVal = collection[pCollection].Value; MonsterActState state = dicActState.ContainsKey(currentVal.actType) ? dicActState[currentVal.actType] : MonsterActState.NONE; MonsterColor color = dicColorType.ContainsKey(currentVal.colorType) ? dicColorType[currentVal.colorType] : MonsterColor.NONE; EnemyFactory.Instance.SetInstance( new Vector3(0, 0, playerTrans.position.z + currentVal.deltaZ), state, color, currentVal.mSpeed); pCollection++; } else if (pTime - collection[pCollection].Key > 1) { pCollection++; } if (pCollection == collection.Length) { pCollection = 0; pTime = 0; } if (EnemyFactory.Instance.ActiveCount < 5 && GameMode.Instance.Player.IsAlive) { pTime += Time.fixedDeltaTime; } }