Ejemplo n.º 1
0
    public void enemyDie(GameLife toDie)
    {
        enemies.Remove(toDie);
        List <int> dropss = new List <int> ();

        dropss.Add(10);
        dropss.Add(3);
        dropss.Add(10);
        dropss.Add(3);
        dropManager.createDrops(dropss, toDie.transform.position);
        killLeft--;
        mainUIManager.updateLeftEnemy();
        if (killLeft > -1000 && killLeft <= 0)
        {
            showBattleFinish(true);
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            return;
        }
        if (used)
        {
            return;
        }
        GameLife enemy = collider.GetComponent <GameLife> ();

        anim.SetTrigger("active");
        used = true;
        enemy.buffManager.addBuff(new Buff(1, 99, 1000));
        //EffectManager.inst.Emit (transform);
        GameObject.Destroy(gameObject, 1.0f);
    }
Ejemplo n.º 3
0
    public List <GameLife> getEnemiesInRange(GameLife center, int range)
    {
        List <GameLife> res = new List <GameLife> ();

        foreach (GameLife gl in BattleManager.getInstance().getTmpEnemyList())
        {
            if (gl.gameObject == center)
            {
                continue;
            }
            int dis = (int)((center.transform.position - gl.transform.position).magnitude * 1000);
            if (dis < range)
            {
                res.Add(gl);
            }
        }
        return(res);
    }
Ejemplo n.º 4
0
 protected override void applyAtk(GameLife hit)
 {
     if (owner != null && owner.isActiveAndEnabled)
     {
         if (isNormalAtk)
         {
             owner.applyNormalAtk(hit);
             EffectManager.inst.EmitAtkCircleEffect(hit.transform, 3);
         }
         else
         {
             owner.applyMagicAtk(hit, skill);
         }
         //hit.DoDamage (owner.damage,owner.property);
     }
     //hit.findclosesr ();
     Release();
 }
