示例#1
0
    public override void OnStartClient()
    {
        PlayerNameHook(pseudo);
        string message = string.Format("{0} : {1}( {2} )", name.Coloring("red"), "OnStartClient", pseudo.Coloring("blue").Bold());

        Console.AddMessage(message);
    }
示例#2
0
    public OSMData(string osmXMLpath)
    {
        XmlTextReader xmlReader = new XmlTextReader(osmXMLpath);

        xmlReader.MoveToContent();
        while (xmlReader.Read())
        {
            if (xmlReader.NodeType.Equals(XmlNodeType.Element))
            {
                switch (xmlReader.LocalName)
                {
                case "node":
                    OSMNode n = ParseOSMNode(xmlReader);
                    nodes.Add(n.Id, n);
                    break;

                case "way":
                    OSMWay way = ParseOSMWay(xmlReader);
                    ways.Add(way.Id, way);
                    break;

                case "relation":
                    OSMRelation relation = ParseOSMRelation(xmlReader);
                    relations.Add(relation.Id, relation);
                    break;

                default:
                    //ignore other nodes
                    break;
                }
            }
        }
        UnityEngine.Debug.Log("New OSMDATA: " + nodes.Count + " Nodes " + ways.Count + " Ways " + relations.Count + " Relations");
        Console.AddMessage("New OSMDATA: " + nodes.Count + " Nodes " + ways.Count + " Ways " + relations.Count + " Relations");
    }
示例#3
0
        public void EngageEnemyNew(GameObject enemy)
        {
            AIController component = enemy.GetComponent <AIController>();

            if (!component || component == this)
            {
                return;
            }
            if (!this.EngagedEnemies.Contains(enemy))
            {
                this.EngagedEnemies.Add(enemy);
            }
            GameObject     owner         = this.StateManager.CurrentState.Owner;
            CharacterStats characterStat = owner.GetComponent <CharacterStats>();

            if (characterStat != null)
            {
                characterStat.NotifyEngagement(enemy);
            }
            GameEventArgs gameEventArg = new GameEventArgs()
            {
                Type           = GameEventType.MeleeEngaged,
                GameObjectData = new GameObject[] { owner }
            };

            component.OnEvent(gameEventArg);
            if (FogOfWar.Instance.PointVisible(owner.transform.position) && (!IEModOptions.DisableEngagement)) // added && ((Mod_GameOptions_GameMode)GameState.Mode).DisableEngagement == 0
            {
                Console.AddMessage(Console.Format(GUIUtils.GetTextWithLinks(100), new object[] { CharacterStats.NameColored(owner), CharacterStats.NameColored(enemy) }));
            }
            component.AddEngagedBy(owner);
        }
示例#4
0
 public static void BSC(string prefabName, int intIsHostile)
 {
     if (GameState.s_playerCharacter.IsMouseOnWalkMesh())
     {
         var isHostile = intIsHostile > 0;
         Console.AddMessage($"Spawning ${(isHostile  ? "Hostile" : "Friendly")}: ${prefabName}", Color.green);
         var newCreature = GameResources.LoadPrefab <UnityEngine.GameObject>(prefabName, true);
         if (newCreature != null)
         {
             newCreature.transform.position = GameInput.WorldMousePosition;
             newCreature.transform.rotation = GameState.s_playerCharacter.transform.rotation;
             var faction = newCreature.Component <Faction>();
             faction.RelationshipToPlayer = isHostile ? Faction.Relationship.Hostile : Faction.Relationship.Neutral;
             faction.UnitHostileToPlayer  = isHostile;
             var teamTag = isHostile ? "monster" : "player";
             faction.CurrentTeamInstance = Team.GetTeamByTag(teamTag);
             var aiPackage = newCreature.Component <AIPackageController>();
             aiPackage.ChangeBehavior(AIPackageController.PackageType.DefaultAI);
             aiPackage.InitAI();
             global::CameraControl.Instance.FocusOnPoint(newCreature.transform.position);
         }
         else
         {
             global::Console.AddMessage("Failed to spawn " + prefabName + " - probably bad naming.", UnityEngine.Color.red);
         }
     }
     else
     {
         global::Console.AddMessage("Mouse is not on navmesh, move mouse elsewhere and try again.", UnityEngine.Color.red);
     }
 }
