Пример #1
0
    IEnumerator GivePlayerVision()
    {
        while (true)
        {
            //yield return new WaitUntil(() => Player.IsUnitMoving == false);

            foreach (MapTile T1 in TilesCloseToPlayer)
            {
                T1.Visible = false;
            }
            TilesCloseToPlayer.Clear();

            List <MapTile> Tiles = LocalMap.GetAreaAround(Player.GridPos, Player.unitStats.VisionRange);

            foreach (MapTile T in Tiles)
            {
                TilesCloseToPlayer.Add(T);
                T.Visible    = true;
                T.Discovered = true;

                if (T.IsBound)
                {
                    // Debug.Log("bruh");


                    Vector3Int TargetPos = LocalMap.GetOppositeTileOnBoarder(T.X, T.Y);
                    LocalMap.FindTile(TargetPos.x, TargetPos.y).Visible    = true;
                    LocalMap.FindTile(TargetPos.x, TargetPos.y).Discovered = true;
                    TilesCloseToPlayer.Add(LocalMap.FindTile(TargetPos.x, TargetPos.y));
                }



                // Debug.Log(T.GetPos);
            }
            //Clear the previous vision first
            yield return(new WaitUntil(() => Player.IsUnitMoving == true));
        }
    }
Пример #2
0
    //GameObject Temp;
    // I should clean this fixed update later
    void Update()   //it has to be update in order to register
    {
        GetInput();
        CameraMovement();
        CameraZoom();
        //select
        if (LMBdown && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) //this prevents me from actually clicking on a UI element
        {
            MapTile Temp = GetMapTileOnMousePos();

            if (Temp != null)
            {
                MapGRef.CurrentTile = Temp;
                UIM.ChangeOfSelection();
            }
            else
            {
                //Making the selection the opposite one
                Vector3Int TempV      = MapGRef.GetOppositeTileOnBoarder(Temp.X, Temp.Y);
                Vector2Int TargetPos  = new Vector2Int(TempV.x, TempV.y);
                MapTile    TargetTile = MapGRef.FindTile(TargetPos.x, TargetPos.y);

                if (TargetTile != null)
                {
                    MapGRef.CurrentTile = TargetTile;
                    UIM.ChangeOfSelection();
                }
            }


            /*
             * if (InMoveMode)// this is for the ON turn thing only
             * {
             *  if (AllCurrentPaths.ContainsKey(MapGRef.CurrentTile))
             *      StartCoroutine(CurUnit.MoveUnitTo(cellPos.x, cellPos.y));
             *
             *  InMoveMode = false;
             * }*/


            //   ShowAllDebugUI();
        }
        //movement
        if (!(MapGRef.TurnModeOn || CurUnit == null || !RMBdown || UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()))
        {
            Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            pz.z = 0;
            Vector3Int cellPos = grid.WorldToCell(pz);


            if (MapGRef.FindTile(cellPos.x, cellPos.y) != null && MapGRef.FindTile(cellPos.x, cellPos.y).Walkable)
            {
                StartCoroutine(CurUnit.MoveUnitTo(cellPos.x, cellPos.y));

                MapGRef.CurrentTile = MapGRef.FindTile(cellPos.x, cellPos.y);
                UIM.ChangeOfSelection();
                //  UIM.ClearPath();
            }
            else
            {
                Vector3Int TempV      = MapGRef.GetOppositeTileOnBoarder(cellPos.x, cellPos.y);
                Vector2Int TargetPos  = new Vector2Int(TempV.x, TempV.y);
                MapTile    TargetTile = MapGRef.FindTile(TargetPos.x, TargetPos.y);

                if (TargetTile != null)
                {
                    StartCoroutine(CurUnit.MoveUnitTo(TargetPos.x, TargetPos.y));

                    MapGRef.CurrentTile = TargetTile;
                    UIM.ChangeOfSelection();
                }
            }
        }

/*
 *      //This is just for the area thing (I gotta migrate all this to the UI_Manager)
 *      if (InMoveMode)
 *      {
 *          Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
 *          pz.z = 0;
 *          Vector3Int cellPos = grid.WorldToCell(pz);
 *          //  Vector3 cellPosFloat = cellPos + new Vector3(0.5f, 0.5f, 0);
 *
 *          MapTile NewCurHoveredTile = MapGRef.FindTile(cellPos.x, cellPos.y);
 *
 *          //So once this happens it is the old one
 *          if (NewCurHoveredTile != CurHoveredTile && AllCurrentPaths.ContainsKey(NewCurHoveredTile))
 *          {
 *              // MapGRef.ThirdLayer.ClearAllTiles();
 *              //This makes it so it everything is cleared
 *              List<MapTile> CurHovPath = AllCurrentPaths[NewCurHoveredTile];
 *              if (CurHovPath != null && CurHovPath != OldCurPath)
 *              {
 *                  //This refreshes the old path to the orginal
 *                  if (OldCurPath != null)
 *                      foreach (MapTile M in OldCurPath)
 *                      {
 *                          if (M != null)
 *                              MapGRef.ThirdLayer.SetTile(new Vector3Int(M.X, M.Y, 0), MapGRef.particles_tiles.Area[5]);
 *                      }
 *
 *                  for (int x = 0; x < CurHovPath.Count; x++)
 *                  {
 *                      if (CurHovPath[x] != null)
 *                      {
 *                          if (x != CurHovPath.Count - 1)
 *                          {
 *
 *                              MapGRef.ThirdLayer.SetTile(new Vector3Int(CurHovPath[x].X, CurHovPath[x].Y, 0), MapGRef.particles_tiles.Area[6]);
 *                          } else
 *                          {
 *                              MapGRef.ThirdLayer.SetTile(new Vector3Int(CurHovPath[x].X, CurHovPath[x].Y, 0), MapGRef.particles_tiles.Area[7]);
 *                          }
 *
 *                      }
 *
 *                  }
 *
 *                  OldCurPath = CurHovPath;
 *
 *              } else
 *
 *
 *
 *                  //  MapGRef.ThirdLayer.SetTile(new Vector3Int(NewCurHoveredTile.X, NewCurHoveredTile.Y, 0), MapGRef.particles_tiles.Area[6]);
 *                  CurHoveredTile = NewCurHoveredTile;
 *          }
 *
 *
 *      }*/

        //DragScreen();

        if (Escp)
        {
            UIM.ShowEscapeMenu();
        }
    }