コード例 #1
0
    /// <summary>
    /// Sets the currently selected Buildable.  This will show the
    /// review the the build area highlight.
    /// </summary>
    public void setSelectedBuildable(BuildableBase buildable)
    {
        this.selectedBuildable = buildable;
        if (this.selectedBuildable != null)
        {
            if (this.selectedBuildable.isRotatable())
            {
                if (this.selectedBuildable.displayRotation == EnumRotation.NONE)
                {
                    this.rot = Rotation.RIGHT;
                }
                else
                {
                    this.rot = Rotation.fromEnum(this.selectedBuildable.displayRotation);
                }
            }
            else
            {
                this.rot = null;
            }
        }

        if (this.selectedBuildable == null)
        {
            this.preview.hide();

            this.areaHighlighter.hide();
        }
        else
        {
            this.preview.show(this.selectedBuildable);
            this.callback_buildClick();
        }
    }
コード例 #2
0
 public void setBuildable(BuildableBase buildable)
 {
     this.buildable = buildable;
     this.sr.transform.localScale = new Vector3(
         this.buildable.getHighlightWidth(),
         this.buildable.getHighlightHeight());
 }
コード例 #3
0
    /// <summary>
    /// Activates the building mode, the buildable will be instantiated and follows the mouse.
    /// </summary>
    /// <param name="buildable"></param>
    public void ActivateBuildMode(BuildableBase buildable)
    {
        ExitBuildMode();

        GameObject buildableResource = Resources.Load <GameObject>($"Buildable");

        if (buildableResource != null)
        {
            buildableData = buildable;

            buildableToBuild      = Instantiate(buildableResource, PlayerNetwork.LocalPlayer.transform.position, Quaternion.identity);
            buildableToBuild.name = buildable.Name;

            buildableToBuildRenderer = buildableToBuild.GetComponent <Renderer>();

            buildableToBuild.GetComponent <MeshRenderer>().sharedMaterials = GetReplacementMaterials(buildable.Model.GetComponent <MeshRenderer>().sharedMaterials);
            buildableToBuild.GetComponent <MeshFilter>().sharedMesh        = buildable.Model.GetComponent <MeshFilter>().sharedMesh;

            gridRenderer.enabled = true;
            gridRenderer.sharedMaterial.SetFloat("_GridSpacing", gridSpacing);
            gridRenderer.sharedMaterial.SetFloat("_GridDistance", buildingRange);

            StartCoroutine(FollowMouse());
        }
        else
        {
            Debug.LogError($"BuildingController - Buildable '{buildable.Name}' not found");
        }
    }
コード例 #4
0
    private void RPC_SpawnBuildable(Vector3 position, int photonId, string itemId, Quaternion quaternion = new Quaternion())
    {
        BuildableBase buildable = ItemFactory.CreateNewItem(itemId) as BuildableBase;
        var           prefab    = buildable.PrefabToSpawn;

        GameObject gameObj = Instantiate(prefab, position, quaternion);

        gameObj.GetComponent <BuildableWorldObject>().enabled   = true;
        gameObj.GetComponent <BuildableWorldObject>().buildable = buildable;
        if (gameObj.GetComponent <Collider>())
        {
            gameObj.GetComponent <Collider>().enabled = true;
        }
        else if (gameObj.GetComponentsInChildren <Collider>() != null)
        {
            foreach (Collider c in gameObj.GetComponentsInChildren <Collider>())
            {
                gameObj.GetComponentInChildren <Collider>().enabled = true;
            }
        }
        gameObj.name = buildable.Name;

        PhotonView[] nViews = gameObj.GetComponentsInChildren <PhotonView>();
        nViews[0].viewID = photonId;
    }
コード例 #5
0
    public void setBuildable(BuildableBase buildable)
    {
        Sprite floorOverlaySprite  = null;
        Sprite objectSprite        = null;
        Sprite objectOverlaySprite = null;

        buildable.getSprites(ref floorOverlaySprite, ref objectSprite, ref objectOverlaySprite);

        this.func(floorOverlaySprite, this._imgFloorOverlay);
        this.func(objectSprite, this._imgObject);
        this.func(objectOverlaySprite, this._imgObjectOverlay);
    }
コード例 #6
0
ファイル: BuildableBase.cs プロジェクト: CodeShaper13/ms49
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();

            this.DrawDefaultInspector();

            BuildableBase script = (BuildableBase)this.target;

            if (script.isRotatable())
            {
                EditorGUILayout.PropertyField(this.displayRotation);
                EditorGUILayout.PropertyField(this.overrideRotationMsg);
            }

            this.serializedObject.ApplyModifiedProperties();
        }
コード例 #7
0
    private void createBuildableListButton(BuildableBase buildable, MilestoneData unlockingMilestone)
    {
        BuildableListEntry btn = GameObject.Instantiate(
            this._entryBtnPrefab,
            this._buildableBtnArea).GetComponent <BuildableListEntry>();

        btn.setStructureData(buildable, unlockingMilestone);

        // Add the Button to the list
        if (buildable.tab == null || buildable.tab == this._miscellaneousTab)
        {
            this.tabs[0].addButton(btn); // 0 is the miscellaneous tab
        }
        else
        {
            bool added = false;
            foreach (TabContents tc in this.tabs)
            {
                if (buildable.tab == tc.tab)
                {
                    tc.addButton(btn);
                    added = true;
                    break;
                }
            }

            if (!added)
            {
                // Create a new tab.
                TabContents newTab = this.createTab(buildable.tab);
                newTab.addButton(btn);
            }
        }

        this.buildableListButton.Add(btn);
    }