Inheritance: Environment
Beispiel #1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (movementInput.y > 0 && collision.tag == "Edge")
        {
            float camX = mainCam.transform.position.x;
            mainCam.transform.position = new Vector3(mainCam.transform.position.x + Time.deltaTime, 0, -10);
        }

        if (collision.tag == "Water")
        {
            Puddle puddle = collision.GetComponent <Puddle>();
            if (waterLevel.value < 1 && puddle.water > 0)
            {
                if (!puddle.isInfinite)
                {
                    puddle.water     -= lossAmount * Time.deltaTime;
                    waterLevel.value += (lossAmount + (lossAmount / 2)) * Time.deltaTime;
                }
            }
        }

        if (collision.tag == "Obstacle")
        {
            if (!isHit)
            {
                collision.GetComponent <AudioSource>().Play();
                lives--;
                StartCoroutine(Hit());
            }
        }
    }
Beispiel #2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Bounce")
        {
            if (textRings)
            {
                textRings.GetComponent <TextMeshProUGUI>().text = "Rings: " + ProceduralGeneration.instance.GetBallRing();
            }
            Puddle puddle = collision.gameObject.GetComponent <Puddle>();
            if (puddle)
            {
                puddle.AffectBall(gameObject);
            }
            bounce = true;
        }
        else if (collision.gameObject.tag == "Trampoline")
        {
            collision.gameObject.GetComponentInParent <Trampoline>().BumpBall(gameObject);

            if (textRings)
            {
                textRings.GetComponent <TextMeshProUGUI>().text = "Rings: " + ProceduralGeneration.instance.GetBallRing();
            }
            bounce = true;
        }
        else if (collision.gameObject.tag == "Obstacle")
        {
            // Lose
            //Destroy(gameObject);
            SceneController.Instance.GoPlay();
        }
    }
Beispiel #3
0
    private void Consume(Puddle other)
    {
        float totalArea = Area() + other.Area();

        radius = (float)Math.Sqrt(totalArea / (float)Math.PI);
        UpdateSize();

        other.Destroy();
    }
Beispiel #4
0
    public override void Update()
    {
        base.Update();

        resource.Spend(leak * Time.deltaTime);

        puddleSpawnTimer -= Time.deltaTime;

        while (puddleSpawnTimer <= 0)
        {
            Puddle.Create(puddle, target.transform.position, puddleAmount);
            Liquid.Create(liquid.gameObject, target.transform.position, puddleAmount);
            puddleSpawnTimer += puddlePeriod;
        }
    }
Beispiel #5
0
    public void Destroy()
    {
        Debug.Log("Item " + name + " was destroyed");

        if (puddle && puddleAmount > 0)
        {
            Puddle.Create(puddle, transform.position, puddleAmount);
        }

        if (explosion)
        {
            GameObject createdExplosion = Instantiate(explosion, transform.position, Quaternion.identity);
        }

        Destroy(gameObject);
    }
Beispiel #6
0
    public static void Create(GameObject prefab, Vector3 position, float amount)
    {
        if (amount <= 0)
        {
            Debug.Log("Failed to create puddle with zero amount");
            return;
        }

        GameObject newPuddle  = Instantiate(prefab);
        Puddle     puddleData = newPuddle.GetComponent <Puddle>();

        if (puddleData == null)
        {
            Debug.Log("Failed to get puddle script data on puddle creation");
            Destroy(newPuddle);
            return;
        }

        newPuddle.transform.position = position;

        puddleData.radius = (float)Math.Sqrt(amount / (float)Math.PI);

        newPuddle.transform.localScale = new Vector3(puddleData.radius, puddleData.radius, puddleData.radius);
    }
