コード例 #1
0
        public void InitSuperglobals()
        {
            FileVersionInfo CoreVersion = ShellCore.GetVersion();
            FileVersionInfo Version     = GetVersion();

            ShxmlInitVariable("ShellUIVer", $"{Version.FileMajorPart}.{Version.FileMinorPart}.{Version.FileBuildPart}.{Version.FilePrivatePart}");
            ShxmlInitVariable("ShellCoreVer", $"{CoreVersion.FileMajorPart}.{CoreVersion.FileMinorPart}.{CoreVersion.FileBuildPart}.{CoreVersion.FilePrivatePart}");
        }
コード例 #2
0
        public ShellPage()
        {
            this.NavigationCacheMode = NavigationCacheMode.Required;

            ShellCore.InitializeContainer();
            ShellCore.Container.RegisterSingleton <IPlatformProvider, WinRTPlatformProvider>();

            ConfigurePlatform();
        }
コード例 #3
0
    public void AddCoreArrow(ShellCore core)
    {
        if (coreArrows.ContainsKey(core))
        {
            return;
        }

        coreArrows.Add(core, Instantiate(arrowPrefab, transform, false).transform);
        coreArrows[core].GetComponent <SpriteRenderer>().color = FactionManager.GetFactionColor(core.faction);
        UpdatePosition(coreArrows[core], core.transform.position, core.faction != PlayerCore.Instance.faction);
    }
コード例 #4
0
ファイル: ShellApplication.cs プロジェクト: cschwarz/AppShell
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            ShellCore.InitializeContainer();

            ConfigurePlatform();

            shellCore.Configure();
            shellCore.Initialize();
        }
コード例 #5
0
        public ShellApplication()
        {
            shellViews = new Dictionary <string, Page>();

            shellCore = Activator.CreateInstance <T>();
            shellCore.Shells.CollectionChanged += Shells_CollectionChanged;
            shellCore.PropertyChanged          += ShellCore_PropertyChanged;

            ConfigurePlatform();

            shellCore.Configure();
        }
コード例 #6
0
    public override void Init()
    {
        carriers = new List <Entity>();

        Entity[] targetEntities = BattleZoneManager.getTargets();
        if (targetEntities == null)
        {
            Debug.LogError("Battle zone target list not initialized");
            ai.setMode(AirCraftAI.AIMode.Inactive);
            return;
        }

        for (int i = 0; i < targetEntities.Length; i++)
        {
            if (targetEntities[i] is ICarrier)
            {
                if (targetEntities[i].faction == craft.faction)
                {
                    carriers.Add(targetEntities[i]);
                }
            }
        }

        if (craft is ShellCore)
        {
            shellcore = craft as ShellCore;
        }
        else
        {
            Debug.LogError("Battle zone AI should only be used by shellcores!");
        }

        nextSearchTime     = Time.time;
        nextStateCheckTime = Time.time;

        for (int i = 0; i < AIData.vendors.Count; i++)
        {
            int rockCount = 0;
            for (int j = 0; j < AIData.energyRocks.Count; j++)
            {
                if ((AIData.energyRocks[j].transform.position - AIData.vendors[i].transform.position).sqrMagnitude < 100)
                {
                    rockCount++;
                }
            }
            AITargets.Add(new AITarget(AIData.vendors[i], rockCount + 1f));
        }
        for (int i = 0; i < carriers.Count; i++)
        {
            AITargets.Add(new AITarget(carriers[i], 100f));
        }
    }
コード例 #7
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            Forms.Init();

            ShellCore.InitializeContainer();
            ShellCore.Container.RegisterSingleton <IPlatformProvider, iOSPlatformProvider>();

            ConfigurePlatform();

            LoadApplication(Activator.CreateInstance <T>());

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
コード例 #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Forms.Init(this, savedInstanceState, typeof(TResource).Assembly);

            ShellCore.InitializeContainer();
            ShellCore.Container.RegisterSingleton <IPlatformProvider, AndroidPlatformProvider>();

            ConfigurePlatform();

            LoadApplication(Activator.CreateInstance <TApplication>());
        }
コード例 #9
0
        [STAThread]                     // unfortunately we have to use this
        static void Main(string[] args) // shell main
        {
            Shl = new Shell();

            bool?init_result = Shl.Init(args);

            if (init_result == null)
            {
                Console.WriteLine("Error Code CRITICAL-001: ShellCore/ShellUI Initalization Failed. Shell cannot start. Press any key to exit.");
                Console.ReadKey();
                ShellCore.Exit(0);
            }
        }
コード例 #10
0
    public static Entity BuyItem(ShellCore core, int index, IVendor vendor)
    {
        if (core.unitsCommanding.Count >= core.GetTotalCommandLimit())
        {
            return(null);
        }

        GameObject creation = new GameObject();

        creation.transform.position = vendor.GetPosition();
        var blueprint = vendor.GetVendingBlueprint();

        switch (blueprint.items[index].entityBlueprint.intendedType)
        {
        case EntityBlueprint.IntendedType.Turret:
            Turret tur = creation.AddComponent <Turret>();
            tur.blueprint = blueprint.items[index].entityBlueprint;
            core.SetTractorTarget(creation.GetComponent <Draggable>());
            tur.SetOwner(core);

            if (SectorManager.instance && SectorManager.instance.GetComponentInChildren <BattleZoneManager>())
            {
                var stats = SectorManager.instance.GetComponentInChildren <BattleZoneManager>().stats.Find(s => s.faction == core.faction);
                if (stats == null)
                {
                    stats = new BattleZoneManager.Stats(core.faction);
                    SectorManager.instance.GetComponentInChildren <BattleZoneManager>().stats.Add(stats);
                }
                stats.turretSpawns++;
            }
            break;

        case EntityBlueprint.IntendedType.Tank:
            Tank tank = creation.AddComponent <Tank>();
            tank.blueprint = blueprint.items[index].entityBlueprint;
            tank.SetOwner(core);
            break;

        default:
            break;
        }

        creation.GetComponent <Entity>().spawnPoint = vendor.GetPosition();
        creation.GetComponent <Entity>().faction    = core.faction;
        creation.name = blueprint.items[index].entityBlueprint.name;
        core.sectorMngr.InsertPersistentObject(blueprint.items[index].entityBlueprint.name, creation);
        core.AddPower(-blueprint.items[index].cost);
        return(creation.GetComponent <Entity>());
    }
コード例 #11
0
ファイル: Harvester.cs プロジェクト: BaegEhl/shellcore
    protected override void Start()
    {
        ID = AbilityID.Harvester;

        if (!owner)
        {
            owner = (Core as Turret).owner as ShellCore;
        }
        if (!tractor)
        {
            tractor       = gameObject.AddComponent <TractorBeam>();
            tractor.owner = Core;
            tractor.BuildTractor();
        }
    }
