Inheritance: MonoBehaviour
Esempio n. 1
0
	// Use this for initialization
	void Start () {
        player = GameObject.FindGameObjectWithTag("Player");
        var = GetComponent<ObjectVariables>();
        rgd = GetComponent<Rigidbody2D>();
        org = transform.position;

	}
Esempio n. 2
0
        protected virtual void SerializeImpl(IO.BitStream s)
        {
            var condition_write_order = s.IsWriting ? mCompilerState.ConditionWriteOrder : null;
            var action_write_order    = s.IsWriting ? mCompilerState.ActionWriteOrder : null;
            var trigger_write_order   = s.IsWriting ? mCompilerState.TriggerWriteOrder : null;

            Collections.ActiveListUtil.Serialize(s, Conditions, Database.Limits.Conditions.CountBitLength,
                                                 this, NewConditionFromBitStream, condition_write_order);
            Collections.ActiveListUtil.Serialize(s, Actions, Database.Limits.Actions.CountBitLength,
                                                 this, NewActionFromBitStream, action_write_order);
            Collections.ActiveListUtil.Serialize(s, Triggers, Database.Limits.Triggers.CountBitLength,
                                                 this, NewTriggerFromBitStream, trigger_write_order);
            s.StreamElements(GameStatistics, Database.Limits.GameStatistics.CountBitLength, this, _model => _model.NewGameStatistic());
            GlobalVariables.Serialize(this, s);
            PlayerVariables.Serialize(this, s);
            ObjectVariables.Serialize(this, s);
            TeamVariables.Serialize(this, s);
            s.StreamElements(HudWidgets, Database.Limits.HudWidgets.CountBitLength);
            SerializeTriggerEntryPoints(s);
            ObjectTypeReferences.SerializeWords(s, Shell.EndianFormat.Little);
            s.StreamElements(ObjectFilters, Database.Limits.ObjectFilters.CountBitLength);
            if (Database.Limits.SupportsGameObjectFilters)
            {
                SerializeGameObjectFilters(s);
            }
        }
Esempio n. 3
0
	void Start () 
	{
		objectVar = GetComponent<ObjectVariables>();
		growlingGoat = GetComponent<AIGrowlingGoat>();
		playerVar = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerVariables>();
		collider = GetComponent<Collider2D>();
	}
Esempio n. 4
0
	void Start () {
        player = GameObject.FindGameObjectWithTag("Player");
        var_Player = player.GetComponent<PlayerVariables>();
        sprite_dialog = obj_dialog.GetComponent<SpriteRenderer>();
        aud = GetComponent<AudioSource>();
        var = GetComponent<ObjectVariables>();
	}	
Esempio n. 5
0
	// Use this for initialization
	void Start () {
        var = GetComponent<ObjectVariables>();
        audioManager = GameObject.FindGameObjectWithTag("GLOBAL_audio");
        aud = audioManager.GetComponent<AudioSource>();
        player = GameObject.FindGameObjectWithTag("Player");
        var_player = player.GetComponent<PlayerVariables>();
	}
Esempio n. 6
0
	void Start ()
    {
        playerVar = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerVariables>();
		goat = transform.GetChild(0).gameObject.GetComponent<GoatAnimator>();
		goatObject = transform.GetChild(1).gameObject.GetComponent<ObjectVariables>();
		benchArray = GameObject.FindGameObjectsWithTag("OBJECT_bench");
		timeUntilCanAttack = Random.Range(2, 5);
	}
