예제 #1
0
    public void Rotate()
    {
        ItemSwitch();

        switch (direction)
        {
        case ItemDirection.North:
            this.transform.Rotate(0, 90, 0);
            direction = ItemDirection.East;
            break;

        case ItemDirection.East:
            this.transform.Rotate(0, 90, 0);
            direction = ItemDirection.South;
            break;

        case ItemDirection.South:
            this.transform.Rotate(0, 90, 0);
            direction = ItemDirection.West;
            break;

        case ItemDirection.West:
            this.transform.Rotate(0, 90, 0);
            direction = ItemDirection.North;
            break;
        }
    }
예제 #2
0
 public void SetDirectionOfTile(int X, int Y, int Z, ItemDirection dir)
 {
     if (isOnGrid(X, Y, Z))
     {
         _tile [X, Y, Z].Direction = dir;
     }
 }
예제 #3
0
            private void CreateCandyMonsterCandy(GameEntity entity, ItemDirection direction)
            {
                var fake = Contexts.sharedInstance.game.CreateEntity();

                fake.isCandyFakeItem = true;
                fake.AddItemDirection(direction);
                fake.AddGridPosition(entity.willSpawnItem.GridPosition);
            }
예제 #4
0
 public Tile(GameObject obj, IVector3 pos)
 {
     _position     = pos;
     _itemType     = Item.EMPTY;
     _itemAttached = null;
     _obj          = obj;
     _frictionVal  = FrictionValue.LOW;
     _direction    = ItemDirection.LEFT;
 }
예제 #5
0
    void Awake()
    {
        itemID    = ++itemIDGenerator;
        direction = ItemDirection.South;

        if (type == ItemType.Door)
        {
            mat1 = this.transform.FindChild("Door Mat 1").gameObject;
            mat2 = this.transform.FindChild("Door Mat 2").gameObject;
        }
    }
예제 #6
0
 /// <summary>
 /// Evolved constructor
 /// </summary>
 /// <param name="p_Id">Id code</param>
 /// <param name="p_bMasterLedOn">Led On definition</param>
 /// <param name="p_pInitalLocation">Initial location</param>
 /// <param name="p_dDirection">Direction</param>
 /// <param name="p_sSpeed">Speed</param>
 public LedMatrixItem(int p_Id,
                      bool[,]       p_bMasterLedOn,
                      Point p_pInitalLocation,
                      ItemDirection p_dDirection,
                      ItemSpeed p_sSpeed)
 {
     // Initialisations
     m_Id               = p_Id;
     m_bMasterLedOn     = p_bMasterLedOn;
     m_dDirection       = p_dDirection;
     m_sSpeed           = p_sSpeed;
     m_pCurrentLocation = p_pInitalLocation;
 }
    private void CreateCandyMonster(GameEntity candyHead, int length, ItemDirection itemDirection)
    {
        var orgX        = candyHead.gridPosition.value.x;
        var orgY        = candyHead.gridPosition.value.y;
        var fakeItemIds = new Stack <int>();

        switch (itemDirection)
        {
        case ItemDirection.Left:
            for (int x = orgX - 1; x >= orgX - length; x--)
            {
                var fake = _candies[x, orgY];
                ConvertCandyFakeItem(fake, candyHead, fakeItemIds);
            }

            break;

        case ItemDirection.Down:
            for (int y = orgY - 1; y >= orgY - length; y--)
            {
                var fake = _candies[orgX, y];
                ConvertCandyFakeItem(fake, candyHead, fakeItemIds);
            }

            break;

        case ItemDirection.Right:
            for (int x = orgX + 1; x <= orgX + length; x++)
            {
                var fake = _candies[x, orgY];
                ConvertCandyFakeItem(fake, candyHead, fakeItemIds);
            }

            break;

        case ItemDirection.Up:
            for (int y = orgY + 1; y <= orgY + length; y++)
            {
                var fake = _candies[orgX, y];
                ConvertCandyFakeItem(fake, candyHead, fakeItemIds);
            }

            break;
        }

        candyHead.ReplaceLayer(length - 1);
        candyHead.AddItemDirection(itemDirection);
        candyHead.AddOrderedFakeItems(fakeItemIds);
    }
