private void FixedUpdate()
    {
        time += Time.fixedDeltaTime;
        if (unitGeneratorNodes.Count > 0)
        {
            float nextTime = unitGeneratorNodes.Peek().timeNext;
            if (time > nextTime)
            {
                time -= nextTime;

                UnitGeneratorNode unitGeneratorNode = unitGeneratorNodes.Dequeue();
                if (unitGeneratorNode != null)
                {
                    GameObject gameObject = unitGeneratorNode.gameObject;
                    GameObject unit       = poolManager.Spawn(gameObject, transform.position, transform.rotation);

                    MoveToPointByNavMesh unitMoveToPointByNavMesh = unit.GetComponent <MoveToPointByNavMesh>();
                    if (unitMoveToPointByNavMesh != null)
                    {
                        unitMoveToPointByNavMesh.point = GameManager.Instance.baseTower;
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void OnTriggerEnter(Collider other)
    {
        GameObject collisionGameObject = other.gameObject;

        if (collisionGameObject != null)
        {
            UnitData collisionUnitData = collisionGameObject.GetComponent <UnitData>();
            UnitData thisUnitData      = gameObject.GetComponent <UnitData>();
            if (collisionUnitData != null && thisUnitData != null)
            {
                if (collisionUnitData.team != thisUnitData.team)
                {
                    targets.Add(collisionUnitData.gameObject);

                    MoveToPointByNavMesh moveToPointByNavMesh = this.gameObject.GetComponent <MoveToPointByNavMesh>();
                    if (moveToPointByNavMesh != null)
                    {
                        moveToPointByNavMesh.StopMove();
                    }
                }
            }
            else
            {
                if (thisUnitData == null)
                {
                    Debug.LogWarning("Try get UnitData is faled (" + gameObject.name + ")");
                }
            }
        }
    }