示例#5
0
 public static void Log(string message)
 {
     if (_Instance != null)
     {
         _Instance.AddMessage(message);
     }
 }
示例#6
0
 public static void PlayerPrefs_Delete(string name)
 {
     if (!PlayerPrefs.HasKey(name))
     {
         Console.AddMessage("A key with this name was not found in PlayerPrefs.");
     }
     PlayerPrefs.DeleteKey(name);
 }
示例#7
0
 // Update is called once per frame
 void Update()
 {
     if ((Time.time - lapTime) > 2f)
     {
         lapTime = Time.time;
         Console.AddMessage(Time.time + ": Startet ConsoleTester");
     }
 }
示例#8
0
        public static void ExtractMemorials()
        {
            string xmlPath = PathHelper.Combine(Application.dataPath, "Managed/iemod", "MemorialEntries.xml");
            string xml     = Resources.Load("Data/UI/BackerMemorials").ToString();

            File.WriteAllText(xmlPath, xml);
            Console.AddMessage("Extraction: done.");
        }
示例#9
0
    void CmdRenamePlayer(string _pseudo)
    {
        // using syncvar from the server to rename all clients
        pseudo = _pseudo;
        string message = string.Format("{0} : {1}({2})", name.Coloring("red"), "CmdRenamePlayer", _pseudo.Coloring("blue").Bold());

        Console.AddMessage(message);
    }
示例#10
0
        private static void ReplaceAtlas(bool state)
        {
            /*			// THIS IS WHAT YOU WOULD DO if you wanted to use a custom atlas
             * //
             * //			UIAtlas copy = (UIAtlas) UIAtlas.Instantiate (attackspr.atlas);
             * //			copy.name = "Pizda";
             * //			attackspr.atlas = copy;
             * //			copy.spriteMaterial =  new Material(UIAtlasManager.Instance.Inventory.spriteMaterial.shader);
             * //			copy.spriteMaterial.mainTexture = atlasTexture;
             * //
             * //			copy.spriteList.Clear ();
             * //
             * //			UIAtlas.Sprite sprite1 = new UIAtlas.Sprite ();
             * //			sprite1.inner = new Rect (283, 18, 42, 42);
             * //			sprite1.outer = new Rect (0, 0, 0, 0);
             * //			sprite1.paddingLeft = 0;
             * //			sprite1.paddingTop = 0;
             * //			sprite1.paddingRight = 0;
             * //			sprite1.paddingBottom = 0;f
             * //			sprite1.name = "test1";
             * //
             * //			copy.spriteList.Add (sprite1);
             * //
             */// END
            var icon = Attack.Child("Icon");

            if (state)
            {
                if (AlternateActionBarAtlas == null)
                {
                    var alternateAtlas = Path.Combine(Path.Combine(Application.dataPath, "Managed/iemod/buttons"),
                                                      "ActionBarAlternate.png");

                    if (File.Exists(alternateAtlas))
                    {
                        var atlasTexture = new Texture2D(512, 256, TextureFormat.RGB24, false);
                        var bytes        = File.ReadAllBytes(alternateAtlas);
                        atlasTexture.LoadImage(bytes);
                        atlasTexture.name       = "AlternateAtlas";
                        AlternateActionBarAtlas = atlasTexture;
                        icon.Component <UISprite>().atlas.spriteMaterial.mainTexture = atlasTexture;                        //attack icon
                    }
                    else
                    {
                        Console.AddMessage("Couldn't read file at path: " + alternateAtlas, Color.red);
                    }
                }
                else
                {
                    icon.Component <UISprite>().atlas.spriteMaterial.mainTexture = AlternateActionBarAtlas;
                }
            }
            else
            {
                icon.Component <UISprite>().atlas.spriteMaterial.mainTexture = DefaultActionBarAtlas;
            }
        }
示例#11
0
    void PlayerNameHook(string hook)
    {
        //Console.AddMessage (name.Coloring("red")+" :PlayerNameHook()");
        PlayerNamePlate.text = hook;
        name = hook;
        string message = string.Format("{0} : {1}({2})", name.Coloring("red"), "PlayerNameHook", hook.Coloring("blue").Bold());

        Console.AddMessage(message);
    }
