コード例 #1
0
    // My personal checks for pathfinding
    private bool PathFindingChecks(CubeLocationScript neightbourScript, Vector3 neighbourHalfVect)
    {
        CubeLocationScript neightbourHalfScript = _locationManager.GetLocationScript(neighbourHalfVect);

        if (neightbourHalfScript != null)
        {
            //		if (neightbourScript._isPanel) { // this might cause problems
            //			return false;
            //		}

            if (neightbourHalfScript._isPanel)
            {
                return(false);
            }

            if (neightbourScript._cubeOccupied)
            {
                return(false);
            }

            if (!_unitCanClimbWalls)               // if human
            {
                if (!neightbourScript._isHumanWalkable && !neightbourScript._isHumanClimbable && !neightbourScript._isHumanJumpable)
                {
                    return(false);
                }
            }

            //////////

            return(true);
        }
        return(false);
    }
コード例 #2
0
    public void SetCubeNeighbours(CubeLocationScript cubeScript)
    {
        if (!isServer)
        {
            Debug.LogError("Got a client trying to do server stuff here!");
        }

        if (cubeScript == null)
        {
            Debug.LogError("cubeScript == null! not sure what this means just yet");
        }
        else
        {
            // If any of the half neighbours are panels, then this cubeScript location can be set to walkable/climable...etc
            foreach (Vector3 vect in cubeScript.NeighbourHalfVects)
            {
                CubeLocationScript neighbourScript = _locationManager.GetLocationScript(vect);
                // setup Panels in cubes
                if (neighbourScript != null && neighbourScript._isPanel)
                {
                    // Debug.Log("f**k we HAVE A PANEL in half neighbour");
                    SetUpPanelInCube(neighbourScript);
                    break;
                }
            }
        }
    }
コード例 #3
0
    ////////////////////////////////////////////////
    ////////////////////////////////////////////////

    public GameObject CreateDefaultCube(Vector3Int localGridLoc, Transform parent)
    {
        GameObject cubeObject = Instantiate(GetNodePrefab(NodeTypes.CubeObject), parent, false); // empty cube

        cubeObject.transform.SetParent(parent);
        cubeObject.transform.localPosition = localGridLoc;

        CubeLocationScript cubeScript = cubeObject.GetComponent <CubeLocationScript>();

        cubeScript.CubeMoveable = false;

        if (Mathf.Abs(localGridLoc.y) % 2 == 0) // I fucken HATE THIS Has caused lots of issues
        {
            if (Mathf.Abs(localGridLoc.z) % 2 == 0)
            {
                if (Mathf.Abs(localGridLoc.x) % 2 == 0)
                {
                    cubeScript.CubeMoveable = true;
                }
            }
        }

        Vector3    cubeGlobalPos = cubeObject.transform.position;
        Vector3Int globalGridLoc = new Vector3Int(Mathf.FloorToInt(cubeGlobalPos.x), Mathf.FloorToInt(cubeGlobalPos.y), Mathf.FloorToInt(cubeGlobalPos.z));

        cubeScript.CubeID        = globalGridLoc;
        cubeScript.MapNodeParent = parent.GetComponent <MapNode>();
        cubeScript.CubeLayerID   = parent.GetComponent <MapNode>().NodeLayerCount;

        return(cubeObject);
    }
