Пример #1
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();
            SelfDeactivator sa = (SelfDeactivator)(target);

            sa.useObjectPool = EditorGUILayout.Toggle("Use pool: ", sa.useObjectPool);
            sa.duration      = EditorGUILayout.FloatField("Duration: ", sa.duration);
        }
Пример #2
0
        public void Shoot(AttackInstance attInst = null, Transform sp = null)
        {
            if (attInst.tgtUnit == null || attInst.tgtUnit.GetTargetT() == null)
            {
                ObjectPoolManager.Unspawn(thisObj);
                return;
            }

            attInstance = attInst;
            target      = attInstance.tgtUnit;
            //print(attInstance.srcUnit.unitName + " attacks " + attInstance.tgtUnit.unitName + " with " + attInstance.damage + " damage");

            targetPos = target.GetTargetT().position;
#if Game_2D
            hitThreshold = Mathf.Max(.01f, target.hitThreshold);
#else
            hitThreshold = Mathf.Max(.1f, target.hitThreshold);
#endif
            shootPoint = sp;

            if (shootPoint != null)
            {
                thisT.rotation = shootPoint.rotation;
            }
            if (shootEffect != null && !target.dead)
            {
                GameObject shootEffectInstance = ObjectPoolManager.Spawn(shootEffect, thisT.position, thisT.rotation);
                if (shootEffectInstance)
                {
                    effectSetting = shootEffectInstance.GetComponent <EffectSettings>();
                    if (effectSetting == null)
                    {
                        effectSetting = shootEffectInstance.GetComponentInChildren <EffectSettings>();
                    }
                    if (effectSetting)
                    {
                        if (effectSetting.EffectType == EffectSettings.EffectTypeEnum.Other)
                        {
                            Vector3 direction = (targetPos - thisT.position).normalized;
                            shootEffectInstance.transform.rotation = Quaternion.LookRotation(direction);
                        }

                        effectSetting.Target = target.GetTargetT().gameObject;
                        SelfDeactivator selfDeactivator = shootEffectInstance.GetComponent <SelfDeactivator>();
                        if (selfDeactivator == null)
                        {
                            selfDeactivator = shootEffectInstance.AddComponent <SelfDeactivator>();
                        }
                        selfDeactivator.duration = attInstance.srcUnit.CurrentStat.cooldown;
                    }
                }
                Unit.onDestroyedE += OnTargetDestroy;
            }
            hit = false;


            if (Ab_Start_Holder)
            {
                AbilityManager.instance.ActivateAbility(Ab_Start_Holder.ability, attInstance.srcUnit, targetPos, target);
            }

            if (type == _ShootObjectType.Projectile)
            {
                StartCoroutine(ProjectileRoutine());
            }
            else if (type == _ShootObjectType.Beam)
            {
                StartCoroutine(BeamRoutine());
            }
            else if (type == _ShootObjectType.Missile)
            {
                StartCoroutine(MissileRoutine());
            }
            else if (type == _ShootObjectType.Effect && EffectDelay > 0)
            {
                StartCoroutine(EffectRoutine());
            }
            else
            {
                Hit();
            }
        }