Exemplo n.º 1
0
    public override void OnActivated(TinyObject tiny)
    {
        Debug.Log("hi");
        var player = (Player)tiny;

        player.extraJumps += 1;
    }
Exemplo n.º 2
0
    public Leveller(TinyObject host, Dictionary <int, Powerup> powerups)
    {
        powerupMap = powerups;
        this.host  = host;

        level = 0;
        LevelUp();
    }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        TinyObject target = other.gameObject.GetComponent <TinyObject>();

        if (target != null && target != owner)
        {
            target.HandleHit(this);
        }
    }
Exemplo n.º 4
0
    public override void HandleHit(TinyObject tiny)
    {
        var damager        = (Damager)tiny;
        var projectileBody = tiny.gameObject.GetComponent <Rigidbody2D>();

        body.AddForce(projectileBody.velocity.normalized * forceConstant * damager.damage);

        GameObject.Destroy(tiny.gameObject);
    }
Exemplo n.º 5
0
    public override void OnActivated(TinyObject tiny)
    {
        // Make sure to remove old one if it exists
        OnDeactivated(tiny);

        var player = (Player)tiny;

        player.weapon1 = NewWeapon();
        player.weapon1.GetComponent <TinyWeapon>().holder = player;
    }
Exemplo n.º 6
0
    public override void HandleHit(TinyObject tiny)
    {
        var damager = tiny as Damager;

        if (damager != null)
        {
            TakeDamage(damager.damage);
        }

        GameObject.Destroy(tiny.gameObject);
    }
Exemplo n.º 7
0
    public override void OnDeactivated(TinyObject tiny)
    {
        var player = (Player)tiny;

        if (player.weapon1 != null)
        {
            GameObject.Destroy(player.weapon1);
        }

        player.weapon1 = null;
    }
Exemplo n.º 8
0
    public override void HandleHit(TinyObject tiny)
    {
        // Once we have different things hitting the player we can diversify this
        var projectile = (Projectile)tiny;

        health -= projectile.damage;
        if (health < 0)
        {
            KillPlayer();
            projectile.owner.AddExperience(experienceValue);
        }
    }
Exemplo n.º 9
0
        private void writeObject(TextWriter writer, TinyObject obj, TinyToken parent, int indentLevel)
        {
            var parentIsArray = parent != null && parent.Type == TinyTokenType.Array;

            var first = true;

            foreach (var property in obj)
            {
                if (!first || !parentIsArray)
                {
                    writeIndent(writer, indentLevel);
                }

                var key = property.Key;
                if (key.Contains(" ") || key.Contains(":") || key.StartsWith("-"))
                {
                    key = "\"" + YamlUtil.EscapeString(key) + "\"";
                }

                var value = property.Value;
                if (value.IsEmpty)
                {
                    writer.WriteLine(key + ":");
                }
                else if (value.IsInline)
                {
                    writer.Write(key + ": ");
                    write(writer, value, obj, 0);
                }
                else
                {
                    writer.WriteLine(key + ":");
                    write(writer, value, obj, indentLevel + 1);
                }
                first = false;
            }
        }
Exemplo n.º 10
0
    public override void OnDeactivated(TinyObject tiny)
    {
        var player = (Player)tiny;

        player.extraJumps -= 1;
    }
Exemplo n.º 11
0
        private void saveText(string path)
        {
            if (disposedValue)
            {
                throw new ObjectDisposedException(nameof(Project));
            }

            // Create the opener file
            if (!File.Exists(path))
            {
                File.WriteAllText(path, "# This file is only used to open the project\n# Project data is contained in the .sbrew folder");
            }

            var projectDirectory = Path.GetDirectoryName(path);

            var gitIgnorePath = Path.Combine(projectDirectory, ".gitignore");

            if (!File.Exists(gitIgnorePath))
            {
                File.WriteAllText(gitIgnorePath, ".sbrew/user.yaml\n.sbrew.tmp\n.sbrew.bak\n.cache\n.vs");
            }

            var targetDirectory = Path.Combine(projectDirectory, DataFolder);

            using (var directoryWriter = new SafeDirectoryWriter(targetDirectory))
            {
                // Write the index
                {
                    var indexRoot = new TinyObject
                    {
                        { "FormatVersion", Version },
                        { "MapsetPath", PathHelper.WithStandardSeparators(MapsetPath) },
                        { "BeatmapId", MainBeatmap.Id },
                        { "BeatmapName", MainBeatmap.Name },
                        { "Assemblies", importedAssemblies },
                        { "Layers", layerManager.Layers.Select(l => l.Guid.ToString("N")) },
                    };

                    var indexPath = directoryWriter.GetPath("index.yaml");
                    indexRoot.Write(indexPath);
                }

                // Write user specific data
                {
                    var userRoot = new TinyObject
                    {
                        { "FormatVersion", Version },
                        { "Editor", Program.FullName },
                        { "OwnsOsb", OwnsOsb },
                    };

                    var userPath = directoryWriter.GetPath("user.yaml");
                    userRoot.Write(userPath);
                }

                // Write each effect
                foreach (var effect in effects)
                {
                    var effectRoot = new TinyObject
                    {
                        { "FormatVersion", Version },
                        { "Name", effect.Name },
                        { "Script", effect.BaseName },
                    };

                    var configRoot = new TinyObject();
                    effectRoot.Add("Config", configRoot);

                    foreach (var field in effect.Config.SortedFields)
                    {
                        var fieldRoot = new TinyObject
                        {
                            { "Type", field.Type.FullName },
                            { "Value", ObjectSerializer.ToString(field.Type, field.Value) },
                        };
                        if (field.DisplayName != field.Name)
                        {
                            fieldRoot.Add("DisplayName", field.DisplayName);
                        }
                        configRoot.Add(field.Name, fieldRoot);

                        if ((field.AllowedValues?.Length ?? 0) > 0)
                        {
                            var allowedValuesRoot = new TinyObject();
                            fieldRoot.Add("AllowedValues", allowedValuesRoot);

                            foreach (var allowedValue in field.AllowedValues)
                            {
                                allowedValuesRoot.Add(allowedValue.Name, ObjectSerializer.ToString(field.Type, allowedValue.Value));
                            }
                        }
                    }

                    var layersRoot = new TinyObject();
                    effectRoot.Add("Layers", layersRoot);

                    foreach (var layer in layerManager.Layers.Where(l => l.Effect == effect))
                    {
                        var layerRoot = new TinyObject
                        {
                            { "Name", layer.Identifier },
                            { "OsbLayer", layer.OsbLayer },
                            { "DiffSpecific", layer.DiffSpecific },
                            { "Visible", layer.Visible },
                        };
                        layersRoot.Add(layer.Guid.ToString("N"), layerRoot);
                    }

                    var effectPath = directoryWriter.GetPath("effect." + effect.Guid.ToString("N") + ".yaml");
                    effectRoot.Write(effectPath);
                }

                directoryWriter.Commit();
                changed = false;
            }
        }
Exemplo n.º 12
0
    public override void OnDeactivated(TinyObject tiny)
    {
        var player = (Player)tiny;

        player.force /= 2f;
    }
Exemplo n.º 13
0
 public abstract void OnDeactivated(TinyObject tiny);
Exemplo n.º 14
0
 public virtual void HandleHit(TinyObject tiny)
 {
     // Default behaviour is to do nothing.
 }