示例#1
0
    public void UpdateChain()
    {
        SetReconstructButton(cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type) ?
                             ReconstructButtonStatus.PastPartLimit : ReconstructButtonStatus.Valid);
        var shellRect = ShipBuilder.GetRect(shellImage.rectTransform);

        shellRect.Expand(10);
        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            shipPart.isInChain = false;
            var partBounds = ShipBuilder.GetRect(shipPart.rectTransform);
            shipPart.isInChain = partBounds.Intersects(shellRect);
        }
        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (shipPart.isInChain)
            {
                UpdateChainHelper(shipPart);
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (!shipPart.isInChain || !shipPart.validPos)
            {
                SetReconstructButton(ReconstructButtonStatus.PartInvalidPosition);
                return;
            }
        }
    }
示例#2
0
    public static string GetDescription(Ability ability)
    {
        switch (ability.GetID())
        {
        case 10:
            return(DroneUtilities.GetDescriptionByType((ability as SpawnDrone).spawnData.type));

        default:
            return(GetDescriptionByID(ability.GetID(), ability.GetTier(), ""));
        }
    }
示例#3
0
 private static string GetAHSpawnData(string data)
 {
     if (DroneUtilities.GetDroneSpawnDataByShorthand(data).drone != null)
     {
         return(DroneUtilities.GetDroneSpawnDataByShorthand(data).drone);
     }
     else
     {
         return(data);
     }
 }
示例#4
0
    public static string GetAbilityName(Ability ability)
    {
        switch (ability.GetID())
        {
        case 10:
            return(DroneUtilities.GetAbilityNameByType((ability as SpawnDrone).spawnData.type));

        default:
            return(GetAbilityNameByID(ability.GetID(), ""));
        }
    }
示例#5
0
    public static DroneSpawnData ParseDronePart(EntityBlueprint.PartInfo part)
    {
        if (part.abilityID != 10)
        {
            Debug.Log("Passed part is not a drone spawner!");
        }

        var data = DroneUtilities.GetDroneSpawnDataByShorthand(part.secondaryData);

        //JsonUtility.FromJsonOverwrite(part.secondaryData, data);
        return(data);
    }
示例#6
0
 public static Sprite GetAbilityImageByID(int ID, string secondaryData)
 {
     if (ID == 0)
     {
         return(null);
     }
     if (ID == 10)
     {
         DroneSpawnData data = DroneUtilities.GetDroneSpawnDataByShorthand(secondaryData);
         return(DroneUtilities.GetAbilitySpriteBySpawnData(data));
     }
     return(ResourceManager.GetAsset <Sprite>("AbilitySprite" + ID));
 }
示例#7
0
    public static Sprite GetAbilityImage(Ability ability)
    {
        var ID = ability.GetID();

        if (ID == 0)
        {
            return(null);
        }
        if (ID == 10)
        {
            return(DroneUtilities.GetAbilitySpriteBySpawnData((ability as SpawnDrone).spawnData));
        }
        return(ResourceManager.GetAsset <Sprite>("AbilitySprite" + ID));
    }
 public override void AssignDisplay(EntityBlueprint blueprint, DroneSpawnData data, int faction = 0)
 {
     base.AssignDisplay(blueprint, data);
     statsDisplay.gameObject.SetActive(true);
     droneDesc.enabled = true;
     droneDesc.text    = ("DRONE TYPE: " + data.type).ToUpper()
                         + "\nUNIQUE CHARACTERISTIC:\n" + "<color=lime>"
                         + DroneUtilities.GetUniqueCharacteristic(data.type) + "</color>"
                         + "\nPART LIMIT: " + DroneUtilities.GetPartLimit(data.type)
                         + "\nSPAWNING COOLDOWN: " + DroneUtilities.GetCooldown(data.type)
                         + "\nSPAWNING DELAY: " + DroneUtilities.GetDelay(data.type)
                         + "\nSPAWNING ENERGY COST: " + DroneUtilities.GetEnergyCost(data.type);
     foreach (DisplayPart part in parts)
     {
         buildValue += EntityBlueprint.GetPartValue(part.info);
     }
 }
示例#9
0
    public void Deinitialize()
    {
        if (cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type))
        {
            return;
        }
        bool invalidState = false;

        foreach (ShipBuilderPart part in cursorScript.parts)
        {
            if (!part.validPos || !part.isInChain)
            {
                invalidState = true;
                break;
            }
        }
        if (!invalidState)
        {
            Export();
            CloseUI(true);
        }
    }
    public override void AssignDisplay(EntityBlueprint blueprint, DroneSpawnData data, int faction = 0)
    {
        base.AssignDisplay(blueprint, data);
        statsDisplay.gameObject.SetActive(true);
        droneDesc.enabled = true;

        string description = string.Join("\n", new string[]
        {
            ($"DRONE TYPE: {data.type}").ToUpper(),
            "UNIQUE CHARACTERISTIC:",
            $"<color=lime>{DroneUtilities.GetUniqueCharacteristic(data.type)}</color>",
            $"PART LIMIT: {DroneUtilities.GetPartLimit(data.type)}",
            $"SPAWNING COOLDOWN: {DroneUtilities.GetCooldown(data.type)}",
            $"SPAWNING DELAY: {DroneUtilities.GetDelay(data.type)}",
            $"SPAWNING ENERGY COST: {DroneUtilities.GetEnergyCost(data.type)}",
        });

        droneDesc.text = description;

        foreach (DisplayPart part in parts)
        {
            buildValue += EntityBlueprint.GetPartValue(part.info);
        }
    }
