Beispiel #1
0
    // rotates tile by 90 degrees, updating textures and wall activations
    public void Rotate()
    {
        int  tempTex  = mWallNorth.CurrentMaterial;
        bool tempAct  = mWallNorth.IsActive;
        bool tempPass = mWallNorth.IsPassable;

        UpdateAttachedObjectsList();

        // rotate Textures
        mWallNorth.SetTexture(mWallWest.CurrentMaterial);
        mWallWest.SetTexture(mWallSouth.CurrentMaterial);
        mWallSouth.SetTexture(mWallEast.CurrentMaterial);
        mWallEast.SetTexture(tempTex);

        // rotate Wall activation & passbility
        SetWallStatus(LookingDirection.North, mWallWest.IsActive, mWallWest.IsPassable);
        SetWallStatus(LookingDirection.West, mWallSouth.IsActive, mWallSouth.IsPassable);
        SetWallStatus(LookingDirection.South, mWallEast.IsActive, mWallEast.IsPassable);
        SetWallStatus(LookingDirection.East, tempAct, tempPass);

        // Rotate attached Objects
        foreach (GameObject obj in AttachedObjects)
        {
            Vector2 relPos    = new Vector2(obj.transform.localPosition.x - transform.localPosition.x, obj.transform.localPosition.z - transform.localPosition.z);
            Vector2 newRelPos = new Vector2(relPos.y * 1, relPos.x * -1);
            obj.transform.position = new Vector3(transform.localPosition.x + newRelPos.x, obj.transform.position.y, transform.localPosition.z + newRelPos.y);
            obj.transform.Rotate(0, 90, 0);
            // rotate wall facing is object has attachedToWall component
            AttachedToWall attachObj = obj.GetComponent <AttachedToWall>();
            if (attachObj != null)
            {
                attachObj.Rotate(this);
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// Sets the texture of the specified wall
    /// </summary>
    /// <param name='wall'>
    /// Target wall (N, S, W, E)
    /// </param>
    /// <param name='tex'>
    /// Specified Texture
    /// </param>
    public void SetWallTexture(int wall, int tex)
    {
        switch (wall)
        {
        case (int)LookingDirection.North:
            mWallNorth.SetTexture(tex);
            break;

        case (int)LookingDirection.South:
            mWallSouth.SetTexture(tex);
            break;

        case (int)LookingDirection.West:
            mWallWest.SetTexture(tex);
            break;

        case (int)LookingDirection.East:
            mWallEast.SetTexture(tex);
            break;

        case 4:                 //ceiling
            mCeiling.SetTexture(tex);
            break;

        case 5:                 //floor
            mFloor.SetTexture(tex);
            break;
        }
    }