////////////////////////////////////////////////

    public static void SetUnitActive(bool onOff, int playerContID, Vector3Int unitID)
    {
        UnitScript unit = _unitObjectsByPlayerID[playerContID][unitID];

        if (unit == null)
        {
            Debug.LogError("SetUnitActive ERROR unit == null");
            return;
        }

        if (_activeUnit == null)
        {
            _activeUnit = unit;
        }

        if (onOff)
        {
            if (_activeUnit.UnitID != unit.UnitID)
            {
                _activeUnit.DeActivateUnit();
            }

            _activeUnit.ClearPathFindingNodes();
            _activeUnit = unit;
            _activeUnit.ActivateUnit();
            AssignCameraToActiveUnit();

            Debug.Log("Unit: " + unitID + " : SetActive");

            // _locationManager.DebugTestPathFindingNodes(_activeUnit);
        }
        else
        {
            if (_activeUnit.UnitID != unit.UnitID)
            {
                Debug.LogError("should not be here Unit is active and another unit is tying to get turned off");
            }
            else
            {
                _activeUnit.DeActivateUnit();
                _activeUnit = null;
            }
        }
    }
Exemplo n.º 2
0
    ////////////////////////////////////////////////

    public static void SetUnitActive(bool onOff, int playerContID, int unitID)
    {
        UnitScript unit = _unitObjects[playerContID][unitID];

        if (unit == null)
        {
            Debug.LogError("SetUnitActive ERROR unit == null");
            return;
        }

        if (_activeUnit == null)
        {
            _activeUnit = unit;
        }

        if (onOff)
        {
            if (_activeUnit.NetID.Value != unit.NetID.Value)
            {
                _activeUnit.DeActivateUnit();
            }

            print("SetUnitActive <<<<<<<<<<<<<<<<<<<< unitId: " + unit.NetID.Value);

            _activeUnit = unit;
            _activeUnit.ActivateUnit();

            // _locationManager.DebugTestPathFindingNodes(_activeUnit);
        }
        else
        {
            if (_activeUnit.NetID.Value != unit.NetID.Value)
            {
                Debug.LogError("should not be here Unit is active and another unit is tying to get turned off");
            }
            else
            {
                _activeUnit.DeActivateUnit();
                _activeUnit = null;
            }
        }
    }