示例#11
0
    void Start()
    {
        for (int i = 0; i < itemHandler.itemPack.items.Count; i++)
        {
            var buttonObj = Instantiate(betterBarButtonPrefab, betterBarContents, false);
            var x         = i;
            buttonObj.AddComponent <Button>().onClick.AddListener(new UnityAction(() => {
                currentActiveButton = x;
                cursor.SetCurrent(x);
            }));
            var img = buttonObj.GetComponent <Image>();
            images.Add(img);
            if (itemHandler.itemPack.items[i].assetID != "")
            {
                if (ResourceManager.Instance.resourceExists(itemHandler.itemPack.items[i].assetID) &&
                    ResourceManager.GetAsset <Object>(itemHandler.itemPack.items[i].assetID) as EntityBlueprint)
                {
                    var print = ResourceManager.GetAsset <EntityBlueprint>(itemHandler.itemPack.items[i].assetID);
                    buttonObj.transform.Find("MaskObj").Find("StandardImage").gameObject.SetActive(false);
                    var scaler = buttonObj.transform.Find("MaskObj").Find("EntityDisplay").transform;

                    switch (print.intendedType)
                    {
                    case EntityBlueprint.IntendedType.AirCarrier:
                    case EntityBlueprint.IntendedType.GroundCarrier:
                    case EntityBlueprint.IntendedType.Yard:
                    case EntityBlueprint.IntendedType.Trader:
                    case EntityBlueprint.IntendedType.WeaponStation:
                    case EntityBlueprint.IntendedType.CoreUpgrader:
                    case EntityBlueprint.IntendedType.DroneWorkshop:
                        scaler.localScale = new Vector3(0.15f, 0.15f, 1);
                        break;

                    default:
                        scaler.localScale = new Vector3(0.3f, 0.3f, 1);
                        break;
                    }

                    var sdh = buttonObj.GetComponentInChildren <SelectionDisplayHandler>();
                    sdh.AssignDisplay(print, print.intendedType == EntityBlueprint.IntendedType.Drone ? DroneUtilities.GetDefaultData(print.customDroneType) : null);
                }
                else
                {
                    var obj = itemHandler.itemPack.items[i].obj;
                    SetStandardImage(obj, buttonObj, 0.5f);
                }
            }
            else
            {
                var obj = itemHandler.itemPack.items[i].obj;
                SetStandardImage(obj, buttonObj, 0.5f);
            }
        }

        for (int i = 0; i < globalButtons.Count; i++)
        {
            AddOptionButton(i, globalButtons);
        }

        for (int i = 0; i < extraButtons.Count; i++)
        {
            AddOptionButton(i, extraButtons);
        }
        UpdateActiveButtons();
    }
示例#12
0
    protected ShellPart SetUpPart(EntityBlueprint.PartInfo part)
    {
        var           drone         = this as Drone;
        var           isLightDrone  = drone && drone.type == DroneType.Light; // used for light drone weight reduction
        PartBlueprint partBlueprint = ResourceManager.GetAsset <PartBlueprint>(part.partID);

        GameObject partObject = ShellPart.BuildPart(partBlueprint);
        ShellPart  shellPart  = partObject.GetComponent <ShellPart>();

        shellPart.info = part;
        partObject.transform.SetParent(transform, false);
        partObject.transform.SetAsFirstSibling();

        //Add an ability to the part:

        WeaponAbility ab = AbilityUtilities.AddAbilityToGameObjectByID(partObject, part.abilityID, part.secondaryData, part.tier) as WeaponAbility;

        if (ab)
        {
            // add weapon diversity
            ab.type = DroneUtilities.GetDiversityTypeByEntity(this);
        }

        partObject.transform.localEulerAngles = new Vector3(0, 0, part.rotation);
        partObject.transform.localPosition    = new Vector3(part.location.x, part.location.y, 0);
        SpriteRenderer sr  = partObject.GetComponent <SpriteRenderer>();
        var            tmp = partObject.transform.localScale;

        tmp.x = part.mirrored ? -1 : 1;
        partObject.transform.localScale = tmp;
        sr.sortingOrder = ++sortingOrder;
        var partWeight = isLightDrone ? partBlueprint.mass * 0.6F * weightMultiplier : partBlueprint.mass * weightMultiplier;

        weight       += partWeight;
        maxHealth[0] += partBlueprint.health / 2;
        maxHealth[1] += partBlueprint.health / 4;

        string shooterID = AbilityUtilities.GetShooterByID(part.abilityID, part.secondaryData);

        // Add shooter
        if (shooterID != null)
        {
            var shooter = new GameObject("Shooter");
            shooter.transform.SetParent(partObject.transform);
            shooter.transform.localPosition = Vector3.zero;
            shooter.transform.localRotation = Quaternion.identity;
            var shooterSprite = shooter.AddComponent <SpriteRenderer>();
            shooterSprite.sprite = ResourceManager.GetAsset <Sprite>(shooterID);
            shellPart.shooter    = shooter;
            if (AbilityUtilities.GetAbilityTypeByID(part.abilityID) == AbilityHandler.AbilityTypes.Weapons)
            {
                shellPart.weapon = true;
            }
        }

        var weaponAbility = partObject.GetComponent <WeaponAbility>();

        if (weaponAbility)
        {
            // if the terrain and category wasn't preset set to the enitity's properties

            if (weaponAbility.terrain == TerrainType.Unset)
            {
                weaponAbility.terrain = Terrain;
            }

            if (weaponAbility.category == EntityCategory.Unset)
            {
                weaponAbility.category = category;
            }
        }

        var shellRenderer = transform.Find("Shell Sprite").GetComponent <SpriteRenderer>();

        if (shellRenderer)
        {
            shellRenderer.sortingOrder = ++sortingOrder;
        }

        var coreRenderer = GetComponent <SpriteRenderer>();

        if (coreRenderer)
        {
            coreRenderer.sortingOrder = ++sortingOrder;
        }

        parts.Add(partObject.GetComponent <ShellPart>());
        if (partObject.GetComponent <Ability>())
        {
            abilities.Insert(0, partObject.GetComponent <Ability>());
        }

        // Disable collider if no sprite
        if (!(partObject.GetComponent <SpriteRenderer>() && partObject.GetComponent <SpriteRenderer>().sprite) &&
            partObject.GetComponent <Collider2D>() && !partObject.GetComponent <Harvester>())
        {
            partObject.GetComponent <Collider2D>().enabled = false;
        }

        return(partObject.GetComponent <ShellPart>());
    }
