Пример #1
0
    public void Prebuild(Buildable buildable)
    {
        if (current != null)
        {
            CancelCurrent();
        }
        SetBuilding(buildable);

        //Attach object to mouse and create the effect of being built
        switch (buildable)
        {
        case Buildable.Powerstation_left: {
            current = CreateChargeSpotLeft();
            AttachToMouse(current);
            AttachWeaver(current, Side.left);
            SetTemporaryConnectibles(current);
            AddConnectibleWeaversToStations(current);
            break;
        }

        case Buildable.Powerstation_right: {
            current = CreateChargeSpotRight();
            AttachToMouse(current);
            AttachWeaver(current, Side.right);
            SetTemporaryConnectibles(current);
            AddConnectibleWeaversToStations(current);
            break;
        }

        case Buildable.Powerstation_up: {
            current = CreateChargeSpotUp();
            AttachToMouse(current);
            AttachWeaver(current, Side.up);
            SetTemporaryConnectibles(current);
            AddConnectibleWeaversToStations(current);
            break;
        }

        case Buildable.Powerstation_down: {
            current = CreateChargeSpotDown();
            AttachToMouse(current);
            AttachWeaver(current, Side.down);
            SetTemporaryConnectibles(current);
            AddConnectibleWeaversToStations(current);
            break;
        }

        case Buildable.Pole: {
            current = Pole.CreatePole().gameObject;
            AttachToMouse(current);
            current.GetComponent <FollowMouse>().discrete = false;
            current.AddComponent <PoleWeaver>();
            //Set temporary connection
            SetTemporaryConnectibles(current);
            break;
        }

        case Buildable.Plant: {
            current = Powerplant.CreatePowerplant().gameObject;
            AttachToMouse(current);
            //reuse of RoadValidityChecker
            current.AddComponent <RoadValidityChecker>();
            current.AddComponent <ConnectibleWeaver>();
            SetTemporaryConnectibles(current);
            break;
        }
        }

        //Fold all houses
        FoldDecorations();
    }