コード例 #4
0
    // this is a bit different, the actual MOVEABLE cube script gets passed in here coz slopes sit in the cube object not the half cube objects
    // THIS IS GOING TO CAUSE PROBLEMS IN FUTURE COZ THERES NO CHECKS IF THEY CAN MOVE ONTO SLOPE, ITS ALWAYS YES
    private static void SetUpCeilingAnglePanel(CubeLocationScript cubeScript, PanelPieceScript panelScript)
    {
        Vector3 cubeLoc = cubeScript.CubeStaticLocVector;

        Vector3            TopHalfVect          = new Vector3(cubeLoc.x, cubeLoc.y + 1, cubeLoc.z);
        Vector3            bottomHalfVect       = new Vector3(cubeLoc.x, cubeLoc.y - 1, cubeLoc.z);
        CubeLocationScript cubeScriptHalfTop    = LocationManager.GetHalfLocationScript_CLIENT(TopHalfVect);    // ontop panel
        CubeLocationScript cubeScriptHalfBottom = LocationManager.GetHalfLocationScript_CLIENT(bottomHalfVect); // underneath panel

        if (cubeScriptHalfBottom != null)                                                                       // ontop
        {
            panelScript.cubeScriptRight = cubeScript;
            panelScript.cubeRightVector = cubeLoc;
            panelScript.rightPosNode    = new Vector3(0, 4.5f, 0); // future issue here if want to move unit bit further on x,z axis on slope

            SetHumanCubeRules(cubeScript, true, true, true);
            SetAlienCubeRules(cubeScript, true, true, true);
        }

        if (cubeScriptHalfTop != null) // underneath
        {
            panelScript.cubeScriptLeft = cubeScript;
            panelScript.cubeLeftVector = cubeLoc;
            panelScript.leftPosNode    = new Vector3(0, -4.5f, 0); // future issue here if want to move unit bit further on x,z axis on slope

            SetHumanCubeRules(cubeScript, true, true, true);
            SetAlienCubeRules(cubeScript, true, true, true);
        }
    }
コード例 #5
0
    public void MoveUnit(List <CubeLocationScript> _pathNodes)
    {
        Debug.Log("MoveUnit!");

        int[] stats = GetComponent <UnitScript>()._unitCombatStats;
        _unitsSpeed = stats[0];

        if (_pathNodes.Count > 0)
        {
            _finalTarget     = _pathNodes[_pathNodes.Count - 1];
            _finalTargetVect = _finalTarget.CubeLocVector;

            if (moveInProgress)
            {
                _tempNodes = _pathNodes;
                _newPath   = true;
            }
            else
            {
                Reset();
                _nodes         = _pathNodes;
                moveInProgress = true;
                SetTarget();
            }
        }
    }
コード例 #6
0
    ////////////////////////////////////////////////

    public void MoveUnit(List <Vector3Int> path)
    {
        AnimationManager.SetAnimatorBool(_animators, "Combat_Walk", true);

        _unitsSpeed = gameObject.transform.GetComponent <UnitScript>().UnitCombatStats[1]; // movement

        _finalTargetLoc    = path[path.Count - 1];
        _finalTargetScript = LocationManager.GetLocationScript_CLIENT(_finalTargetLoc);

        if (path.Count > 0)
        {
            if (moveInProgress)
            {
                foreach (Vector3Int nodeVect in _nodes)
                {
                    LocationManager.GetLocationScript_CLIENT(nodeVect)._platform_Panel_Cube._panelScriptChild.PanelIsDEActive();
                }
                _newPathNodes = path;
                _newPathSet   = true;
            }
            else
            {
                ResetValues();
                _nodes         = path;
                moveInProgress = true;
                foreach (Vector3Int nodeVect in _nodes)
                {
                    LocationManager.GetLocationScript_CLIENT(nodeVect)._platform_Panel_Cube._panelScriptChild.PanelIsActive();
                }
                SetNextTarget();
            }
        }
    }
コード例 #7
0
    private void SetTarget()
    {
        if (_unitInterrupted)
        {
            _gameManager._playerManager._playerObject.GetComponent <UnitsAgent>().MakeUnitRecalculateMove(GetComponent <UnitScript>(), _finalTargetVect);
            _unitInterrupted = false;
        }

        if (_nodes.Count > 0)
        {
            if (!_newPath)
            {
                _currTarget     = _nodes[locCount];
                _currTargetVect = new Vector3(_currTarget.CubeLocVector.x, _currTarget.CubeLocVector.y, _currTarget.CubeLocVector.z);
                if (!_gameManager._locationManager.SetUnitOnCube(GetComponent <UnitScript>(), _currTargetVect))
                {
                    Debug.LogWarning("units movement interrupted >> recalculating");
                    _unitInterrupted = true;
                    Reset();
                    StartCoroutine(RecalculateMove(3.0f));
                }
            }
            else
            {
                SetNewpath();
            }
        }
    }