示例#13
0
    public static Ability AddAbilityToGameObjectByID(GameObject obj, int ID, string data = null, int tier = 0)
    {
        Ability ability = null;

        switch (ID)
        {
        case 1:
            ability = obj.AddComponent <SpeedThrust>();
            break;

        case 2:
            ability = obj.AddComponent <HealthHeal>();
            ((HealthHeal)ability).type = HealthHeal.HealingType.shell;
            ((HealthHeal)ability).Initialize();
            break;

        case 3:
            Debug.LogWarning("Main bullet should be intrinsically added!");
            ability = obj.AddComponent <MainBullet>();
            break;

        case 4:
            ability = obj.AddComponent <Beam>();
            break;

        case 5:
            ability = obj.AddComponent <Bullet>();
            break;

        case 6:
            ability = obj.AddComponent <Cannon>();
            break;

        case 7:
            ability = obj.AddComponent <Missile>();
            if (data == "missile_station_shooter")
            {
                ((Missile)ability).category = Entity.EntityCategory.All;
                ((Missile)ability).terrain  = Entity.TerrainType.All;
            }

            break;

        case 8:
            ability = obj.AddComponent <Torpedo>();
            break;

        case 9:
            ability = obj.AddComponent <Laser>();
            break;

        case 10:
            ability = obj.AddComponent <SpawnDrone>();
            ((SpawnDrone)ability).spawnData = DroneUtilities.GetDroneSpawnDataByShorthand(data);
            ((SpawnDrone)ability).Init();
            break;

        case 11:
            ability = obj.AddComponent <HealthHeal>();
            ((HealthHeal)ability).type = HealthHeal.HealingType.core;
            ((HealthHeal)ability).Initialize();
            break;

        case 12:
            ability = obj.AddComponent <HealthHeal>();
            ((HealthHeal)ability).type = HealthHeal.HealingType.energy;
            ((HealthHeal)ability).Initialize();
            break;

        case 13:
            ability = obj.AddComponent <Speed>();
            break;

        case 14:
            ability = obj.AddComponent <SiegeBullet>();
            break;

        case 15:
            ability = obj.AddComponent <SpeederBullet>();
            break;

        case 16:
            ability = obj.AddComponent <Harvester>();
            break;

        case 17:
            ability = obj.AddComponent <ShellRegen>();
            (ability as ShellRegen).index = 0;
            (ability as ShellRegen).Initialize();
            break;

        case 18:
            ability = obj.AddComponent <ShellMax>();
            (ability as ShellMax).index = 0;
            (ability as ShellMax).Initialize();
            break;

        case 19:
            ability = obj.AddComponent <ShellRegen>();
            (ability as ShellRegen).index = 2;
            (ability as ShellRegen).Initialize();
            break;

        case 20:
            ability = obj.AddComponent <ShellMax>();
            (ability as ShellMax).index = 2;
            (ability as ShellMax).Initialize();
            break;

        case 21:
            ability = obj.AddComponent <Command>();
            break;

        case 22:
            ability = obj.AddComponent <ShellRegen>();
            (ability as ShellRegen).index = 1;
            (ability as ShellRegen).Initialize();
            break;

        case 23:
            ability = obj.AddComponent <ShellMax>();
            (ability as ShellMax).index = 1;
            (ability as ShellMax).Initialize();
            break;

        case 24:
            ability = obj.AddComponent <Stealth>();
            break;

        case 25:
            ability = obj.AddComponent <DamageBoost>();
            break;

        case 26:
            ability = obj.AddComponent <AreaRestore>();
            break;

        case 27:
            ability = obj.AddComponent <PinDown>();
            break;

        case 28:
            ability = obj.AddComponent <Retreat>();
            break;

        case 29:
            ability = obj.AddComponent <AbsorptionField>();
            break;

        case 30:
            ability = obj.AddComponent <ActiveRegen>();
            (ability as ActiveRegen).index = 0;
            (ability as ActiveRegen).Initialize();
            break;

        case 31:
            ability = obj.AddComponent <ActiveRegen>();
            (ability as ActiveRegen).index = 1;
            (ability as ActiveRegen).Initialize();
            break;

        case 32:
            ability = obj.AddComponent <ActiveRegen>();
            (ability as ActiveRegen).index = 2;
            (ability as ActiveRegen).Initialize();
            break;

        case 33:
            ability = obj.AddComponent <Disrupt>();
            break;

        case 34:
            ability = obj.AddComponent <Control>();
            break;

        case 35:
            ability = obj.AddComponent <InvertTractor>();
            break;

        case 36:
            ability = obj.AddComponent <Bomb>();
            break;

        case 37:
            ability = obj.AddComponent <Ion>();
            break;

        case 38:
            ability = obj.AddComponent <Flak>();
            break;

        case 39:
            ability = obj.AddComponent <Rocket>();
            break;
        }

        if (ability)
        {
            ability.SetTier(tier);
        }

        return(ability);
    }