예제 #8
0
        /// <summary>
        /// Set the direction of an item
        /// </summary>
        /// <param name="p_iItemId">Id of the item</param>
        /// <param name="p_dDirection">New direction</param>
        public void SetItemDirection(int p_iItemId,
                                     ItemDirection p_dDirection)
        {
            int iItemIdx = -1;

            // Get the item index
            iItemIdx = GetItemIdxFromId(p_iItemId);
            if (iItemIdx == -1)
            {
                return;
            }

            // Set new direction
            m_lItemList[iItemIdx].SetDirection(p_dDirection);
            return;
        }
예제 #9
0
        /// <summary>
        /// Add an item built from text to the item list
        /// </summary>
        /// <param name="p_sText">New item text</param>
        /// <param name="p_pLocation">Initial position of the new item</param>
        /// <param name="p_dDirection">Direction of the new item</param>
        /// <param name="p_sSpeed">Speed of the new item</param>
        /// <returns>Item Id</returns>
        public int AddTextItem(string p_sText,
                               Point p_pLocation,
                               ItemDirection p_dDirection,
                               ItemSpeed p_sSpeed)
        {
            // Updates Id counting
            m_iItemIdCount++;

            // New item
            LedMatrixItem lmiMyNewItem = new LedMatrixItem(m_iItemIdCount,
                                                           GetLedOnFromString(p_sText),
                                                           p_pLocation,
                                                           p_dDirection,
                                                           p_sSpeed);

            // Add the item to the list
            m_lItemList.Add(lmiMyNewItem);

            // Return item Id
            return(m_iItemIdCount);
        }
예제 #10
0
        /// <summary>
        /// Add an item to the item list
        /// </summary>
        /// <param name="p_bMasterLedOn">Led On definition of the new item</param>
        /// <param name="p_pLocation">Initial position of the new item</param>
        /// <param name="p_dDirection">Direction of the new item</param>
        /// <param name="p_sSpeed">Speed of the new item</param>
        /// <returns>Item Id</returns>
        public int AddItem(bool[,]       p_bMasterLedOn,
                           Point p_pLocation,
                           ItemDirection p_dDirection,
                           ItemSpeed p_sSpeed)
        {
            // Updates Id counting
            m_iItemIdCount++;

            // New item
            LedMatrixItem lmiMyNewItem = new LedMatrixItem(m_iItemIdCount,
                                                           p_bMasterLedOn,
                                                           p_pLocation,
                                                           p_dDirection,
                                                           p_sSpeed);

            // Add the item to the list
            m_lItemList.Add(lmiMyNewItem);

            // Return item Id
            return(m_iItemIdCount);
        }
예제 #11
0
파일: Room.cs 프로젝트: Gapti/Hospital
    public bool AgainstWall(ItemDirection direction, Vector3 bl, int xD, int zD)
    {
        switch (direction)
        {
        case ItemDirection.North:
            if (bl.z == TopLeft.z)
            {
                return(true);
            }
            break;

        case ItemDirection.East:
            if (bl.x == TopRight.x)
            {
                return(true);
            }
            break;

        case ItemDirection.South:
            if (bl.z == BottomLeft.z)
            {
                return(true);
            }
            break;

        case ItemDirection.West:
            if (bl.x == TopLeft.x)
            {
                return(true);
            }
            break;
        }

        //Debug.Log ("door not valid " + direction);

        return(false);
    }