Beispiel #7
0
    private GameObject CreatePillar(float x, float z, float s, float h, Color[] ringColor, GameObject obj, bool isAnimate, int ring)
    {
        Vector3 position   = new Vector3(x, transform.position.y, z);
        Color   floorColor = ringColor[0];
        Color   bodyColor  = ringColor[1];

        BiomData biomData = Bioms.instance.GetCurrentBiomData();

        GameObject pillar = Instantiate(obj, position, Quaternion.identity);

        pillar.GetComponent <Pillar>().SetRing(ring);

        // Animations
        if (isAnimate)
        {
            pillar.GetComponent <Animator>().SetTrigger("Appear");
        }

        // Coloring
        Transform pillarModel = pillar.transform.GetChild(0);

        if (obj.tag == "Bounce")
        {
            pillarModel.GetChild(0).GetComponent <Renderer>().material.color = floorColor;
            pillarModel.GetChild(1).GetComponent <Renderer>().material.color = bodyColor;
        }
        pillarModel.localScale = new Vector3(s, h, s);

        // Puddle
        if (Random.value <= biomData.PuddleSpawnChance && obj.tag == "Bounce")
        {
            Puddle puddle = pillarModel.GetChild(0).gameObject.AddComponent(typeof(Puddle)) as Puddle;

            // Text
            Vector3 textSpawnPosition = pillarModel.GetChild(0).position;
            textSpawnPosition = new Vector3(textSpawnPosition.x, textSpawnPosition.y + 0.1f, textSpawnPosition.z);
            GameObject textPuddle = Instantiate(pillarTextObj, textSpawnPosition, Quaternion.identity);
            textPuddle.transform.parent = pillarModel.GetChild(0);

            if (Random.value <= biomData.PuddleBoostChance)
            {
                // Text
                textPuddle.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = (int)(biomData.PuddleBoostPower * 100) + "%";

                puddle.SetPuddleType(Puddle.PuddleTypes.BOOST);
            }
            else
            {
                // Text
                textPuddle.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = (int)(biomData.PuddleSlowPower * 100) + "%";

                puddle.SetPuddleType(Puddle.PuddleTypes.SLOW);
            }
        }

        // Diamonds
        if (Random.value <= biomData.DiamondsSpawnChance && obj.tag == "Bounce")
        {
            GameObject diamond = Diamond.SpawnDiamond(
                biomData.DiamondsVariety,
                Bioms.instance.GetDiamondsPrefabs(),
                Bioms.instance.GetDiamondsProbabilities(),
                pillarModel.GetChild(0));
            diamond.transform.parent = pillarModel;
        }

        return(pillar);
    }
Beispiel #8
0
        public void FindCreature(Mobile from, int creatureLevel)
        {
            if (from == null)
            {
                return;
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            int waterLocationChecks = 20;

            int minSpawnRadius = 3;
            int maxSpawnRadius = 6;

            bool foundWaterSpot   = false;
            bool spawnedCreatures = false;

            Point3D spawnLocation = Location;
            Point3D newLocation   = new Point3D();

            for (int a = 0; a < waterLocationChecks; a++)
            {
                int x = X;

                int xOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    xOffset *= -1;
                }

                x += xOffset;

                int y = Y;

                int yOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    yOffset *= -1;
                }

                y += yOffset;

                newLocation.X = x;
                newLocation.Y = y;
                newLocation.Z = -5;

                bool waterTile = BaseBoat.IsWaterTile(newLocation, Map);

                if (waterTile)
                {
                    if (BaseBoat.FindBoatAt(newLocation, Map) != null)
                    {
                        continue;
                    }

                    SpellHelper.AdjustField(ref spawnLocation, Map, 12, false);

                    foundWaterSpot = true;
                    break;
                }
            }

            if (!foundWaterSpot)
            {
                return;
            }

            int count = 0;

            switch (creatureLevel)
            {
            case 1:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Puddle();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 2:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new WaterElemental();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 3:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new DeepSeaSerpent();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 4:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Kraken();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;
            }
        }
Beispiel #9
0
    public void Add(Puddle puddle)
    {
        {
            Debug.Log("Adding new puddle (current puddle count is " + puddlesCount + ")");

            int i;
            for (i = addSearchStart; i < puddles.Length; i++)
            {
                if (puddles[i] == null)
                {
                    puddles[i] = puddle;
                    index      = i;
                    if (i > last)
                    {
                        last = i;
                    }
                    if (i < first)
                    {
                        first = i;
                    }
                    addSearchStart = i + 1;
                    break;
                }
            }

            if (i >= puddles.Length)
            {
                last = puddles.Length;
                Array.Resize <Puddle>(ref puddles, puddles.Length * 2);
                puddles[last]  = puddle;
                index          = last;
                addSearchStart = last + 1;

                for (i = last + 1; i < puddles.Length; i++)
                {
                    puddles[i] = null;
                }
            }

            puddlesCount++;
        }

Restart:
        Debug.Log(
            "Puddles info:   " +
            "length: " + puddles.Length + ";  " +
            "first: " + first + ";  " +
            "last: " + last + ";  " +
            "add search start: " + addSearchStart);

        for (int i = first; i <= last; i++)
        {
            if (puddles[i] == null)
            {
                continue;
            }

            for (int j = i + 1; j <= last; j++)
            {
                if (puddles[j] == null)
                {
                    continue;
                }

                float distance = (puddles[i].transform.position - puddles[j].transform.position).magnitude;

                if (distance <= puddles[i].radius)
                {
                    puddles[i].Consume(puddles[j]);
                    goto Restart;
                }

                if (distance <= puddles[j].radius)
                {
                    puddles[j].Consume(puddles[i]);
                    goto Restart;
                }
            }
        }
    }