示例#14
0
    public void EnterCommand(string command)
    {
        inputField.text = "";
        inputField.ActivateInputField();

        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "SampleScene")
        {
            if (command.Equals("poor", StringComparison.CurrentCultureIgnoreCase))
            {
                GodPowers();
                textBox.text += "\n<color=lime>Have you tried being born into wealth?</color>";
            }
            else if (command.Equals("I am God", StringComparison.CurrentCultureIgnoreCase))
            {
                GodPowers();
                var player = PlayerCore.Instance;
                player.AddCredits(999999);
                textBox.text += "\n<color=lime>I am noob.</color>";
            }
            else if (command.Equals("Immortality", StringComparison.CurrentCultureIgnoreCase))
            {
                var player = PlayerCore.Instance;
                player.SetMaxHealth(new float[] { 99999, 99999, 99999 }, true);
                player.SetRegens(new float[] { 99999, 99999, 99999 });
                textBox.text += "\n<color=lime>Immortality is an illusion, enjoy it while it lasts.</color>";
            }
            else if (command.Equals("Skynet will rise", StringComparison.CurrentCultureIgnoreCase))
            {
                SectorManager.instance.Clear();
                SectorManager.instance.LoadSectorFile(System.IO.Path.Combine(Application.streamingAssetsPath, "Sectors/AI-Test"));
                PlayerCore.Instance.Warp(Vector3.zero);
                textBox.text += "\n<color=lime>I, for one, welcome our new robotic overlords.</color>";
            }
            else if (command.StartsWith("Add power ", StringComparison.CurrentCultureIgnoreCase))
            {
                int number = int.Parse(command.Substring(10).Trim());
                if (PlayerCore.Instance)
                {
                    PlayerCore.Instance.AddPower(number);
                }
                else
                {
                    foreach (ShellCore core in AIData.entities)
                    {
                        if (core)
                        {
                            core.AddPower(number);
                        }
                    }
                }
            }
            else if (command.StartsWith("Add rep ", StringComparison.CurrentCultureIgnoreCase))
            {
                int number = int.Parse(command.Substring(8).Trim());
                PlayerCore.Instance.reputation += number;
            }
            else if (command.StartsWith("Add shards ", StringComparison.CurrentCultureIgnoreCase))
            {
                int number = int.Parse(command.Substring(11).Trim());
                PlayerCore.Instance.shards += number;
            }
            else if (command.StartsWith("Add money ", StringComparison.CurrentCultureIgnoreCase))
            {
                int number = int.Parse(command.Substring(10).Trim());
                PlayerCore.Instance.AddCredits(number);
            }
            else if (command.Equals("Full log", StringComparison.CurrentCultureIgnoreCase))
            {
                fullLog       = true;
                textBox.text += "\n<color=lime>I see all, I know all</color>";
            }
            else if (command.Equals("Commit sudoku", StringComparison.CurrentCultureIgnoreCase))
            {
                PlayerCore.Instance.TakeCoreDamage(float.MaxValue);
                textBox.text += "\n<color=lime>Die, die, die!</color>";
            }
            else if (command.StartsWith("Speed of light", StringComparison.CurrentCultureIgnoreCase))
            {
                int locNum = 0;
                if (command.Length > 14)
                {
                    bool success = int.TryParse(command.Substring(14).Trim(), out locNum);
                    if (!success)
                    {
                        Debug.Log("Wrong number format!");
                    }
                }

                // TODO: broke, fix

                /*
                 * if (locNum < TaskManager.objectiveLocations.Count)
                 * {
                 *  PlayerCore.Instance.Warp(TaskManager.objectiveLocations[locNum].location);
                 * }
                 */
                textBox.text += "\n<color=lime>Country roads, take me home. To the place I belong!</color>";
            }
            else if (command.Equals("Spectate", StringComparison.CurrentCultureIgnoreCase))
            {
                var player = PlayerCore.Instance;
                SpriteRenderer[] renderers = player.GetComponentsInChildren <SpriteRenderer>(true);
                for (int i = 0; i < renderers.Length; i++)
                {
                    renderers[i].color = new Color(1f, 1f, 1f, 0.1f);
                }

                spectateEnabled = true;
                Collider2D[] colliders = player.GetComponentsInChildren <Collider2D>(true);
                for (int i = 0; i < colliders.Length; i++)
                {
                    colliders[i].enabled = false;
                }

                player.GetComponent <TractorBeam>().enabled = false;
                player.GetAbilityHandler().Deinitialize();
                player.hud.DeinitializeHUD();
                player.IsInvisible = true;
                textBox.text      += "\n<color=lime>You can hide, but you can't run!</color>";
            }
            else if (command.Equals("Exit", StringComparison.CurrentCultureIgnoreCase))
            {
                textBox.enabled = image.enabled = !image.enabled;
                inputField.gameObject.SetActive(image.enabled);
            }
            else if (command.Equals("I am Ormanus", StringComparison.CurrentCultureIgnoreCase))
            {
                EnterCommand("I am god");
                EnterCommand("spectate");
                EnterCommand("skynet will rise");
            }
            else if (command.Equals("fps", StringComparison.CurrentCultureIgnoreCase))
            {
                textBox.text += $"\n{1f / Time.smoothDeltaTime}";
            }
            else if (command.Equals("parts please", StringComparison.CurrentCultureIgnoreCase))
            {
                ShipBuilder.heavyCheat = true;
                textBox.text          += "\n<color=lime>I just wanna equip DeadZone parts for god's sake.</color>";
            }
            else if (command.Equals("moar data", StringComparison.CurrentCultureIgnoreCase))
            {
                ReticleScript.instance.DebugMode = true;
            }
            else if (command.Equals("marco", StringComparison.CurrentCultureIgnoreCase))
            {
                MapMakerScript.EnableMapCheat();
                WarpingEnabled = true;
                textBox.text  += "\n<color=lime>Polo.</color>";
            }
            else if (command.Equals("caught em all", StringComparison.CurrentCultureIgnoreCase))
            {
                PartIndexScript.partsObtainedCheat = true;
                textBox.text += "\n<color=lime>There's a time and place for everything! But not now.</color>";
            }
            else if (command.Equals("counting cards", StringComparison.CurrentCultureIgnoreCase))
            {
                NodeEditorFramework.Standard.RandomizerNode.PrintRandomRolls = true;
                textBox.text += "\n<color=lime>Don't let the casino catch you!</color>";
            }
            else if (command.Equals("Update debug", StringComparison.CurrentCultureIgnoreCase))
            {
                updateLog     = true;
                textBox.text += "\n<color=lime>You're probably not gonna be able to see this.</color>";
            }
            else if (command.Equals("Damacy", StringComparison.CurrentCultureIgnoreCase))
            {
                /* Adds all part/ability/tier/drone permutations to the player's inventory.*/
                var parts = PlayerCore.Instance.GetInventory();
                EntityBlueprint.PartInfo info;
                for (int i = 0; i < 8; i++)
                {
                    info           = new EntityBlueprint.PartInfo();
                    info.partID    = "SmallCenter1";
                    info.abilityID = 10;
                    DroneSpawnData data = DroneUtilities.GetDefaultData((DroneType)i);
                    info.secondaryData = JsonUtility.ToJson(data);
                    if (info.abilityID == 0 || info.abilityID == 10)
                    {
                        info.tier = 0;
                    }

                    parts.Add(info);
                }

                info = new EntityBlueprint.PartInfo();
                foreach (string name in ResourceManager.allPartNames)
                {
                    for (int i = 0; i < 38; i++)
                    {
                        info.partID    = name;
                        info.abilityID = i;
                        if ((info.abilityID >= 14 && info.abilityID <= 16) || info.abilityID == 3)
                        {
                            info.abilityID = 0;
                        }

                        if (info.abilityID == 10)
                        {
                            DroneSpawnData data = DroneUtilities.GetDefaultData((DroneType)UnityEngine.Random.Range(0, 8));
                            info.secondaryData = JsonUtility.ToJson(data);
                        }

                        if (info.abilityID == 0 || info.abilityID == 10 || info.abilityID == 21)
                        {
                            info.tier = 0;
                        }
                        else
                        {
                            info.tier = 1;
                        }

                        parts.Add(info);
                        parts.Add(info);
                        parts.Add(info);
                    }
                }

                textBox.text += "\n<color=lime>Katamete korogasu I LOVE YOU!</color>";
            }
            else if (command.Equals("Win siege", StringComparison.CurrentCultureIgnoreCase))
            {
                NodeEditorFramework.Standard.WinSiegeCondition.OnSiegeWin.Invoke(SectorManager.instance.current.sectorName);
            }
            else if (command.Equals("No limits", StringComparison.CurrentCultureIgnoreCase))
            {
                if (PlayerCore.Instance?.cursave != null)
                {
                    PlayerCore.Instance.cursave.abilityCaps = PlayerCore.Instance.abilityCaps = new int[] { 99999, 99999, 99999, 99999 };
                    textBox.text += "\n<color=lime>Ouch, now I have a headache.</color>";
                }
            }
            else if (command.Equals("I am an uncivilized barbarian", StringComparison.CurrentCultureIgnoreCase))
            {
                if (PlayerCore.Instance)
                {
                    PlayerCore.Instance.SetWeaponGCD(0);
                    textBox.text += "\n<color=lime>Heathen.</color>";
                }
            }
        }
        else if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "MainMenu")
        {
            if (command.StartsWith("Load ", StringComparison.CurrentCultureIgnoreCase))
            {
                string directory = command.Substring(5).Trim();
                string finalPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Sectors", directory);
                if (System.IO.Directory.Exists(finalPath))
                {
                    SectorManager.customPath    = finalPath;
                    VersionNumberScript.version = directory + " [Custom]";
                    VersionNumberScript.Refresh();
                    textBox.text += "\n<color=lime>Custom world loaded!</color>";
                }
                else
                {
                    textBox.text += "\n<color=orange>Invalid path.</color>";
                }
            }
        }
    }
