コード例 #1
0
        //for 'point' shootobject, which hits the target poins immediately (after a frame)
        IEnumerator PointRoutine(AimInfo aimInfo)
        {
            yield return(null);

            thisT.position = aimInfo.hitPoint;                  //move the shootobject to hitpoint

            OnTriggerEnter(aimInfo.collider);
        }
コード例 #2
0
    /// <summary>
    /// 得到目标的位移
    /// </summary>
    /// <param name="pSearcher">搜寻者自身的位移</param>
    /// <returns></returns>
    public Transform getAim(Transform pSearcher)
    {
        //if (!collisionLayer.isAliveFullCheck(nowAim) && (mAimList.Count > 0))
        //Debug.Log(activeCheck(nowAim, pSearcher));
        //Debug.Log("mAimList.Count" + mAimList.Count);

        if(!activeCheck(nowAim, pSearcher))
        {
            nowAim = popAim();
        }

        return nowAim == null ? null : nowAim.aimTransform;
    }
コード例 #3
0
ファイル: AiAimList.cs プロジェクト: Seraphli/TheInsectersWar
 public Transform getRandomAim(AimInfo pAimInfo)
 {
     if(pAimInfo.race== Race.eNone)
     {
         if (pAimInfo.aimUnitType == GameSceneManager.UnitManagerType.stronghold)
         {
             return getRandomAim( GameSceneManager.
                     Singleton.getManager(GameSceneManager.MapManagerType.stronghold).managerRoot
                     );
         }
         else
             return null;
     }
     return getRandomAim(GameSceneManager.
         Singleton.getManager(pAimInfo.race, pAimInfo.aimUnitType).managerRoot
         );
 }
コード例 #4
0
    public void checkAndAddAim(AimInfo pAim)
    {
        //Debug.Log(pAim);
        //Debug.Log(nowAim);
        //Debug.Log(pAim && (nowAim != pAim));
        //if (collisionLayer.isAliveFullCheck(pAim) && (nowAim != pAim))
        //Debug.Log(pAim.aimTransform.name);
        //Debug.Log("added before" + mAimList.Count);
        if (activeCheck(pAim))//目标可用可用
        {
            //如果原目标与新的不一样,并且可用,则增加到候选表中
            if (
                nowAim != null
                && nowAim.aimTransform != pAim.aimTransform
                && activeCheck(nowAim)
                )
                mAimList.Add(nowAim);

            //新目标
            nowAim = pAim;
        }
        refreshAimDebugInfo();
        //Debug.Log("added after" + mAimList.Count);
    }
コード例 #5
0
ファイル: ShootObject.cs プロジェクト: NDGAME/Git_test
        //for 'point' shootobject, which hits the target poins immediately (after a frame)
        IEnumerator PointRoutine(AimInfo aimInfo)
        {
            yield return null;

            thisT.position=aimInfo.hitPoint;	//move the shootobject to hitpoint

            OnTriggerEnter(aimInfo.collider);
        }
コード例 #6
0
ファイル: ShootObject.cs プロジェクト: NDGAME/Git_test
        //function call to fire the object
        public void Shoot(int srcL, float srcR, Transform shootPoint, AttackInstance aInstance=null, AimInfo aimInfo=null)
        {
            Init();

            thisObj.SetActive(true);

            //cached all the passed information lcoally
            attInstance=aInstance;
            srcLayer=srcL;	//the layer of the shooting unit (so we know it's from player or AI)
            srcRange=srcR;	//the range of the shooting unit (so we know when to stop)

            state=_State.Shot;
            shootTime=Time.time;	//to track how long the shoot object is has been
            travelledDistance=0;	//to track how far the shoot object is has been fired

            //if there's any hideObject, set it to true (it's probably set to false when the shoot-object last hit something)
            if(hideObject!=null) hideObject.SetActive(true);

            //instantiate the shoot effect
            ShootEffect(thisT.position, thisT.rotation);

            if(type==_SOType.Simple || type==_SOType.Homing){
                //if(aInstance!=null && thisCollider.enabled){
                    //~ Physics.IgnoreCollision(aInstance.srcUnit.GetCollider(), thisObj.GetComponent<Collider>(), true);
                    //Debug.Log("collision avoidance with shooter unresolved");
                    //Physics.IgnoreCollision(srcCollider, thisCollider, true);
                //}

                // for homing shootobject, the shootobject needs to be aiming at some position, or a specific unit
                if(type==_SOType.Homing){
                    if(aimInfo.targetT!=null) targetUnit=aimInfo.unit;

                    targetPos=aimInfo.hitPoint+new Vector3(Random.value-0.5f, 0, Random.value-0.5f)*2*spread;
                    initialPos=shootPoint.position;
                    initialDist=Vector3.Distance(targetPos, initialPos);

                    curveMod=Random.Range(0, 2f);
                    dummyPos=thisT.TransformPoint(Vector3.forward*speed*5);
                    dummyPos=(targetPos+dummyPos)/2;
                }
            }
            else if(type==_SOType.Beam){
                //if(attachedToShootPoint) transform.parent=shootPoint;
                thisT.parent=shootPoint;
                ObjectPoolManager.Unspawn(thisObj, beamDuration-.01f);
            }
            else if(type==_SOType.Point){
                StartCoroutine(PointRoutine(aimInfo));
            }

            //update the layermask used to do the hit detection in accordance to rules set in GameControl
            UpdateSphereCastMask(!GameControl.SOHitFriendly(), !GameControl.SOHitShootObject(), !GameControl.SOHitCollectible());
        }
