Exemplo n.º 1
0
    private void instanceElement <T>(ElementReference context) where T : Element
    {
        if (!ConditionChecker.check(context.getConditions()))
        {
            return;
        }

        if (!contexts.ContainsKey(context))
        {
            ElementReference new_context = new ElementReference(context.getTargetId(), context.getX(), context.getY());
            new_context.setScale(context.getScale());
            contexts.Add(context, new_context);
        }

        context = contexts [context];

        GameObject base_prefab;
        Transform  parent;
        Element    element;

        switch (typeof(T).ToString())
        {
        case "Atrezzo":
            base_prefab = Atrezzo_Prefab;
            parent      = Atrezzos;
            element     = Game.Instance.GameState.getAtrezzo(context.getTargetId());
            break;

        case "NPC":
            base_prefab = Character_Prefab;
            parent      = Characters;
            element     = Game.Instance.GameState.getCharacter(context.getTargetId());
            break;

        case "Item":
            base_prefab = Object_Prefab;
            parent      = Objects;
            element     = Game.Instance.GameState.getObject(context.getTargetId());
            break;

        default:
            return;
        }

        GameObject ret   = GameObject.Instantiate(base_prefab);
        Transform  trans = ret.GetComponent <Transform> ();

        ret.GetComponent <Representable> ().Context = context;
        ret.GetComponent <Representable> ().Element = element;
        trans.SetParent(parent);
    }
        /**
         * Contructor.
         *
         * @param sceneDataControl
         *            Parent scene controller
         * @param elementReference
         *            Element reference of the data control structure
         */
        public ElementReferenceDataControl(SceneDataControl sceneDataControl, ElementReference elementReference, int type, int referenceNumber)
        {
            this.sceneDataControl = sceneDataControl;
            this.elementReference = elementReference;
            this.type             = type;
            this.visible          = true;
            if (type == Controller.ITEM_REFERENCE || type == Controller.NPC_REFERENCE)
            {
                this.influenceAreaDataControl = new InfluenceAreaDataControl(sceneDataControl, elementReference.getInfluenceArea(), this);
            }

            // Create subcontrollers
            Dictionary <string, ConditionsController.ConditionContextProperty> context1 = new Dictionary <string, ConditionsController.ConditionContextProperty>();

            ConditionsController.ConditionOwner parent = new ConditionsController.ConditionOwner(Controller.SCENE, sceneDataControl.getId());
            ConditionsController.ConditionOwner owner  = new ConditionsController.ConditionOwner(type, elementReference.getTargetId(), parent);
            context1.Add(ConditionsController.CONDITION_OWNER, owner);

            conditionsController = new ConditionsController(elementReference.getConditions(), context1);
        }
 public override void updateVarFlagSummary(VarFlagSummary varFlagSummary)
 {
     // Update the flag summary with the conditions
     ConditionsController.updateVarFlagSummary(varFlagSummary, elementReference.getConditions());
 }