Ejemplo n.º 1
0
    [Command] //The [Command] attribute indicates that the following function will be called by the Client, but will be run on the Server
    public void CmdTellServerToMoveUnit(NetworkInstanceId clientNetID, NetworkInstanceId unitNetID, int[] movePath)
    {
        if (!isServer)
        {
            return;
        }
        Debug.Log("CmdTellServerToMoveUnit unitNetID.value " + (int)unitNetID.Value);

        GameObject     unit       = network_Unit_Objects[unitNetID];
        UnitScript     unitScript = unit.GetComponent <UnitScript>();
        List <Vector3> pathVects  = DataManipulation.ConvertIntArrayIntoVectors(movePath);

        unit.GetComponent <MovementScript>().MoveUnit(pathVects);
    }
    public void CreatePathFindingNodes(GameObject unit, int unitNetID, int[] path)
    {
        unit.GetComponent <UnitScript>().ClearPathFindingNodes();

        List <Vector3> vects = _dataManipulation.ConvertIntArrayIntoVectors(path);

        List <CubeLocationScript> scriptList = new List <CubeLocationScript>();

        foreach (Vector3 vect in vects)
        {
            CubeLocationScript script = _locationManager.GetLocationScript(vect);
            script.CreatePathFindingNode(unitNetID);
            scriptList.Add(script);
            //Debug.Log("pathfinding VISUAL node set at vect: " + vect);
        }

        unit.GetComponent <UnitScript>().AssignPathFindingNodes(scriptList);
    }