Esempio n. 1
0
    //void CheckGameState()
    //{
    //    Util.Delay(null, checkGameStateDelay, () =>
    //     {
    //         if (FindObjectsOfType<PlayerMovement>().Length == 0)
    //         {
    //             em.RaiseGameStateChanged(GameManager.GameState.Lost);
    //         } else if (FindObjectsOfType<Absorption>().Length == 1)
    //         {
    //             em.RaiseGameStateChanged(GameManager.GameState.Won);
    //         }
    //     });
    //}

    public void Absorb(Absorption other, float percentage)
    {
        if (!npcMerge && !(isPlayer || other.isPlayer))
        {
            return;
        }

        var area      = Area();
        var otherArea = other.Area();

        if (area < otherArea)
        {
            return;
        }

        float otherNewArea;
        float myNewArea;

        if (area == otherArea && other.isPlayer)
        {
            otherNewArea = Area() + other.Area() * percentage;
            myNewArea    = other.Area() * (1 - percentage);
        }
        else
        {
            otherNewArea = other.Area() * (1 - percentage);
            myNewArea    = Area() + other.Area() * percentage;
        }
        Scale(myNewArea);
        other.Scale(otherNewArea);
        other.DestroyTiny();
        DestroyTiny();
        //CheckGameState();
    }
Esempio n. 2
0
    public override void Trigger(TriggerableContext context)
    {
        // Debug.Log($"Transistor shape triggered with {ClosestNeighbors.Count} neighbors!");

        foreach (Shape shape in ClosestNeighbors)
        {
            if (CanAbsorpToExplosion(shape))
            {
                context.WillExplode = true;
            }
            else if (CanAbsorp(shape))
            {
                Absorption absorption = new Absorption();
                absorption.Consumer = this;
                absorption.Consumee = shape;

                if (!context.Absorptions.Contains(absorption))
                {
                    context.Absorptions.Add(absorption);
                    context.Completed = false;
                    // Debug.Log("...and absorbed one of them!");
                }
            }
        }
    }
Esempio n. 3
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in tiggeredGO)
        {
            Triggered2D t2d = go.GetComponent <Triggered2D>();

            Absorption abs = go.GetComponent <Absorption>();
            foreach (GameObject target in t2d.Targets)
            {
                if (target.GetComponent <CanInfect>() == null)
                {
                    abs.nbrAbsorption++;

                    GameObjectManager.unbind(target);

                    Object.Destroy(target);
                }
            }
        }
    }
Esempio n. 4
0
        private static Effect GetEffect(EffectType prim)
        {
            Effect eff = null;

            switch (prim)
            {
            case EffectType.Speed:
                eff = new Speed();
                break;

            case EffectType.Slowness:
                eff = new Slowness();
                break;

            case EffectType.Haste:
                eff = new Haste();
                break;

            case EffectType.MiningFatigue:
                eff = new MiningFatigue();
                break;

            case EffectType.Strength:
                eff = new Strength();
                break;

            case EffectType.InstantHealth:
                eff = new InstantHealth();
                break;

            case EffectType.InstantDamage:
                eff = new InstantDamage();
                break;

            case EffectType.JumpBoost:
                eff = new JumpBoost();
                break;

            case EffectType.Nausea:
                eff = new Nausea();
                break;

            case EffectType.Regeneration:
                eff = new Regeneration();
                break;

            case EffectType.Resistance:
                eff = new Resistance();
                break;

            case EffectType.FireResistance:
                eff = new FireResistance();
                break;

            case EffectType.WaterBreathing:
                eff = new WaterBreathing();
                break;

            case EffectType.Invisibility:
                eff = new Invisibility();
                break;

            case EffectType.Blindness:
                eff = new Blindness();
                break;

            case EffectType.NightVision:
                eff = new NightVision();
                break;

            case EffectType.Hunger:
                eff = new Hunger();
                break;

            case EffectType.Weakness:
                eff = new Weakness();
                break;

            case EffectType.Poison:
                eff = new Poison();
                break;

            case EffectType.Wither:
                eff = new Wither();
                break;

            case EffectType.HealthBoost:
                eff = new HealthBoost();
                break;

            case EffectType.Absorption:
                eff = new Absorption();
                break;

            case EffectType.Saturation:
                eff = new Saturation();
                break;
            }
            return(eff);
        }