コード例 #7
0
    /// <summary>
    /// 检测目标点是否可用,可用则返回真
    /// </summary>
    /// <param name="pAimInfo">目标点信息</param>
    /// <param name="pSearcher">寻找者的位置</param>
    /// <returns></returns>
    bool activeCheck(AimInfo pAimInfo,Transform pSearcher)
    {
        //Debug.Log(pAimInfo==null?"null":pAimInfo.ToString());
        if (pAimInfo != null)
        {
            switch (pAimInfo.aimType)
            {
                case AimType.checkPoint:
                    if (pAimInfo.aimTransform)
                    {
                        Vector3 lLengthVector
                            = pAimInfo.aimTransform.position - pSearcher.position;

                        //Debug.Log("" + lLengthVector.sqrMagnitude + ">" + sqrCheckPointRadius);
                        return lLengthVector.sqrMagnitude > sqrCheckPointRadius;
                    }
                    else
                        return false;

                case AimType.aliveAim:
                    //Debug.Log(AimType.aliveAim);
                    return collisionLayer.isAliveFullCheck(pAimInfo.aimTransform);

            }
            Debug.LogError("activeCheck(AimInfo pAimInfo,Transform pSearcher)");
        }
        //Debug.Log("pAimInfo==null");
        return false;
    }
コード例 #8
0
    /// <summary>
    /// 检测目标点是否可用,可用则返回真
    /// </summary>
    /// <param name="pAimInfo">目标点信息</param>
    /// <returns></returns>
    bool activeCheck(AimInfo pAimInfo)
    {
        if (pAimInfo!=null)
        {
            switch(pAimInfo.aimType)
            {
                case AimType.checkPoint:
                    return pAimInfo.aimTransform;
                    //break;

                case AimType.aliveAim:
                    //Debug.Log(collisionLayer.isAliveFullCheck(pAimInfo.aimTransform));
                    return collisionLayer.isAliveFullCheck(pAimInfo.aimTransform);
                    //break;

                //default:
                //    Debug.LogError("activeCheck(AimInfo pAimInfo)");
                    //break;
            }
            Debug.LogError("activeCheck(AimInfo pAimInfo)");

        }
        //Debug.Log("activeCheck(AimInfo pAimInfo) return false");
        return false;
    }
コード例 #9
0
 //移除当前的目标
 public void removeNowAim()
 {
     nowAim = popAim();
 }
コード例 #10
0
        //function call to fire the object
        public void Shoot(int srcL, float srcR, Transform shootPoint, AttackInstance aInstance = null, AimInfo aimInfo = null)
        {
            Init();

            thisObj.SetActive(true);

            //cached all the passed information lcoally
            attInstance = aInstance;
            srcLayer    = srcL;         //the layer of the shooting unit (so we know it's from player or AI)
            srcRange    = srcR;         //the range of the shooting unit (so we know when to stop)

            state             = _State.Shot;
            shootTime         = Time.time;      //to track how long the shoot object is has been
            travelledDistance = 0;              //to track how far the shoot object is has been fired

            //if there's any hideObject, set it to true (it's probably set to false when the shoot-object last hit something)
            if (hideObject != null)
            {
                hideObject.SetActive(true);
            }

            //instantiate the shoot effect
            ShootEffect(thisT.position, thisT.rotation, shootPoint);

            if (type == _SOType.Simple || type == _SOType.Homing)
            {
                //if(aInstance!=null && thisCollider.enabled){
                //~ Physics.IgnoreCollision(aInstance.srcUnit.GetCollider(), thisObj.GetComponent<Collider>(), true);
                //Debug.Log("collision avoidance with shooter unresolved");
                //Physics.IgnoreCollision(srcCollider, thisCollider, true);
                //}

                // for homing shootobject, the shootobject needs to be aiming at some position, or a specific unit
                if (type == _SOType.Homing)
                {
                    if (aimInfo.targetT != null)
                    {
                        targetUnit = aimInfo.unit;
                    }

                    targetPos   = aimInfo.hitPoint + new Vector3(Random.value - 0.5f, 0, Random.value - 0.5f) * 2 * spread;
                    initialPos  = shootPoint.position;
                    initialDist = Vector3.Distance(targetPos, initialPos);

                    curveMod = Random.Range(0, 2f);
                    dummyPos = thisT.TransformPoint(Vector3.forward * speed * 5);
                    dummyPos = (targetPos + dummyPos) / 2;
                }
            }
            else if (type == _SOType.Beam)
            {
                //if(attachedToShootPoint) transform.parent=shootPoint;
                thisT.parent = shootPoint;
                ObjectPoolManager.Unspawn(thisObj, beamDuration - .01f);
            }
            else if (type == _SOType.Point)
            {
                StartCoroutine(PointRoutine(aimInfo));
            }

            //update the layermask used to do the hit detection in accordance to rules set in GameControl
            UpdateSphereCastMask(!GameControl.SOHitFriendly(), !GameControl.SOHitShootObject(), !GameControl.SOHitCollectible());
        }