Exemplo n.º 1
0
    public void Update()
    {
        //our instance can't do anything until the other instances are ready
        if (!finishedInstantiating && GameRuleIconStorage.instance != null && GameRuleSpawnableObjectRegistry.instance != null) {
            //add descriptors for selectable components to the selection map
            //classes with subcomponents will also produce popups
            //conditions
            List<GameRuleDesignComponentDescriptor> gameRuleConditionSelection = (componentSelectionMap[typeof(GameRuleCondition)] = new List<GameRuleDesignComponentDescriptor>());
            gameRuleEventHappenedConditionDurationDescriptor = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleEventHappenedCondition),
                GameRuleIconStorage.instance.genericEventIcon, 0,
                new System.Type[] {
                    typeof(GameRuleEventType)
                });
            gameRuleConditionSelection.Add(gameRuleEventHappenedConditionDurationDescriptor);
            gameRuleConditionSelection.Add(new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleZoneCondition),
                GameRuleIconStorage.instance.genericZoneIcon, 1,
                new System.Type[] {
                    typeof(GameRuleSourceSelector),
                    typeof(RuleStubZoneType)
                }));

            //actions get specially handled since their class is controlled by the condition
            //they don't have icons because they never appear in popups and are fully represented by the icons in their subcomponents
            //the subcomponents will get assigned in complementComponent
            gameRuleEffectActionDescriptor = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleEffectAction),
                null, -1,
                null);
            //metarules don't even have any popup, they are 100% 1:1 with conditions
            gameRuleMetaRuleActionDescriptor = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleMetaRuleAction),
                null, -1,
                null);

            //event types for GameRuleEventHappenedConditions
            List<GameRuleDesignComponentDescriptor> gameRuleEventTypeSelection = (componentSelectionMap[typeof(GameRuleEventType)] = new List<GameRuleDesignComponentDescriptor>());
            foreach (GameRuleEventType eventType in GameRuleEvent.eventTypesList) {
                gameRuleEventTypeSelection.Add(new GameRuleDesignComponentEventTypeDescriptor(eventType, 1));
            }

            //selectors
            //these get used for a few things
            //selectors and effects for actions change based on the event type source
            List<GameRuleDesignComponentDescriptor> playerSelectorSelection = (sourceSelectorMap[typeof(TeamPlayer)] = new List<GameRuleDesignComponentDescriptor>());
            foreach (GameRuleSelector selector in GameRuleSelector.getPlayerSourceSelectors()) {
                playerSelectorSelection.Add(new GameRuleDesignComponentSelectorDescriptor(selector));
            }
            List<GameRuleDesignComponentDescriptor> ballSelectorSelection = (sourceSelectorMap[typeof(Ball)] = new List<GameRuleDesignComponentDescriptor>());
            foreach (GameRuleSelector selector in GameRuleSelector.getBallSourceSelectors()) {
                ballSelectorSelection.Add(new GameRuleDesignComponentSelectorDescriptor(selector));
            }

            //zone types
            //each zone type corresponds to one metarule
            List<GameRuleDesignComponentDescriptor> zoneSelection = (componentSelectionMap[typeof(RuleStubZoneType)] = new List<GameRuleDesignComponentDescriptor>());
            zoneSelection.Add(new GameRuleDesignComponentZoneTypeDescriptor(
                GameRuleRequiredObjectType.BoomerangZone,
                GameRuleIconStorage.instance.boomerangZoneIcon));
            //right now this is only for zones which are only on players
            List<GameRuleDesignComponentDescriptor> gameRuleSourceSelectorSelection = (componentSelectionMap[typeof(GameRuleSourceSelector)] = new List<GameRuleDesignComponentDescriptor>());
            gameRuleSourceSelectorSelection.Add(new GameRuleDesignComponentSelectorDescriptor(GameRulePlayerSelector.instance));

            //effects
            //first, map each effect to a descriptor
            Dictionary<System.Type, GameRuleDesignComponentDescriptor> effectTypeDescriptorMap = new Dictionary<System.Type, GameRuleDesignComponentDescriptor>();
            effectTypeDescriptorMap[typeof(GameRulePointsPlayerEffect)] = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRulePointsPlayerEffect),
                //this descriptor doesn't have an icon but components for it will make one
                null, 0,
                new System.Type[] {
                    //we'll just use this as the key for our list of possible point values
                    typeof(GameRulePointsPlayerEffect)
                });
            effectTypeDescriptorMap[typeof(GameRuleDuplicateEffect)] = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleDuplicateEffect),
                GameRuleIconStorage.instance.duplicatedIcon, 0, null);
            effectTypeDescriptorMap[typeof(GameRuleFreezeEffect)] = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleFreezeEffect),
                GameRuleIconStorage.instance.frozenIcon, 0,
                new System.Type[] {
                    typeof(GameRuleActionDuration)
                });
            effectTypeDescriptorMap[typeof(GameRuleDizzyEffect)] = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleDizzyEffect),
                GameRuleIconStorage.instance.dizzyIcon, 0,
                new System.Type[] {
                    typeof(GameRuleActionDuration)
                });
            effectTypeDescriptorMap[typeof(GameRuleBounceEffect)] = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleBounceEffect),
                GameRuleIconStorage.instance.bouncyIcon, 0,
                new System.Type[] {
                    typeof(GameRuleActionDuration)
                });
            //next, go through and pull all the effect types from their corresponding list
            List<GameRuleDesignComponentDescriptor> playerEffectSelection = (sourceEffectMap[typeof(TeamPlayer)] = new List<GameRuleDesignComponentDescriptor>());
            foreach (System.Type effectType in GameRuleEffect.playerSourceEffects) {
                playerEffectSelection.Add(effectTypeDescriptorMap[effectType]);
            }
            List<GameRuleDesignComponentDescriptor> ballEffectSelection = (sourceEffectMap[typeof(Ball)] = new List<GameRuleDesignComponentDescriptor>());
            foreach (System.Type effectType in GameRuleEffect.ballSourceEffects) {
                ballEffectSelection.Add(effectTypeDescriptorMap[effectType]);
            }

            //metarules are controlled by the zones
            zoneTypeMetaRuleMap[GameRuleRequiredObjectType.BoomerangZone] = new GameRuleDesignComponentMetaRuleDescriptor(
                GameRulePlayerSwapMetaRule.instance);

            //event sources and targets
            GameRuleDesignComponentEventParticipantDescriptor teamPlayerDescriptor = new GameRuleDesignComponentEventParticipantDescriptor(
                typeof(TeamPlayer),
                GameRuleIconStorage.instance.playerIcon);
            GameRuleDesignComponentEventParticipantDescriptor ballDescriptor = new GameRuleDesignComponentEventParticipantDescriptor(
                typeof(Ball),
                GameRuleIconStorage.instance.genericBallIcon);
            List<GameRuleDesignComponentDescriptor> fieldObjectDescriptors = new List<GameRuleDesignComponentDescriptor>();
            foreach (GameRuleSpawnableObject spawnableObject in GameRuleSpawnableObjectRegistry.instance.goalSpawnableObjects) {
                fieldObjectDescriptors.Add(new GameRuleDesignComponentFieldObjectDescriptor(
                    spawnableObject.spawnedObject.GetComponent<FieldObject>().sportName,
                    spawnableObject.icon));
            }
            fieldObjectDescriptors.Add(new GameRuleDesignComponentFieldObjectDescriptor(
                "boundary",
                GameRuleIconStorage.instance.boundaryIcon));
            //go through all the event types and build up the lists of the potential source and target descriptors per event type
            foreach (GameRuleEventType eventType in GameRuleEvent.eventTypesList) {
                List<GameRuleDesignComponentDescriptor> sourcesList = (potentialSourcesForEventMap[eventType] = new List<GameRuleDesignComponentDescriptor>());
                Dictionary<System.Type, List<GameRuleDesignComponentDescriptor>> targetsMap =
                    (potentialTargetsForEventSourceMap[eventType] = new Dictionary<System.Type, List<GameRuleDesignComponentDescriptor>>());

                foreach (KeyValuePair<System.Type, List<System.Type>> sourceAndTargets in GameRuleEvent.potentialEventsList[eventType]) {
                    //add this source to the list of sources for the event type
                    System.Type sourceType = sourceAndTargets.Key;
                    if (sourceType == typeof(TeamPlayer))
                        sourcesList.Add(teamPlayerDescriptor);
                    else if (sourceType == typeof(Ball))
                        sourcesList.Add(ballDescriptor);
                    else
                        throw new System.Exception("Bug: invalid event source type " + sourceType);

                    //add all the targets to this source's list of targets for this event type
                    List<GameRuleDesignComponentDescriptor> targetsList = (targetsMap[sourceType] = new List<GameRuleDesignComponentDescriptor>());
                    foreach (System.Type targetType in sourceAndTargets.Value) {
                        if (targetType == typeof(TeamPlayer))
                            targetsList.Add(teamPlayerDescriptor);
                        else if (targetType == typeof(Ball))
                            targetsList.Add(ballDescriptor);
                        else if (targetType == typeof(FieldObject))
                            targetsList.AddRange(fieldObjectDescriptors);
                        else
                            throw new System.Exception("Bug: invalid event source type " + sourceType);
                    }
                }
            }

            //point descriptors for a points effect
            List<GameRuleDesignComponentDescriptor> pointAmountSelection = (componentSelectionMap[typeof(GameRulePointsPlayerEffect)] = new List<GameRuleDesignComponentDescriptor>());
            for (int i = GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MAX_VALUE - GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MASK;
                i <= GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MAX_VALUE;
                i++) {
                pointAmountSelection.Add(new GameRuleDesignComponentIntDescriptor(i));
            }

            //action durations
            List<GameRuleDesignComponentDescriptor> gameRuleActionDurationSelection = (componentSelectionMap[typeof(GameRuleActionDuration)] = new List<GameRuleDesignComponentDescriptor>());
            gameRuleActionDurationSelection.Add(new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleActionFixedDuration),
                GameRuleIconStorage.instance.clockIcon, 0,
                new System.Type[] {
                    //we'll just use this as the key for our list of possible second durations
                    typeof(GameRuleActionFixedDuration)
                }));
            gameRuleActionUntilConditionDurationDescriptor = new GameRuleDesignComponentClassDescriptor(
                typeof(GameRuleActionUntilConditionDuration),
                GameRuleIconStorage.instance.genericEventIcon, 0,
                //we need an event happend condition but in a different form, we'll fill this in when this descriptor is assigned
                null);
            gameRuleActionDurationSelection.Add(gameRuleActionUntilConditionDurationDescriptor);

            //now that we have our descriptors, we can build our selection map
            //only some classes make easy popups, the others will need special handling
            //duration length descriptors for fixed durations
            List<GameRuleDesignComponentDescriptor> fixedDurationSelection = (componentSelectionMap[typeof(GameRuleActionFixedDuration)] = new List<GameRuleDesignComponentDescriptor>());
            for (int i = 0; i <= GameRuleActionFixedDuration.DURATION_SERIALIZATION_MASK; i++) {
                fixedDurationSelection.Add(new GameRuleDesignComponentIntDescriptor(i));
            }

            //for until-condition durations, each source type has a list of valid events that it can use
            foreach (KeyValuePair<System.Type, List<GameRuleEventType>> sourceTypeWithEventTypes in GameRuleEvent.potentialEventTypesMap) {
                List<GameRuleDesignComponentDescriptor> eventTypesForSource = (potentialEventsForSourceMap[sourceTypeWithEventTypes.Key] = new List<GameRuleDesignComponentDescriptor>());
                foreach (GameRuleEventType eventType in sourceTypeWithEventTypes.Value) {
                    eventTypesForSource.Add(new GameRuleDesignComponentEventTypeDescriptor(eventType, 0));
                }
            }

            //and finally we'll build our complete rule that the user can change
            gameRuleConditionComponent = new GameRuleDesignComponent(null, typeof(GameRuleCondition));
            gameRuleActionComponent = new GameRuleDesignComponent(null, gameRuleConditionComponent);
            gameRuleComponent = new GameRuleDesignComponent(
                null,
                new GameRuleDesignComponentClassDescriptor(
                    typeof(GameRule),
                    GameRuleIconStorage.instance.resultsInIcon, 1, null));
            gameRuleComponent.subComponents = new GameRuleDesignComponent[] {gameRuleConditionComponent, gameRuleActionComponent};
            redisplayRule();

            finishedInstantiating = true;
        }
    }
