public bool AddBuilding(Building building, DIRECTION dir, POSITION_TYPE posType, bool inBuilding, bool continous) { int idx = building.TileTypes.IndexOf(type); if (idx >= 0) { if (building.Buildable[idx]) { if (inBuilding && !m_inBuilding) { if (continous) { building.SwitchToContinuousSprite(); } m_inBuilding = building; PositionBuilding(m_inBuilding, dir, posType); return(true); } else if (!inBuilding && !m_outBuilding) { if (continous) { building.SwitchToContinuousSprite(); } m_outBuilding = building; PositionBuilding(m_outBuilding, dir, posType); return(true); } } } return(false); }
public void InitStruct() { Type = POSITION_TYPE.CARTESIAN_POSITION; Delay = 0.0f; CartesianPosition.InitStruct(); Actuators.InitStruct(); HandMode = HAND_MODE.POSITION_MODE; Fingers.InitStruct(); }
private void PositionBuilding(Building building, DIRECTION dir, POSITION_TYPE posType) { // Tile is TOP LEFT // Building is CENTER Vector3 offset = new Vector3(64, -64, -0.5f); if (dir == DIRECTION.CENTER) { if (posType == POSITION_TYPE.CENTER) { } else if (posType == POSITION_TYPE.LEFT) { offset.x = building.SpriteSize.x / 2.0f; } else if (posType == POSITION_TYPE.RIGHT) { offset.x = 128 - building.SpriteSize.x / 2.0f; } } else if (dir == DIRECTION.TOP_LEFT) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 90.0f); } else if (dir == DIRECTION.TOP) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 270.0f); } else if (dir == DIRECTION.TOP_RIGHT) { } else if (dir == DIRECTION.LEFT) { } else if (dir == DIRECTION.RIGHT) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 180.0f); } else if (dir == DIRECTION.BOTTOM_LEFT) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 180.0f); } else if (dir == DIRECTION.BOTTOM) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 90.0f); } else if (dir == DIRECTION.BOTTOM_RIGHT) { building.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f), 270.0f); } building.transform.position = transform.position + offset; }
public virtual Vector2 position(POSITION_TYPE posType = POSITION_TYPE.RELATIVE) { if (!isReady()) return Vector2.zero; switch (posType) { case POSITION_TYPE.ABSOLUTE: return Utilities.Math.copy(_boxRect.position); case POSITION_TYPE.RELATIVE: return Utilities.Math.copy(_boxRect.anchoredPosition); case POSITION_TYPE.PERCENT: Vector2 parentSize = _mc.canvas().GetComponent<RectTransform>().sizeDelta / 2; if (_parent != null) parentSize = _parent.size() / 2; Vector2 retVal = Utilities.Math.copy(_boxRect.anchoredPosition); retVal.x -= parentSize.x; retVal.y -= parentSize.y; retVal.x /= parentSize.x; retVal.y /= parentSize.y; return retVal; default: return Vector2.zero; } }
public virtual bool position(Vector2 position, POSITION_TYPE posType = POSITION_TYPE.PERCENT) { if (!isReady()) return false; switch (posType) { case POSITION_TYPE.PERCENT: Vector2 parentSize = _mc.canvas().GetComponent<RectTransform>().sizeDelta / 2; if (_parent != null) parentSize = _parent.size() / 2; _boxRect.anchoredPosition = new Vector2( position.x * parentSize.x, position.y * parentSize.y); return true; case POSITION_TYPE.ABSOLUTE: _boxRect.position = position; return true; case POSITION_TYPE.RELATIVE: _boxRect.anchoredPosition = position; return true; default: return false; } }