예제 #1
0
  private void SetActor(EditGridActor editGridActor, Vector2Int gridPos, int index)
  {
      if (_PlayGridHolder.PlayGrid.GetPlayTile(gridPos).ActorIndex != IndexChoseActor)
      {
          if (IndexChoseActor != 0)
          {
              if (IndexChoseActor == 1 && _player != null)
              {
                  return;
              }

              GameObject newObject = Instantiate(editGridActor.GameObject,
                                                 _PlayGridHolder.PlayGrid.GetWorldPositionCentreCell(gridPos),
                                                 Quaternion.identity);
              _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).ActorIndex = index;
              _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).GridActor  = newObject;
              newObject.GetComponent <GridActor>().playGidHolder       = gameObject;
              newObject.GetComponent <GridActor>().PlayGrid            = _PlayGridHolder.PlayGrid;
              newObject.GetComponent <GridActor>().SetGridPos(gridPos);
              if (IndexChoseActor == 1)
              {
                  newObject.GetComponent <GridActorPlayer>().SetPause();
                  _player = newObject;
              }
          }
          else
          {
              Destroy(_PlayGridHolder.PlayGrid.GetPlayTile(gridPos).GridActor);
              _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).ActorIndex = index;
              _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).GridActor  = null;
          }
      }
  }
예제 #2
0
    private void SetActor(EditGridActor editGridActor, Vector2Int gridPos, int index)
    {
        GameObject newObject = Instantiate(editGridActor.GameObject, _PlayGridHolder.PlayGrid.GetWorldPositionCentreCell(gridPos),
                                           Quaternion.identity);

        _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).ActorIndex = index;
        _PlayGridHolder.PlayGrid.GetPlayTile(gridPos).GridActor  = newObject;
        newObject.GetComponent <GridActor>().playGidHolder       = gameObject;
        newObject.GetComponent <GridActor>().PlayGrid            = newPlayGrid;
        newObject.GetComponent <GridActor>().SetGridPos(gridPos);
        Debug.Log("L'index est de" + index);
        if (index == 1)
        {
            newObject.transform.GetChild(0).gameObject.SetActive(true);
            _player = newObject;
        }

        if (index == 2)
        {
            _ennemis.Add(newObject);
        }
    }
예제 #3
0
  // Update is called once per frame
  void Update()
  {
      if (EditMode)
      {
          Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));

          if (_cursor == null)
          {
              _cursor = Instantiate(EditeCursor);
              EditPanel.SetActive(true);
          }
          _cursor.transform.position = Vector3.Lerp(_cursor.transform.position, _PlayGridHolder.PlayGrid.GetWorldPositionCentreCell(mouseWorldPos), 0.5f);

          if (Input.GetButton("Fire1") && !_cursorOnPanel)
          {
              if (EditorActoie == editorActoie.EditTiles)
              {
                  EditPlayTile chosetile = TempletBuilder.EditPlayTiles[IndexChoseTile];
                  SetTile(chosetile, _PlayGridHolder.PlayGrid.GetXY(mouseWorldPos), IndexChoseTile);
              }
              else if (EditorActoie == editorActoie.EditActor)
              {
                  EditGridActor choseActor = TempletActors.EditGridActors[IndexChoseActor];
                  SetActor(choseActor, _PlayGridHolder.PlayGrid.GetXY(mouseWorldPos), IndexChoseActor);
              }

              /*switch (chosetile.Layer)
               * {case 0 :
               *      if (_PlayGridHolder.PlayGrid.GetPlayTile(mouseWorldPos).Tag1!=IndexChoseTile)
               *      {
               *          Vector2 GridPos = _PlayGridHolder.PlayGrid.GetXY(mouseWorldPos);
               *          if (chosetile.UsingRuleTile)
               *          {
               *              _tilemap1.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.RuleTile);
               *          }
               *          else
               *          {
               *              _tilemap1.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.Tile);
               *          }
               *
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).IsWalable1 =
               *              chosetile.IsWalkeble;
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).Tag1 = IndexChoseTile;
               *      }
               *  break;
               *  case 1 :
               *      if (_PlayGridHolder.PlayGrid.GetPlayTile(mouseWorldPos).Tag2!=IndexChoseTile)
               *      {
               *          Vector2 GridPos = _PlayGridHolder.PlayGrid.GetXY(mouseWorldPos);
               *          if (chosetile.UsingRuleTile)
               *          {
               *              _tilemap2.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.RuleTile);
               *          }
               *          else
               *          {
               *              _tilemap2.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.Tile);
               *          }
               *
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).IsWalable2 =
               *              chosetile.IsWalkeble;
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).Tag2 = IndexChoseTile;
               *      }
               *      break;
               *  case 2 :if (_PlayGridHolder.PlayGrid.GetPlayTile(mouseWorldPos).Tag3!=IndexChoseTile)
               *      {
               *          Vector2 GridPos = _PlayGridHolder.PlayGrid.GetXY(mouseWorldPos);
               *          if (chosetile.UsingRuleTile)
               *          {
               *              _tilemap3.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.RuleTile);
               *          }
               *          else
               *          {
               *              _tilemap3.SetTile(new Vector3Int((int) GridPos.x, (int) GridPos.y, 0), chosetile.Tile);
               *          }
               *
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).IsWalable3 =
               *              chosetile.IsWalkeble;
               *          _PlayGridHolder.PlayGrid.GetPlayTile((int) GridPos.x, (int) GridPos.y).Tag2 = IndexChoseTile;
               *      }
               *      break;
               * }*/
          }
      }
      else
      {
          if (_cursor != null)
          {
              Destroy(_cursor);
              EditPanel.SetActive(false);
          }
      }

      if (MapSaveInfo.alpha != 0)
      {
          MapSaveInfo.alpha = Mathf.Clamp(MapSaveInfo.alpha - SaveInfoFadeFactor * Time.deltaTime, 0, 1);
      }
      if (MapSaveErrorInfo.alpha != 0)
      {
          MapSaveErrorInfo.alpha = Mathf.Clamp(MapSaveErrorInfo.alpha - (SaveInfoFadeFactor * Time.deltaTime), 0, 1);
      }
  }