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
    // Use this for initialization
    void Start()
    {
        AttachedToWall obj = gameObject.GetComponent <AttachedToWall>();

        mWallAttachedTo = obj.mWallAttachedTo;

        GetComponent <Triggerable>().mReceiverState = mState;
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        AttachedToWall obj = GetComponent <AttachedToWall>();

        if (obj)
        {
            mFacingDirection = obj.mFacing;
        }

        // adjust Facing Order in accordance to own facing
        for (int count = 0; count < (int)mFacingDirection; count++)
        {
            mFacingOrder.Insert(0, mFacingOrder[3]);
            mFacingOrder.RemoveAt(4);
        }
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        wallAttachObject = gameObject.GetComponent <AttachedToWall>();
        mWallAttachedTo  = wallAttachObject.mWallAttachedTo;

        if (mWallAttachedTo)
        {
            mWallAttachedTo.SetPassabble(mOpen);
        }

        if (mMatOpen == null)
        {
            SetMaterials("Wall_Stone_Door");
        }

        GetComponent <Triggerable>().mReceiverState = mOpen;
    }
Beispiel #5
0
    // paramters:
    // obj - obj to create
    // dest - if true, destroy middle object, if false create obj
    public void AddObject(int obj, ObjectTypes objType, TilePositions pos, bool attachToSide)
    {
        //mMiddleObject = obj;
        GameObject tempObj   = null;
        Vector3    objPos    = new Vector3(0, (float)World.TILE_HEIGHT / 2, 0) + transform.position;
        float      posFactor = 5;

        if (attachToSide)
        {
            posFactor = 10f;
        }

        // Instantitate correctly by tyoe
        switch (objType)
        {
        case ObjectTypes.Decals:
            tempObj      = Instantiate(World.Instance.mDecalsPrefabList[obj]) as GameObject;
            tempObj.name = gameObject.name + "_" + World.Instance.mDecalsPrefabNameList[obj];
            break;

        case ObjectTypes.Items:
            tempObj      = Instantiate(World.Instance.mItemsPrefabList[obj]) as GameObject;
            tempObj.name = gameObject.name + "_" + World.Instance.mItemsPrefabNameList[obj];
            break;

        case ObjectTypes.Triggerables:
            tempObj      = Instantiate(World.Instance.mTriggerablesPrefabList[obj]) as GameObject;
            tempObj.name = gameObject.name + "_" + World.Instance.mTriggerablesPrefabNameList[obj];
            break;

        case ObjectTypes.Enemies:
            tempObj      = Instantiate(World.Instance.mEnemiesPrefabList[obj]) as GameObject;
            tempObj.name = gameObject.name + "_" + World.Instance.mEnemiesPrefabNameList[obj];
            break;
        }

        // attach to wall and get name
        AttachedToWall attachObj = tempObj.GetComponent <AttachedToWall>();

        // calculate position in world and wall attachment
        switch (pos)
        {
        case TilePositions.NorthWest:
            objPos += new Vector3(-posFactor, 0, posFactor);
            break;

        case TilePositions.North:
            objPos += new Vector3(0, 0, posFactor);
            if (attachObj != null)
            {
                attachObj.mWallAttachedTo = WallNorth;
                attachObj.mFacing         = LookingDirection.South;
            }
            break;

        case TilePositions.NorthEast:
            objPos += new Vector3(posFactor, 0, posFactor);
            break;

        case TilePositions.West:
            objPos += new Vector3(-posFactor, 0, 0);
            tempObj.transform.Rotate(Vector3.up * -90);
            if (attachObj != null)
            {
                attachObj.mWallAttachedTo = WallWest;
                attachObj.mFacing         = LookingDirection.East;
            }
            break;

        case TilePositions.East:
            objPos += new Vector3(posFactor, 0, 0);
            tempObj.transform.Rotate(Vector3.up * 90);
            if (attachObj != null)
            {
                attachObj.mWallAttachedTo = WallEast;
                attachObj.mFacing         = LookingDirection.West;
            }
            break;

        case TilePositions.SouthWest:
            objPos += new Vector3(-posFactor, 0, -posFactor);
            break;

        case TilePositions.South:
            objPos += new Vector3(0, 0, -posFactor);
            tempObj.transform.Rotate(Vector3.up * 180);
            if (attachObj != null)
            {
                attachObj.mWallAttachedTo = WallSouth;
                attachObj.mFacing         = LookingDirection.North;
            }
            break;

        case TilePositions.SouthEast:
            objPos += new Vector3(posFactor, 0, -posFactor);
            break;

        case TilePositions.RandomPos:
            float posXRandom = Random.Range(-1f, 1f);
            float posYRandom = Random.Range(-1f, 1f);
            objPos += new Vector3(posFactor * posXRandom, 0, -posFactor * posYRandom);
            break;

        case TilePositions.Middle:
            objPos += new Vector3(0, 0, 0);
            break;
        }

        // Place in world and attach to correct anchor
        switch (objType)
        {
        case ObjectTypes.Decals:
            tempObj.transform.localPosition = objPos;
            tempObj.transform.parent        = mLevelPartBelongingTo.mDecalObjectsAnchor;
            break;

        case ObjectTypes.Items:
            if (mItemPlaced)
            {
                DestroyImmediate(mItemPlaced.gameObject);
            }
            ItemObject itemObj = tempObj.GetComponent <ItemObject>();
            itemObj.mTilePlacedOn           = this;
            tempObj.transform.localPosition = objPos;
            tempObj.transform.parent        = mLevelPartBelongingTo.mItemObjectsAnchor;
            mItemPlaced = tempObj.GetComponent <ItemObject>();
            break;

        case ObjectTypes.Triggerables:
            tempObj.transform.localPosition = objPos;
            tempObj.transform.parent        = mLevelPartBelongingTo.mTriggableListAnchor;
            break;

        case ObjectTypes.Enemies:
            tempObj.transform.localPosition = objPos;
            tempObj.transform.parent        = mLevelPartBelongingTo.mEnemiesAnchor;
            tempObj.GetComponent <MovableActor>().mStartingTile = this;
            break;
        }

        // add to AttachedObjects List
        AttachedObjects.Add(tempObj);
    }