Example #1
0
 // Use this for initialization
 void Start()
 {
     if (type == _AttackCreepType.Attack && shootObject != null)
     {
         ShootObject shootObj = shootObject.GetComponent <ShootObject>();
         if (shootObj != null && shootObj.type == _ShootObjectType.Projectile)
         {
             turretMaxAngle = shootObj.maxShootAngle;
             turretMaxRange = shootObj.maxShootRange;
         }
     }
 }
Example #2
0
    public void Shoot()
    {
        if (Time.time - lastShootT < cooldown)
        {
            return;
        }

        lastShootT = Time.time;

        foreach (Transform sp in shootPoint)
        {
            GameObject  shootObj = (GameObject)Instantiate(shootObject, sp.position, sp.rotation);
            ShootObject soCom    = shootObj.GetComponent <ShootObject>();
            if (soCom != null)
            {
                soCom.Shoot(damage, 0);
            }
        }
    }
    public override void OnInspectorGUI()
    {
        ShootObject shootObj = (ShootObject)target;

        Undo.SetSnapshotTarget(shootObj, "ShootObjectEditor");

        if (!init)
        {
            Init();
        }

        GUI.changed = false;

        //shootObj.type

        //shootObj.type= EditorGUILayout.EnumPopup("Type: ", shootObj.type);

        if (shootObj.type == _ShootObjectType.Projectile)
        {
            type = 0;
        }
        else if (shootObj.type == _ShootObjectType.Missile)
        {
            type = 1;
        }
        else if (shootObj.type == _ShootObjectType.Beam)
        {
            type = 2;
        }
        else if (shootObj.type == _ShootObjectType.Effect)
        {
            type = 3;
        }

        type = EditorGUILayout.IntPopup("Type: ", type, typeLabel, typeID);
        EditorGUILayout.Space();

        if (type == 0)
        {
            shootObj.type = _ShootObjectType.Projectile;
            //if(shootObj.type==_ShootObjectType.Projectile){


            shootObj.speed         = EditorGUILayout.FloatField("Speed:", shootObj.speed);
            shootObj.maxShootRange = EditorGUILayout.FloatField("Max Range:", shootObj.maxShootRange);
            shootObj.maxShootAngle = EditorGUILayout.FloatField("Max Angle:", shootObj.maxShootAngle);
        }
        else if (type == 1)
        {
            shootObj.type = _ShootObjectType.Missile;
            //if(shootObj.type==_ShootObjectType.Missile){


            shootObj.speed         = EditorGUILayout.FloatField("Speed:", shootObj.speed);
            shootObj.maxShootRange = EditorGUILayout.FloatField("Max Range:", shootObj.maxShootRange);
            shootObj.maxShootAngle = EditorGUILayout.FloatField("Max Angle:", shootObj.maxShootAngle);
        }
        else if (type == 2)
        {
            shootObj.type = _ShootObjectType.Beam;
            //if(shootObj.type==_ShootObjectType.Instant){


            shootObj.lineRenderer    = (LineRenderer)EditorGUILayout.ObjectField("LineRenderer:", shootObj.lineRenderer, typeof(LineRenderer), false);
            shootObj.beamLength      = EditorGUILayout.FloatField("Beam Length:", shootObj.beamLength);
            shootObj.duration        = EditorGUILayout.FloatField("Active Duration:", shootObj.duration);
            shootObj.continousDamage = EditorGUILayout.Toggle("ContinousDamage", shootObj.continousDamage);

            if (shootObj.lineRenderer == null)
            {
                shootObj.lineRenderer = shootObj.gameObject.GetComponent <LineRenderer>();
            }
        }
        else if (type == 3)
        {
            shootObj.type = _ShootObjectType.Effect;
            //if(shootObj.type==_ShootObjectType.Effect){


            shootObj.pType = EditorGUILayout.IntPopup("EffectType: ", shootObj.pType, effectTypeLabel, effectTypeID);
            if (effectType == 1)
            {
                //if(shootObj.GetParticleSystem()==null) shootObj.GetParticleSystem();
            }
            else if (effectType == 2)
            {
                //if(shootObj.GetParticleEmitter()==null) shootObj.GetParticleEmitter();
                shootObj.oneShot = EditorGUILayout.Toggle("OneShot", shootObj.oneShot);
            }
        }

        EditorGUILayout.Space();


        shootObj.shootAudio = (AudioClip)EditorGUILayout.ObjectField("Shoot Sound: ", shootObj.shootAudio, typeof(AudioClip), false);

        if (type != 3)
        {
            shootObj.hitAudio = (AudioClip)EditorGUILayout.ObjectField("Hit Sound: ", shootObj.hitAudio, typeof(AudioClip), false);
            EditorGUILayout.Space();


            shootObj.shootEffect = (GameObject)EditorGUILayout.ObjectField("Shoot Effect: ", shootObj.shootEffect, typeof(GameObject), false);
            shootObj.hitEffect   = (GameObject)EditorGUILayout.ObjectField("hit Effect: ", shootObj.hitEffect, typeof(GameObject), false);
            EditorGUILayout.Space();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(shootObj);
            Undo.CreateSnapshot();
            Undo.RegisterSnapshot();
        }
        Undo.ClearSnapshotTarget();
    }