コード例 #12
0
ファイル: Yard.cs プロジェクト: FoeFear/shellcore
    private void RepairShellCore(ShellCore shellCore)
    {
        if (shellCore.isYardRepairing)
        {
            return;
        }

        if (shellCore.HasPartsDamagedOrDestroyed())
        {
            StartCoroutine(shellCore.StartYardRepair());
        }
        else if (shellCore.HasShellOrCoreDamaged())
        {
            shellCore.HealToMax();
        }
    }
コード例 #13
0
ファイル: PartyManager.cs プロジェクト: FoeFear/shellcore
    public void UnassignBackend(string charID, ShellCore member)
    {
        if (member && member.GetAI() != null)
        {
            member.GetAI().follow(null);
        }

        partyMembers.Remove(member);
        if (charID != null)
        {
            partyResponses.Remove(charID);
        }

        if (member && partyIndicators.ContainsKey(member))
        {
            Destroy(partyIndicators[member]);
            partyIndicators.Remove(member);
        }
    }
コード例 #14
0
        public void InstallModule(Module module)
        {
            Console.WriteLine("Adding to Module List");
            XmlDocument ModuleXml  = ShellCore.XmlOpenFile("Modules.xml");
            XmlNode     moduleRoot = ShellCore.XmlGetRootNode(ModuleXml, true, "Modules", 58);

            ModuleXml = ShellCore.XmlAddNode(ModuleXml, moduleRoot, "Module");
            XmlNode moduleModule = ShellCore.XmlGetNode(moduleRoot, "Module");

            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Name", module.Name.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Author", module.Author.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Version", module.Version.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Copyright", module.Copyright.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Website", module.Website.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Dll", module.Dll.Trim());
            ModuleXml = ShellCore.XmlAddAttribute(ModuleXml, moduleModule, "Extends", module.Extends.ToString());
            ModuleXml = ShellCore.XmlSaveFile(ModuleXml, "Modules.xml");
            ShellCore.DeleteFileEx("Modules/Module.xml");
            ShellCore.DeleteFileEx("Module.zip");
        }
コード例 #15
0
        public string ShxmlRunFunction(XmlNode node)
        {
            XmlAttributeCollection attributes = node.Attributes;

            foreach (XmlAttribute attribute in attributes)
            {
                switch (attribute.Name)
                {
                case "path":
                    path = attribute.Value;
                    return(path);
                }
            }

            if (path == null)
            {
                ShellCore.ElmThrowException(26);
                return(Convert.ToString("27")); // this code never runs so we don't have a problem!!!! yay!!!!
            }

            return("");
        }
コード例 #16
0
 public void InitShellModule(ShellCore ShlCore)
 {
     ShellCore = ShlCore;
 }
コード例 #17
0
        internal bool?Init(string[] args)  // initalizes the shell
        {
            ShellCore   = new ShellCore();
            ShellUI     = new ShellUI();
            ShellModule = new ShellModule();
            ShellCore.InitShellCore();
            ShellCore.CheckCompatibility();
            ShellCore.ElmInitExceptionManager();
            ShellCore.ShlWriteLog("Test.txt", "test.");
            ShellUI.InitShellUI();
            ShellModule.InitShellModule(ShellCore);
            ShellTask ShlTask = ShellCore.InitTask(new string[0], "task 1", 400, 150);

            ShlTask.Run();
            ShellTask ShlTask2 = ShellCore.InitTask(new string[0], "task 3", 360, 200);

            ShlTask2.Run();

            Console.Clear(); // so we can do stuff


            ShellCore.ShlHandleCmdArguments(args); // universal arguments (config - user name...)
            // SHELL MAIN ARGUMENTS
            string arg2 = "";

            if (args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string thearg = args[i];
                    if (args.Length - i > 0)
                    {
                        arg2 = args[i + 1];
                    }
                    switch (thearg)
                    {
                    default:
                        ShellUI.ShXML.XmlParseScript(args[0]);
                        Console.WriteLine("Script has completed. Press enter to exit.");
                        Console.ReadKey();
                        ShellCore.Exit(0);
                        return(null);

                    case "installmodule":
                        ShellModule.InstallModule(false, arg2);
                        Console.WriteLine("Module successfully installed. Press any key to exit Shell.");
                        Console.ReadKey();
                        return(true);
                    }
                }
            }

            if (ShellCore == null || ShellUI == null)
            {
                return(null);
            }

            Console.WriteLine("Welcome to Shell\n");
            Console.WriteLine("Shell Embedded GUI Platform, version 8.0 alpha\n");

            Console.WriteLine("DLL Versions:");

            FileVersionInfo shellcore_ver   = ShellCore.GetVersion();
            FileVersionInfo shellui_ver     = ShellUI.GetVersion();
            FileVersionInfo shellmodule_ver = ShellModule.GetVersion();

            ShellCore.ShlSetWindowTitle($"Shell - core ver {shellcore_ver.FileMajorPart}.{shellcore_ver.FileMinorPart}.{shellcore_ver.FileBuildPart}.{shellcore_ver.FilePrivatePart}.");

            Console.WriteLine($"ShellCore Version: {shellcore_ver.FileMajorPart}.{shellcore_ver.FileMinorPart}.{shellcore_ver.FileBuildPart}.{shellcore_ver.FilePrivatePart}");
            Console.WriteLine($"ShellUI Version: {shellui_ver.FileMajorPart}.{shellui_ver.FileMinorPart}.{shellui_ver.FileBuildPart}.{shellui_ver.FilePrivatePart}\n");
            Console.WriteLine($"ShellModule Version: {shellmodule_ver.FileMajorPart}.{shellmodule_ver.FileMinorPart}.{shellmodule_ver.FileBuildPart}.{shellmodule_ver.FilePrivatePart}\n");

            ShellUI.ShXML.XmlParseScript("Whatsyourname.xml");

            Console.WriteLine("DEBUG: Variables created");

            foreach (ShxmlVariable ShxmlVar in ShellUI.ShXML.Varlist)
            {
                switch (ShxmlVar.Type)
                {
                case 0:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varint}. Type = Int.");
                    continue;

                case 1:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varstring}. Type = String.");
                    continue;

                case 2:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varchar}. Type = Char.");
                    continue;

                case 3:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.vardouble}. Type = Double.");
                    continue;

                case 4:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varfloat}. Type = Float.");
                    continue;

                case 5:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varbool}. Type = Boolean.");
                    continue;
                }
            }

            Console.ReadKey();
            return(true);
        }
コード例 #18
0
ファイル: Harvester.cs プロジェクト: BaegEhl/shellcore
 public void SetOwner(ShellCore owner)
 {
     this.owner = owner;
 }
