예제 #1
0
 void OnEnable()
 {
     lastTime    = 0;
     alert       = false;
     levelNum    = PlayerPrefs.GetInt("OpenLevel");
     targetLevel = Resources.Load <TargetLevel>("Targets/Level" + levelNum);
 }
예제 #2
0
        internal TargetChildMapping(string name, string prefix, TypeInfo typeInfo, TargetLevel targetLevel)
            : base(name, prefix, null, true)
        {
            _targetLevel    = targetLevel;
            _targetTypeInfo = typeInfo.GenericTypeArguments.First().GetTypeInfo();
            var namedProperties = GetNamedProperties().ToList();
            var properties      = _targetTypeInfo.GetAllProperties();

            foreach (var prop in properties)
            {
                if (prop.Name == "NestedLevel") // I am trying to remove this
                {
                }
                else if (IsChild(prop))
                {
                    AddChildLevel(this, prop);
                }
                else if (
                    prop.SetMethod != null &&
                    prop.SetMethod.IsPublic &&
                    prop.Name != "Parent" &&
                    !_attributes.Any(x => x.TargetName == prop.Name))
                {
                    _attributes.Add(new TargetAttributeMapping(prop, _mappingId));
                }
                else
                {
                }        // Do Nothing, it's a special readonly property
            }
        }
 public TargetMappings(string mappingId,
                       TypeInfo targetTypeInfo,
                       string targetName,
                       TargetLevel targetLevel,
                       bool allowMultiple = false)
     : base(mappingId, targetTypeInfo, targetName, targetLevel, allowMultiple)
 {
 }
 public TargetMapping(string mapingpId, 
             TypeInfo targetTypeInfo, 
             string targetName, 
             TargetLevel targetLevel, 
             bool allowMultiple=false)
 {
     _mapingpId = _mapingpId;
     _targetName = targetName;
     _targetTypeInfo = targetTypeInfo;
     _targetLevel = targetLevel;
     _allowMultiple = allowMultiple;
 }
 public TargetMapping(string mapingpId,
                      TypeInfo targetTypeInfo,
                      string targetName,
                      TargetLevel targetLevel,
                      bool allowMultiple = false)
 {
     _mapingpId      = _mapingpId;
     _targetName     = targetName;
     _targetTypeInfo = targetTypeInfo;
     _targetLevel    = targetLevel;
     _allowMultiple  = allowMultiple;
 }
예제 #6
0
        /// <summary>Deserialize into new object instance</summary>
        public Teleporter(LevelDeserializeContext context)
        {
            TargetLevel = context.br.ReadNullableString();
            if (TargetLevel != null)
            {
                TargetLevel = TargetLevel.ToLowerInvariant();
            }
            targetSpawn = context.br.ReadNullableString();

            if (context.Version >= 18)
            {
                neverSelectAtRandom = context.br.ReadBoolean();
            }

            base.Deserialize(context);
        }
