Esempio n. 1
0
        private void CreatEffect(object sender, BulletArrivedEventArgs e)
        {
            //根据不同物体 生成不同特效
            //args.Hit.collider.gameoject
//             switch (e.Hit.collider.tag)
//             {
//                 case"":
//                     break;
//             }
            //自定义规则,特效命名规则:合理利用资源名称
            //Effect+物体标签tag
            if (e.Hit.collider == null)
            {
                return;
            }
            string     prefabName = "Effect" + e.Hit.collider.tag;
            GameObject prefab     = ResourcesManager.Load <GameObject>(prefabName);

            if (prefab == null)
            {
                return;
            }
            //朝向法线方向,向法线方向移动一点
            GameObjectPool.instance.CreateObject(prefabName, prefab, e.Hit.point + e.Hit.normal * 0.01f, Quaternion.LookRotation(e.Hit.normal));
        }
Esempio n. 2
0
        //到达目标点:
        //1.对象池回收

        protected virtual void ArriveTargetPoint()
        {
            if (ArrivedTargetPoint != null)
            {
                BulletArrivedEventArgs args = new BulletArrivedEventArgs()
                {
                    Hit = hit
                };
                ArrivedTargetPoint(this, args);
            }


            GameObjectPool.instance.CollectObject(gameObject);
        }