Example #4
0
    //called by a support creep to buff this creep
    //~ private List<BuffStat> activeBuffList=new List<BuffStat>();
    //~ public void Buff(BuffStat newBuff){
    //~ if(activeBuffList.Contains(newBuff)) return;

    //~ activeBuffList.Add(newBuff);

    //~ damage=damage*(1+newBuff.damageBuff);
    //~ range=range*(1+newBuff.rangeBuff);
    //~ cooldown=cooldown*(1-newBuff.cooldownBuff);
    //~ if(newBuff.regenHP>0) StartCoroutine(RegenHPRoutine(newBuff));
    //~ }


    //~ //remove buff effect
    //~ public void UnBuff(int buffID){
    //~ BuffStat tempBuff;
    //~ for(int i=0; i<activeBuffList.Count; i++){
    //~ tempBuff=activeBuffList[i];
    //~ if(tempBuff.buffID==buffID){
    //~ damage=damage/(1+tempBuff.damageBuff);
    //~ range=range/(1+tempBuff.rangeBuff);
    //~ cooldown=cooldown/(1-tempBuff.cooldownBuff);

    //~ activeBuffList.RemoveAt(i);

    //~ break;
    //~ }
    //~ }
    //~ }

    //~ IEnumerator RegenHPRoutine(BuffStat buff){
    //~ while(activeBuffList.Contains(buff)){
    //~ //HPAttribute.HP=Mathf.Min(HPAttribute.fullHP, HP+);
    //~ unit.GainHP(Time.deltaTime*buff.regenHP);
    //~ yield return null;
    //~ }
    //~ }


    IEnumerator AttackRoutine()
    {
        if (shootPoint == null || shootPoint.Length == 0)
        {
            shootPoint    = new Transform[1];
            shootPoint[0] = unit.thisT;
        }
        while (true)
        {
            float delay = 0;

            if (target != null && !unit.IsStunned() && !unit.IsDead() && targetInLOS && currentClip > 0)
            {
                Vector3 targetPoint = target.GetTargetT().position;

                if (unit.PlayAttack())
                {
                    delay = aniAttackTimeOffset;
                    yield return(new WaitForSeconds(delay));
                }

                if (target != null)
                {
                    if (attackMethod == _AttackMethod.Range)
                    {
                        if (shootObject != null)
                        {
                            foreach (Transform sPoint in shootPoint)
                            {
                                GameObject  obj      = ObjectPoolManager.Spawn(shootObject, sPoint.position, sPoint.rotation);
                                ShootObject shootObj = obj.GetComponent <ShootObject>();
                                shootObj.Shoot(target, this, sPoint);
                            }
                        }
                    }
                    else if (attackMethod == _AttackMethod.Melee)
                    {
                        ApplyEffect(target);
                    }
                }
                else
                {
                    if (attackMethod == _AttackMethod.Range)
                    {
                        if (shootObject != null)
                        {
                            foreach (Transform sPoint in shootPoint)
                            {
                                GameObject  obj      = ObjectPoolManager.Spawn(shootObject, sPoint.position, sPoint.rotation);
                                ShootObject shootObj = obj.GetComponent <ShootObject>();
                                shootObj.Shoot(targetPoint, this, sPoint);
                            }
                        }
                    }
                }

                if (attackSound != null)
                {
                    AudioManager.PlaySound(attackSound, unit.thisT.position);
                }

                yield return(new WaitForSeconds(cooldown - delay));
            }
            else
            {
                //~ Debug.Log("target:"+target+"  stunned:"+unit.IsStunned()+"  targetInLOS:"+targetInLOS+"   clipSize:"+currentClip);

                if (cdTracking == _CDTracking.Precise)
                {
                    yield return(null);
                }
                else
                {
                    yield return(new WaitForSeconds(Random.Range(0, cooldown)));
                }
            }
        }
    }