Exemplo n.º 1
0
 public void SetUnitActive(bool onOff, UnitScript unit = null)
 {
     if (onOff)
     {
         if (_activeUnit)
         {
             _activeUnit.ActivateUnit(false);
         }
         //_gameManager._cubeManager.SetCubeActive (false);
         _activeUnit = unit;
         //_gameManager._locationManager.DebugTestPathFindingNodes(_activeUnit);
     }
     else
     {
         _activeUnit = null;
     }
 }
    ////////////////////////////////////////////////

    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.º 3
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;
            }
        }
    }
Exemplo n.º 4
0
    private void Update()
    {
        Vector3 mousePos = Input.mousePosition;

        mousePos.z = 0;
        mousePos   = Camera.main.ScreenToWorldPoint(mousePos);
        cursorObject.transform.position = new Vector3(Round(mousePos.x), Round(mousePos.y), -9);

        if (activeUnit)
        {
            activeEffect.transform.position = activeUnit.transform.position;
            hp.text = activeUnit.health.ToString();
            mp.text = activeUnit.movesRemaining.ToString();
            sp.text = activeUnit.mana.ToString();
            if (!UIObject.activeInHierarchy)
            {
                UIObject.SetActive(true);
            }
        }
        else if (UIObject.activeInHierarchy)
        {
            UIObject.SetActive(false);
        }

        if (Input.GetMouseButtonDown(0) && !unitLocked)
        {
            foreach (UnitScript u in units)
            {
                if ((Vector2)u.transform.position == (Vector2)cursorObject.transform.position && u.playerNum == playerTurn)
                {
                    activeUnit = u;
                    activeUnit.ActivateUnit();
                }
            }
        }
    }