コード例 #19
0
        //TODO: Clean up this function. It blows ass and sucks dick right now.
        public ShxmlVariable ShxmlDeclareVariable(XmlNode node) // Automatically determines the type. Internal?
        {
            ShxmlVariable          xmlvar   = new ShxmlVariable();
            XmlAttributeCollection XmlAttrs = node.Attributes;

            string var_name  = null;
            string var_type  = null;
            string var_value = null;

            foreach (XmlAttribute Attribute in XmlAttrs)
            {
                if (Attribute.Name == "name")
                {
                    var_name = Attribute.Value;
                }

                // get it!
                if (Attribute.Name == "type")
                {
                    var_type = Attribute.Value;
                }

                if (Attribute.Name == "value")
                {
                    var_value = Attribute.Value;
                }
            }


            foreach (ShxmlVariable var in Varlist)
            {
                //Console.WriteLine(var.Name);
                if (var.Name == var_name)
                {
                    //var = null;
                    ShellCore.ElmThrowException(11);
                    return(xmlvar); // silently return if duplicate
                }
            }

            xmlvar.Name = var_name;

            //todo: sometimes for some reason (doubles) it doesn't set the variable
            // split this? -- for function parameters maybe??
            try
            {
                switch (var_type)
                {
                case null:
                    xmlvar.Type = -1;

                    try
                    {
                        xmlvar.Type      = 3;
                        xmlvar.vardouble = Convert.ToDouble(var_value);     // this deliberately triggers an exception
                    }

                    catch (FormatException)   // use an exception handler to set the type
                    {
                        xmlvar.Type      = 1; // ITS A STRING
                        xmlvar.varstring = var_value;
                    }

                    if (xmlvar.Type == -1)
                    {
                        ShellCore.ElmThrowException(5);
                        return(xmlvar);
                    }

                    if (var_value == "true" || var_value == "false")
                    {
                        xmlvar.Type    = 5;
                        xmlvar.varbool = Convert.ToBoolean(var_value);
                    }

                    Varlist.Add(xmlvar);
                    return(xmlvar);

                case "int":
                case "Int":
                    ShxmlInitVariable(var_name, Convert.ToInt32(var_value));
                    return(xmlvar);

                case "str":
                case "Str":
                case "string":
                case "String":
                    //xmlvar.Name = var_name;
                    ShxmlInitVariable(var_name, var_value);
                    return(xmlvar);

                case "letter":
                case "char":
                case "character":
                case "Char":
                case "Character":
                case "Letter":
                    ShxmlInitVariable(var_name, Convert.ToChar(var_value));
                    return(xmlvar);

                case "double":
                case "Double":
                case "number":
                case "Number":
                    ShxmlInitVariable(var_name, Convert.ToDouble(var_value));
                    return(xmlvar);

                case "float":
                case "Float":
                    ShxmlInitVariable(var_name, Convert.ToSingle(var_value));
                    return(xmlvar);

                case "bool":
                case "Bool":
                case "BOOL":
                case "Boolean":
                case "boolean":
                case "truefalse":
                case "true/false":
                case "true false":
                case "falsetrue":
                case "false/true":
                case "false or true":
                case "true or false":
                    ShxmlInitVariable(var_name, Convert.ToBoolean(var_value));
                    return(xmlvar);

                // floats not supported
                default:
                    ShellCore.ElmThrowException(5);
                    return(xmlvar);
                }
            }
            catch (FormatException)
            {
                ShellCore.ElmThrowException(7);
                return(xmlvar);
            }
            //return xmlvar;
        }