Exemplo n.º 2
0
    //build the popup from the given list of descriptors
    //also receives the component that this popup will edit and the type of component used to find the descriptors
    public void buildPopup(GameRuleDesignComponent cr, List<GameRuleDesignComponentDescriptor> pd, System.Type describedType)
    {
        //instead of Start(), this is the place where stuff will get initialized
        //store a bunch of size information for positioning things
        RectTransform iconArea = (RectTransform)(transform.GetChild(1));
        iconAreaBottomLeft = iconArea.offsetMin;
        iconAreaTopRight = iconArea.offsetMax; //x and y are both negative for an inset corner
        iconAreaTotalBounds = iconAreaBottomLeft - iconAreaTopRight;
        iconContainer = (RectTransform)(transform.GetChild(2));
        //throw the container out to under the canvas so that it renders over the whole rule
        iconContainer.SetParent(GameRuleDesigner.instance.uiCanvas);
        RectTransform iconContainerSpacing = (RectTransform)(iconContainer.GetChild(0));
        iconContainerSpacingSize = iconContainerSpacing.sizeDelta;
        //we only needed these to get their size, we can get rid of them now
        Destroy(iconArea.gameObject);
        Destroy(iconContainerSpacing.gameObject);

        //now we can build the popup
        transform.SetParent(GameRuleDesigner.instance.iconContainerTransform);
        //setting the parent screwed up the scale so fix it
        transform.localScale = new Vector3(1.0f, 1.0f);
        componentRepresented = cr;
        popupDescriptors = pd;
        //go through all the descriptors and add their icon to this popup
        foreach (GameRuleDesignComponentDescriptor descriptor in popupDescriptors) {
            RectTransform popupIcon;
            //int descriptors don't have icon prefabs, so we have to construct the icons
            if (descriptor is GameRuleDesignComponentIntDescriptor) {
                List<GameObject> iconList = new List<GameObject>();
                int i = ((GameRuleDesignComponentIntDescriptor)descriptor).intDescribed;
                if (i >= 0) {
                    if (describedType == typeof(GameRulePointsPlayerEffect))
                        iconList.Add(GameRuleIconStorage.instance.charPlusIcon);
                    GameRuleIconStorage.instance.addDigitIcons(i, iconList);
                } else {
                    iconList.Add(GameRuleIconStorage.instance.charMinusIcon);
                    GameRuleIconStorage.instance.addDigitIcons(-i, iconList);
                }
                //make a gameobject to hold all of the icons
                popupIcon = groupIcons(iconList);
            //almost all other descriptors we can construct normally
            //if it doesn't have an icon then it's a special case we know about
            } else if (descriptor.displayIcon == null) {
                if (descriptor is GameRuleDesignComponentClassDescriptor) {
                    System.Type otherType = ((GameRuleDesignComponentClassDescriptor)descriptor).typeDescribed;
                    //a points effect shows up as "+?"
                    if (otherType == typeof(GameRulePointsPlayerEffect))
                        popupIcon = groupIcons(new List<GameObject>(new GameObject[] {
                            GameRuleIconStorage.instance.charPlusIcon,
                            GameRuleIconStorage.instance.charQmarkIcon
                        }));
                    else
                        throw new System.Exception("Bug: no special popup icon cases for type " + otherType);
                } else
                    throw new System.Exception("Bug: no special popup icon cases for " + descriptor);
            //it has an icon, it's probably normal
            } else
                popupIcon = componentRepresented.getIconMaybeOpponent(descriptor);
            popupIcon.SetParent(iconContainer);
            popupIcons.Add(popupIcon);
        }
        //we add a "cancel" icon at the end to ensure there's room to cancel out of the popup
        RectTransform cancelIcon = instantiateIcon(GameRuleDesigner.instance.cancelIconPopupPrefab);
        cancelIcon.SetParent(iconContainer);
        popupIcons.Add(cancelIcon);

        //if we're doing a points effect, default to the "+1" choice
        if (describedType == typeof(GameRulePointsPlayerEffect))
            cr.assignDescriptor(popupDescriptors[
                GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MASK - GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MAX_VALUE + 1]);
        //if we're doing a fixed duration, default to the rule generator min value
        else if (describedType == typeof(GameRuleActionFixedDuration))
            cr.assignDescriptor(popupDescriptors[GameRuleGenerator.ACTION_DURATION_SECONDS_SHORTEST]);
        else
            cr.assignDescriptor(popupDescriptors[0]);
    }