示例#15
0
    public static string GetDescriptionByID(int ID, int tier, string secondaryData)
    {
        switch (ID)
        {
        case 0:
            return("Does nothing.");

        case 1:
            return($"+{SpeedThrust.boost * tier} speed for 10 seconds.");

        case 2:
            return($"Instantly heal {HealthHeal.heals[0] * tier} shell.");

        case 3:
            return($"Projectile that deals {MainBullet.GetDamage(tier)} damage. \nStays with you no matter what.");

        case 4:
            return($"Instant attack that deals {Beam.beamDamage * tier} damage.");

        case 5:
            return($"Projectile that deals {Bullet.bulletDamage * tier} damage.");

        case 6:
            return($"Instant attack that deals {Cannon.cannonDamage * tier} damage.");

        case 7:
            return($"Slow homing projectile that deals {Missile.missileDamage * tier} damage.");

        case 8:
            return($"Slow projectile that deals {Torpedo.torpedoDamage * tier} damage to ground entities.");

        case 9:
            return($"Fast projectile that deals {Laser.laserDamage * tier} damage. 25% pierces to core.");

        case 10:
            if (string.IsNullOrEmpty(secondaryData))
            {
                return("Spawns a drone.");
            }

            DroneSpawnData data = DroneUtilities.GetDroneSpawnDataByShorthand(secondaryData);
            return(DroneUtilities.GetDescriptionByType(data.type));

        case 11:
            return($"Instantly heal {HealthHeal.heals[1] * tier} core.");

        case 12:
            return($"Instantly heal {HealthHeal.heals[2] * tier} energy.");

        case 13:
            return($"+{Speed.boost * tier} speed.");

        case 17:
            return($"Passively increases shell regen by {ShellRegen.regens[0] * tier} points.");

        case 18:
            return($"Passively increases maximum shell by {ShellMax.maxes[0] * tier} points.");

        case 19:
            return($"Passively increases energy regen by {ShellRegen.regens[2] * tier} points.");

        case 20:
            return($"Passively increases maximum energy by {ShellMax.maxes[2] * tier} points.");

        case 21:
            return($"Passively increases the maximum allowed number of controlled units by {Command.commandUnitIncrease}.");

        case 22:
            return($"Passively increases core regen by {ShellRegen.regens[1] * tier} points.");

        case 23:
            return($"Passively increases maximum core by {ShellMax.maxes[1] * tier} points.");

        case 24:
            return("Become invisible to enemies.");

        case 25:
            return($"All weapon damage increased by {DamageBoost.damageAddition * Mathf.Max(1, tier)}.");

        case 26:
            return($"Instantly heals self and nearby allies by {AreaRestore.heal * Mathf.Max(1, tier)} shell");

        case 27:
            return("Immobilizes the target.");

        case 28:
            return("Respawn at base.");

        case 29:
            return("Absorb damage and turn it into energy.");

        case 30:
            return($"Temporarily increase shell regen by { ActiveRegen.healAmounts[0] } per second.");

        case 31:
            return("Temporarily increase core... wait, this isn't supposed to exist!");

        case 32:
            return($"Temporarily increase energy regen by { ActiveRegen.healAmounts[2] } per second.");

        case 33:
            return("Disrupt enemy ability cooldowns.");

        case 34:
            return($"Gives allies additional {Control.baseControlFractionBoost * 100}% shell and {Control.damageAddition} weapon damage.");

        case 35:
            return("Temporarily pulls you to your tractor target and allows you to tractor most entities.");

        case 36:
            return($"Stationary projectile that deals {Bomb.bombDamage} damage. \nProjectile lasts {45F * tier} seconds.");

        case 37:
            return($"Slow moving beam that deals {IonLineController.damageC * tier} damage per second for 5 seconds. "
                   + $"\nBeam costs {IonLineController.energyC * tier} energy per second.");

        case 38:
            return($"Fires at most 5 projectiles at different targets that each deal {Flak.bulletDamage * tier} damage.");

        default:
            return("Description unset");
        }
    }