コード例 #20
0
    public Entity SpawnEntity(EntityBlueprint blueprint, Sector.LevelEntity data)
    {
        GameObject gObj = new GameObject(data.name);
        string     json = null;

        switch (blueprint.intendedType)
        {
        case EntityBlueprint.IntendedType.ShellCore:
        {
            ShellCore shellcore = gObj.AddComponent <ShellCore>();
            try
            {
                // Check if data has blueprint JSON, if it does override the current blueprint
                // this now specifies the path to the JSON file instead of being the JSON itself
                json = data.blueprintJSON;
                if (json != null && json != "")
                {
                    blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

                    // try parsing directly, if that fails try fetching the entity file
                    try
                    {
                        JsonUtility.FromJsonOverwrite(json, blueprint);
                    }
                    catch
                    {
                        JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText
                                                          (resourcePath + "\\Entities\\" + json + ".json"), blueprint);
                    }

                    //Debug.Log(data.name);
                    blueprint.entityName = data.name;
                }
                else
                {
                    shellcore.entityName = blueprint.entityName = data.name;
                }

                if (current.type == Sector.SectorType.BattleZone)
                {
                    // add core arrow
                    if (MinimapArrowScript.instance && !(shellcore is PlayerCore))
                    {
                        shellcore.faction = data.faction;
                        MinimapArrowScript.instance.AddCoreArrow(shellcore);
                    }


                    // set the carrier of the shellcore to the associated faction's carrier
                    if (carriers.ContainsKey(data.faction))
                    {
                        shellcore.SetCarrier(carriers[data.faction]);
                    }

                    battleZone.AddTarget(shellcore);
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e.Message);
                //blueprint = obj as EntityBlueprint;
            }
            shellcore.sectorMngr = this;
            break;
        }

        case EntityBlueprint.IntendedType.PlayerCore:
        {
            if (player == null)
            {
                player            = gObj.AddComponent <PlayerCore>();
                player.sectorMngr = this;
            }
            else
            {
                Destroy(gObj);
                return(null);
            }

            break;
        }

        case EntityBlueprint.IntendedType.Turret:
        {
            gObj.AddComponent <Turret>();
            break;
        }

        case EntityBlueprint.IntendedType.Tank:
        {
            gObj.AddComponent <Tank>();
            break;
        }

        case EntityBlueprint.IntendedType.Bunker:
        {
            json = data.blueprintJSON;
            if (json != null && json != "")
            {
                var dialogueRef = blueprint.dialogue;
                blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

                // try parsing directly, if that fails try fetching the entity file
                try
                {
                    JsonUtility.FromJsonOverwrite(json, blueprint);
                }
                catch
                {
                    JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText
                                                      (resourcePath + "\\Entities\\" + json + ".json"), blueprint);
                }

                blueprint.dialogue = dialogueRef;
            }

            blueprint.entityName = data.name;
            Bunker bunker = gObj.AddComponent <Bunker>();
            stations.Add(bunker);
            bunker.vendingBlueprint =
                blueprint.dialogue != null
                        ? blueprint.dialogue.vendingBlueprint
                        : ResourceManager.GetAsset <VendingBlueprint>(data.vendingID);
            break;
        }

        case EntityBlueprint.IntendedType.Outpost:
        {
            json = data.blueprintJSON;
            if (json != null && json != "")
            {
                var dialogueRef = blueprint.dialogue;
                blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

                // try parsing directly, if that fails try fetching the entity file
                try
                {
                    JsonUtility.FromJsonOverwrite(json, blueprint);
                }
                catch
                {
                    JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText
                                                      (resourcePath + "\\Entities\\" + json + ".json"), blueprint);
                }
                blueprint.dialogue = dialogueRef;
            }

            blueprint.entityName = data.name;
            Outpost outpost = gObj.AddComponent <Outpost>();
            stations.Add(outpost);
            outpost.vendingBlueprint =
                blueprint.dialogue != null
                        ? blueprint.dialogue.vendingBlueprint
                        : ResourceManager.GetAsset <VendingBlueprint>(data.vendingID);
            break;
        }

        case EntityBlueprint.IntendedType.Tower:
        {
            break;
        }

        case EntityBlueprint.IntendedType.Drone:
        {
            Drone drone = gObj.AddComponent <Drone>();
            //drone.path = ResourceManager.GetAsset<Path>(data.pathID);
            break;
        }

        case EntityBlueprint.IntendedType.AirCarrier:
            json = data.blueprintJSON;
            if (json != null && json != "")
            {
                blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

                // try parsing directly, if that fails try fetching the entity file
                try
                {
                    JsonUtility.FromJsonOverwrite(json, blueprint);
                }
                catch
                {
                    JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText
                                                      (resourcePath + "\\Entities\\" + json + ".json"), blueprint);
                }
            }

            blueprint.entityName = data.name;
            AirCarrier carrier = gObj.AddComponent <AirCarrier>();
            if (!carriers.ContainsKey(data.faction))
            {
                carriers.Add(data.faction, carrier);
            }
            carrier.sectorMngr = this;
            break;

        case EntityBlueprint.IntendedType.GroundCarrier:
            json = data.blueprintJSON;
            if (json != null && json != "")
            {
                blueprint = ScriptableObject.CreateInstance <EntityBlueprint>();

                // try parsing directly, if that fails try fetching the entity file
                try
                {
                    JsonUtility.FromJsonOverwrite(json, blueprint);
                }
                catch
                {
                    JsonUtility.FromJsonOverwrite(System.IO.File.ReadAllText
                                                      (resourcePath + "\\Entities\\" + json + ".json"), blueprint);
                }
            }

            blueprint.entityName = data.name;
            GroundCarrier gcarrier = gObj.AddComponent <GroundCarrier>();
            if (!carriers.ContainsKey(data.faction))
            {
                carriers.Add(data.faction, gcarrier);
            }
            gcarrier.sectorMngr = this;
            break;

        case EntityBlueprint.IntendedType.Yard:
            Yard yard = gObj.AddComponent <Yard>();
            yard.mode = BuilderMode.Yard;
            break;

        case EntityBlueprint.IntendedType.WeaponStation:
            gObj.AddComponent <WeaponStation>();
            break;

        case EntityBlueprint.IntendedType.CoreUpgrader:
            gObj.AddComponent <CoreUpgrader>();
            break;

        case EntityBlueprint.IntendedType.Trader:
            Yard trade = gObj.AddComponent <Yard>();
            trade.mode = BuilderMode.Trader;
            try
            {
                bool ok = true;
                if (blueprint.dialogue == null)
                {
                    ok = false;
                }
                if (blueprint.dialogue.traderInventory == null)
                {
                    ok = false;
                }
                if (data.blueprintJSON == null || data.blueprintJSON == "")
                {
                    ok = false;
                }
                if (ok)
                {
                    ShipBuilder.TraderInventory inventory = JsonUtility.FromJson <ShipBuilder.TraderInventory>(data.blueprintJSON);
                    if (inventory.parts != null)
                    {
                        blueprint.dialogue.traderInventory = inventory.parts;
                    }
                }
                else
                {
                    blueprint.dialogue.traderInventory = new List <EntityBlueprint.PartInfo>();
                }
            }
            catch (System.Exception e)
            {
                Debug.LogWarning(e);
                blueprint.dialogue.traderInventory = new List <EntityBlueprint.PartInfo>();
            }
            break;

        case EntityBlueprint.IntendedType.DroneWorkshop:
            Yard workshop = gObj.AddComponent <Yard>();
            workshop.mode = BuilderMode.Workshop;
            break;

        default:
            break;
        }
        Entity entity = gObj.GetComponent <Entity>();

        // TODO: These lines should perhaps be moved somewhere inside Entity itself, they need to run before even Awake is called
        if (!AIData.entities.Contains(entity))
        {
            AIData.entities.Add(entity);
        }
        entity.sectorMngr = this;
        entity.faction    = data.faction;
        entity.spawnPoint = entity.transform.position = data.position;
        entity.blueprint  = blueprint;

        if (entity as AirCraft && data.patrolPath != null && data.patrolPath.waypoints != null && data.patrolPath.waypoints.Count > 0)
        {
            // patrolling
            (entity as AirCraft).GetAI().setPath(data.patrolPath, null, true);
        }

        if (data.ID == "" || data.ID == null || (objects.ContainsKey(data.ID) && !objects.ContainsValue(gObj)))
        {
            data.ID = objects.Count.ToString();
        }
        entity.ID = data.ID;

        if (!objects.ContainsKey(data.ID))
        {
            objects.Add(data.ID, gObj);
        }
        return(entity);
    }
コード例 #21
0
ファイル: ShellUI.Core.cs プロジェクト: starfrost013/Shell
 public ShellUI()
 {
     ShellCore = new ShellCore();
     ShellCore.ElmInitExceptionManager();
 }