コード例 #8
0
    //////////////////////////////////////////////
    private bool DetermineIfPanelIsLowerThanUnit() // Compares cube local locations
    {
        if (UnitsManager.ActiveUnit == null)
        {
            return(false);
        }

        CubeLocationScript unitCube = UnitsManager.ActiveUnit.CubeUnitIsOn;

        //Debug.Log("f**k unitCube = " + unitCube);
        //Debug.Log("f**k unitCube.MapNodeParent = " + unitCube.MapNodeParent);

        float unitMapNodeYLocPos = unitCube.MapNodeParent.transform.localPosition.y;
        float thisMapNodeYLocPos = cubeScriptParent.MapNodeParent.transform.localPosition.y;

        if (thisMapNodeYLocPos > unitMapNodeYLocPos) // Mapnodes above unit always turn transpaarent
        {
            return(false);
        }

        float unitCubeYLocPos = unitCube.transform.localPosition.y;
        float thisCubeYLocPos = cubeScriptParent.transform.localPosition.y;

        return(unitCubeYLocPos > thisCubeYLocPos);
    }
コード例 #9
0
    ///////////////////////////////////////////

    public static bool SetUnitOnCube_CLIENT(UnitScript unitScript, Vector3 loc)
    {
        int unitNetId = (int)unitScript.NetID.Value;
        CubeLocationScript cubescript = CheckIfCanMoveToCube_CLIENT(unitScript.CubeUnitIsOn, loc, unitScript.UnitCanClimbWalls);

        if (cubescript != null)
        {
            if (!_unitLocation.ContainsKey(unitNetId))
            {
                _unitLocation.Add(unitNetId, cubescript);
            }
            else
            {
                CubeLocationScript oldCubescript = _unitLocation[unitNetId];
                oldCubescript.CubeOccupied = false;
                _unitLocation[unitNetId]   = cubescript;
            }
            cubescript.CubeOccupied = true;
            unitScript.CubeUnitIsOn = cubescript;
            Debug.Log("SetUnitOnCube loc:  " + loc);
            return(true);
        }
        else
        {
            Debug.LogError("Unit cannot move to a location");
            return(false);
        }
    }
コード例 #10
0
    ///////////////////////////////////////////

    public static bool SetUnitOnCube_CLIENT(UnitScript unitScript, Vector3Int loc)
    {
        Vector3Int         unitId     = unitScript.UnitID;
        CubeLocationScript cubescript = CheckIfCanMoveToCube_CLIENT(unitScript.CubeUnitIsOn, loc, unitScript.UnitCanClimbWalls);

        if (cubescript != null)
        {
            if (!_unitLocation.ContainsKey(unitId))
            {
                _unitLocation.Add(unitId, cubescript);
            }
            else
            {
                CubeLocationScript oldCubescript = _unitLocation[unitId];
                oldCubescript.CubeOccupied = false;
                _unitLocation[unitId]      = cubescript;
            }
            cubescript.CubeOccupied = true;

            unitScript.CubeUnitIsOn = cubescript;

            //if (unitScript.CubeUnitIsOn != null && unitScript.CubeUnitIsOn._platform_Panel_Cube != null)
            //{
            //    cubescript._platform_Panel_Cube._panelScriptChild.PanelPieceChangeColor("Pink");
            //}
            return(true);
        }
        else
        {
            Debug.LogError("Unit cannot move to a location " + loc);
            return(false);
        }
    }
コード例 #11
0
    private List <CubeLocationScript> RetracePath(int movement, CubeLocationScript startNode, CubeLocationScript endNode)
    {
        List <CubeLocationScript> path        = new List <CubeLocationScript>();
        CubeLocationScript        currentNode = endNode;

        while (currentNode != startNode)
        {
            path.Add(currentNode);
            currentNode = currentNode.parentPathFinding;
        }
        path.Reverse();

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

        int pathLength = movement;

        if (movement > path.Count)
        {
            movement = path.Count;
        }

        for (int i = 0; i < movement; i++)
        {
            _finalPath.Add(path [i]);
        }

        foreach (CubeLocationScript script in _finalPath)
        {
            script.CreatePathFindingNode();             // puts circles in path, visual reference
        }
        return(_finalPath);
    }
コード例 #12
0
    ////////////////////////////////////////////////

    public static bool BuildMovementPath(CubeLocationScript endLocScript)
    {
        if (_currActiveCube == endLocScript)
        {
            return(true);
        }
        else
        {
            _currActiveCube = endLocScript;
        }

        UnitScript activeUnit = UnitsManager.ActiveUnit;

        if (activeUnit != null)
        {
            UnitsManager.ActiveUnit.ClearPathFindingNodes();
        }

        _movePath = SetUnitsPath(endLocScript);
        if (_movePath != null)
        {
            CreatePathFindingNodes_CLIENT(UnitsManager.ActiveUnit, _movePath);
            return(true);
        }
        else
        {
            //_currActiveCube = null;
            return(false);
        }
    }