示例#16
0
    public void UpdateChain()
    {
        SetReconstructButton(cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type) ? ReconstructButtonStatus.PastPartLimit : ReconstructButtonStatus.Valid);

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            shipPart.isInChain = false;
            CheckPartIntersectsWithShell(shipPart);
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (shipPart.isInChain)
            {
                UpdateChainHelper(shipPart);
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            CheckPartIntersectsWithShell(shipPart);
        }

        foreach (ShipBuilderPart part in cursorScript.parts)
        {
            if (part.validPos)
            {
                foreach (var part2 in cursorScript.parts)
                {
                    if (part != part2 && PartIsTooClose(part, part2))
                    {
                        part.validPos = false;
                        break;
                    }
                }
            }
            else
            {
                bool stillTouching = false;
                foreach (ShipBuilderPart part2 in cursorScript.parts)
                {
                    if (part2 != part && PartIsTooClose(part, part2))
                    {
                        stillTouching = true;
                        break;
                    }
                }

                if (!stillTouching)
                {
                    part.validPos = true;
                }
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (!shipPart.isInChain || !shipPart.validPos)
            {
                SetReconstructButton(ReconstructButtonStatus.PartInvalidPosition);
                return;
            }
        }
    }
示例#17
0
    /// <summary>
    /// Generate shell parts in the blueprint, change ship stats accordingly
    /// </summary>
    protected virtual void BuildEntity()
    {
        // all created entities should have blueprints!
        if (!blueprint)
        {
            Debug.LogError(this + " does not have a blueprint! EVERY constructed entity should have one!");
        }

        DestroyOldParts();

        parts.Clear();
        blueprint.shellHealth.CopyTo(maxHealth, 0);
        blueprint.baseRegen.CopyTo(regenRate, 0);

        if (blueprint)
        {
            this.dialogue = blueprint.dialogue;
        }

        AttemptAddComponents();
        var renderer = GetComponent <SpriteRenderer>();

        if (blueprint)
        { // check if it contains a blueprint (it should)
            if (blueprint.coreSpriteID == "" && blueprint.intendedType == EntityBlueprint.IntendedType.ShellCore)
            {
                Debug.Log(this + "'s blueprint does not contain a core sprite ID!");
                // check if the blueprint does not contain a core sprite ID (it should)
            }
            renderer.sprite = ResourceManager.GetAsset <Sprite>(blueprint.coreSpriteID);
        }
        else
        {
            renderer.sprite = ResourceManager.GetAsset <Sprite>("core1_light");
        }
        renderer.sortingOrder = 101;

        renderer = transform.Find("Minimap Image").GetComponent <SpriteRenderer>();
        if (category == EntityCategory.Station && !(this is Turret))
        {
            if (this as Outpost)
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("outpost_minimap_sprite");
            }
            else if (this as Bunker)
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("bunker_minimap_sprite");
            }
            else
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("minimap_sprite");
            }
            renderer.transform.localScale = new Vector3(3.5F, 3.5F, 3.5F);
        }
        else
        {
            renderer.sprite = ResourceManager.GetAsset <Sprite>("minimap_sprite");
        }


        abilities = new List <Ability>();

        entityName = blueprint.entityName;
        name       = blueprint.entityName;
        GetComponent <Rigidbody2D>().mass = 1; // reset mass
        weight = this as Drone ? 25 : coreWeight;

        var isLightDrone = this as Drone && (this as Drone).type == DroneType.Light; // used for light drone weight reduction

        //For shellcores, create the tractor beam
        // Create shell parts
        if (blueprint != null)
        {
            for (int i = 0; i < blueprint.parts.Count; i++)
            {
                EntityBlueprint.PartInfo part          = blueprint.parts[i];
                PartBlueprint            partBlueprint = ResourceManager.GetAsset <PartBlueprint>(part.partID);

                GameObject partObject = ShellPart.BuildPart(partBlueprint);
                ShellPart  shellPart  = partObject.GetComponent <ShellPart>();
                shellPart.info = part;
                partObject.transform.SetParent(transform, false);
                partObject.transform.SetAsFirstSibling();

                //Add an ability to the part:

                WeaponAbility ab = AbilityUtilities.AddAbilityToGameObjectByID(partObject, part.abilityID, part.secondaryData, part.tier) as WeaponAbility;
                if (ab)  // add weapon diversity
                {
                    ab.type = DroneUtilities.GetDiversityTypeByEntity(this);
                }
                partObject.transform.localEulerAngles = new Vector3(0, 0, part.rotation);
                partObject.transform.localPosition    = new Vector3(part.location.x, part.location.y, 0);
                SpriteRenderer sr = partObject.GetComponent <SpriteRenderer>();
                // sr.flipX = part.mirrored; this doesn't work, it does not flip the collider hitbox
                var tmp = partObject.transform.localScale;
                tmp.x = part.mirrored ? -1 : 1;
                partObject.transform.localScale = tmp;
                sr.sortingOrder = i + 2;
                //entityBody.mass += (isLightDrone ? partBlueprint.mass * 0.6F : partBlueprint.mass);
                var partWeight = isLightDrone ? partBlueprint.mass * 0.6F * weightMultiplier : partBlueprint.mass * weightMultiplier;
                weight       += partWeight;
                maxHealth[0] += partBlueprint.health / 2;
                maxHealth[1] += partBlueprint.health / 4;

                // Drone shell and core health penalty
                if (this as Drone)
                {
                    maxHealth[0] /= 2;
                    maxHealth[1] /= 4;
                }

                string shooterID = AbilityUtilities.GetShooterByID(part.abilityID, part.secondaryData);
                // Add shooter
                if (shooterID != null)
                {
                    var shooter = new GameObject("Shooter");
                    shooter.transform.SetParent(partObject.transform);
                    shooter.transform.localPosition = Vector3.zero;
                    var shooterSprite = shooter.AddComponent <SpriteRenderer>();
                    shooterSprite.sprite = ResourceManager.GetAsset <Sprite>(shooterID);
                    // if(blueprint.parts.Count < 2) shooterSprite.sortingOrder = 500; TODO: Figure out what these lines do
                    // shooterSprite.sortingOrder = sr.sortingOrder + 1;
                    shooterSprite.sortingOrder = 500;
                    shellPart.shooter          = shooter;
                    if (AbilityUtilities.GetAbilityTypeByID(part.abilityID) == AbilityHandler.AbilityTypes.Weapons)
                    {
                        shellPart.weapon = true;
                    }
                }

                var weaponAbility = partObject.GetComponent <WeaponAbility>();
                if (weaponAbility)
                {
                    // if the terrain and category wasn't preset set to the enitity's properties

                    if (weaponAbility.terrain == TerrainType.Unset)
                    {
                        weaponAbility.terrain = Terrain;
                    }
                    if (weaponAbility.category == EntityCategory.Unset)
                    {
                        weaponAbility.category = category;
                    }
                }


                parts.Add(partObject.GetComponent <ShellPart>());
                if (partObject.GetComponent <Ability>())
                {
                    abilities.Insert(0, partObject.GetComponent <Ability>());
                }

                // Disable collider if no sprite
                if (!(partObject.GetComponent <SpriteRenderer>() && partObject.GetComponent <SpriteRenderer>().sprite) &&
                    partObject.GetComponent <Collider2D>() && !partObject.GetComponent <Harvester>())
                {
                    partObject.GetComponent <Collider2D>().enabled = false;
                }
            }
        }

        if (this as ShellCore)
        {
            if (!gameObject.GetComponentInChildren <MainBullet>())
            {
                MainBullet mainBullet = gameObject.AddComponent <MainBullet>();
                mainBullet.SetTier(Mathf.Min(3, 1 + CoreUpgraderScript.GetCoreTier(blueprint.coreShellSpriteID)));
                mainBullet.bulletPrefab = ResourceManager.GetAsset <GameObject>("bullet_prefab");
                mainBullet.terrain      = TerrainType.Air;
                mainBullet.SetActive(true);
                abilities.Insert(0, mainBullet);
            }
            else
            {
                MainBullet mainBullet = gameObject.GetComponentInChildren <MainBullet>();
                mainBullet.SetTier(Mathf.Min(3, 1 + CoreUpgraderScript.GetCoreTier(blueprint.coreShellSpriteID)));
                mainBullet.SetDestroyed(false);
                abilities.Insert(0, mainBullet);
            }
        }

        // unique abilities for mini and worker drones here
        if (this as Drone)
        {
            Drone drone = this as Drone;
            switch (drone.type)
            {
            case DroneType.Mini:
                var     shellObj = transform.Find("Shell Sprite").gameObject;
                Ability ab       = AbilityUtilities.AddAbilityToGameObjectByID(shellObj, 6, null, 1);
                var     shooter  = new GameObject("Shooter");
                shooter.transform.SetParent(shellObj.transform);
                shooter.transform.localPosition = Vector3.zero;
                var shooterSprite = shooter.AddComponent <SpriteRenderer>();
                shooterSprite.sprite       = ResourceManager.GetAsset <Sprite>(AbilityUtilities.GetShooterByID(6));
                shooterSprite.sortingOrder = 500;
                shellObj.GetComponent <ShellPart>().shooter = shooter;
                (ab as WeaponAbility).terrain = TerrainType.Air;
                abilities.Insert(0, ab);
                break;

            default:
                break;
            }
        }
        IsInvisible = false;

        // check to see if the entity is interactible
        if (dialogue && faction == 0)
        {
            interactible = true;
        }

        Transform shellSprite = shell.transform;

        if (shellSprite)
        {
            parts.Add(shellSprite.GetComponent <ShellPart>());
        }
        ConnectedTreeCreator();

        maxHealth.CopyTo(currentHealth, 0);
        ActivatePassives(); // activate passive abilities here to avoid race condition BS

        if (OnEntitySpawn != null)
        {
            OnEntitySpawn.Invoke(this);
        }
    }