コード例 #22
0
        static void Main(string[] args)
        {
            ShellTest     ShellTest = new ShellTest();
            ShellCore     ShellCore = new ShellCore();
            ShellUI       ShellUI   = new ShellUI(); // initalize shellui
            List <double> arguments = new List <double> {
                4, 3
            };                                                  // v5.5+


            FileVersionInfo shellcore_ver = ShellCore.GetVersion();

            if (shellcore_ver.ProductMajorPart < 8) // version check
            {
                ShellTest.SorryIncompatible();
            }
            else if (shellcore_ver.ProductMajorPart < 8 & shellcore_ver.ProductBuildPart < 87)
            {
                ShellTest.SorryIncompatible();
            }

            ShellCore.InitShellCore();
            ShellCore.ElmInitExceptionManager();
            Console.Title = "Shell Test Application";
            Console.WriteLine("This is an automated testing application designed for testing Shell. This will bring up standard Windows dialogs and create registry keys to verify the functionality of the Shell DLLs. Press enter to continue.");
            Console.ReadKey();


            // V2+, last modified v7.0 build 24 iirc
            double        result   = ShellCore.BaseMath(ShellCore.BaseMathOperation.Add, 1, arguments);
            double        result2  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Subtract, 1, arguments);
            double        result3  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Divide, 1, arguments);
            double        result4  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Multiply, 1, arguments);
            double        result5  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Modulus, 1, arguments);
            double        result6  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Sqrt, 1, arguments);
            double        result7  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Sin, 1, arguments);
            double        result8  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Cos, 1, arguments);
            double        result9  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Tan, 1, arguments);
            double        result10 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Asin, 1, arguments);
            double        result11 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Acos, 1, arguments);
            double        result12 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Atan, 1, arguments);
            double        result13 = ShellCore.Power(4, 3);
            List <double> result14 = ShellCore.Ratio(6, 4, 3); // v7+

            Console.WriteLine($"Basic Math arg 0 result: {result}");
            Console.WriteLine($"Basic Math arg 1 result: {result2}");
            Console.WriteLine($"Basic Math arg 2 result: {result3}");
            Console.WriteLine($"Basic Math arg 3 result: {result4}");
            Console.WriteLine($"Basic Math arg 4 result: {result5}");
            Console.WriteLine($"Basic Math arg 5 result: {result6}");
            Console.WriteLine($"Basic Math arg 6 result: {result7}");
            Console.WriteLine($"Basic Math arg 7 result: {result8}");
            Console.WriteLine($"Basic Math arg 8 result: {result9}");
            Console.WriteLine($"Basic Math arg 9 result: {result10}");
            Console.WriteLine($"Basic Math arg 10 result: {result11}");
            Console.WriteLine($"Basic Math arg 11 result: {result12}");
            Console.WriteLine($"Power result: {result13}");
            Console.WriteLine($"Ratio result: {result14[0]}, {result14[1]}");

            ShellCore.WinMsgBox("Shell", "This is a message box!");                                                                // v6+
            string openResult = ShellCore.WinOpenDialog("ShellCore Version 6 open dialog", ".txt", "Text documents (.txt)|*.txt"); // v6+

            if (openResult == null)
            {
                Console.WriteLine("No file selected.");
            }
            else
            {
                Console.WriteLine(openResult);
            }

            string saveResult = ShellCore.WinSaveDialog("ShellCore Version 6 save dialog", ".txt", "Text documents (.txt)|*.txt"); // v6+

            if (saveResult == null)
            {
                Console.WriteLine("No file selected.");
            }

            ShellCore.ShlBeep(1000, 400);
            ShellCore.CreateFileEx("dummy.tmp");
            ShellCore.CopyFileEx("dummy.tmp", "dummy2.tmp");
            ShellCore.MoveFileEx("dummy2.tmp", "dummy3.tmp");
            ShellCore.CreateFileEx("dummy4.tmp");
            ShellCore.CreateFolderEx("TestFolder");  // v0.8.7x+
            ShellCore.SetFileHiddenEx("dummy4.tmp"); // v7+
            Console.WriteLine("Now testing ShellUI...");
            ShellUI.UiDrawMultiple('T', 8);
            ShellUI.UiDrawBlankSpace(16);
            ShellUI.UiSetConsoleColour(ConsoleColor.Black, ConsoleColor.White);
            ShellUI.UiSetWindowSize(25, 10);
            ShellUI.UiSetWindowSize(100, 63);
            ShellUI.UiSetCursorPosition(24, 24);
            ShellUI.UiSetCursorSize(5);
            ShellCore.WinPlaySound("tada.wav"); // v8.0.50+
            ShellUI.UiSetWindowTitle("ddddddddddddddddddddddddd");
            Console.WriteLine("Now testing ShellCore ExceptionsLite");

            ShellCore.ShlWriteLog("ShellLog.txt", "This is a test");                           // v6+
            ShellCore.ShlCloseLog();                                                           // v6+
            ShellCore.WinCreateRegKey(RegistryHive.CurrentUser, "ShellTest");                  // v7+
            ShellCore.WinCreateRegKey(RegistryHive.CurrentUser, "ShellTest2");                 // v7+
            RegistryKey Reg = ShellCore.WinOpenRegKey(RegistryHive.CurrentUser, "ShellTest");  // v7+

            ShellCore.WinSetRegValue(Reg, "Test", "TestThis");                                 // v7+
            ShellCore.WinSetRegValue(Reg, "Test3", "This");                                    // v7+
            ShellCore.WinDeleteRegValue(Reg, "Test3");                                         // v7+
            ShellCore.WinDeleteRegKey(RegistryHive.CurrentUser, "ShellTest2");                 // v7+
            ShellCore.DownloadFileEx("http://shell.x10.mx/dummy.txt", "dummy2.txt");           // v8.0.62+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3001, "This is a test.", 0); // v4+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3002, "This is a test.", 1); // v4+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3003, "This is a test.", 2); // v4+

            ShellCore.ElmThrowException(3001);                                                 // v4+
            ShellCore.ElmThrowException(3002);                                                 // v4+
            ShellCore.ElmThrowException(3003);                                                 // v4+

            XmlDocument XmlTest = ShellCore.XmlCreateFile("Test.xml");                         // v8.0.8x+

            XmlTest = ShellCore.XmlAddNode(XmlTest, "ShellCoreXMLServicesTest", "test");
            ShellCore.XmlSaveFile(XmlTest, "Test.xml");

            // clean up

            Console.WriteLine("Testing complete. If it didn't crash or display any exceptions (excluding the test exceptions triggered, #3001, 3002, and 3003), that means it's all good. Press enter to exit.");
            Console.ReadKey();

            ShellCore.DeleteFileEx("dummy.tmp");    // v4+
            ShellCore.DeleteFileEx("dummy2.tmp");   // v4+
            ShellCore.DeleteFileEx("dummy2.txt");   // v4+
            ShellCore.DeleteFileEx("dummy3.tmp");   // v4+
            ShellCore.DeleteFileEx("dummy4.tmp");   // v4+
            ShellCore.DeleteFolderEx("TestFolder"); // v8.0.7x+
            ShellCore.DeleteFileEx("Test.xml");     // v4/v8.0.94+
            Environment.Exit(0xD15EA5E);
        }