コード例 #13
0
    ////////////////////////////////////////////////


    // If ANY kind of wall/floor/object make neighbour cubes walkable
    public static void SetUpPanelInCube(CubeLocationScript neighbourHalfScript)
    {
        PanelPieceScript panelScript = neighbourHalfScript._panelScriptChild;

        switch (panelScript.name)
        {
        case "Floor":
            SetUpFloorPanel(neighbourHalfScript, panelScript);
            break;

        case "Wall":
            SetUpWallPanel(neighbourHalfScript, panelScript);
            break;

        case "FloorAngle":         // angles put in half points
            SetUpFloorAnglePanel(neighbourHalfScript, panelScript);
            break;

        case "CeilingAngle":         // This is the exact same as ceilingFloor
            SetUpCeilingAnglePanel(neighbourHalfScript, panelScript);
            break;

        default:
            Debug.Log("f**k no issue:  " + panelScript.name);
            break;
        }
    }
コード例 #14
0
    private void SetUpFloorAnglePanel(CubeLocationScript cubeScript, PanelPieceScript panelScript)
    {
        Vector3 cubeLoc = cubeScript.CubeLocVector;

        //cubeScript._isPanel = false; // this might cause issues

        Vector3 centerVect = new Vector3(cubeLoc.x, cubeLoc.y, cubeLoc.z);

        panelScript.cubeScriptLeft = cubeScript;
        panelScript.cubeLeftVector = centerVect;
        panelScript.leftPosNode    = new Vector3(0, 0, -4.5f);

        panelScript.cubeScriptRight = cubeScript;
        panelScript.cubeRightVector = centerVect;
        panelScript.rightPosNode    = new Vector3(0, 0, 4.5f);

        //cubeScript._isHumanWalkable = true;

        //		// 8 points for each panel
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x - 1, cubeLoc.y - 1, cubeLoc.z - 1));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x + 0, cubeLoc.y - 1, cubeLoc.z - 1));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x + 1, cubeLoc.y - 1, cubeLoc.z - 1));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x - 1, cubeLoc.y + 0, cubeLoc.z + 0));
        //		// middle
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x + 1, cubeLoc.y + 0, cubeLoc.z + 0));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x - 1, cubeLoc.y + 1, cubeLoc.z + 1));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x + 0, cubeLoc.y + 1, cubeLoc.z + 1));
        //		DoHalfPointsForWalls (new Vector3 (cubeLoc.x + 1, cubeLoc.y + 1, cubeLoc.z + 1));
    }
コード例 #15
0
    public bool SetUnitOnCube(UnitScript unitScript, Vector3 loc)
    {
        if (!isServer)
        {
            Debug.LogError("Got a client trying to do server stuff here!");
        }

        //Debug.Log("SetUnitOnCube");

        int unitNetId = (int)unitScript.NetID.Value;
        CubeLocationScript cubescript = CheckIfCanMoveToCube(unitScript, unitScript.CubeUnitIsOn, loc);

        if (cubescript != null)
        {
            if (!_unitLocation.ContainsKey(unitNetId))
            {
                _unitLocation.Add(unitNetId, cubescript);
            }
            else
            {
                CubeLocationScript oldCubescript = _unitLocation[unitNetId];
                oldCubescript.CubeOccupied    = false;
                oldCubescript.FlagToSayIsMine = null;
                _unitLocation[unitNetId]      = cubescript;
            }
            cubescript.CubeOccupied = true;
            unitScript.CubeUnitIsOn = cubescript;
            return(true);
        }
        else
        {
            Debug.LogError("Unit cannot move to a location");
            return(false);
        }
    }
コード例 #16
0
 public void ResetPathFindingValues()
 {
     _pathFindingNode   = null;
     _parentPathFinding = null;
     fCost = 0;
     hCost = 0;
     gCost = 0;
 }