Esempio n. 7
0
 private void CacheVariable()
 {
     if (Application.isPlaying && (this.v == null || !((UnityEngine.Object) this.sourceObj != (UnityEngine.Object)null)))
     {
         if (this.varType == VariableType.Global)
         {
             this.sourceObj = GlobalVariables.Instance;
             this.v         = GlobalVariables.Instance.variables.FindVariable(this.varName);
             if (this.v == null)
             {
                 Debug.LogErrorFormat("The Global Variable [{0}] does not exist.", this.varName);
             }
             else if (!base.isSetter)
             {
                 this.v.onValueChange += this.BoundValueChanged;
             }
         }
         else if (this.varType == VariableType.Blox)
         {
             BloxContainer bloxContainer = this.CacheSourceObject() as BloxContainer;
             if (!((UnityEngine.Object)bloxContainer == (UnityEngine.Object)null))
             {
                 if (!string.IsNullOrEmpty(this.triggerBloxEvent))
                 {
                     bloxContainer.TriggerEvent(this.triggerBloxEvent);
                 }
                 this.v = bloxContainer.FindVariable(this.bloxIdent, this.varName);
                 if (this.v == null)
                 {
                     Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdent);
                     Debug.LogErrorFormat("The Blox Variable [{0}] does not exist in Blox [{1}] on GameObject [{2}]", this.varName, ((object)blox != null) ? blox.screenName : null, bloxContainer.name);
                 }
                 else if (!base.isSetter)
                 {
                     this.v.onValueChange += this.BoundValueChanged;
                 }
             }
         }
         else if (this.varType == VariableType.Object)
         {
             ObjectVariables objectVariables = this.CacheSourceObject() as ObjectVariables;
             if (!((UnityEngine.Object)objectVariables == (UnityEngine.Object)null))
             {
                 this.v = objectVariables.FindVariable(this.varName);
                 if (this.v == null)
                 {
                     Debug.LogErrorFormat("The Object Variable [{0}] does not exist on GameObject [{1}]", this.varName, objectVariables.name);
                 }
                 else if (!base.isSetter)
                 {
                     this.v.onValueChange += this.BoundValueChanged;
                 }
             }
         }
     }
 }
Esempio n. 8
0
	// Use this for initialization
	void Start () {
        var = GetComponent<ObjectVariables>();

        obj_sceneChanger = GameObject.FindGameObjectWithTag("GLOBAL_sceneChanger");
        sceneChanger = obj_sceneChanger.GetComponent<SceneChanger>();
    }
Esempio n. 9
0
        public plyVar RunAndGetVariable(Type expectedType = null)
        {
            if (this.varType == plyVariablesType.Event)
            {
                this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                if (this.v == null)
                {
                    if (base.owningBlock == null)
                    {
                        BloxBlock obj = base.paramBlocks[0];
                        expectedType = (((obj != null) ? obj.returnType : null) ?? typeof(object));
                    }
                    else if (base.fieldIdx == -1)
                    {
                        expectedType = (base.owningBlock.ContextType() ?? typeof(object));
                    }
                    else
                    {
                        Type[] array = base.owningBlock.ParamTypes();
                        expectedType = ((array == null || base.fieldIdx < 0 || base.fieldIdx >= array.Length) ? typeof(object) : (array[base.fieldIdx] ?? typeof(object)));
                    }
                    this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                    if (this.v == null)
                    {
                        base.LogError("The Event Variable [" + this.varName + "] does not exist in Event [" + base.owningEvent.screenName + "] on GameObject: " + base.owningEvent.container.name, null);
                        return(null);
                    }
                }
            }
            else if (this.varType != plyVariablesType.Blox)
            {
                if (this.varType == plyVariablesType.Object)
                {
                    GameObject gameObject = null;
                    object     obj2       = (base.paramBlocks[1] == null) ? base.owningEvent.container.gameObject : base.paramBlocks[1].Run();
                    if (obj2 != null)
                    {
                        gameObject = (obj2 as GameObject);
                        if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null)
                        {
                            Component component = obj2 as Component;
                            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                            {
                                gameObject = component.gameObject;
                            }
                        }
                    }
                    if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
                    {
                        ObjectVariables component2 = gameObject.GetComponent <ObjectVariables>();
                        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                        {
                            this.v = component2.variables.FindVariable(this.varName);
                            if (this.v == null)
                            {
                                base.LogError("The Object Variable [" + this.varName + "] does not exist on GameObject: " + gameObject.name, null);
                                return(null);
                            }
                            goto IL_0265;
                        }
                        base.LogError("Could not find ObjectVariables component on GameObject [" + gameObject.name + "] for Object Variable: " + this.varName, null);
                        return(null);
                    }
                    base.LogError("The 2nd field must be set to a target GameObject that has the Object Variable component on it with the variable named: " + this.varName, null);
                    return(null);
                }
                if (this.varType != plyVariablesType.Global)
                {
                    base.LogError("Invalid Variable Type specified. This should not happen.", null);
                    return(null);
                }
            }
            goto IL_0265;
IL_0265:
            return(this.v);
        }
Esempio n. 10
0
	void Start()
    {
        ctrl_Beehive = sprite_Beehive.GetComponent<BeehiveController>();
        var_Beehive = beehive.GetComponent<ObjectVariables>();
        var_Bees = bees.GetComponent<ObjectVariables>();
    }
Esempio n. 11
0
    // Use this for initialization
    void Start () {
        var = GetComponent<ObjectVariables>();
	}
