예제 #1
0
 //对每个成员分别开启协程
 public IEnumerator AttackReach(IAttackResultMode m, float attackValue, GameObject bulletObjectPrefab, Vector3 startPosition)
 {
     foreach (Creature c in group)
     {
         c.StartCoroutine(c.AttackReach(m, attackValue, bulletObjectPrefab, startPosition));
     }
     yield break;
 }
예제 #2
0
 //开启协程等待攻击到达
 public IEnumerator AttackReach(IAttackResultMode m, float attackValue, GameObject bulletObjectPrefab, Vector3 startPosition)
 {
     //生成子弹并设定其目标
     if (bulletObjectPrefab != null)
     {
         GameObject bulletGameObject = Instantiate(bulletObjectPrefab);
         bulletGameObject.transform.position = startPosition;
         BulletObject bulletObject = bulletGameObject.GetComponent <BulletObject>();
         bulletObject.target = gameObject;
         if (bulletObject.spaceObjectPrefab != null)
         {
             bulletObject.attackResultMode = m;
             bulletObject.attackValue      = attackValue;
             yield break;//终止协程,因为bulletObject中会完成攻击,防止计算2次伤害
         }
         yield return(new WaitUntil(bulletObject.ReachSignal));
     }
     //处理攻击结果(各种ITarget的AttackReach最终都会来到这里)
     nowHealth -= m.getHealthReduction(this, attackValue);
 }
예제 #3
0
    public IEnumerator AttackReach(IAttackResultMode m, float attackValue, GameObject bulletObjectPrefab, Vector3 startPosition)
    {
        creaturesCanAttack = new List <Creature>();
        gameObject.GetComponent <Collider>().enabled = false;
        //生成子弹并设定其目的地
        if (bulletObjectPrefab != null)
        {
            GameObject bulletGameObject = Instantiate(bulletObjectPrefab);
            bulletGameObject.transform.position = startPosition;
            BulletObject bulletObject = bulletGameObject.GetComponent <BulletObject>();
            bulletObject.target = gameObject;
            yield return(new WaitUntil(bulletObject.ReachSignal));
        }
        gameObject.GetComponent <Collider>().enabled = true;
        yield return(0);//必须等到下一帧触发器结果出来

        CreatureGroup group = new CreatureGroup(m.filter.FilterList(creaturesCanAttack, PublicData.noMax));

        print("666");
        StartCoroutine(group.AttackReach(m, attackValue, null, PublicData.noMeaning));
    }
예제 #4
0
파일: AttackMode.cs 프로젝트: ztqer/MyGame
 public AttackMode(IAttackResultMode m1, IAttackFlyMode m2)
 {
     attackResultMode = m1;
     attackFlyMode    = m2;
 }
예제 #5
0
 //动画结束后进行结算
 public void AttackFly(ITarget t, IAttackResultMode m, float attackValue)
 {
     PlayAnimation();
     GlobalChangeController.GetInstance().StartCoroutine(t.AttackReach(m, attackValue, null, startPosition));
 }