示例#12
0
 public static void DeleteIEModSettings(bool areYouSure)
 {
     if (!areYouSure)
     {
         Console.AddMessage("You need to pass 'true' if you really want to delete all settings.", Color.red);
         return;
     }
     IEModOptions.DeleteAllSettings();
     Console.AddMessage("All settings have been deleted.", Color.green);
 }
示例#13
0
 /// <summary>
 /// Replies to the player with a specific message
 /// </summary>
 /// <param name="player"></param>
 /// <param name="message"></param>
 private static void ReplyWith(Player player, string message)
 {
     if (player.IsServer)
     {
         Console.AddMessage(message);
     }
     else
     {
         EventManager.CallEvent(new PlayerErrorEvent(player.Id, message));
     }
 }
示例#14
0
        public static void PlayerPrefs_DeleteAll(bool confirmation)
        {
            if (!confirmation)
            {
                Console.AddMessage("You need to supply a 'true' argument if you're sure you want to clear all preferences.");
                return;
            }

            PlayerPrefs.DeleteAll();
            Console.AddMessage("All preferences cleared. Please restart the game so that no errors occur.");
        }
示例#15
0
    public override void OnStartLocalPlayer()
    {
        pseudo = GameManager.Instance.LocalPlayerName;

        // duplicate code with playernamehook ... but...
        PlayerNamePlate.text = pseudo;
        name = pseudo;

        string message = string.Format("{0} : {1}( {2} )", name.Coloring("red"), "OnStartLocalPlayer", pseudo.Coloring("blue").Bold());

        Console.AddMessage(message);
        CmdRenamePlayer(pseudo);
    }
示例#16
0
        /// <summary>
        /// Advances time by 8 hours
        /// Direct call to Scripts AdvanceTimeByHoursNoRest
        /// </summary>
        public static void AdvanceTime()
        {
            Scripts.AdvanceTimeByHoursNoRest(8);

            Stronghold stronghold = GameState.Stronghold;

            if (stronghold != null)
            {
                stronghold.AddTurns(1);
                stronghold.AdvanceOneTurn();
                Console.AddMessage("Stronghold turn advanced by 1", Color.green);
            }
        }
示例#17
0
        public static void Skill(Guid character, CharacterStats.SkillType skill, int score)
        {
            CharacterStats characterStatsComponent = Scripts.GetCharacterStatsComponent(character);

            if (characterStatsComponent == null)
            {
                Debug.Log(string.Concat("Skill: Error - stats component not found for '", character, "'."));
                return;
            }

            switch (skill)
            {
            case CharacterStats.SkillType.Stealth:
            {
                characterStatsComponent.StealthSkill = score;
                break;
            }

            case CharacterStats.SkillType.Athletics:
            {
                characterStatsComponent.AthleticsSkill = score;
                break;
            }

            case CharacterStats.SkillType.Lore:
            {
                characterStatsComponent.LoreSkill = score;
                break;
            }

            case CharacterStats.SkillType.Mechanics:
            {
                characterStatsComponent.MechanicsSkill = score;
                break;
            }

            case CharacterStats.SkillType.Survival:
            {
                characterStatsComponent.SurvivalSkill = score;
                break;
            }

            case CharacterStats.SkillType.Crafting:
            {
                characterStatsComponent.CraftingSkill = score;
                break;
            }
            }
            Console.AddMessage(string.Concat(new object[] { characterStatsComponent.name, "'s ", skill, " is now ", score.ToString() }));
        }
