Пример #1
0
    public Object GetObject(string name, Vector3 position, Quaternion rotation)
    {
        string key = name + "(Clone)";
        Object o;

        if (pool.ContainsKey(key) && pool[key].Count > 0)
        {
            ArrayList list = pool[key];
            o = list[0] as Object;
            list.Remove(0);
            //重新初始化相关状态
            (o as GameObject).SetActive(true);
            (o as GameObject).transform.position = position;
            (o as GameObject).transform.rotation = rotation;
            //(o as GameObject).GetComponent<DelayDestroy>().Init();
        }
        else
        {
            o = Instantiate(Resources.Load(name), position, rotation) as Object;
        }
        DelayDestroy dd = (o as GameObject).GetComponent <DelayDestroy>();

        dd.Init();
        return(o);
    }
Пример #2
0
    void editor_onActorPassBallOut(ActorView actor)
    {
        if (actorEffect != null)
        {
            GameObject   ga    = GameObject.Instantiate(actorEffect);
            DelayDestroy delay = ga.AddComponent <DelayDestroy>();
            delay.destroyTime = 5.0f;
            if (actorEffectPoint == null)
            {
                ga.transform.parent = actor.transform;
            }
            else
            {
                ga.transform.parent = actorEffectPoint;
            }
            ga.transform.localPosition = Vector3.zero;
        }

        if (ballTailEffect != null)
        {
            GameObject   ga    = GameObject.Instantiate(ballTailEffect);
            DelayDestroy delay = ga.AddComponent <DelayDestroy>();
            delay.destroyTime          = 10.0f;
            ga.transform.parent        = SceneViews.instance.getCurFBScene().ball.transform;
            ga.transform.localPosition = Vector3.zero;
        }
    }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Explosion")) //폭탄
     {
         DelayDestroy enemy = other.GetComponent <DelayDestroy>();
         Hit(enemy.damage, enemy.transform.position, enemy.nuckBackDistance);
     }
 }
Пример #4
0
 void editor_onBallHit(Vector3 position)
 {
     if (ballHitEffect != null)
     {
         GameObject   ga    = GameObject.Instantiate(ballHitEffect);
         DelayDestroy delay = ga.AddComponent <DelayDestroy>();
         delay.destroyTime     = 5.0f;
         ga.transform.position = position;
     }
 }
Пример #5
0
    public void Kill(Vector3 velocity)
    {
        //velocity.y = 0;
        gc.subtract_from_enemies_done(1);
        gameObject.layer = LayerMask.NameToLayer("DeadEnemy");
        print(velocity);
        rb.velocity   = velocity;
        rb.useGravity = true;
        DelayDestroy script = gameObject.AddComponent <DelayDestroy>();

        script.destroyTime     = DIE_TIME;
        script.onDestroyObject = deathParticlesPrefab;
        enabled = false;
    }
Пример #6
0
    private void OnTriggerEnter2D(Collider2D other) //충돌함수
    {
        if (pv.IsMine)
        {
            if (other.CompareTag("Teleport")) //순간이동
            {
                StopAllCoroutines();
                canMove = true;
                SetAnimRPC(0);
                FindObjectOfType<Fade>().Teleport(this,GameObject.Find(other.name + "_T").transform.position);
            }

            if (other.CompareTag("Explosion")) //폭탄
            {
                DelayDestroy enemy = other.GetComponent<DelayDestroy>();
                if (enemy.isWire)
                {
                    if (!enemy.gameObject.GetComponent<PhotonView>().IsMine)
                    {
                        if(pc.isKor()) 
                            Hit(enemy.damage, enemy.myName,enemy.nuckBackDistance,enemy.transform.position);
                        else
                            Hit(enemy.damage, enemy.myName2,enemy.nuckBackDistance,enemy.transform.position);   
                        enemy.gameObject.GetComponent<Mine>().DestroyRPC();
                    }
                }
                else
                {
                    if(pc.isKor()) 
                        Hit(enemy.damage, enemy.myName,enemy.nuckBackDistance,enemy.transform.position);
                    else
                        Hit(enemy.damage, enemy.myName2,enemy.nuckBackDistance,enemy.transform.position);
                    StartCoroutine(superTick());   
                }
            }

            if (other.CompareTag("rantem"))
                playerItem.ranTem();
        }
    }
Пример #7
0
        private static void ExecuteEffectEvent(ActionStatus status, EffectEventArgs args)
        {
            Transform parent = null;

            switch (args.BindingType)
            {
            case EffectBindingType.BindingOnwer:
            {
                parent = status.Onwer.CacheTransform;
            }
            break;

            case EffectBindingType.BindingSkeleton:
            {
                parent = status.Onwer.GetSkeleton(args.BindingSkeletonName);
            }
            break;
            }

            GameObject inst = null;
            PrefabPool prefabPool;

            if (_prefabInst.TryGetValue(args.ResourcePath, out prefabPool))
            {
                inst = prefabPool.SpawnInstance().gameObject;
            }
            else
            {
                var prefab = (GameObject)ResourceCenter.LoadAsset(args.ResourcePath);
                prefabPool = new PrefabPool(prefab.transform);
                inst       = prefabPool.SpawnInstance().gameObject;
                _prefabInst.Add(args.ResourcePath, prefabPool);
            }


            inst.transform.parent        = parent;
            inst.transform.localPosition = new Vector3(args.PositionX * 0.01f, args.PositionY * 0.01f, args.PositionZ * 0.01f);
            inst.transform.localRotation = Quaternion.Euler(args.RotateX, args.RotateY, args.RotateZ);



            switch (args.LifeType)
            {
            case EffectLifeType.OwnerHit:
                break;

            case EffectLifeType.InterruptAction:
                break;

            case EffectLifeType.FollowAction:
            case EffectLifeType.TimeOut:
            {
                DelayDestroy delayDestroy = inst.GetComponent <DelayDestroy>();
                if (delayDestroy == null)
                {
                    delayDestroy            = inst.AddComponent <DelayDestroy>();
                    delayDestroy.OnCompleta = OnRecycle;
                }
                delayDestroy.ResourceName = args.ResourcePath;
                delayDestroy.TimeMs       = args.LifeTime;
                delayDestroy.Start();
            }
            break;
            }


            inst.SetActive(true);
        }