Exemplo n.º 3
0
 //we need to do special initialization and we need to construct this without it doing anything
 public GameRuleDesignComponent(GameRuleDesignComponent p)
 {
     parent = p;
 }
Exemplo n.º 4
0
    public void assignDescriptor(GameRuleDesignComponentDescriptor newDescriptor)
    {
        //if there's no change then don't change anything
        if (newDescriptor == descriptor)
            return;

        //if we're replacing a descriptor we need to get rid of everything it had
        bool hadOldDescriptor = descriptor != null;
        if (hadOldDescriptor)
            destroyComponent(false);
        descriptor = newDescriptor;

        //if the descriptor is part of a popup then it will manage the icon
        if (componentPopup != null)
            componentIcon = componentPopup.setPopupIcon(newDescriptor);
        //most components that are not part of a popup have an icon that represents it
        else if (newDescriptor.displayIcon != null) {
            componentIcon = getIconMaybeOpponent(newDescriptor);
            componentIcon.SetParent(GameRuleDesigner.instance.iconContainerTransform);
            componentIcon.localScale = new Vector3(1.0f, 1.0f);
        }

        //if it's got subcomponents, each one of them needs a popup
        //we also need to pick a default for each one
        //each event type has its own list that it will use
        if (newDescriptor is GameRuleDesignComponentEventTypeDescriptor) {
            GameRuleEventType eventType = ((GameRuleDesignComponentEventTypeDescriptor)newDescriptor).eventTypeDescribed;
            //event-happened conditions and until-conditions both have event types
            //based on which one this is, the structure of the subcomponents is different
            //if we're in a regular event-happened condition, we have a source type and target type
            if (parent.descriptor == GameRuleDesigner.instance.gameRuleEventHappenedConditionDurationDescriptor) {
                //if we had an old descriptor, we want to check if the source type changed
                System.Type oldSourceType;
                if (hadOldDescriptor)
                    oldSourceType = ((GameRuleDesignComponentEventParticipantDescriptor)(subComponents[0].descriptor)).typeDescribed;
                //otherwise, we need to initialize the subcomponents array
                else {
                    oldSourceType = null;
                    subComponents = new GameRuleDesignComponent[2];
                }
                //constructing the component auto-assigns the target descriptor
                (subComponents[0] = new GameRuleDesignComponent(this)).assignPopup(GameRuleDesigner.instance.potentialSourcesForEventMap[eventType], null);
                if (hadOldDescriptor) {
                    System.Type newSourceType = ((GameRuleDesignComponentEventParticipantDescriptor)(subComponents[0].descriptor)).typeDescribed;
                    //the source type switched, we need to refresh the effect action's subcomponents
                    if (oldSourceType != newSourceType) {
                        GameRuleDesigner.instance.gameRuleActionComponent.destroyComponent(false);
                        GameRuleDesigner.instance.gameRuleActionComponent.assignEffectActionSelector(newSourceType);
                    }
                }
            //if we're in an until-condition duration, our parent is the source type and our only subcomponent is the target type
            } else if (parent.parent.descriptor == GameRuleDesigner.instance.gameRuleActionUntilConditionDurationDescriptor) {
                if (!hadOldDescriptor)
                    subComponents = new GameRuleDesignComponent[1];
                subComponents[0] = new GameRuleDesignComponent(this, GameRuleDesigner.instance.potentialTargetsForEventSourceMap
                    [eventType]
                    //the source of the until-condition trigger is the target of a selector on the source of the original condition
                    [((GameRuleDesignComponentSelectorDescriptor)(parent.descriptor)).selectorDescribed.targetType()]);
            } else
                throw new System.Exception("Bug: event type changed with parent " + parent.descriptor);
        //this is the source or the target of an event-happened-condition, which could be the condition or an until-condition duration
        //if it's the condition, we need to change other stuff
        } else if (newDescriptor is GameRuleDesignComponentEventParticipantDescriptor) {
            //we changed the general condition source
            //we need to update the target type and possibly also an action type
            if (parent.parent.descriptor == GameRuleDesigner.instance.gameRuleEventHappenedConditionDurationDescriptor &&
                parent.subComponents[0] == this) {
                System.Type sourceType = ((GameRuleDesignComponentEventParticipantDescriptor)newDescriptor).typeDescribed;
                //if the source changed from an old one then we need to update the action
                //if this is the first time then the action gets set elsewhere
                if (hadOldDescriptor) {
                    parent.subComponents[1].destroyComponent(true);
                    GameRuleDesigner.instance.gameRuleActionComponent.destroyComponent(false);
                    GameRuleDesigner.instance.gameRuleActionComponent.assignEffectActionSelector(sourceType);
                }
                parent.subComponents[1] = new GameRuleDesignComponent(parent, GameRuleDesigner.instance.potentialTargetsForEventSourceMap
                    [((GameRuleDesignComponentEventTypeDescriptor)(parent.descriptor)).eventTypeDescribed]
                    [sourceType]);
            }
        //when we assign an until-condition, we need to pick the source type and it will pick the event type which will pick the target type
        } else if (descriptor == GameRuleDesigner.instance.gameRuleActionUntilConditionDurationDescriptor) {
            subComponents = new GameRuleDesignComponent[] {
                new GameRuleDesignComponent(this, GameRuleDesigner.instance.sourceSelectorMap[
                    ((GameRuleDesignComponentEventParticipantDescriptor)(GameRuleDesigner.instance.gameRuleConditionComponent.subComponents[0].subComponents[0].descriptor)).typeDescribed])
            };
        //we changed a selector descriptor, this is an effect action, until-condition duration, or a zone source
        } else if (newDescriptor is GameRuleDesignComponentSelectorDescriptor) {
            System.Type parentType = ((GameRuleDesignComponentClassDescriptor)(parent.descriptor)).typeDescribed;
            //when we change the selector for an effect action, we need to update the possible effects
            if (parentType == typeof(GameRuleEffectAction)) {
                if (hadOldDescriptor)
                    parent.subComponents[1].destroyComponent(true);
                parent.subComponents[1] = new GameRuleDesignComponent(parent, GameRuleDesigner.instance.sourceEffectMap[
                    ((GameRuleDesignComponentSelectorDescriptor)(newDescriptor)).selectorDescribed.targetType()]);
            //we changed the source of an until-condition, we need to refresh the event type
            } else if (parentType == typeof(GameRuleActionUntilConditionDuration)) {
                subComponents = new GameRuleDesignComponent[] {
                    new GameRuleDesignComponent(this, GameRuleDesigner.instance.potentialEventsForSourceMap[
                        ((GameRuleDesignComponentSelectorDescriptor)(descriptor)).selectorDescribed.targetType()])
                };
            }
        //the rest of the descriptors build their subcomponents normally
        } else if (newDescriptor.subComponents != null) {
            subComponents = new GameRuleDesignComponent[newDescriptor.subComponents.Length];
            for (int i = 0; i < subComponents.Length; i++) {
                //the component will build itself from the popup types list
                subComponents[i] = new GameRuleDesignComponent(this, newDescriptor.subComponents[i]);
            }

            //a few components need to send changes to other components
            //zone type was changed, assign the right metarule
            if (newDescriptor is GameRuleDesignComponentZoneTypeDescriptor) {
                GameRuleRequiredObjectType zoneType = ((GameRuleDesignComponentZoneTypeDescriptor)newDescriptor).zoneTypeDescribed;
                GameRuleDesigner.instance.gameRuleActionComponent.assignMetaRuleSubComponent(zoneType);
            //the condition changed, update the action with the corresponding descriptor
            } else if (this == GameRuleDesigner.instance.gameRuleConditionComponent) {
                if (hadOldDescriptor)
                    GameRuleDesigner.instance.gameRuleActionComponent.complementComponent(this);
            }
        } else
            subComponents = null;

        //save the component that actually gets displayed to render this component
        if (componentPopup != null)
            componentDisplayed = (RectTransform)(componentPopup.transform);
        else if (componentIcon != null)
            componentDisplayed = componentIcon;
        else
            componentDisplayed = null;
    }
