Exemple #1
0
    public override void Activate(Behavior_Seeker activator)
    {
        activate_tool = activator.GetTool();

        mining = false;
        float base_mining_power = Time.deltaTime * Manager_Main.Instance.GetMiningLevel() * Manager_Main.Instance.GetToolSpeedup(activate_tool);

        switch (activate_tool.type)
        {
        case Manager_Main.Tool_Type.Gloves:
            mining_multiplier = Parameters_Mining.Instance.gloves_mining_multiplier;
            mining            = true;
            Manager_Sounds.Instance.PlayBasicHit(ref_self_sprite_renderer.isVisible);
            break;

        case Manager_Main.Tool_Type.Pickaxe:
            mining_multiplier = Parameters_Mining.Instance.pickaxe_mining_multiplier;
            mining            = true;
            Manager_Sounds.Instance.PlayBasicHit(ref_self_sprite_renderer.isVisible);
            break;

        case Manager_Main.Tool_Type.Hammer:
            mining_multiplier = Parameters_Mining.Instance.hammer_mining_multiplier;
            script_parent_spawner.DecreaseDurability(base_mining_power * mining_multiplier);
            Grow(Parameters_Mining.Instance.hammer_grow_mult);
            Shake(Parameters_Mining.Instance.hammer_shake_mult);
            Manager_Sounds.Instance.PlayHammerHit(ref_self_sprite_renderer.isVisible);
            break;

        case Manager_Main.Tool_Type.Bomb:
            mining_multiplier = Parameters_Mining.Instance.bomb_mining_multiplier;
            float        explosion_radius  = Parameters_Mining.Instance.bomb_radius + Manager_Main.Instance.GetMiningLevel() * Parameters_Mining.Instance.bomb_mine_level_scale;
            Collider2D[] nearby_objs_colli = Physics2D.OverlapCircleAll(transform.position, explosion_radius);
            foreach (Collider2D colli in nearby_objs_colli)
            {
                if (colli.tag == "Node")
                {
                    Behavior_Node script_node = colli.GetComponent <Behavior_Node>();
                    script_node.GetSpawner().DecreaseDurability(base_mining_power * mining_multiplier);
                    script_node.Grow();
                }
            }
            script_parent_spawner.PlayEffectExplosion(explosion_radius, Manager_Main.Instance.GetGemColors()[activate_tool.tier]);
            Manager_Sounds.Instance.PlayBombHit(ref_self_sprite_renderer.isVisible);
            break;

        case Manager_Main.Tool_Type.Staff:
            mining_multiplier = Parameters_Mining.Instance.staff_mining_multiplier;
            mining            = true;
            Manager_Sounds.Instance.PlayStaffHit(ref_self_sprite_renderer.isVisible);
            break;

        case Manager_Main.Tool_Type.Torch:
            mining_multiplier = Parameters_Mining.Instance.torch_mining_multiplier;
            mining_auto_off   = Parameters_Mining.Instance.torch_burn_duration_seconds + Manager_Main.Instance.GetMiningLevel() * Parameters_Mining.Instance.torch_duration_level_scale;
            mining_start_time = Time.time;
            mining            = true;
            Manager_Sounds.Instance.PlayTorchHit(ref_self_sprite_renderer.isVisible);
            break;
        }
    }
Exemple #2
0
    private void Update()
    {
        if (mining)
        {
            float base_mining_power = Time.deltaTime * Manager_Main.Instance.GetMiningLevel() * Manager_Main.Instance.GetToolSpeedup(activate_tool);

            if (activate_tool.type == Manager_Main.Tool_Type.Staff)
            {
                // Chaining
                HashSet <int>            processed_targets = new HashSet <int>();
                Queue <Behavior_Spawner> targets           = new Queue <Behavior_Spawner>();
                targets.Enqueue(script_parent_spawner);

                while (targets.Count > 0)
                {
                    Behavior_Spawner target = targets.Dequeue();
                    target.DecreaseDurability(base_mining_power * mining_multiplier);
                    target.PlayParticleLightning();
                    processed_targets.Add(target.gameObject.GetInstanceID());

                    Collider2D[] nearby_objs_colli = Physics2D.OverlapCircleAll(target.gameObject.transform.position, Parameters_Mining.Instance.staff_chain_radius + Manager_Main.Instance.GetMiningLevel() * Parameters_Mining.Instance.staff_mine_level_scale);
                    foreach (Collider2D colli in nearby_objs_colli)
                    {
                        if (colli.tag == "Node")
                        {
                            Behavior_Node    new_node    = colli.GetComponent <Behavior_Node>();
                            Behavior_Spawner new_spawner = new_node.GetSpawner();

                            if (!processed_targets.Contains(new_spawner.gameObject.GetInstanceID()))
                            {
                                // Unprocessed Target
                                targets.Enqueue(new_spawner);
                                new_node.Grow();
                            }
                        }
                    }
                }
            }
            else if (activate_tool.type == Manager_Main.Tool_Type.Torch)
            {
                float e_time = Time.time - mining_start_time;
                if (e_time >= mining_auto_off)
                {
                    mining = false;
                }
                else
                {
                    script_parent_spawner.DecreaseDurability(base_mining_power * mining_multiplier);

                    // Effect
                    script_parent_spawner.PlayParticleFire();
                }
            }
            else
            {
                script_parent_spawner.DecreaseDurability(base_mining_power * mining_multiplier);
            }

            // Play effect
            Grow();
        }
    }