Пример #1
0
 public override void OnTargetLock(RTSGameObject rtsGameObject)
 {
     if (isPursuing)
     {
         StopMoving();
     }
 }
Пример #2
0
        //------------------------------ Attacking ------------------------------
        #region Attacking
        public override void Attack(RTSGameObject rtsGameObject)
        {
            if (targetToPursue != rtsGameObject)                //If we are not aleready pursuing this RTS target
            {
                targetToPursue = HoverManager.main.currentHoverRTSObject;

                if (isTargetLock)                   //We are already targeting someone
                {
                    targetLock = targetToPursue;

                    if (coroutineAttack != null)
                    {
                        StopCoroutine(coroutineAttack);
                    }
                    coroutineAttack = StartCoroutine(Attack(turret, targetLock.gameObject));
                }
                else                            //If we do not yet have a targetLock

                {
                }

                TravelToPath(targetToPursue.transform.position);
            }
            else
            {
                //Debug.Log("Already pusuing this target.");
            }
        }
Пример #3
0
 //------------------------------ OnTargetLock ------------------------------
 #region OnTargetLock
 public override void OnTargetLockEnter(RTSGameObject rtsGameObject)
 {
     if (coroutineAttack != null)
     {
         StopCoroutine(coroutineAttack);
     }
     coroutineAttack = StartCoroutine(Attack(turret, targetLock.gameObject));
 }
Пример #4
0
        public void StopAttacking()
        {
            isAttacking    = false;
            targetToPursue = null;
            targetLock     = null;

            if (coroutineAttack != null)
            {
                StopCoroutine(coroutineAttack);
            }
            OnAttackingEnd();               //Method message
        }
Пример #5
0
 public override void OnAttacking(RTSGameObject rtsGameObject)
 {
     //Debug.Log("OnAttacking");
 }
Пример #6
0
 public override void OnPursuing(RTSGameObject rtsGameObject)
 {
     //Debug.Log("OnPursuing");
 }
Пример #7
0
 public override void Attack(RTSGameObject rtsGameObject)
 {
     //Todo:
 }
Пример #8
0
        }                                                                                                       //Called while this object has found a target lock

        public virtual void OnTargetLockLeave(RTSGameObject rtsGameObject)
        {
        }                                                                                                       //Called once when this object has lost it's target lock
Пример #9
0
        }                                                                                                       //Called once when this object has found a target lock

        public virtual void OnTargetLock(RTSGameObject rtsGameObject)
        {
        }                                                                                                       //Called while this object has found a target lock
Пример #10
0
        }                                                                                                       //Called while object is searching for a target lock

        public virtual void OnTargetLockEnter(RTSGameObject rtsGameObject)
        {
        }                                                                                                       //Called once when this object has found a target lock
Пример #11
0
 public abstract void Attack(RTSGameObject rtsGameObject);
Пример #12
0
        public virtual void Update()
        {
            if (teamController != null && canAttack) //If we have a teamController && If we can attack
            {
                if (!isTargetLock)                   //If we dont have a target lock

                {
                    OnTargetLockSearch();                       //Method message

                    //Searching for targetLock using attack radius
                    RaycastHit[] hits = Physics.SphereCastAll(this.transform.position, attackRadius, Vector3.up);
                    foreach (RaycastHit hit in hits)
                    {
                        GameObject hitGameObject = hit.collider.gameObject;
                        if (hitGameObject != gameObject)                            //If the gameObject is not ourself
                        {
                            RTSGameObject hitRTSGameObject = hitGameObject.GetComponent <RTSGameObject>();
                            if (hitRTSGameObject != null)                               //If the object is a RTSGameObject

                            //if(hitRTSGameObject.unitType == UnitType.UnitEnemy || hitRTSGameObject.unitType == UnitType.BuildingEnemy) {
                            //	FindTargetLock(hitGameObject);
                            //}

                            {
                                if (teamController.IsRTSEnemy(hitRTSGameObject))
                                {
                                    FindTargetLock(hitGameObject);
                                }

                                if (teamController.team == Team.Red)
                                {
                                    //Debug.Log("Attack: " + attackRadius);
                                }
                            }
                        }
                    }
                }
                //If we do have a target lock
                else
                {
                    bool hasFoundTargetLock = false;

                    //Check if the lock target still within range
                    RaycastHit[] hits = Physics.SphereCastAll(this.transform.position, attackRadius, Vector3.up);
                    foreach (RaycastHit hit in hits)
                    {
                        GameObject hitGameObject = hit.collider.gameObject;

                        if (hitGameObject.GetComponent <RTSGameObject>() == targetLock)                           //If we have found our target lock
                        {
                            hasFoundTargetLock = true;
                            break;
                        }
                    }

                    if (hasFoundTargetLock)                         //If the target lock is still within range
                    //Debug.Log("Found target");
                    {
                        OnTargetLock(targetLock);       //Method message
                    }
                    else                                //If the target left
                    {
                        OnTargetLockLeave(targetLock);  //Method message
                        targetLock = null;
                    }
                }
            }

            if (health <= 0)
            {
                Destroy();
            }
        }
Пример #13
0
        }                                                                                                       //Called once when this object starts attacking another object.

        public virtual void OnAttacking(RTSGameObject rtsGameObject)
        {
        }                                                                                                       //Called while this object is attacking another object.
Пример #14
0
        }                                                                                                       //Called once when this object has lost it's target lock

        public virtual void OnAttackingStart(RTSGameObject rtsGameObject)
        {
        }                                                                                                       //Called once when this object starts attacking another object.
Пример #15
0
 public override void OnTargetLockLeave(RTSGameObject rtsGameObject)
 {
     StopAttacking();
 }
Пример #16
0
 //Method Messages
 public virtual void OnPursuing(RTSGameObject rtsGameObject)
 {
 }                                                                                                       //Called while this object is pursuing another object.