Exemplo n.º 5
0
 //construct from a specific list of descriptors not obainable from the component selection map
 public GameRuleDesignComponent(GameRuleDesignComponent p, List<GameRuleDesignComponentDescriptor> popupDescriptors)
 {
     parent = p;
     assignPopup(popupDescriptors, null);
 }
Exemplo n.º 6
0
 //this component is controlled by the other component
 public GameRuleDesignComponent(GameRuleDesignComponent p, GameRuleDesignComponent otherComponent)
 {
     parent = p;
     complementComponent(otherComponent);
 }
Exemplo n.º 7
0
 //construct from a list of descriptors
 //the variables for this component will change to reflect which component it represents
 public GameRuleDesignComponent(GameRuleDesignComponent p, System.Type t)
 {
     parent = p;
     assignPopup(GameRuleDesigner.instance.componentSelectionMap[t], t);
 }
Exemplo n.º 8
0
 public void complementComponent(GameRuleDesignComponent otherComponent)
 {
     GameRuleDesignComponentDescriptor otherDescriptor = otherComponent.descriptor;
     if (otherDescriptor is GameRuleDesignComponentClassDescriptor) {
         System.Type otherType = ((GameRuleDesignComponentClassDescriptor)otherDescriptor).typeDescribed;
         if (otherType == typeof(GameRuleEventHappenedCondition)) {
             assignDescriptor(GameRuleDesigner.instance.gameRuleEffectActionDescriptor);
             subComponents = new GameRuleDesignComponent[2];
             assignEffectActionSelector(((GameRuleDesignComponentEventParticipantDescriptor)(otherComponent.subComponents[0].subComponents[0].descriptor)).typeDescribed);
         } else if (otherType == typeof(GameRuleZoneCondition)) {
             assignDescriptor(GameRuleDesigner.instance.gameRuleMetaRuleActionDescriptor);
             subComponents = new GameRuleDesignComponent[1];
             assignMetaRuleSubComponent(((GameRuleDesignComponentZoneTypeDescriptor)(otherComponent.subComponents[1].descriptor)).zoneTypeDescribed);
         } else
             throw new System.Exception("Bug: cannot complement design component descriptor type " + otherType);
     } else
         throw new System.Exception("Bug: cannot complement design component descriptor " + otherDescriptor);
 }