예제 #7
0
        public override void Serialize(LevelSerializeContext context)
        {
            if (TargetLevel != null)
            {
                TargetLevel = TargetLevel.ToLowerInvariant();
            }
            context.bw.WriteNullableString(TargetLevel);
            context.bw.WriteNullableString(targetSpawn);

            if (context.Version >= 18)
            {
                context.bw.Write(neverSelectAtRandom);
            }

            base.Serialize(context);
        }
        /// <summary>
        /// The ToString implementation.
        /// </summary>
        /// <param name="format">The format specifier to use, e.g. <b>Console.WriteLine(workspace.ToString("L"));</b></param>
        /// <param name="provider">Allow clients to format output for their own types using [ICustomFormatter](https://msdn.microsoft.com/en-us/library/system.icustomformatter.aspx).</param>
        /// <returns>The formatted string.</returns>
        /// <exception cref="FormatException">thrown if an invalid format string is specified.</exception>
        /// \par Format specifiers:
        /// \arg \c G Name of the workspace, e.g. MARS_DEV3_barnyrd. Default when not using a format specifier.
        /// \arg \c LV Long version (verbose).
        /// \arg \c I Workspace ID number.
        /// \arg \c L Workspace [location](@ref AcUtils#AcWorkspace#Location).
        /// \arg \c S Location on the host ([storage](@ref AcUtils#AcWorkspace#Storage)) where the elements physically reside.
        /// \arg \c M Machine name ([host](@ref AcUtils#AcWorkspace#Host)) where the elements physically reside.
        /// \arg \c H \e True if the workspace is hidden, \e False otherwise.
        /// \arg \c D Depot name.
        /// \arg \c TL [Target level](@ref AcUtils#AcWorkspace#TargetLevel): how up-to-date the workspace should be.
        /// \arg \c UL [Update level](@ref AcUtils#AcWorkspace#UpdateLevel): how up-to-date the workspace actually is.
        /// \arg \c U Time of the oldest non-member file in the workspace with (\e modified) status, otherwise the time the \c update command was issued.
        /// \arg \c T [Workspace type](@ref AcUtils#WsType): standard, exclusive-file locking, anchor-required, or reference tree.
        /// \arg \c E [End-of-line character](@ref AcUtils#WsEOL) in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style.
        /// \arg \c PI Workspace owner's principal ID number.
        /// \arg \c PN Workspace owner's principal name.
        public string ToString(string format, IFormatProvider provider)
        {
            if (provider != null)
            {
                ICustomFormatter fmt = provider.GetFormat(this.GetType()) as ICustomFormatter;
                if (fmt != null)
                {
                    return(fmt.Format(format, this, provider));
                }
            }

            if (String.IsNullOrEmpty(format))
            {
                format = "G";
            }

            switch (format.ToUpperInvariant())
            {
            case "G":         // name of the workspace, e.g. MARS_DEV3_barnyrd
                return(Name); // general format should be short since it can be called by anything

            case "LV":        // long version (verbose)
                return($"{Name} ({ID}) {{{Type}}}{Environment.NewLine}" +
                       $@"Location: ""{Location}"", Storage: ""{Storage}""{Environment.NewLine}" +
                       $"Host: {Host}, ULevel-Target [{UpdateLevel}:{TargetLevel}]{((TargetLevel != UpdateLevel) ? " (incomplete)" : String.Empty)}{Environment.NewLine}" +
                       $"Depot: {Depot}, EOL: {EOL}, Hidden: {Hidden}{Environment.NewLine}");

            case "I":     // workspace ID number
                return(ID.ToString());

            case "L":     // workspace location
                return(Location);

            case "S":     // location on the host (storage) where the elements physically reside
                return(Storage);

            case "M":     // machine name (host) where the elements physically reside
                return(Host);

            case "H":     // True if workspace is hidden, False otherwise
                return(Hidden.ToString());

            case "D":     // depot name
                return(Depot.ToString());

            case "TL":     // how up-to-date the workspace should be
                return(TargetLevel.ToString());

            case "UL":     // how up-to-date the workspace actually is
                return(UpdateLevel.ToString());

            case "U":     // time of the oldest non-member file in the workspace with modified status, otherwise time the update command was issued
                return(FileModTime.ToString());

            case "T":     // type of workspace: standard, exclusive-file locking, anchor-required, or reference tree
                return(Type.ToString());

            case "E":     // end-of-line character in use by the workspace: platform-appropriate, Unix/Linux style, or Windows style
                return(EOL.ToString());

            case "PI":     // ID number of the AccuRev principal who owns the workspace
                return(Principal.ID.ToString());

            case "PN":     // principal name of the workspace owner
                return(Principal.Name);

            default:
                throw new FormatException($"The {format} format string is not supported.");
            }
        }
 public TargetMappingChild(string mappingId, TypeInfo targetTypeInfo, string targetName, TargetLevel targetLevel, bool allowMultiple)
     : base(mappingId, targetTypeInfo, targetName, targetLevel)
 {
     _allowMultiple = allowMultiple;
 }
 public TargetMapping AddMapping(string mappingId,  TypeInfo targetType, string targetName, TargetLevel targetLevel)
 {
     var newItem = new TargetMapping(mappingId, targetType, targetName, targetLevel);
     _mappings.Add(newItem);
     return newItem;
 }
 public TargetMapping AddChildMapping(string mappingId, TypeInfo targetType, string targetName, string attributeName, TargetLevel targetLevel, bool allowMultiple)
 {
     var newItem = new TargetMapping(mappingId, targetType, targetName, targetLevel, allowMultiple);
     _mappings.Add(newItem);
     return newItem;
 }
 public TargetMappings(string mappingId,
             TypeInfo targetTypeInfo,
             string targetName,
             TargetLevel targetLevel,
             bool allowMultiple = false)
     : base(mappingId, targetTypeInfo, targetName, targetLevel, allowMultiple)
 {
 }