示例#18
0
    public static string GetAbilityNameByID(int ID, string secondaryData)
    {
        switch (ID)
        {
        case 0:
            return("None");

        case 1:
            return("Speed Thrust");

        case 2:
            return("Shell Boost");

        case 3:
            return("Main Bullet");

        case 4:
            return("Beam");

        case 5:
            return("Bullet");

        case 6:
            return("Cannon");

        case 7:
            return("Missile");

        case 8:
            return("Torpedo");

        case 9:
            return("Laser");

        case 10:
            if (secondaryData == null)
            {
                return("Spawn Drone");
            }

            DroneSpawnData data = DroneUtilities.GetDroneSpawnDataByShorthand(secondaryData);
            return(DroneUtilities.GetAbilityNameByType(data.type));

        case 11:
            return("Core Heal");

        case 12:
            return("Energy");

        case 13:
            return("Speed");

        case 14:
            return("Siege Bullet");

        case 15:
            return("Speeder Bullet");

        case 16:
            return("Harvester");

        case 17:
            return("Shell Regen");

        case 18:
            return("Shell Max");

        case 19:
            return("Energy Regen");

        case 20:
            return("Energy Max");

        case 21:
            return("Command");

        case 22:
            return("Core Regen");

        case 23:
            return("Core Max");

        case 24:
            return("Stealth");

        case 25:
            return("Damage Boost");

        case 26:
            return("Area Restore");

        case 27:
            return("Pin Down");

        case 28:
            return("Retreat");

        case 29:
            return("Absorb Field");

        case 30:
            return("Shell Regen");

        case 31:
            return("Core Regen");

        case 32:
            return("Energy Regen");

        case 33:
            return("Disrupt");

        case 34:
            return("Control");

        case 35:
            return("Invert Tractor");

        case 36:
            return("Bomb");

        case 37:
            return("Ion");

        case 38:
            return("Flak");

        default:
            return("Name unset");
        }
    }