示例#18
0
        private void add_TrySwitchingToOtherWeapon()
        {
            try
            {
                var ownerPartyMemberAI = this.Owner?.GetComponent <PartyMemberAI>();
                if (!ownerPartyMemberAI)
                {
                    return; // attacker isn't a party member, ignore
                }
                var ownerEquipment = this.Owner.GetComponent <Equipment>();
                var ownerCurItems  = ownerEquipment?.CurrentItems;
                if (ownerCurItems == null || ownerCurItems.PrimaryWeapon == null || ownerCurItems.SelectedWeaponSet <= 0)
                {
                    return; // owner doesn't have primary weapon OR currently equipped set is first one, ignore
                }
                var ownerPrimaryAttack = ownerCurItems.PrimaryWeapon.GetComponent <AttackBase>();
                if (ownerPrimaryAttack != this)
                {
                    return; // owner's current weapon is not what caused the attack, ignore
                }
                // find potential candidate for weapon switch (should be another ranged weapon that is either non-reloadable or already loaded)
                for (int i = ownerCurItems.SelectedWeaponSet - 1; i >= 0; --i)
                {
                    var candidateWeapon = ownerCurItems.AlternateWeaponSets[i]?.PrimaryWeapon;
                    var candidateAttack = candidateWeapon?.GetComponent <AttackRanged>();
                    if (!candidateAttack)
                    {
                        continue;
                    }

                    var candidateFirearm = candidateAttack as AttackFirearm;
                    if (candidateFirearm != null && candidateFirearm.RequiresReload)
                    {
                        continue; // skip firearms that need reloading
                    }
                    // found one!
                    Console.AddMessage($"{CharacterStats.NameColored(this.Owner)} switches to {candidateWeapon.Name} (weapon set {i + 1})!");
                    ownerEquipment.SelectWeaponSet(i, true);
                    break;
                }
            }
            catch (Exception e)
            {
                Console.AddMessage($"Gunslinger::TrySwitchingToOtherWeapon: exception {e.Message}", e.StackTrace);
            }
        }
示例#19
0
        public static void ImportStats(string fileName)
        {
            // Load document
            XmlDocument doc     = new XmlDocument();
            string      xmlPath = PathHelper.Combine(Application.dataPath, "Managed/iemod/customStats", (fileName + ".xml"));

            try
            {
                doc.Load(xmlPath);
            }
            catch (FileNotFoundException e)
            {
                Console.AddMessage("File not found");
                return;
            }

            // Retrieve all CharStats in current game
            CharacterStats[] characterStatsArray = UnityEngine.Object.FindObjectsOfType <CharacterStats>();
            foreach (XmlNode node in doc.DocumentElement)
            {
                string npcName = node.Attributes[0].Value;
                //Find Character sheet associated with that name, heavily insipired by the orignial FindCharacter command
                for (int i = 0; i < (int)characterStatsArray.Length; i++)
                {
                    CharacterStats characterStat = characterStatsArray[i];
                    if (characterStat.name.ToLower().Contains(npcName.ToLower()) || CharacterStats.Name(characterStat).ToLower().Contains(npcName.ToLower()))
                    {
                        // Switch stats arround accordingly
                        characterStat.BaseMight        = int.Parse(node["Might"].InnerText);
                        characterStat.BaseConstitution = int.Parse(node["Constitution"].InnerText);
                        characterStat.BaseDexterity    = int.Parse(node["Dexterity"].InnerText);
                        characterStat.BasePerception   = int.Parse(node["Perception"].InnerText);
                        characterStat.BaseIntellect    = int.Parse(node["Intellect"].InnerText);
                        characterStat.BaseResolve      = int.Parse(node["Resolve"].InnerText);

                        //  Display change in console... Mostly for testing and paranoia
                        Console.AddMessage(string.Concat(new string[] { characterStat.name, "'s stats have been imported from ", fileName }));

                        // Break out of inner loop once that NPC has been adjusted... ugly but probably quicker than anything else I know....
                        break;
                    }
                }
            }
        }
示例#20
0
        private void add_TrySwitchingToFirearm(GameObject owner)
        {
            try
            {
                if (owner == null)
                {
                    return;
                }

                var ownerEquipment = owner.GetComponent <Equipment>();
                var ownerCurItems  = ownerEquipment?.CurrentItems;
                var ownerCurAttack = ownerCurItems?.PrimaryWeapon?.GetComponent <AttackRanged>();
                if (ownerCurAttack == null)
                {
                    return; // current weapon is not a ranged one, ignore
                }
                // find potential candidate for weapon switch (last weapon in "firearm chain" starting from next weapon)
                int switchTo = ownerCurItems.SelectedWeaponSet;
                for (int i = ownerCurItems.SelectedWeaponSet + 1; i < ownerCurItems.AlternateWeaponSets.Length; ++i)
                {
                    if (!ownerCurItems.AlternateWeaponSets[i]?.PrimaryWeapon?.GetComponent <AttackFirearm>())
                    {
                        break; // chain is broken, stop
                    }
                    switchTo = i;
                }

                if (switchTo != ownerCurItems.SelectedWeaponSet)
                {
                    // found something to switch to!
                    var betterWeapon = ownerCurItems.AlternateWeaponSets[switchTo].PrimaryWeapon;
                    Console.AddMessage($"{CharacterStats.NameColored(owner)} switches to {betterWeapon.Name} (weapon set {switchTo + 1})!");
                    ownerEquipment.SelectWeaponSet(switchTo, true);
                }
            }
            catch (Exception e)
            {
                Console.AddMessage($"Gunslinger::TrySwitchingToFirearm: exception {e.Message}", e.StackTrace);
            }
        }
