コード例 #1
0
    public GameObject Play(string effName, Vector3 offest, Transform parent, float lifeTime = 0)
    {
        if (string.IsNullOrEmpty(effName))
        {
            return(null);
        }
        string effPath = PathManager.GetEffectPath(effName);
        var    eff     = PoolManager.InstantiateGameObject(effPath, PoolType.Effect);

        if (parent != null)
        {
            eff.transform.SetParent(parent);
            eff.transform.localScale = parent.localScale;
            //if (parent.localScale.x > 0)
            //{
            eff.transform.localPosition = offest;
            //}
            //else
            //{
            //    eff.transform.localPosition = new Vector3(-offest.x, offest.y, offest.z);
            //}
        }
        else
        {
            eff.transform.position = offest;
        }
        var          ctrl = eff.GetComponent <EffectCtrl>() ?? eff.AddComponent <EffectCtrl>();
        EffectConfig cfg  = new EffectConfig();

        cfg.LifeTime = lifeTime;
        MonoBehaviourManager.Add(ctrl, cfg);
        return(eff);
    }
コード例 #2
0
    public GameObject Play(string effName, Vector3 pos, bool isFaceRight, float lifeTime = 0)
    {
        if (string.IsNullOrEmpty(effName))
        {
            return(null);
        }
        string effPath = PathManager.GetEffectPath(effName);
        var    eff     = PoolManager.InstantiateGameObject(effPath, PoolType.Effect);

        eff.transform.position = pos;
        if (isFaceRight)
        {
            eff.transform.localScale = Vector3.one;
        }
        else
        {
            eff.transform.localScale = new Vector3(-1, 1, 1);
        }
        var          ctrl = eff.GetComponent <EffectCtrl>() ?? eff.AddComponent <EffectCtrl>();
        EffectConfig cfg  = new EffectConfig();

        cfg.LifeTime = lifeTime;
        MonoBehaviourManager.Add(ctrl, cfg);
        return(eff);
    }
コード例 #3
0
    private void Start()
    {
        var player = MonoBehaviourManager.GetById(PlayerId);

        if (player == null)
        {
            PlayerConfig rCfg = PlayerConfig.GetData(PlayerId);
            string       path = PathManager.RolePrefabsPath + rCfg.Name + "/" + rCfg.Name;
            var          obj  = ResourceManager.Load <GameObject>(path);
            var          go   = GameObject.Instantiate(obj);
            go.transform.position = transform.position;
            DontDestroyOnLoad(go);
            var character = go.GetComponent <Character>();
            MonoBehaviourManager.Add(character);
            CameraManager.SetFollowTarget(character.transform);
        }
        else
        {
            player.transform.position = transform.position;
            CameraManager.SetFollowTarget(player.transform);
        }
    }
コード例 #4
0
 IEnumerator ShootStartIE()
 {
     while (_wave > 0)
     {
         var bullet = PoolManager.InstantiateGameObject(_bullet, PoolType.Bullet);
         MonoBehaviourManager.Add(bullet.GetComponent <BulletBase>(), _bulletDamage, _targetLayer);
         bullet.transform.position = transform.position;
         bullet.transform.right    = _bulletDir;
         _wave--;
         if (_intervalTime != 0)
         {
             float timeCount = 0;
             while (timeCount < _intervalTime)
             {
                 timeCount += GameManager.DeltaTime;
                 yield return(null);
             }
         }
         //yield return new WaitForSeconds(_intervalTime);
     }
     ShootEnd = true;
 }
コード例 #5
0
    private void Start()
    {
        string path = "";

        switch (Type)
        {
        case EnemyType.怪物:
            MonsterConfig mCfg = MonsterConfig.GetData(EnemyId);
            path = PathManager.RolePrefabsPath + mCfg.Name + "/" + mCfg.Name;
            break;

        case EnemyType.Boss:
            BossConfig bCfg = BossConfig.GetData(EnemyId);
            path = PathManager.RolePrefabsPath + bCfg.Name + "/" + bCfg.Name;
            break;
        }
        var obj = ResourceManager.Load <GameObject>(path);
        var go  = GameObject.Instantiate(obj);

        go.transform.SetParent(transform, false);
        var character = go.GetComponent <Character>();

        MonoBehaviourManager.Add(character);
    }
コード例 #6
0
 void OnEnable()
 {
     MonoBehaviourManager.Add(this);
 }