Example #1
0
    void FixedUpdate()
    {
        m_cellsInSight = Physics.OverlapSphere(transform.position, m_visionRange);
        bool targetFound = false;
        foreach (Collider hitInfo in m_cellsInSight) {
            if (hitInfo.gameObject.tag == "Unit" || hitInfo.gameObject.tag == "EnemyCell") {
                dele_randomSet -= RandomMove;
                dele_randomSet -= RandomSplit;

                targetFound = true;
                if (Vector3.Distance(transform.position, hitInfo.transform.position) > m_cancerCell.attackRange) {
                    m_cancerCell.primaryTarget = null;
                    m_cancerCell.Move(hitInfo.transform.position);

                } else {
                    if (m_cancerCell.primaryTarget == null) {
                        m_cancerCell.primaryTarget = hitInfo.transform.gameObject;
                        m_cancerCell.currentState = CellState.ATTACK;
                    }
                }
                break;
            }
        }
        if (!targetFound) {
            m_cancerCell.currentState = CellState.IDLE;
                dele_randomSet += RandomSplit;
                dele_randomSet += RandomMove;
        }
    }
Example #2
0
 void Start()
 {
     m_cancerCell.isMine = false;
     m_cancerCell.isAIPossessed = false;
     m_cancerCell.tag = "CancerCell";
     m_cancerCell.SetSpeed(m_cancerCell.navAgent.speed * .25f);
     m_cancerCell.currentState = CellState.IDLE;
     if (GetComponent<FogOfWarHider>() == null) gameObject.AddComponent<FogOfWarHider>();
     if (GetComponent<FogOfWarViewer>()) Destroy(GetComponent<FogOfWarViewer>());
     dele_randomSet += RandomMove;
     dele_randomSet += RandomSplit;
     InvokeRepeating("ExecuteDelegate", 1.0f, 5.0f);
 }