コード例 #17
0
    ////////////////////////////////////////////////
    ////////////////////////////////////////////////

    public static void CreatePanelForCube(int[] cubeData, CubeLocationScript cubeScript)
    {
        GameObject panelObject = WorldBuilder._nodeBuilder.CreatePanelObject(cubeScript);

        panelObject.GetComponent <ObjectScript>().objectStyle = (CubeObjectStyles)cubeData[1];

        if (panelObject.GetComponent <Renderer>())
        {
            ObjectTextures texEnum = (ObjectTextures)cubeData[2];
            string         matName = "MapTextures/Materials/" + texEnum.ToString();
            Material       mat     = (Material)Resources.Load(matName, typeof(Material));
            panelObject.GetComponent <Renderer>().material = mat;
        }


        PanelPieceScript panelScript = panelObject.GetComponent <PanelPieceScript>();

        int rotX = cubeData[4];
        int rotY = cubeData[5];
        int rotZ = cubeData[6];

        panelObject.GetComponent <ObjectScript>().forcedRotation = new Vector3Int(rotX, rotY, rotZ);

        panelObject.transform.localScale *= 200;

        if (cubeData[0] == (int)CubeObjectTypes.Panel_Floor) // Floor
        {
            panelObject.GetComponent <ObjectScript>().objectType = CubeObjectTypes.Panel_Floor;
            cubeScript.CubeIsSlope  = false;
            panelScript._panelYAxis = 0;
        }
        else if (cubeData[0] == (int)CubeObjectTypes.Panel_Wall) // Floor
        {
            panelObject.GetComponent <ObjectScript>().objectType = CubeObjectTypes.Panel_Wall;
            cubeScript.CubeIsSlope = false;

            rotZ = 90;

            panelScript._panelYAxis = rotY;
        }
        else if (cubeData[0] == (int)CubeObjectTypes.Panel_Angle) // Floor
        {
            panelObject.GetComponent <ObjectScript>().objectType = CubeObjectTypes.Panel_Angle;
            cubeScript.CubeIsSlope = true;
        }
        else
        {
            Debug.LogError("GOT AN ISSUE HERE");
        }

        //Debug.Log("f**k TEST >>>>>>>>>> rotX " + rotX + " + rotY " + rotY + " + rotZ " + rotZ);

        panelObject.transform.localRotation = Quaternion.Euler(new Vector3Int(rotX, rotY, rotZ));


        // panelObject.transform.tag = panelName;
        // panelScript.name = panelName;
    }
コード例 #18
0
    ////////////////////////////////////////////////
    ////////////////////////////////////////////////

    ////////////////////////////////////////////////
    ////// SERVER FUNCTIONS ////////////////////////
    ////////////////////////////////////////////////


    ////////////////////////////////////////////////
    ////// CLIENT FUNCTIONS ////////////////////////
    ////////////////////////////////////////////////

    public static void SetCubeScriptToLocation_CLIENT(Vector3Int vect, CubeLocationScript script)
    {
        if (!_LocationLookup.ContainsKey(vect))
        {
            _LocationLookup.Add(vect, script);
            return;
        }
        // Debug.LogError("trying to assign script to already taking location!!!"); // this now happens all the time because maps overlap eachother with new map system
    }
コード例 #19
0
    private void DoHalfPointsForWalls(Vector3 nodeVect)
    {
        CubeLocationScript nodeScript = _locationManager.GetLocationScript(nodeVect);

        if (nodeScript != null)
        {
            nodeScript._isPanel         = true;
            nodeScript._isHumanWalkable = false;
        }
    }
コード例 #20
0
 public void SetUnitToNextLocation_CLIENT()
 {
     if (_pathNodeCount < _pathFindingNodes.Count)
     {
         Vector3            vect   = _pathFindingNodes[_pathNodeCount].CubeStaticLocVector;
         CubeLocationScript script = LocationManager.GetLocationScript_CLIENT(vect);
         CubeUnitIsOn = script;
     }
     _pathNodeCount++;
 }
コード例 #21
0
 public static void SetCubeScriptToHalfLocation_CLIENT(Vector3 vect, CubeLocationScript script)
 {
     if (!_LocationHalfLookup.ContainsKey(vect))
     {
         //Debug.Log("fucken adding HALF script to vect: " + vect + " script: " + script);
         _LocationHalfLookup.Add(vect, script);
         return;
     }
     Debug.LogError("trying to assign script to already taking location!!!");
 }