Beispiel #10
0
        public void FindCreature(Mobile from, int creatureLevel)
        {
            if (from == null)
            {
                return;
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            int waterLocationChecks = 20;

            int minSpawnRadius = 3;
            int maxSpawnRadius = 6;

            bool foundWaterSpot   = false;
            bool spawnedCreatures = false;

            Point3D spawnLocation = Location;
            Point3D newLocation   = new Point3D();

            for (int a = 0; a < waterLocationChecks; a++)
            {
                int x = X;

                int xOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    xOffset *= -1;
                }

                x += xOffset;

                int y = Y;

                int yOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    yOffset *= -1;
                }

                y += yOffset;

                newLocation.X = x;
                newLocation.Y = y;
                newLocation.Z = -5;

                bool waterTile = BaseShip.IsWaterTile(newLocation, Map);

                if (waterTile)
                {
                    if (BaseShip.FindShipAt(newLocation, Map) != null)
                    {
                        continue;
                    }

                    SpellHelper.AdjustField(ref spawnLocation, Map, 12, false);

                    foundWaterSpot = true;
                    break;
                }
            }

            if (!foundWaterSpot)
            {
                return;
            }

            int count = 0;

            switch (creatureLevel)
            {
            case 1:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Puddle();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something was hiding in the wreckage!*");
                }
                break;

            case 2:
                if (player.ShipOccupied != null)
                {
                    if (!player.ShipOccupied.Deleted && player.ShipOccupied.m_SinkTimer == null)
                    {
                        count = Utility.RandomMinMax(2, 4);

                        for (int a = 0; a < count; a++)
                        {
                            BaseCreature bc_Creature = new ColossusTermite();

                            bc_Creature.m_WasFishedUp = true;
                            bc_Creature.MoveToWorld(player.ShipOccupied.GetRandomEmbarkLocation(false), from.Map);
                            spawnedCreatures = true;
                        }
                    }
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*the wreckage was full of termites!*");
                }
                break;

            case 3:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new DeepSeaSerpent();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something was hiding in the wreckage!*");
                }
                break;

            case 4:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Kraken();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something was hiding in the wreckage!*");
                }
                break;
            }
        }