Esempio n. 5
0
        public void Effect(Player player, string effect, int level, int duration)
        {
            if ("clear".Equals(effect, StringComparison.InvariantCultureIgnoreCase))
            {
                player.Level.BroadcastMessage($"Removed all effects for {player.Username}.", MessageType.Raw);
                player.RemoveAllEffects();
                return;
            }

            EffectType effectType;

            if (Enum.TryParse(effect, true, out effectType))
            {
                Effect eff = null;
                switch (effectType)
                {
                case EffectType.Speed:
                    eff = new Speed();
                    break;

                case EffectType.Slowness:
                    eff = new Slowness();
                    break;

                case EffectType.Haste:
                    eff = new Haste();
                    break;

                case EffectType.MiningFatigue:
                    eff = new MiningFatigue();
                    break;

                case EffectType.Strength:
                    eff = new Strength();
                    break;

                case EffectType.InstantHealth:
                    eff = new InstantHealth();
                    break;

                case EffectType.InstantDamage:
                    eff = new InstantDamage();
                    break;

                case EffectType.JumpBoost:
                    eff = new JumpBoost();
                    break;

                case EffectType.Nausea:
                    eff = new Nausea();
                    break;

                case EffectType.Regeneration:
                    eff = new Regeneration();
                    break;

                case EffectType.Resistance:
                    eff = new Resistance();
                    break;

                case EffectType.FireResistance:
                    eff = new FireResistance();
                    break;

                case EffectType.WaterBreathing:
                    eff = new WaterBreathing();
                    break;

                case EffectType.Invisibility:
                    eff = new Invisibility();
                    break;

                case EffectType.Blindness:
                    eff = new Blindness();
                    break;

                case EffectType.NightVision:
                    eff = new NightVision();
                    break;

                case EffectType.Hunger:
                    eff = new Hunger();
                    break;

                case EffectType.Weakness:
                    eff = new Weakness();
                    break;

                case EffectType.Poison:
                    eff = new Poison();
                    break;

                case EffectType.Wither:
                    eff = new Wither();
                    break;

                case EffectType.HealthBoost:
                    eff = new HealthBoost();
                    break;

                case EffectType.Absorption:
                    eff = new Absorption();
                    break;

                case EffectType.Saturation:
                    eff = new Saturation();
                    break;
                }

                if (eff != null)
                {
                    eff.Level     = level;
                    eff.Duration  = duration;
                    eff.Particles = false;

                    player.SetEffect(eff);
                    player.Level.BroadcastMessage($"{player.Username} added effect {effectType} with strenght {level}", MessageType.Raw);
                }
            }
        }
Esempio n. 6
0
        public void Effect(Player player, string effect, int level = 1, int duration = 20)
        {
            EffectType effectType;

            if (Enum.TryParse(effect, true, out effectType))
            {
                Effect eff = null;
                switch (effectType)
                {
                case EffectType.Speed:
                    eff = new Speed();
                    break;

                case EffectType.Slowness:
                    eff = new Slowness();
                    break;

                case EffectType.Haste:
                    eff = new Haste();
                    break;

                case EffectType.MiningFatigue:
                    eff = new MiningFatigue();
                    break;

                case EffectType.Strenght:
                    eff = new Strength();
                    break;

                case EffectType.InstandHealth:
                    eff = new InstandHealth();
                    break;

                case EffectType.InstantDamage:
                    eff = new InstantDamage();
                    break;

                case EffectType.JumpBoost:
                    eff = new JumpBoost();
                    break;

                case EffectType.Nausea:
                    eff = new Nausea();
                    break;

                case EffectType.Regeneration:
                    eff = new Regeneration();
                    break;

                case EffectType.Resistance:
                    eff = new Resistance();
                    break;

                case EffectType.FireResistance:
                    eff = new FireResistance();
                    break;

                case EffectType.WaterBreathing:
                    eff = new WaterBreathing();
                    break;

                case EffectType.Invisibility:
                    eff = new Invisibility();
                    break;

                case EffectType.Blindness:
                    eff = new Blindness();
                    break;

                case EffectType.NightVision:
                    eff = new NightVision();
                    break;

                case EffectType.Hunger:
                    eff = new Hunger();
                    break;

                case EffectType.Weakness:
                    eff = new Weakness();
                    break;

                case EffectType.Poison:
                    eff = new Poison();
                    break;

                case EffectType.Wither:
                    eff = new Wither();
                    break;

                case EffectType.HealthBoost:
                    eff = new HealthBoost();
                    break;

                case EffectType.Absorption:
                    eff = new Absorption();
                    break;

                case EffectType.Saturation:
                    eff = new Saturation();
                    break;

                case EffectType.Glowing:
                    eff = new Glowing();
                    break;

                case EffectType.Levitation:
                    eff = new Levitation();
                    break;
                }

                if (eff != null)
                {
                    eff.Level     = level;
                    eff.Duration  = duration;
                    eff.Particles = false;

                    player.SetEffect(eff);
                    player.Level.BroadcastMessage(string.Format("{0} added effect {1} with strenght {2}", player.Username, effectType, level), MessageType.Raw);
                }
            }
        }