Ejemplo n.º 1
0
        public object Clone(FormationGroupContainer container, bool asset)
        {
            FormationGroup clone = new FormationGroup {formation = formation, position = position, rotation = rotation, needsClearing = needsClearing, spawnTime = spawnTime};

            // enemies
            clone.enemies = new Enemy.Classes[enemies.Length];
            Array.Copy(enemies, clone.enemies, enemies.Length);

            // paths
            clone.paths = new Path[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                if (paths[i] == null) continue;

                Type pathType = paths[i].GetType();
                Path path = (Path)ScriptableObject.CreateInstance(pathType.Name);

                if (asset)
                {
                    AssetDatabase.AddObjectToAsset(path, container);
                }

                clone.paths[i] = path;
                FieldInfo[] fields = pathType.GetFields();
                foreach (FieldInfo field in fields)
                {
                    field.SetValue(clone.paths[i], field.GetValue(paths[i]));
                }
            }

            return clone;
        }
Ejemplo n.º 2
0
        public void Set(FormationGroup group)
        {
#if UNITY_EDITOR
            formationGroup = (FormationGroup)group.Clone(this, true);
#endif
        }
Ejemplo n.º 3
0
 public void Initialize(FormationGroup formationGroup)
 {
     this.formationGroup = formationGroup;
 }
Ejemplo n.º 4
0
 private void CreateFormationGroup(int formationIndex, FormationGroup formationGroup)
 {
     levelManager.formationGroups[formationIndex] = formationGroup;
     enemyToggles[formationIndex] = new bool[formationGroup.enemies.Length];
     Repaint();
 }
Ejemplo n.º 5
0
 private void SaveFormationGroup(FormationGroup formationGroup)
 {
     var window = GetWindow<SaveWindow>(true, "Save Formation", true);
     window.minSize = window.maxSize = new Vector2(300f, 100f);
     window.Initialize(formationGroup);
 }