Exemplo n.º 1
0
    public void MoveToThisTile()
    {
        DungeonPlayer dp = FindObjectOfType <DungeonSceneManager>().GetPlayer();

        dp.SetIndex(tileIndex);
        dp.Move(transform.position);
    }
Exemplo n.º 2
0
 public Spell(SpellDef def, DungeonObject owner, Vector2 position) : base(def, position, "spells", state: Cast)
 {
     SpellDef = def;
     Position = new((int)Position.X / 16 * 16, (int)Position.Y / 16 * 16);
     game     = DungeonGame.Instance;
     player   = DungeonPlayer.Instance;
     Owner    = owner;
 }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region Methods
        /// <summary>
        /// Creates a new player2D instance and places it in the middle of the screen.
        /// </summary>
        /// <returns>
        /// Created canvas wrapper of player
        /// </returns>
        private DungeonPlayer SpawnPlayer()
        {
            // Calculate position
            int[] position =
            {
                CanvasSize[0] / 2,
                CanvasSize[1] / 2
            };

            // Instantiate player
            DungeonPlayer dungeonPlayer = new DungeonPlayer(Program.Player);

            // Set player 2d position
            dungeonPlayer.Position = position;

            // Return the created player instance
            return(dungeonPlayer);
        }
Exemplo n.º 4
0
    private void Start()
    {
        tileSpawner = FindObjectOfType <TileSpawner>();

        // 플레이어 배치
        TileIndex startIdx   = tileSpawner.GetStartIndex();
        float     tileWidth  = tileSpawner.GetTileWidth();
        float     tileHeight = tileSpawner.GetTileHeight();

        // 플레이어 배치 좌표 계산
        Vector3 startPos = new Vector3();

        startPos.x = startIdx.x * tileWidth;
        startPos.y = startIdx.y * tileHeight;

        playerObj = Instantiate(PlayerPrefab, startPos, Quaternion.identity);
        dunPlayer = playerObj.GetComponent <DungeonPlayer>();
        dunPlayer.SetIndex(startIdx);

        // 카메라에 추적대상 설정
        FindObjectOfType <DungeonCamera>().SetTarget(dunPlayer.GetAnchor());
    }
Exemplo n.º 5
0
 private void InitializePlayer()
 {
     myPlayer = SpawnPlayer();
 }