Ejemplo n.º 5
0
    public void EmitBullet(string style, Tower owner, GameLife target, bool isHoming = true, SkillState skill = null, int vHight = 0, int height = 0)
    {
        GameObject b;

        if (_componentPool.Count > 0)
        {
            b = _componentPool.Pop();
        }
        else
        {
            b = GameObject.Instantiate(bulletPrefab, owner.transform.parent);
        }

        if (!bulletDic.ContainsKey(style))
        {
            AnimatorOverrideController tAnimCtrl = Resources.Load("OverrideAnimCtrl/bullet/" + style) as AnimatorOverrideController;
            if (tAnimCtrl != null)
            {
                bulletDic [style] = tAnimCtrl;
            }
            else
            {
                bulletDic [style] = Resources.Load("OverrideAnimCtrl/bullet/Default") as AnimatorOverrideController;
            }
            //GameObject a = Resources.Load ("Prefabs/bullet/"+style) as GameObject;
//			if (a != null) {
//				bulletSpritesDic [style] = a.GetComponent<SpriteRenderer> ().sprite;
//			} else {
//				bulletSpritesDic [style] = new Sprite();
//			}
        }
        AnimatorOverrideController animCtrl = bulletDic[style];

        BallisticBullet bullet = b.GetComponent <BallisticBullet> ();

        bullet.GetComponentInChildren <Animator>().runtimeAnimatorController = animCtrl;

        bullet.init(owner, target, isHoming, skill, vHight, height);
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Awake()
 {
     gl         = GetComponent <GameLife> ();
     trapPrefab = Resources.Load("Prefabs/traps/trap01") as GameObject;
     shield     = transform.Find("shield").gameObject;
 }
Ejemplo n.º 7
0
	public void EmitSpawnTowerEffect(int towerIdx,Vector2Int toSpawnPosInCell, GameLife player,float time){
		
		GameObject effect = GameObject.Instantiate (spawnTowerEffectPrefab,player.transform.parent);
		SpawnTowerEffect e = effect.GetComponent<SpawnTowerEffect> ();
		e.init (towerIdx,toSpawnPosInCell,new Vector2Int(player.posXInt,player.posYInt),time);
	}
Ejemplo n.º 8
0
 void Awake()
 {
     enemyCtrl = GetComponent <EnemyController> ();
     owner     = GetComponent <GameLife> ();
 }
Ejemplo n.º 9
0
    void applyUnhomingRangeAtk(GameLife atkTarget)
    {
        string bulletStyle = tt.tbase.bulletStyle.bulletName;

        genBullet(bulletStyle, atkTarget, null, false, false);
    }
Ejemplo n.º 10
0
    void checkAtkBehaviour(int dTime)
    {
        //如果当前未攻击 不进行判定
        if (atkStage == eAtkStage.READY)
        {
            return;
        }

        //累加攻击计时器 并改变攻击状态
        atkBhvTimer += dTime;

        bool isAttackEffect = false;

        if (atkStage == eAtkStage.PRE_YAO && atkBhvTimer > atkPreTime)
        {
            atkStage       = eAtkStage.POST_YAO;
            isAttackEffect = true;
        }
        else if (atkStage == eAtkStage.POST_YAO && atkBhvTimer > atkPreTime + atkPostTime)
        {
            atkStage    = eAtkStage.READY;
            atkBhvTimer = 0;
        }

        //当攻击丢失时 重置攻击状态
        if (atkTarget == null || !atkTarget.IsAlive)
        {
            isAttackEffect = false;
            atkStage       = eAtkStage.READY;
            atkBhvTimer    = 0;
        }
        //当还未进行攻击时 返回
        if (!isAttackEffect)
        {
            return;
        }

        switch (atkType)
        {
        case eAtkType.NONE:
            return;

        case eAtkType.MELLE_POINT:
            applyNormalAtk(atkTarget);
            break;

        case eAtkType.RANGED_HOMING:
            applyHomingRangeAtk(atkTarget);
            break;

        case eAtkType.MELLE_AOE:
            applayMeleeAOE(atkTarget);
            break;

        case eAtkType.RANGED_INSTANT:
            applyNormalAtk(atkTarget);
            break;

        case eAtkType.RANGED_MULTI:
            break;

        case eAtkType.RANGED_UNHOMING:
            applyUnhomingRangeAtk(atkTarget);
            break;

        default:                  /* 可选的 */
            break;
        }

        atkTarget = null;
    }
Ejemplo n.º 11
0
 void applyMeleeAtk(GameLife atkTarget)
 {
     applyNormalAtk(atkTarget);
 }
Ejemplo n.º 12
0
    void checkAutoSkill(int dTime)
    {
        if (checkSkillTimer > 0)
        {
            checkSkillTimer -= dTime;
        }
        if (checkSkillTimer > 0)
        {
            return;
        }

        if (castStage != eAtkStage.READY)
        {
            return;
        }
        checkSkillTimer = CHECK_SKILL_INTERVAL;

        List <int> readySkills = skillComponent.getReadySkill();

        GameLife closestOne = MapManager.getInstance().getClosestEnemy(this);

        List <int> readyUsableSkill = new List <int> ();

        if (readySkills.Count == 0)
        {
            return;
        }
        if (closestOne == null || !closestOne.IsAlive)
        {
            return;
        }

        for (int i = 0; i < readySkills.Count; i++)
        {
            SkillState skill = skillComponent.skills [readySkills [i]];

            int diss = (posXInt - closestOne.posXInt) * (posXInt - closestOne.posXInt) + (posYInt - closestOne.posYInt) * (posYInt - closestOne.posYInt);
            int dis  = (int)Mathf.Sqrt(diss);


            //Vector2 diff = closestOne.transform.position - transform.position;

            TowerSkill s = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId);

            if (s.tsType == eTowerSkillType.SELF_TARGET)
            {
                readyUsableSkill.Add(readySkills[i]);
            }
            else
            {
                if (dis <= s.x[skill.skillLevel - 1])
                {
                    readyUsableSkill.Insert(0, readySkills[i]);
                }
            }
        }

        if (readyUsableSkill.Count == 0)
        {
            return;
        }

        SkillState toUse = skillComponent.skills[readyUsableSkill [0]];
        TowerSkill ss    = GameStaticData.getInstance().getTowerSkillInfo(toUse.skillId);

        if (ss.tsType == eTowerSkillType.SELF_TARGET)
        {
            anim.SetTrigger("buff");
        }
        else if (ss.tsType == eTowerSkillType.ACTIVE)
        {
            castTarget = closestOne;
            anim.SetTrigger("skill");
            anim.SetFloat("skill_style", Random.Range(0, 2) * 1.0f);
        }
        else
        {
        }

        skillComponent.setSkillCD(readyUsableSkill [0]);
        castBhvTimer = 0;
        castStage    = eAtkStage.PRE_YAO;
        castIdx      = readyUsableSkill [0];
    }
Ejemplo n.º 13
0
 protected virtual bool validTarget(GameLife gl)
 {
     return(true);
 }
Ejemplo n.º 14
0
 protected virtual void applyAtk(GameLife hit)
 {
 }
Ejemplo n.º 15
0
    void setTarget()
    {
        target = BattleManager.getInstance().player.gl;
//		target.followers.Add (this);
    }