コード例 #22
0
    private void StartMoving()
    {
        Vector3 unitCurrPos = _unit.transform.position;

        if (locCount < _nodes.Count)
        {
            CubeLocationScript target = _nodes [locCount];

            if (target != null)
            {
                Vector3 currTarget = new Vector3(target.cubeLoc.x, target.cubeLoc.y, target.cubeLoc.z);

                if (!target._cubeOccupied || target._flagToSayIsMine == this || target._flagToSayIsMine == null)
                {
                    target._flagToSayIsMine = this;
                    target._cubeOccupied    = true;
                    collision = false;

                    if (!target.gameObject.transform.Find("pathFindingNode(Clone)"))
                    {
                        target.CreatePathFindingNode();                          // puts circles in path, visual reference
                    }

                    if (unitCurrPos != currTarget)
                    {
                        _unit.transform.position = Vector3.MoveTowards(unitCurrPos, currTarget, _nodes.Count * Time.deltaTime);
                    }
                    else
                    {
                        if (target.gameObject.transform.Find("pathFindingNode(Clone)").gameObject)
                        {
                            Destroy(target.gameObject.transform.Find("pathFindingNode(Clone)").gameObject);
                        }
                        target._cubeOccupied    = false;
                        target._flagToSayIsMine = null;
                        _nodes [locCount]       = null;
                        locCount += 1;
                        if (locCount == _nodes.Count)
                        {
                            FinishMoving();
                        }
                    }
                }
                else if (target._flagToSayIsMine != this && target._flagToSayIsMine != false)
                {
                    if (collision == false)
                    {
                        collision = true;
                        CubeLocationScript nodeToRemove = _nodes [_nodes.Count - 1];
                        _nodes.Remove(nodeToRemove);
                    }
                }
            }
        }
    }
コード例 #23
0
 // tries to spawn visual nodes in all current moveable locations for a unit
 public void DebugTestPathFindingNodes(UnitScript unit)
 {
     foreach (KeyValuePair <Vector3, CubeLocationScript> element in _LocationLookup)
     {
         CubeLocationScript script = CheckIfCanMoveToCube(unit, unit.CubeUnitIsOn, element.Key);
         if (script != null)
         {
             script.CreatePathFindingNode((int)unit.NetID.Value);
         }
     }
 }
コード例 #24
0
    int GetDistance(CubeLocationScript nodeA, CubeLocationScript nodeB)
    {
        int dstX = (int)Mathf.Abs(nodeA.CubeLocVector.x - nodeB.CubeLocVector.x);
        int dstY = (int)Mathf.Abs(nodeA.CubeLocVector.y - nodeB.CubeLocVector.y);

        if (dstX > dstY)
        {
            return(14 * dstY + 10 * (dstX - dstY));
        }
        return(14 * dstX + 10 * (dstY - dstX));
    }
コード例 #25
0
    /*
     *  private void DoHalfPointsForWalls(Vector3 nodeVect) {
     *
     *          CubeLocationScript nodeScript = _locationManager.GetLocationScript(nodeVect);
     *          if (nodeScript != null) {
     *                  nodeScript._isPanel = true;
     *                  nodeScript.IsHumanWalkable = false;
     *          }
     *  }
     */


    private void MakeClimbableEdges(Vector3 nodeVect)
    {
        CubeLocationScript nodeScript = _locationManager.GetLocationScript(nodeVect);

        if (nodeScript != null)
        {
            if (!nodeScript._isPanel)
            {
                //nodeScript.IsHumanClimbable = true;
            }
        }
    }