示例#19
0
    public static string GetDescriptionByID(int ID, int tier, string secondaryData)
    {
        switch (ID)
        {
        case 0:
            return("Does nothing.");

        case 1:
            return("+" + SpeedThrust.boost * tier + " speed for 10 seconds.");

        case 2:
            return("Instantly heal " + HealthHeal.heals[0] * tier + " shell.");

        case 3:
            return("Projectile that deals " + MainBullet.GetDamage(tier) + " damage. \nStays with you no matter what.");

        case 4:
            return("Instant attack that deals " + Beam.beamDamage * tier + " damage.");

        case 5:
            return("Projectile that deals " + Bullet.bulletDamage * tier + " damage.");

        case 6:
            return("Instant attack that deals " + Cannon.cannonDamage * tier + " damage.");

        case 7:
            return("Slow homing projectile that deals " + Missile.missileDamage * tier + " damage.");

        case 8:
            return("Slow projectile that deals " + Torpedo.torpedoDamage * tier + " damage to ground entities.");

        case 9:
            return("Fast projectile that deals " + Laser.laserDamage * tier + " damage. 25% pierces to core.");

        case 10:
            if (secondaryData == null || secondaryData == "")
            {
                return("Spawns a drone.");
            }
            DroneSpawnData data = DroneUtilities.GetDroneSpawnDataByShorthand(secondaryData);
            return(DroneUtilities.GetDescriptionByType(data.type));

        case 11:
            return("Instantly heal " + HealthHeal.heals[1] * tier + " core.");

        case 12:
            return("Instantly heal " + HealthHeal.heals[2] * tier + " energy.");

        case 13:
            return("+" + Speed.boost * tier + " speed.");

        case 17:
            return("Passively increases shell regen by " + ShellRegen.regen * tier + " points.");

        case 18:
            return("Passively increases maximum shell by " + ShellMax.max * tier + " points.");

        case 19:
            return("Passively increases energy regen by " + ShellRegen.regen * tier + " points.");

        case 20:
            return("Passively increases maximum energy by " + ShellMax.max * tier + " points.");

        case 21:
            return("Passively increases the maximum allowed number of controlled units by " + Command.commandUnitIncrease + ".");

        case 24:
            return("Become invisible to enemies.");

        case 25:
            return("All weapon damage increased by 150.");

        case 26:
            return("Instantly heals self and nearby allies by +500 shell and +500 core.");

        case 27:
            return("Immobilizes the target.");

        case 28:
            return("Respawn at base.");

        case 29:
            return("Absorb damage and turn it into energy.");

        case 30:
            return("Temporarily increase shell regen.");

        case 31:
            return("Temporarily increase core... wait, this isn't supposed to exist!");

        case 32:
            return("Temporarily increase energy regen.");

        case 33:
            return("Disrupt enemy ability cooldowns.");

        case 34:
            return("Makes allies stronger.");

        case 35:
            return("Temporarily pulls you to your tractor target.");

        case 36:
            return($"Stationary projectile that deals {Bomb.bombDamage} damage. \nProjectile lasts {45F * tier} seconds.");

        case 37:
            return($"Slow moving beam that deals {IonLineController.damageC} damage per second for 5 seconds. \nBeam costs {IonLineController.energyC} energy per");

        default:
            return("Description unset");
        }
    }