예제 #12
0
 /// <summary>
 /// Define the direction of the item
 /// </summary>
 /// <param name="p_dDirection">Direction of the item</param>
 public void SetDirection(ItemDirection p_dDirection)
 {
     m_dDirection = p_dDirection;
 }
    private void CalculateCandyLength(GameEntity[,] itemGrid, int orgX, int orgY, out int length,
                                      out ItemDirection itemDirection)
    {
        //left
        int candyLength = 0;

        for (int x = orgX - 1; x >= 0; x--)
        {
            if (itemGrid[x, orgY] == null)
            {
                break;
            }
            if (!itemGrid[x, orgY].isCandyFakeItem)
            {
                break;
            }
            if (itemGrid[x, orgY].itemDirection.Value != ItemDirection.Left)
            {
                break;
            }

            candyLength++;
        }

        if (candyLength > 0)
        {
            length        = candyLength;
            itemDirection = ItemDirection.Left;
            return;
        }

        //right
        for (int x = orgX + 1; x < _width; x++)
        {
            if (itemGrid[x, orgY] == null)
            {
                break;
            }
            if (!itemGrid[x, orgY].isCandyFakeItem)
            {
                break;
            }
            if (itemGrid[x, orgY].itemDirection.Value != ItemDirection.Right)
            {
                break;
            }

            candyLength++;
        }

        if (candyLength > 0)
        {
            length        = candyLength;
            itemDirection = ItemDirection.Right;
            return;
        }

        //up
        for (int y = orgY + 1; y < _height; y++)
        {
            if (itemGrid[orgX, y] == null)
            {
                break;
            }
            if (!itemGrid[orgX, y].isCandyFakeItem)
            {
                break;
            }
            if (itemGrid[orgX, y].itemDirection.Value != ItemDirection.Up)
            {
                break;
            }

            candyLength++;
        }

        if (candyLength > 0)
        {
            length        = candyLength;
            itemDirection = ItemDirection.Up;
            return;
        }

        //down
        for (int y = orgY - 1; y >= 0; y--)
        {
            if (itemGrid[orgX, y] == null)
            {
                break;
            }
            if (!itemGrid[orgX, y].isCandyFakeItem)
            {
                break;
            }
            if (itemGrid[orgX, y].itemDirection.Value != ItemDirection.Down)
            {
                break;
            }

            candyLength++;
        }

        length        = candyLength;
        itemDirection = ItemDirection.Down;
    }
예제 #14
0
파일: Room.cs 프로젝트: Gapti/Hospital
    public void DisableWallsForDoors(ItemDirection direction, Vector3 bl, int xD, int zD)
    {
        Vector3 otherDoorPos;
        Vector3 firstDoorPos;

        switch (direction)
        {
        case ItemDirection.West:

            otherDoorPos = new Vector3(bl.x, bl.y, bl.z);
            firstDoorPos = new Vector3(bl.x, bl.y, bl.z - xD);

            foreach (GameObject t in leftWalls)
            {
                if (t.transform.position == firstDoorPos || t.transform.position == otherDoorPos)
                {
                    t.gameObject.SetActive(false);
                }
            }
            break;

        case ItemDirection.East:

            otherDoorPos = new Vector3(bl.x, bl.y, bl.z + xD);
            firstDoorPos = new Vector3(bl.x, bl.y, bl.z + zD);


            foreach (GameObject t in rightWalls)
            {
                if (t.transform.position == firstDoorPos || t.transform.position == otherDoorPos)
                {
                    t.gameObject.SetActive(false);
                }
            }

            break;

        case ItemDirection.South:
            //working
            otherDoorPos = new Vector3(bl.x + zD, bl.y, bl.z);

            foreach (GameObject t in bottomWalls)
            {
                if (t.transform.position == bl || t.transform.position == otherDoorPos)
                {
                    t.gameObject.SetActive(false);
                }
            }

            break;

        case ItemDirection.North:

            otherDoorPos = new Vector3(bl.x - zD, bl.y, bl.z);
            firstDoorPos = new Vector3(bl.x - xD, bl.y, bl.z);

            foreach (GameObject t in topWalls)
            {
                if (t.transform.position == firstDoorPos || t.transform.position == otherDoorPos)
                {
                    t.gameObject.SetActive(false);
                }
            }

            break;
        }
    }