コード例 #26
0
    ////////////////////////////////////////////////

    //private void AnnoyingFuckingAngleMovementThing() // this is to fix the f*****g camera spinning around in weird angles 10% of the time when a unit moves onto a diff sided panel
    //{
    //    if (_TARGETObjectScript.objectType == CubeObjectTypes.Panel_Wall)
    //    {
    //        if (_lastPanelYAxis == -1)
    //        {
    //            _lastPanelYAxis = _TARGETPanelScript._panelYAxis;
    //            changeWallAngle = false;
    //        }
    //        else
    //        {
    //            if (_lastPanelYAxis != _TARGETPanelScript._panelYAxis)
    //            {
    //                changeWallAngle = true;
    //            }
    //            else
    //            {
    //                changeWallAngle = false;
    //            }

    //            _lastPanelYAxis = _TARGETPanelScript._panelYAxis;

    //        }
    //        Debug.Log("f**k changeWallAngle " + changeWallAngle);
    //    }
    //}

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

    private void SetNextTarget()
    {
        _TARGETCubeID     = _nodes[locCount];
        _TARGETCubeScript = LocationManager.GetLocationScript_CLIENT(_TARGETCubeID);
        if (_TARGETCubeScript._platform_Panel_Cube.GetCubePanel != null)
        {
            _TARGETPanelScript  = _TARGETCubeScript._platform_Panel_Cube.GetCubePanel;
            _TARGETObjectScript = _TARGETPanelScript.gameObject.GetComponent <ObjectScript>();

            //AnnoyingFuckingAngleMovementThing();

            if (MovementManager._gravityActivated)
            {
                //    unitContainerTransformLOCAL.localEulerAngles = new Vector3(0, unitContainerTransformLOCAL.localEulerAngles.y, 0);
                //    unitContainerAnglesGLOBAL.localEulerAngles = new Vector3(0, 0, 0);
            }
            else
            {
                rotateInProgress = false;

                if (_TARGETObjectScript.objectType != _currObjectScript.objectType)
                {
                    rotateInProgress = true;
                }

                if (_TARGETObjectScript.objectType == _currObjectScript.objectType)
                {
                    int currPanelYAxis   = _currPanelScript._panelYAxis;
                    int targetPanelYAxis = _TARGETPanelScript._panelYAxis;

                    if (currPanelYAxis != targetPanelYAxis)
                    {
                        rotateInProgress = true;
                    }
                }
                ChangeUnitsRotation();
                ChangeCameraRotation();
            }


            if (!LocationManager.SetUnitOnCube_CLIENT(GetComponent <UnitScript>(), _TARGETCubeID))
            {
                Debug.LogWarning("units movement interrupted >> recalculating");
                moveInProgress = false;
                ResetValues();
                if (MovementManager.BuildMovementPath(_finalTargetScript))
                {
                    MovementManager.MakeActiveUnitMove_CLIENT();
                }
            }
        }
    }
コード例 #27
0
    public CubeLocationScript CheckIfCanMoveToCube(Vector3 loc)
    {
        CubeLocationScript cubeScript = GetLocationScript(loc);

        if (cubeScript != null)
        {
            if (cubeScript._cubeOccupied)
            {
                cubeScript = null;
            }
        }
        return(cubeScript);
    }
コード例 #28
0
    private static int GetDistance(CubeLocationScript nodeA, CubeLocationScript nodeB)
    {
        int dstX = Mathf.FloorToInt(Mathf.Abs(nodeA.CubeID.x - nodeB.CubeID.x));
        int dstY = Mathf.FloorToInt(Mathf.Abs(nodeA.CubeID.y - nodeB.CubeID.y));
        int dstZ = Mathf.FloorToInt(Mathf.Abs(nodeA.CubeID.z - nodeB.CubeID.z));

        if (dstX > dstZ)
        {
            return(14 * dstZ + 10 * (dstX - dstZ) + 10 * dstY);
        }

        return(14 * dstX + 10 * (dstZ - dstX) + 10 * dstY);
    }
コード例 #29
0
    ////////////////////////////////////////////////


    public static void SendCubeDataToSERVER_CLIENT(Vector3 vect)
    {
        CubeLocationScript script = GetLocationScript_CLIENT(vect);

        if (script != null)
        {
            NetWorkManager.NetworkAgent.CmdTellServerToUpdateLocation(vect, script.GetCubeData());
        }
        else
        {
            Debug.LogError("GOT AN ISSUE HERE");
        }
    }
コード例 #30
0
    private List <CubeLocationScript> RetracePath(CubeLocationScript startNode, CubeLocationScript endNode)
    {
        List <CubeLocationScript> path        = new List <CubeLocationScript>();
        CubeLocationScript        currentNode = endNode;

        while (currentNode != startNode)
        {
            path.Add(currentNode);
            currentNode = currentNode._parentPathFinding;
        }
        path.Reverse();
        ResetPath();
        return(path);
    }