Esempio n. 1
0
    public bool TryDrop()
    {
        Space hitSpace = GetMouseHitComp <Space>();

        if (hitSpace &&
            (holdingPolluter.GetComponent <Factory>() && hitSpace.GetComponent <FactorySpace>()) ||
            (holdingPolluter.GetComponent <Filter>() && hitSpace.GetComponent <FilterSpace>()))
        {
            var attrib          = holdingPolluter.GetAttrib();
            var placementAttrib = attrib.placementAttrib;
            if (placementAttrib.CanPlaceOn(hitSpace.GetPlaceType()))
            {
                int currentPlayerID = stateManager.GetCurrentPlayerID();

                if (hitSpace.CanPlacePolluter(currentPlayerID, holdingPolluter.GetAttrib()))
                {
                    Purchase();
                    hitSpace.SetPolluter(holdingPolluter);
                    TransformPolluter(hitSpace);
                    SetPolluterText();
                    state = State.EMPTY;

                    return(true);
                }
            }
        }
        return(false);
    }