示例#21
0
        private void add_FixUpTableDrift()
        {
            // we only care about "big" tooltip (one appearing in top-left corner in combat)
            if (this != UIMapTooltipManager.Instance.BigTooltip || this.HealthLabel.alpha <= 0f)
            {
                return;
            }

            try
            {
                // table doesn't position elements correctly if health text is the widest element
                // for some reason (didn't find the root cause yet), all elements will move by +0.25 every other frame, and HealthLabel (which is child of the first table entry) will move by -0.25
                // this causes ugly drift
                // in normal cases (health is not the widest thing), all left-aligned elements will be offset by 20
                // for now, fix it via an ugly hack
                var elements = this.Table.children;

                // first element is an intermediate object that contains HealthLabel
                // when it is the widest element, it will "drift", like the rest; however, this is compensated by the HealthLabel's drift
                // we still want to stop it, since it causes ugly jittering of the text (due to floating-point inaccuracies, I think)
                var hpPos = elements[0].localPosition;
                var hcPos = HealthLabel.cachedTransform.localPosition;
                hpPos.x += hcPos.x;
                hcPos.x  = 0f;
                elements[0].localPosition = hpPos;
                HealthLabel.cachedTransform.localPosition = hcPos;

                // force reposition the remaining elements to the left border
                for (int i = 1; i < elements.Count; ++i)
                {
                    var localPos = elements[i].localPosition;
                    localPos.x = 20f;
                    elements[i].localPosition = localPos;
                }
            }
            catch (Exception e)
            {
                Console.AddMessage($"BetterTooltip: fixup exception {e.Message}", e.StackTrace);
            }
        }
示例#22
0
 void GpibAddress_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (SelectPrologix.Checked)
     {
         try
         {
             if (!ComPort.IsOpen)
             {
                 ComPort.Open();
             }
             ControllerCommand(AddressCommand, GpibAddress.SelectedItem.ToString());
         }
         catch (Exception ex)
         {
             Console.AddMessage(ex.Message);
         }
     }
     else
     {
         throw new NotImplementedException();
     }
 }
示例#23
0
    void Update()
    {
        if (playerGO != null)
        {
            Vector3 playerPosition = playerGO.transform.position;

            float tileUnityWidth = (float)(TileWidth * Scaling);

            currentTileIndex[0] = Mathf.RoundToInt(playerPosition.x / (tileUnityWidth));
            currentTileIndex[1] = Mathf.RoundToInt(playerPosition.z / (tileUnityWidth));

            //Debug.Log("x: " + currentTileIndex[0].ToString() + " y: " + currentTileIndex[1].ToString());

            if (!tiles.ContainsKey(currentTileIndex[0] + ":" + currentTileIndex[1]))
            {
                Console.AddMessage("Creating new Tile: " + currentTileIndex.ToString() + " with LOD" + LOD);
                Tile newTile = Tile.CreateTileGO(currentTileIndex[0], currentTileIndex[1], LOD);
                tiles.Add(currentTileIndex[0] + ":" + currentTileIndex[1], newTile);
                newTile.StartQuery();
            }
        }
    }
示例#24
0
 public static void ToggleWalkMode()
 {
     if (UIWindowManager.KeyInputAvailable)
     {
         if (GameInput.GetControlUp(MappedControl.Deprecated_CHANT_EDITOR))
         {
             WalkMode = !WalkMode;
             string msg;
             Color  color;
             if (WalkMode)
             {
                 msg   = "It is a nice day for a walk";
                 color = Color.green;
             }
             else
             {
                 msg   = "Time to move.  We can sight see later!";
                 color = Color.red;
             }
             Console.AddMessage(msg, color);
         }
     }
 }
