public void Update() { bool newPlaceable = IsPlaceable(); if (_placeable != newPlaceable) { _placeable = newPlaceable; if (mType == EPlaceType.ITEM) { if (newPlaceable) { CItemView.SetItemSurfaceColour(mAsset.mItemType, _gob, CGame.COLOR_BLUEPRRINT); } else { CItemView.SetItemSurfaceColour(mAsset.mItemType, _gob, new Color(1.0f, 0.1f, 0.1f)); } } } if (mType == EPlaceType.ITEM) { Color c = CGame.COLOR_BLUEPRRINT; c.a = 0.4f; if (!_placeable) { c = new Color(1.0f, 0.1f, 0.1f, 0.4f); } Vector2 midOffset = CItem.RotationAxisTable[mRotation].Transform(new Vector2(mAsset.mWidth, mAsset.mLength)); float yOff = 0.001f; float oW = 0.1f; // Draw an outline. Vector3 p1 = mPosition + new Vector3(0, yOff, 0); Vector3 p2 = mPosition + new Vector3(0, yOff, midOffset.y); Vector3 p3 = mPosition + new Vector3(midOffset.x, yOff, midOffset.y); Vector3 p4 = mPosition + new Vector3(midOffset.x, yOff, 0); Vector3 p1p2 = (p2 - p1) * 0.5f + p1; Vector3 p2p3 = (p3 - p2) * 0.5f + p2; Vector3 p3p4 = (p4 - p3) * 0.5f + p3; Vector3 p4p1 = (p1 - p4) * 0.5f + p4; CDebug.DrawYRectQuad(p1p2, oW, Mathf.Abs(midOffset.y) - oW, c); CDebug.DrawYRectQuad(p2p3, Mathf.Abs(midOffset.x) + oW, oW, c); CDebug.DrawYRectQuad(p3p4, oW, Mathf.Abs(midOffset.y) - oW, c); CDebug.DrawYRectQuad(p4p1, Mathf.Abs(midOffset.x) + oW, oW, c); } else if (mType == EPlaceType.UNIT) { CDebug.DrawYRectQuad(mPosition, 0.25f, 0.25f, CGame.COLOR_BLUEPRRINT, false); } else if (mType == EPlaceType.VOLUME || mType == EPlaceType.DECAL) { CDebug.DrawBorderQuads(mPosition, new Vector2(1, 1), CGame.COLOR_BLUEPRRINT, false); } }
private void _Init(EPlaceType Type, Transform Parent, PlacementDelegate PlacementDelegate) { mType = Type; _placeable = false; _placeDelegate = PlacementDelegate; if (mType == EPlaceType.ITEM) { _gob = mAsset.CreateVisuals(EViewDirection.VD_FRONT); _gob.transform.SetParent(Parent); CItemView.SetItemSurfaceColour(mAsset.mItemType, _gob, CGame.COLOR_BLUEPRRINT); } else if (mType == EPlaceType.UNIT) { mRotation = 225; _gob = GameObject.Instantiate(CGame.PrimaryResources.Prefabs[7] as GameObject); _gob.transform.SetParent(Parent); _gob.transform.rotation = Quaternion.AngleAxis(mRotation, Vector3.up); } }