コード例 #23
0
        public ShxmlVariable ShxmlEvaluateStatement(XmlNode token, int mode = 0)
        {
            int    count  = 0;
            double result = 0;

            XmlAttributeCollection attributes = token.Attributes;
            ShxmlVariable          svar       = new ShxmlVariable();
            string x = null;

            OperandList = new List <string>();
            OpList      = new List <char>();
            foreach (XmlAttribute attribute in attributes)
            {
                switch (attribute.Name)
                {
                case "op":
                case "Op":
                case "operation":
                case "Operation":
                    x = attribute.Value;
                    char[] thebits = attribute.Value.ToCharArray();

                    // This works because the first operand is after the first part of the string. Thus we get the correct operands.
                    foreach (char bit in thebits)
                    {
                        switch (bit)
                        {
                        case '+':
                        case '-':
                        case '*':
                        case '/':
                        case '%':
                            OpList.Add(bit);
                            continue;
                        }
                        count++;
                    }
                    continue;

                case "var":
                case "Var":
                case "variable":
                case "Variable":
                    svar.Name = attribute.Value;
                    svar.Type = 3;     // double by default
                    continue;

                default:
                    ShellCore.ElmThrowException(19);
                    return(svar);
                }
            }

            if (svar.Name == null)
            {
                ShellCore.ElmThrowException(40);
            }

            if (OpList.Count == 0)
            {
                ShellCore.ElmThrowException(41);
            }
            char[] OperatorListA = OpList.ToArray();         // convert to array
            cleancut = x.Split(OperatorListA);

            count = 0;         // reset the count

            foreach (string bit2 in cleancut)
            {
                foreach (ShxmlVariable shvar in Varlist)
                {
                    if (cleancut[count] == shvar.Name)
                    {
                        if (shvar.Type == 1)
                        {
                            ShellCore.ElmThrowException(14);         // Can't do stuff to strings...yet.
                        }

                        else if (shvar.Type == 5)
                        {
                            ShellCore.ElmThrowException(15);         // Can't add booleans.
                        }

                        else
                        {
                            OperandList.Add(Convert.ToString(shvar.vardouble));         // convert it to string
                            count++;
                            continue;
                        }
                    }
                }
                OperandList.Add(bit2);
                count++;
            }



            List <ShxmlVariable> vars  = new List <ShxmlVariable>();
            List <double>        bit3  = new List <double>();
            List <double>        bit3c = new List <double>();

            count = 0;     //set count back to 0
            foreach (string bit2 in cleancut)
            {
                string bit2a = bit2.Trim();

                int isVar = 0;
                foreach (ShxmlVariable sxvar in Varlist)
                {
                    if (sxvar.Name == bit2a & bit2a != svar.Name)
                    {
                        isVar = 1;
                        vars.Add(sxvar);
                        bit3.Add(sxvar.vardouble);
                    }
                }
                if (isVar == 0)
                {
                    try
                    {
                        if (bit2a != svar.Name)
                        {
                            double bit2b = Convert.ToDouble(bit2a);
                            bit3.Add(bit2b);
                        }
                    }
                    catch (FormatException)
                    {
                        // error 12 removed from here due to changes in how this works in Shell Development Release
                    }
                }
                isVar = 0;
            }

            // so it's easier
            double[] bit3b = bit3.ToArray();

            ShxmlVariable[] varsb = vars.ToArray();     // local list converted to an array.

            // jesus f*****g christ this code is getting worse!

            foreach (ShxmlVariable varsb2 in varsb)
            {
                bit3c.Add(varsb2.vardouble);
            }

            // this actually parses the stuff
            foreach (double bit3a in bit3b)
            {
                // This is awaiting changes to adding an overload in ShellCore to perform operations on a single int instead of a collection.
                switch (OpList[count])
                {
                case '+':
                    result = bit3a + bit3b[count + 1];
                    continue;

                case '-':
                    result = bit3a - bit3b[count + 1];
                    continue;

                case '*':
                    result = bit3a * bit3b[count + 1];
                    continue;

                case '/':
                    result = bit3a / bit3b[count + 1];
                    continue;

                case '%':
                    result = bit3a % bit3b[count + 1];
                    continue;
                }
                count++;
            }

            count = 0;

            foreach (ShxmlVariable ShxVar in varsb)
            {
                if (OpList.Count - count > 1)
                {
                    switch (OpList[count])
                    {
                    case '+':
                        result = result + bit3c[count];
                        count++;
                        continue;

                    case '-':
                        result = result - bit3c[count];
                        count++;
                        continue;

                    case '*':
                        result = result * bit3c[count];
                        count++;
                        continue;

                    case '/':
                        result = result / bit3c[count];
                        count++;
                        continue;

                    case '%':
                        result = result % bit3c[count];
                        count++;
                        continue;
                    }
                    count++;
                }
            }

            count = 0;
            //update the main list


            svar.vardouble = result;
            return(svar);
        }
コード例 #24
0
        public Module GetModule(string uri, string path)
        {
            Console.WriteLine($"Installing module from the Internet at {uri}..."); // displays a message
            ShellCore.DownloadFileEx(uri, path);
            ShellCore.ExtractZipFile("Module.zip", "Modules");
            XmlDocument ModuleXml = ShellCore.XmlOpenFile("Modules/Module.xml");

            Console.WriteLine($"Reading Module XML file...");
            XmlNode moduleRoot = ModuleXml.FirstChild;
            string  Name       = moduleRoot.Name;

            if (Name == "#comment")
            {
                while (Name == "#comment")
                {
                    moduleRoot = moduleRoot.NextSibling; // get the next node.
                    Name       = moduleRoot.Name;        // get the next node until we have an actual node.
                }
            }

            if (Name != "Module")
            {
                ShellCore.ElmThrowException(55);
            }

            Module Module = new Module();

            foreach (XmlNode attribute in moduleRoot.ChildNodes)
            {
                switch (attribute.Name)
                {
                case "Name":     // module name
                    Module.Name = attribute.InnerText;
                    continue;

                case "Author":     // module author
                    Module.Author = attribute.InnerText;
                    continue;

                case "Version":     // module version
                    Module.Version = attribute.InnerText;
                    continue;

                case "Copyright":     // module copyright
                    Module.Copyright = attribute.InnerText;
                    continue;

                case "Website":     // module website
                    Module.Website = attribute.InnerText;
                    continue;

                case "Dll":     // module dll
                    Module.Dll = attribute.InnerText;
                    continue;

                case "Extends":     // which dll does this module extend
                    string trimmedExtends = attribute.InnerText.Trim();
                    switch (trimmedExtends)
                    {
                    case "shlcore":
                    case "Shlcore":
                    case "shlCore":
                    case "ShlCore":
                    case "shellcore":
                    case "Shellcore":
                    case "shellCore":
                    case "ShellCore":
                        Module.Extends = Extends.ShellCore;
                        continue;

                    case "shlui":
                    case "Shlui":
                    case "shlUi":
                    case "ShlUi":
                    case "ShlUI":
                    case "shellui":
                    case "ShellUi":
                    case "shellUI":
                    case "ShellUI":
                    case "shellUi":
                    case "Shellui":
                    case "shelluI":
                        Module.Extends = Extends.ShellUI;
                        continue;

                    default:
                        ShellCore.ElmThrowException(57);
                        return(Module);
                    }
                }
            }
            return(Module);
        }