示例#25
0
    public void DownloadOSMString()
    {
        try
        {
            Console.AddMessage("Webclient");
            WebClient client = new WebClient();

            UnityEngine.Debug.Log(URL + string.Format(querystring, boundingBox.ToQLString()));
            string url = URL + string.Format(querystring, boundingBox.ToQLString());
            client.Encoding = Encoding.UTF8;
            client.DownloadStringCompleted += ParseOSMXml;
            client.DownloadStringAsync(new Uri(url));
        }
        catch (WebException e)
        {
            UnityEngine.Debug.Log("i got this exception: " + e.Message);
            //retry--;
            //if (retry > 0)
            //{
            UnityEngine.Debug.Log("retry... ");// + retry);
            DownloadOSMString();
            //}
        }
    }
示例#26
0
 public static void ResetCustomUI()
 {
     IEModOptions.Layout = UICustomizer.DefaultLayout.Clone();
     IEModOptions.SaveToPrefs();
     Console.AddMessage("Successfuly reset the UI to default.");
 }
示例#27
0
 public override void PreStartClient()
 {
     Console.AddMessage(name.Coloring("red") + " :PreStartClient()");
 }
示例#28
0
 public override void OnStartServer()
 {
     Console.AddMessage(name.Coloring("red") + " :OnStartServer()");
 }
示例#29
0
    public OSMData(XmlDocument doc)
    {
        XmlNodeList xmlNodes     = doc.GetElementsByTagName("node");
        XmlNodeList xmlWays      = doc.GetElementsByTagName("way");
        XmlNodeList xmlRelations = doc.GetElementsByTagName("relation");

        long  id;
        float longitude;
        float latitude;

        foreach (XmlNode node in xmlNodes)
        {
            if (!long.TryParse(node.Attributes["id"].Value, out id))
            {
                continue;
            }
            if (!float.TryParse(node.Attributes["lon"].Value, out longitude))
            {
                continue;
            }
            if (!float.TryParse(node.Attributes["lat"].Value, out latitude))
            {
                continue;
            }
            OSMNode n = new OSMNode(id, latitude, longitude);

            nodes.Add(id, n);

            XmlNodeList childNodes = node.ChildNodes;

            foreach (XmlNode tagNode in childNodes)
            {
                if (tagNode.Name == "tag")
                {
                    n.Tags.Add(tagNode.Attributes["k"].Value, tagNode.Attributes["v"].Value);
                }
            }
        }

        foreach (XmlNode wayNode in xmlWays)
        {
            if (!long.TryParse(wayNode.Attributes["id"].Value, out id))
            {
                continue;
            }
            OSMWay way = new OSMWay(id);
            ways.Add(id, way);

            XmlNodeList childNodes = wayNode.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                if (childNode.Name == "nd")
                {
                    long referenceId;
                    if (long.TryParse(childNode.Attributes["ref"].Value, out referenceId))
                    {
                        way.WayNodes.Add(referenceId);
                    }
                }

                if (childNode.Name == "tag")
                {
                    way.Tags.Add(childNode.Attributes["k"].Value, childNode.Attributes["v"].Value);
                }
            }
        }

        foreach (XmlNode relNode in xmlRelations)
        {
            if (!long.TryParse(relNode.Attributes["id"].Value, out id))
            {
                continue;
            }

            OSMRelation relation = new OSMRelation(id);

            relations.Add(id, relation);

            XmlNodeList childNodes = relNode.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                if (childNode.Name == "member")
                {
                    if (!long.TryParse(childNode.Attributes["ref"].Value, out id))
                    {
                        continue;
                    }

                    relation.Members.Add(new OSMMember(childNode.Attributes["type"].Value, id, childNode.Attributes["role"].Value));
                }
                if (childNode.Name == "tag")
                {
                    relation.Tags.Add(childNode.Attributes["k"].Value, childNode.Attributes["v"].Value);
                }
            }
        }

        Console.AddMessage("New OSMDATA: " + nodes.Count + " Nodes " + ways.Count + " Ways " + relations.Count + " Relations");
    }
示例#30
0
 // Update is called once per frame
 void Start()
 {
     Console.AddMessage("Console ".Coloring("red") + "Start...".Coloring("green"));
 }