예제 #13
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            targetLevel = (TargetLevel)target;
            if (GUILayout.Button("Load from level"))
            {
                Blocks = 0;

                LoadLevel(int.Parse(targetLevel.name.Replace("Level", "")));
                if (_target == Target.COLLECT)
                {
                    targetLevel.targets.Clear();
                    for (int i = 0; i < targetLevel.targets.Length; i++)
                    {
                        var el = targetLevel.targets[i];
                        if (el.type == _target)
                        {
                            targetLevel.targets.Remove(el);
                        }
                    }
                    for (int i = 0; i < collectItems.Length; i++)
                    {
                        if (ingrCount[i] > 0)
                        {
                            var myTargetTarget = new TargetObject {
                                type = _target
                            };
                            myTargetTarget.icon        = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/JellyGarden/Textures/Items/item_0" + (int)collectItems[i] + ".png");
                            myTargetTarget.color       = (int)collectItems[i] - 1;
                            myTargetTarget.targetCount = ingrCount[i];
                            targetLevel.targets.Add(myTargetTarget);
                        }
                    }
                }
                if (_target == Target.INGREDIENT)
                {
                    targetLevel.targets.Clear();
                    for (int i = 0; i < targetLevel.targets.Length; i++)
                    {
                        var el = targetLevel.targets[i];
                        if (el.type == _target)
                        {
                            targetLevel.targets.Remove(el);
                        }
                    }
                    for (int i = 0; i < ingr.Length; i++)
                    {
                        if (ingrCount[i] > 0)
                        {
                            var myTargetTarget = new TargetObject {
                                type = _target
                            };
                            myTargetTarget.icon        = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/JellyGarden/Textures/Items/ingredient_0" + (int)ingr[i] + ".png");
                            myTargetTarget.targetCount = ingrCount[i];
                            targetLevel.targets.Add(myTargetTarget);
                        }
                    }
                }
                CheckAddTarget(Target.SCORE);
                CheckAddTarget(Target.BLOCKS, _target);
                foreach (var myTargetTarget in targetLevel.targets)
                {
                    if (myTargetTarget.type == Target.SCORE)
                    {
                        myTargetTarget.targetCount = star1;
                        myTargetTarget.icon        = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/JellyGarden/Textures/map/star2.png");
                    }
                    else if (myTargetTarget.type == Target.BLOCKS)
                    {
                        myTargetTarget.targetCount = Blocks;
                        myTargetTarget.icon        = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/JellyGarden/Textures/Blocks/block.png");
                    }
                }


                EditorUtility.SetDirty(targetLevel);
            }
        }
        public TargetMapping AddChildMapping(string mappingId, TypeInfo targetType, string targetName, string attributeName, TargetLevel targetLevel, bool allowMultiple)
        {
            var newItem = new TargetMapping(mappingId, targetType, targetName, targetLevel, allowMultiple);

            _mappings.Add(newItem);
            return(newItem);
        }
        public TargetMapping AddMapping(string mappingId, TypeInfo targetType, string targetName, TargetLevel targetLevel)
        {
            var newItem = new TargetMapping(mappingId, targetType, targetName, targetLevel);

            _mappings.Add(newItem);
            return(newItem);
        }
 public TargetMappingChild(string mappingId, TypeInfo targetTypeInfo, string targetName, TargetLevel targetLevel, bool allowMultiple)
     : base(mappingId, targetTypeInfo, targetName, targetLevel)
 {
     _allowMultiple = allowMultiple;
 }