コード例 #25
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            ShellCore.ShutdownContainer();
        }
コード例 #26
0
        public void ShxmlHandleIfStatement(XmlNode token)         // v0.5.6+ (actually functional in v0.6.0)+
        {
            XmlAttributeCollection attributes = token.Attributes; // no attributes but yeahhhhhhhhhhhhhhhhhhhhhhhhh

            if (!token.HasChildNodes)
            {
                ShellCore.ElmThrowException(33); //Empty if statement
            }

            int    count  = 0;
            double result = 0;

            string        x    = null;
            ShxmlVariable svar = new ShxmlVariable();

            OperandList = new List <string>();
            OpList      = new List <char>();
            foreach (XmlAttribute attribute in attributes)
            {
                switch (attribute.Name)
                {
                case "condition":
                case "Condition":
                case "cond":
                case "Cond":
                    x = attribute.Value;
                    char[] thebits = attribute.Value.ToCharArray();

                    // This works because the first operand is after the first part of the string. Thus we get the correct operands.
                    foreach (char bit in thebits)
                    {
                        switch (bit)
                        {
                        case '=':
                        case '!':
                            OpList.Add(bit);
                            continue;
                        }
                        count++;
                    }
                    continue;

                default:
                    ShellCore.ElmThrowException(19);
                    return;
                }
            }

            if (OpList.Count == 0)
            {
                ShellCore.ElmThrowException(41);
            }

            char[] OperatorListA = OpList.ToArray(); // convert to array
            cleancut = x.Split(OperatorListA);

            count = 0; // reset the count

            foreach (string bit2 in cleancut)
            {
                foreach (ShxmlVariable shvar in Varlist)
                {
                    if (cleancut[count] == shvar.Name)
                    {
                        if (shvar.Type == 1)
                        {
                            ShellCore.ElmThrowException(14); // Can't do stuff to strings...yet.
                        }

                        else if (shvar.Type == 5)
                        {
                            ShellCore.ElmThrowException(15); // Can't add booleans.
                        }

                        else
                        {
                            OperandList.Add(Convert.ToString(shvar.vardouble)); // convert it to string
                            count++;
                            continue;
                        }
                    }
                }
                OperandList.Add(bit2);
                count++;
            }

            List <ShxmlVariable> vars  = new List <ShxmlVariable>();
            List <double>        bit3  = new List <double>();
            List <double>        bit3c = new List <double>();

            count = 0; //set count back to 0
            foreach (string bit2 in cleancut)
            {
                string bit2a = bit2.Trim();

                int isVar = 0;
                foreach (ShxmlVariable sxvar in Varlist)
                {
                    if (sxvar.Name == bit2a & bit2a != svar.Name)
                    {
                        isVar = 1;
                        vars.Add(sxvar);
                        bit3.Add(sxvar.vardouble);
                    }
                }
                if (isVar == 0)
                {
                    try
                    {
                        if (bit2a != svar.Name)
                        {
                            double bit2b = Convert.ToDouble(bit2a);
                            bit3.Add(bit2b);
                        }
                    }
                    catch (FormatException)
                    {
                        // error 12 removed from here due to changes in how this works in Shell Development Release
                    }
                }
                isVar = 0;
            }

            // so it's easier
            double[] bit3b = bit3.ToArray();

            ShxmlVariable[] varsb = vars.ToArray(); // local list converted to an array.

            // jesus f*****g christ this code is getting worse!

            foreach (ShxmlVariable varsb2 in varsb)
            {
                bit3c.Add(varsb2.vardouble);
            }

            // this actually parses the stuff
            foreach (double bit3a in bit3b)
            {
                // This is awaiting changes to adding an overload in ShellCore to perform operations on a single int instead of a collection.
                switch (OpList[count])
                {
                case '=':
                    if (bit3a == bit3b[count + 1])
                    {
                        XmlParseScriptNodes(token.ChildNodes);
                    }

                    continue;

                case '!':
                    if (bit3a != bit3b[count + 1])
                    {
                        XmlParseScriptNodes(token.ChildNodes);
                    }
                    continue;
                }
                count++;
            }

            count = 0;

            foreach (ShxmlVariable ShxVar in varsb)
            {
                if (OpList.Count - count > 1)
                {
                    switch (OpList[count])
                    {
                    case '=':
                        if (result == bit3c[count])
                        {
                            XmlParseScriptNodes(token.ChildNodes);
                            return;
                        }
                        count++;
                        continue;

                    case '!':
                        if (result == bit3c[count])
                        {
                            XmlParseScriptNodes(token.ChildNodes);
                            return;
                        }
                        count++;
                        continue;
                    }
                    count++;
                }
            }

            count = 0;
            //return svar;

            return;
        }
コード例 #27
0
        public void ShxmlConsoleOutput(XmlNode token) // pass
        {
            string        text    = "";
            StringBuilder buildit = new StringBuilder(); // the final string.

            string[] text_s = null;
            int      posx   = -0xd15ea5e;
            int      posy   = -0xd15ea5e;

            XmlAttributeCollection attributes = token.Attributes;

            foreach (XmlAttribute attribute in attributes)
            {
                // check for what we want
                switch (attribute.Name)
                {
                case "text":

                    text = attribute.Value;
                    int count = 0;

                    text_s = text.Split('+');
                    foreach (string text_t in text_s)
                    {
                        foreach (ShxmlVariable xvar in Varlist)
                        {
                            if (text_t == xvar.Name)
                            {
                                if (text_s.Count() - count > 0)
                                {
                                    switch (xvar.Type)
                                    {
                                    // convert to string and add
                                    case 0:
                                        text_s[count] = Convert.ToString(xvar.varint);
                                        continue;

                                    case 1:
                                        text_s[count] = xvar.varstring;
                                        continue;

                                    case 2:
                                        text_s[count] = Convert.ToString(xvar.varchar);
                                        continue;

                                    case 3:
                                        text_s[count] = Convert.ToString(xvar.vardouble);
                                        continue;

                                    case 4:
                                        text_s[count] = Convert.ToString(xvar.varfloat);
                                        continue;

                                    case 5:
                                        text_s[count] = Convert.ToString(xvar.varbool);
                                        continue;
                                    }
                                }
                            }
                        }
                        count++;
                    }

                    foreach (string text_t in text_s)
                    {
                        buildit.Append(text_t);
                    }

                    continue;

                case "posx":
                    try
                    {
                        if (posx == -0xd15ea5e)
                        {
                            posx = Convert.ToInt32(attribute.Value);     // x position (in char cells from 0)
                        }
                    }

                    catch (FormatException)
                    {
                        ShellCore.ElmThrowException(16);
                    }

                    if (posx == -0xd15ea5e)
                    {
                        ShellCore.ElmThrowException(18);
                    }

                    continue;

                case "posy":
                    try
                    {
                        if (posy == -0xd15ea5e)
                        {
                            posy = Convert.ToInt32(attribute.Value);     // y position (in char cells from 0)
                        }
                    }

                    catch (FormatException)
                    {
                        ShellCore.ElmThrowException(17);
                    }

                    if (posy == -0xd15ea5e)
                    {
                        ShellCore.ElmThrowException(18);
                    }


                    continue;

                default:
                    ShellCore.ElmThrowException(19);
                    continue;
                }
            }

            if (posx != -0xd15ea5e & posy != -0xd15ea5e)
            {
                UiSetCursorPosition(posx, posy); // yeah
            }

            //todo: + to separate variables in <Input>??

            // Should've used delegates here. Oh well.

            Console.WriteLine(buildit); // since we're not done...



            return;
        }