Esempio n. 12
0
	// Use this for initialization
	void Start () {
        objectVar = transform.parent.gameObject.GetComponent<ObjectVariables>();
        rb2D = transform.parent.gameObject.GetComponent<Rigidbody2D>();
	}
        public override void ResolveElements()
        {
            if (elementsResolved)
            {
                return;
            }

            // Get the type being extended.
            if (typeContext.TERNARY_ELSE() != null)
            {
                // If there is no type name, error.
                if (typeContext.extends == null)
                {
                    parseInfo.Script.Diagnostics.Error("Expected type name.", DocRange.GetRange(typeContext.TERNARY_ELSE()));
                }
                else
                {
                    // Get the type being inherited.
                    CodeType inheriting = parseInfo.TranslateInfo.Types.GetCodeType(typeContext.extends.Text, parseInfo.Script.Diagnostics, DocRange.GetRange(typeContext.extends));

                    // GetCodeType will return null if the type is not found.
                    if (inheriting != null)
                    {
                        inheriting.Call(parseInfo, DocRange.GetRange(typeContext.extends));

                        Inherit(inheriting, parseInfo.Script.Diagnostics, DocRange.GetRange(typeContext.extends));
                        (Extends as ClassType)?.ResolveElements();
                    }
                }
            }

            base.ResolveElements();

            // Give DefinedMethod and GetMacro a scope to use in case of the static attribute.
            foreach (var definedMethod in typeContext.define_method())
            {
                var newMethod = new DefinedMethod(parseInfo, operationalScope, staticScope, definedMethod, this);

                // Copy to serving scopes.
                if (newMethod.Static)
                {
                    operationalScope.CopyMethod(newMethod);
                }
                else
                {
                    serveObjectScope.CopyMethod(newMethod);
                }
            }

            // Get the macros.
            foreach (var macroContext in typeContext.define_macro())
            {
                var newMacro = parseInfo.GetMacro(operationalScope, staticScope, macroContext);

                // Copy to serving scopes.
                if (newMacro is IMethod asMethod)
                {
                    if (newMacro.Static)
                    {
                        operationalScope.CopyMethod(asMethod);
                    }
                    else
                    {
                        serveObjectScope.CopyMethod(asMethod);
                    }
                }
                else
                {
                    if (newMacro.Static)
                    {
                        operationalScope.CopyVariable((IVariable)newMacro);
                    }
                    else
                    {
                        serveObjectScope.CopyVariable((IVariable)newMacro);
                    }
                }
            }

            // Get the variables defined in the type.
            foreach (var definedVariable in typeContext.define())
            {
                Var newVar = new ClassVariable(operationalScope, staticScope, new DefineContextHandler(parseInfo, definedVariable));

                // Copy to serving scopes.
                if (!newVar.Static)
                {
                    ObjectVariables.Add(new ObjectVariable(newVar));
                    serveObjectScope.CopyVariable(newVar);
                }
                // Add to static scope.
                else
                {
                    staticVariables.Add(newVar);
                    staticScope.CopyVariable(newVar);
                    operationalScope.CopyVariable(newVar);
                }
            }

            // Get the constructors.
            if (typeContext.constructor().Length > 0)
            {
                Constructors = new Constructor[typeContext.constructor().Length];
                for (int i = 0; i < Constructors.Length; i++)
                {
                    Constructors[i] = new DefinedConstructor(parseInfo, operationalScope, this, typeContext.constructor(i));
                }
            }
            else
            {
                // If there are no constructors, create a default constructor.
                Constructors = new Constructor[] {
                    new Constructor(this, new Location(parseInfo.Script.Uri, DocRange.GetRange(typeContext.name)), AccessLevel.Public)
                };
            }

            // If the extend token exists, add completion that only contains all extendable classes.
            if (typeContext.TERNARY_ELSE() != null)
            {
                parseInfo.Script.AddCompletionRange(new CompletionRange(
                                                        // Get the completion items of all types.
                                                        parseInfo.TranslateInfo.Types.AllTypes
                                                        .Where(t => t is ClassType ct && ct.CanBeExtended)
                                                        .Select(t => t.GetCompletion())
                                                        .ToArray(),
                                                        // Get the completion range.
                                                        DocRange.GetRange(typeContext.TERNARY_ELSE(), parseInfo.Script.NextToken(typeContext.TERNARY_ELSE())),
                                                        // This completion takes priority.
                                                        CompletionRangeKind.ClearRest
                                                        ));
            }
            parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, parseInfo, CodeLensSourceType.Type, DefinedAt.range));
        }
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            using (s.EnterCursorBookmark("SerializeFlags"))
                s.StreamCursorEnum(ref TagElementStreamSerializeFlags, true);

            #region TryToPort sanity checks
            if ((TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.TryToPort) != 0)
            {
                if (s.IsWriting)
                {
                    if (Proto.MegaloScriptDatabase.HaloReach == null || Proto.MegaloScriptDatabase.Halo4 == null)
                    {
                        throw new InvalidOperationException("Can't port, other game's DB isn't loaded");
                    }
                }
                else if (s.IsReading)
                {
                    var ex = new InvalidOperationException("Can't load variants saved with TryToPort");
                    s.ThrowReadException(ex);
                }
            }
            #endregion

            bool embed_model_objects = TagElementStreamSerializeFlags.EmbedObjects();
            bool write_sans_ids      = TagElementStreamSerializeFlags.EmbedObjectsWriteSansIds();

            #region Version sanity checks
            if ((TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.IgnoreVersionIds) == 0)
            {
                s.StreamVersionViaAttribute("version", kVersion, "MegaFloW Script");
                s.StreamVersionViaAttribute("dbVersion", Database.Version, "Database");
            }
            #endregion

            using (s.EnterOwnerBookmark(this))
            {
                #region helpful info dump
                if (s.IsWriting && embed_model_objects && !write_sans_ids)
                {
                    using (s.EnterCursorBookmark("IDs"))
                    {
                        s.WriteAttribute("NextCondID", Conditions.FirstInactiveIndex);
                        s.WriteAttribute("NextActionID", Actions.FirstInactiveIndex);
                        s.WriteAttribute("NextValueID", Values.FirstInactiveIndex);
                        s.WriteAttribute("NextTrigID", Triggers.FirstInactiveIndex);
                        if (Database.Limits.SupportsVirtualTriggers)
                        {
                            s.WriteAttribute("NextVirtualTriggerID", VirtualTriggers.FirstInactiveIndex);
                        }
                    }
                }
                #endregion

                #region ObjectTypeReferences
                using (var bm = s.EnterCursorBookmarkOpt("ObjectTypeReferences", ObjectTypeReferences, Predicates.HasBits)) if (bm.IsNotNull)
                    {
                        ObjectTypeReferences.Serialize(s, "Ref", this, SerializeObjectTypeReference,
                                                       Database.StaticDatabase.ObjectTypeList.Types.Count - 1);
                    }
                #endregion

                #region GameStatistics
                using (var bm = s.EnterCursorBookmarkOpt("Statistics", GameStatistics, Predicates.HasItems)) if (bm.IsNotNull)
                    {
                        s.StreamableElements("Stat", GameStatistics, this, _this => _this.NewGameStatistic());
                    }
                #endregion

                #region HudWidgets
                using (var bm = s.EnterCursorBookmarkOpt("HudWidgets", HudWidgets, Predicates.HasItems)) if (bm.IsNotNull)
                    {
                        s.StreamableElements("Widget", HudWidgets);
                    }
                #endregion

                #region Object Filters
                using (var bm = s.EnterCursorBookmarkOpt("ObjectFilters", ObjectFilters, Predicates.HasItems)) if (bm.IsNotNull)
                    {
                        s.StreamableElements("Filter", ObjectFilters);
                    }

                if (Database.Limits.SupportsGameObjectFilters)
                {
                    SerializeGameObjectFilters(s);
                }
                #endregion

                #region Variables
                Predicate <MegaloScriptModelVariableSet> set_is_not_empty = v => v.IsNotEmpty;

                using (var bm = s.EnterCursorBookmarkOpt("GlobalVariables", GlobalVariables, set_is_not_empty)) if (bm.IsNotNull)
                    {
                        GlobalVariables.Serialize(this, s);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("PlayerVariables", PlayerVariables, set_is_not_empty)) if (bm.IsNotNull)
                    {
                        PlayerVariables.Serialize(this, s);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("ObjectVariables", ObjectVariables, set_is_not_empty)) if (bm.IsNotNull)
                    {
                        ObjectVariables.Serialize(this, s);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("TeamVariables", TeamVariables, set_is_not_empty)) if (bm.IsNotNull)
                    {
                        TeamVariables.Serialize(this, s);
                    }
                #endregion

                #region UnionGroups
                if (!TagElementStreamSerializeFlags.EmbedObjectsWriteSansIds())
                {
                    using (s.EnterCursorBookmark("UnionGroups")) Collections.ActiveListUtil.
                        Serialize(s, "Group", UnionGroups, this, NewUnionGroupFromTagStream);
                }
                #endregion

                #region Values or Global Values
                // #NOTE_BLAM: A Values element will be created even if there are no global values
                using (s.EnterCursorBookmark("Values")) Collections.ActiveListUtil.
                    Serialize(s, "Value", Values, this, MegaloScriptValueBase.NewFromTagStream,
                              embed_model_objects ? MegaloScriptValueBase.SkipIfNotGlobalPredicate : null);
                #endregion

                #region Conditions / Actions / Virtual Triggers (non-embedded)
                if (!embed_model_objects)
                {
                    using (s.EnterCursorBookmark("Conditions")) Collections.ActiveListUtil.
                        Serialize(s, "Condition", Conditions, this, NewConditionFromTagStream);
                    using (s.EnterCursorBookmark("Actions")) Collections.ActiveListUtil.
                        Serialize(s, "Action", Actions, this, NewActionFromTagStream);
                    using (s.EnterCursorBookmark("VirtualTriggers")) Collections.ActiveListUtil.
                        Serialize(s, "Trigger", VirtualTriggers, this, NewVirtualTriggerFromTagStream);
                }
                #endregion

                using (s.EnterCursorBookmark("Triggers")) Collections.ActiveListUtil.
                    Serialize(s, "Trigger", Triggers, this, NewTriggerFromTagStream,
                              embed_model_objects ? MegaloScriptTrigger.SkipIfNotRootPredicate : null,
                              GetTriggersTagElementStreamReadMode);

                #region Trigger Indexes
                using (s.EnterCursorBookmark("EntryPoints"))
                {
                    var id_resolving_ctxt = new TriggerIndexNameResolvingContext(this);
                    var id_resolver       = TriggerIndexNameResolvingContext.IdResolver;
                    var name_resolver     = TriggerIndexNameResolvingContext.NameResolver;

                    s.StreamElementOptIdAsString("Initialization", ref mInitializationTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("LocalInitialization", ref mLocalInitializationTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("HostMigration", ref mHostMigrationTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("DoubleHostMigration", ref mDoubleHostMigrationTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("ObjectDeathEvent", ref mObjectDeathEventTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("Local", ref mLocalTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("Pregame", ref mPregameTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                    s.StreamElementOptIdAsString("Incident", ref mIncidentTriggerIndex, id_resolving_ctxt, id_resolver, name_resolver, Predicates.IsNotNull);
                }
                #endregion

                using (var bm = s.EnterCursorBookmarkOpt("ExecutionOrder", TriggerExecutionOrder, Predicates.HasItems)) if (bm.IsNotNull)
                    {
                        s.StreamElements("Trigger", TriggerExecutionOrder, this, SerializeTriggerExecutionOrder);
                    }
            }

            #region List count sanity checks
            if (s.IsReading)
            {
                // #TODO_IMPLEMENT: sanity check list counts
                var limits = Database.Limits;

                limits.GameStatistics.ValidateListCount(GameStatistics, "GameStatistics", s);
                GlobalVariables.ValidateVariableListCounts(s);
                PlayerVariables.ValidateVariableListCounts(s);
                ObjectVariables.ValidateVariableListCounts(s);
                TeamVariables.ValidateVariableListCounts(s);
                limits.HudWidgets.ValidateListCount(HudWidgets, "HudWidgets", s);
                limits.ObjectFilters.ValidateListCount(ObjectFilters, "ObjectFilters", s);
                limits.GameObjectFilters.ValidateListCount(CandySpawnerFilters, "GameObjectFilters", s);
            }
            #endregion
        }
Esempio n. 15
0
	// Use this for initialization
	void Start () {
        var = GetComponent<ObjectVariables>();
        sprite = GetComponent<SpriteRenderer>();
	}
Esempio n. 16
0
	// Use this for initialization
	void Start () 
	{
		objectVar = GetComponent<ObjectVariables>();
		firstEvent = true;
	}
Esempio n. 17
0
	// Use this for initialization
	void Start () {
        var = GetComponent<ObjectVariables>();
        controller = sprite.GetComponent<TVController>();
	}
Esempio n. 18
0
	void Start ()
    {
        var = GetComponent<ObjectVariables>();
        player = GameObject.FindGameObjectWithTag("Player");
        var_player = player.GetComponent<PlayerVariables>();
	}