Beispiel #11
0
        public void RetrievalAttempt(Mobile from, bool fishing)
        {
            if (m_CurrentItem >= m_MaxItems)
            {
                return;
            }

            PlayerMobile pm_From = from as PlayerMobile;

            if (pm_From == null)
            {
                return;
            }

            if (!from.InRange(Location, 2) && from.AccessLevel == AccessLevel.Player)
            {
                from.SendMessage("You are too far from the fountain to continue searching.");
                return;
            }

            pm_From.RevealingAction();

            double baseChance = .10;

            if (fishing)
            {
                baseChance *= 1.25 + (.25 * (from.Skills.Fishing.Value / 120));
            }

            if (Utility.RandomDouble() <= baseChance)
            {
                m_CurrentItem++;

                Item item = null;

                switch (m_CurrentItem)
                {
                case 1:
                    Bag bag = new Bag();

                    for (int a = 0; a < 10; a++)
                    {
                        bag.DropItem(CraftingComponent.GetRandomCraftingComponent(1));
                    }

                    item = bag;
                    break;

                case 2: item = new MiniatureHouse(); break;

                case 3:                        switch (m_TreasurePileLevel)
                    {
                    case 1: item = new TreasurePileSmallAddonDeed(); break;

                    case 2: item = new TreasurePileMediumAddonDeed(); break;

                    case 3: item = new TreasurePileLargeAddonDeed(); break;

                    case 4: item = new TreasurePileHugeAddonDeed(); break;
                    }
                    break;

                case 4: item = new MiniatureTree(); break;

                //case 5: item = DungeonArmor.CreateDungeonArmor(DungeonEnum.None, DungeonArmor.ArmorTierEnum.Tier1, DungeonArmor.ArmorLocation.Unspecified); break;
                case 6: item = new MiniatureFountain(); break;
                    //case 7: item = new DungeonArmorUpgradeHammer(); break;


                    break;
                }

                if (item != null)
                {
                    if (pm_From.AddToBackpack(item))
                    {
                        pm_From.SendMessage("You retrieve an item from the fountain!");
                        pm_From.PlaySound(0x025);

                        return;
                    }

                    else
                    {
                        item.MoveToWorld(from.Location, from.Map);

                        pm_From.PlaySound(0x025);
                        pm_From.SendMessage("You retrieve an item from the fountain! Your pack, however, was full and the item has been placed at your feet.");

                        return;
                    }
                }

                int waterCount = Utility.RandomMinMax(1, 2);
                for (int a = 0; a < waterCount; a++)
                {
                    TimedStatic water = new TimedStatic(Utility.RandomList(4650, 4651, 4653, 4654, 4655), 10);
                    water.Name = "foul water";
                    water.Hue  = 1107;

                    Point3D waterLocation = new Point3D(Location.X + Utility.RandomMinMax(-1, 1), Location.Y + Utility.RandomMinMax(-1, 1), Location.Z);

                    SpellHelper.AdjustField(ref waterLocation, Map, 12, false);
                    water.MoveToWorld(waterLocation, Map);
                }
            }

            else
            {
                if (Utility.RandomDouble() <= .25)
                {
                    PublicOverheadMessage(MessageType.Regular, 0, false, "something ancient stirs from within the fountain!");

                    int waterCount = Utility.RandomMinMax(3, 5);
                    for (int a = 0; a < waterCount; a++)
                    {
                        TimedStatic water = new TimedStatic(Utility.RandomList(4650, 4651, 4653, 4654, 4655), 10);
                        water.Name = "foul water";
                        water.Hue  = 1107;

                        Point3D waterLocation = new Point3D(Location.X + Utility.RandomMinMax(-2, 2), Location.Y + Utility.RandomMinMax(-2, 2), Location.Z);

                        SpellHelper.AdjustField(ref waterLocation, Map, 12, false);
                        water.MoveToWorld(waterLocation, Map);
                    }

                    int creatureCount = 0;

                    double result = Utility.RandomDouble();

                    if (result < .10)
                    {
                        creatureCount = 1;

                        for (int a = 0; a < creatureCount; a++)
                        {
                            new FountainOfEvil().MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else if (result < .15)
                    {
                        creatureCount = Utility.RandomMinMax(1, 2);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            new ElderWaterElemental().MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else if (result < .20)
                    {
                        creatureCount = Utility.RandomMinMax(1, 2);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            new ElderToxicElemental().MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else if (result < .25)
                    {
                        creatureCount = Utility.RandomMinMax(1, 2);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            new ElderPoisonElemental().MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else if (result < .50)
                    {
                        creatureCount = Utility.RandomMinMax(2, 4);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            WaterElemental waterElemental = new WaterElemental();
                            waterElemental.Hue  = 1107;
                            waterElemental.Name = "foul water";
                            waterElemental.MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else if (result < .75)
                    {
                        creatureCount = Utility.RandomMinMax(2, 4);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            new VoidSlime().MoveToWorld(from.Location, from.Map);
                        }
                    }

                    else
                    {
                        creatureCount = Utility.RandomMinMax(3, 5);

                        for (int a = 0; a < creatureCount; a++)
                        {
                            Puddle foulPuddle = new Puddle();
                            foulPuddle.Hue  = 1107;
                            foulPuddle.Name = "foul puddle";
                            foulPuddle.MoveToWorld(from.Location, from.Map);
                        }
                    }

                    return;
                }

                else
                {
                    pm_From.SendMessage("You search the fountain but are unable to locate anything of value.");
                    return;
                }
            }
        }