Exemplo n.º 9
0
 public GameRuleDesignComponent(GameRuleDesignComponent p, GameRuleDesignComponentDescriptor d)
 {
     parent = p;
     assignDescriptor(d);
 }
Exemplo n.º 10
0
    public void assignMetaRuleSubComponent(GameRuleRequiredObjectType zoneType)
    {
        GameRuleDesignComponentMetaRuleDescriptor metaRuleDescriptor = (GameRuleDesignComponentMetaRuleDescriptor)(GameRuleDesigner.instance.zoneTypeMetaRuleMap[zoneType]);
        GameRuleDesignComponent metaRuleComponent = new GameRuleDesignComponent(this, metaRuleDescriptor);

        List<GameObject> iconList = new List<GameObject>();
        metaRuleDescriptor.metaRuleDescribed.addIcons(iconList);
        metaRuleComponent.componentDisplayed = (metaRuleComponent.componentIcon = GameRuleDesignPopup.groupIcons(iconList));
        metaRuleComponent.componentIcon.SetParent(GameRuleDesigner.instance.iconContainerTransform);
        metaRuleComponent.componentIcon.localScale = new Vector3(1.0f, 1.0f);

        subComponents[0] = metaRuleComponent;
    }
Exemplo n.º 11
0
 //set the source type for the effect action
 //the process of doing that will set the effect
 public void assignEffectActionSelector(System.Type sourceType)
 {
     subComponents[0] = new GameRuleDesignComponent(this, GameRuleDesigner.instance.sourceSelectorMap[sourceType]);
 }