コード例 #28
0
        public void XmlParseScriptNodes(XmlNodeList children)
        {
            foreach (XmlNode token in children)
            {
                switch (token.Name)
                {
                default:
                    ShellCore.ElmThrowException(0);
                    return;

                case "#document":
                    continue;

                case "#comment":
                    continue;

                case "shellxml":
                case "Shellxml":
                case "shellXML":
                case "ShellXML":
                    ShellCore.ElmThrowException(3);
                    return;

                case "var":
                case "Var":
                    ShxmlDeclareVariable(token);
                    continue;

                case "operation":
                case "Operation":
                case "op":
                case "Op":
                    ShxmlPerformOperation(token);
                    continue;

                case "input":
                case "Input":
                    ShxmlConsoleInput(token);
                    continue;

                case "output":
                case "Output":
                    ShxmlConsoleOutput(token);
                    continue;

                case "function":
                case "Function":
                    string fpath = ShxmlRunFunction(token);
                    XmlParseScript(fpath, 1);
                    continue;

                case "exception":
                case "Exception":
                    ShxmlException(token);
                    continue;

                case "if":
                case "If":
                    ShxmlHandleIfStatement(token);
                    continue;

                    /* Coming Soon
                    *  case "Else":*/
                }
            }
        }
コード例 #29
0
ファイル: BattleAI.cs プロジェクト: FoeFear/shellcore
    public override void Init()
    {
        carriers         = new List <Entity>();
        harvesterTurrets = new Dictionary <EnergyRock, Turret>();

        Entity[] targetEntities = BattleZoneManager.getTargets();
        if (targetEntities == null)
        {
            Debug.LogError("Battle zone target list not initialized");
            ai.setMode(AirCraftAI.AIMode.Inactive);
            return;
        }

        for (int i = 0; i < targetEntities.Length; i++)
        {
            if (targetEntities[i] is ICarrier)
            {
                if (targetEntities[i].faction == craft.faction)
                {
                    carriers.Add(targetEntities[i]);
                }
            }
        }

        if (craft is ShellCore shellCore)
        {
            shellcore = shellCore;
        }
        else
        {
            Debug.LogError("Battle zone AI should only be used by shellcores!");
        }

        foreach (IOwnable ownable in shellcore.GetUnitsCommanding())
        {
            if (ownable is Turret turret && turret.entityName == "Harvester Turret")
            {
                foreach (var rock in AIData.energyRocks)
                {
                    if (!harvesterTurrets.ContainsKey(rock) &&
                        Vector3.SqrMagnitude(rock.transform.position - turret.transform.position) <= 200)
                    {
                        harvesterTurrets.Add(rock, turret);
                        break;
                    }
                }
            }
        }

        nextSearchTime     = Time.time;
        nextStateCheckTime = Time.time;

        for (int i = 0; i < AIData.vendors.Count; i++)
        {
            int rockCount = 0;
            for (int j = 0; j < AIData.energyRocks.Count; j++)
            {
                if ((AIData.energyRocks[j].transform.position - AIData.vendors[i].transform.position).sqrMagnitude < 100)
                {
                    rockCount++;
                }
            }

            AITargets.Add(new AITarget(AIData.vendors[i], rockCount + 1f));
        }

        for (int i = 0; i < carriers.Count; i++)
        {
            AITargets.Add(new AITarget(carriers[i], 100f));
        }
    }
コード例 #30
-1
        public void ShxmlConsoleInput(XmlNode Token)
        {
            string        text = "";
            int           posx = -0xd15ea5e;
            int           posy = -0xd15ea5e;
            char          chr  = ' ';
            ShxmlVariable svar = new ShxmlVariable(); //TODO: Clean up the code.

            svar.Name = "ddddddddddddddddddddddddddddddddddddddddddddddddddd";
            XmlAttributeCollection attributes = Token.Attributes;

            foreach (XmlAttribute attribute in attributes)
            {
                switch (attribute.Name)
                {
                case "text":
                    text = attribute.Value;
                    continue;

                case "posx":
                    try
                    {
                        posx = Convert.ToInt32(attribute.Value);
                    }

                    catch (FormatException)
                    {
                        ShellCore.ElmThrowException(16);
                    }

                    if (posx == -0xd15ea5e)
                    {
                        ShellCore.ElmThrowException(18);
                    }
                    continue;

                case "posy":
                    try
                    {
                        posy = Convert.ToInt32(attribute.Value);
                    }

                    catch (FormatException)
                    {
                        ShellCore.ElmThrowException(17);
                    }

                    if (posx == -0xd15ea5e)
                    {
                        ShellCore.ElmThrowException(18);
                    }

                    continue;

                case "char":
                    try
                    {
                        chr = Convert.ToChar(attribute.Value);
                    }
                    catch (FormatException)
                    {
                        ShellCore.ElmThrowException(20);
                    }

                    continue;

                case "variable":
                case "var":

                    svar.Name = attribute.Value;

                    if (svar.Name == "")
                    {
                        ShellCore.ElmThrowException(21);
                    }

                    svar.Type = 1;     // string


                    continue;
                }
            }

            if (svar.Name == "ddddddddddddddddddddddddddddddddddddddddddddddddddd")
            {
                ShellCore.ElmThrowException(22); // exception 22 - no variable
            }

            if (posx != -0xd15ea5e & posy != 0xd15ea5e)
            {
                UiSetCursorPosition(posx, posy); // set the cursor position if it is not a default value
            }

            Console.Write($"{text} {chr}");
            svar.varstring = Console.ReadLine();
            Varlist.Add(svar); // add it to the global master variable listash
        }