public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { Log("MobTypeImporter called"); foreach (string assetPath in importedAssets) { Log("MobTypeImporter: " + assetPath); if (assetPath.EndsWith("MobTypes.prefab")) { Log("Found MobTypes Asset: " + assetPath); GameObject assetGameObject = Resources.Load <GameObject>("MobTypes"); MobTypeManager mobTypeManager = assetGameObject.GetComponent <MobTypeManager>(); if (mobTypeManager != null) { if (MobTypeImporter.ParseMobTypes(mobTypeManager)) { Log("MobTypeImporter: has RoomTemplateManager component!"); } else { Debug.LogError("MobTypeImporter: Failed to import room templates"); } } else { Debug.LogError("MobTypeImporter: Asset missing RoomTemplateManager component!"); } AssetDatabase.Refresh(ImportAssetOptions.Default); } } }
public override string ToChatString(GameWorldController gameWorldController) { MobData mobData = gameWorldController.Model.GetMobData(MobID); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); float distance = Point3d.Distance(FromPosition, ToPosition); MathConstants.eDirection direction = MathConstants.GetDirectionForAngle(ToAngle); string facing = ""; switch (direction) { case MathConstants.eDirection.none: facing = "South"; break; case MathConstants.eDirection.right: facing = "East"; break; case MathConstants.eDirection.up: facing = "North"; break; case MathConstants.eDirection.left: facing = "West"; break; case MathConstants.eDirection.down: facing = "South"; break; } return(base.ToChatString(gameWorldController) + mobType.Name + " moved " + distance.ToString("F1") + " feet, now facing " + facing); }
public override string ToChatString(GameWorldController gameWorldController) { MobData mobData = gameWorldController.Model.GetMobData(MobId); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); return(base.ToChatString(gameWorldController) + mobType.Name + " spotted an energy tank"); }
public override string ToChatString(GameWorldController gameWorldController) { MobData mobData = gameWorldController.Model.GetMobData(MobId); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); // TODO: Display what the mob ID attacked return(base.ToChatString(gameWorldController) + " " + mobType.Name + " attacked"); }
public override string ToChatString(GameWorldController gameWorldController) { MobData mobData = gameWorldController.Model.GetMobData(MobId); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); string characterName = gameWorldController.Model.GetCharacterData(CharacterID).character_name; return(base.ToChatString(gameWorldController) + mobType.Name + " spotted " + characterName); }
private static bool ParseMobTypes(MobTypeManager mobTypeManager) { bool success = true; string mob_types_path = mobTypeManager.mobTypePath; Dictionary <string, MobType> mobTypes = new Dictionary <string, MobType>(); try { string mob_types_json = File.ReadAllText(mob_types_path); JsonData jsonObject = JsonMapper.ToObject(mob_types_json); JsonData mobTypeSet = jsonObject["mob_types_set"]; if (mobTypeSet != null && mobTypeSet.Count > 0) { for (int mobTypeIndex = 0; mobTypeIndex < mobTypeSet.Count; ++mobTypeIndex) { JsonData jsonEntry = mobTypeSet[mobTypeIndex]; MobType mobType = MobType.FromObject(jsonEntry); if (ValidateMobType(mobType, mobTypes)) { mobTypes.Add(mobType.Name, mobType); } else { Debug.LogError("MobTypeImporter: ERROR: Problem(s) validating mob type: " + mobType.Name); success = false; } } } else { Debug.LogError("MobTypeImporter: ERROR: No mob types found in file:" + mob_types_path); success = false; } } catch (Exception ex) { Debug.LogError("MobTypeImporter: ERROR: Failed to parse mob types: " + ex.Message); Debug.LogException(ex); success = false; } // Store the mob types into the mob type manager if (success) { MobType[] mobTypeArray = new MobType[mobTypes.Count]; mobTypes.Values.CopyTo(mobTypeArray, 0); mobTypeManager.CacheMobTypes(mobTypeArray); Log(string.Format("MobTypeImporter: Caching {0} mob types(s) in mob manager.", mobTypes.Count)); } return(success); }
public override string ToChatString(GameWorldController gameWorldController) { string speakerName = ""; MobData mobData = gameWorldController.Model.GetMobData(MobId); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); speakerName = mobType.Name; return(base.ToChatString(gameWorldController) + speakerName + " said \"" + Dialog + "\""); }
// Use this for initialization void Start() { Screen.SetResolution(GameConstants.GAME_SCREEN_PIXEL_WIDTH, GameConstants.GAME_SCREEN_PIXEL_HEIGHT, false); m_gameManager = this.gameObject.AddComponent("GameManager") as GameManager; m_gameManager.SetTargetGameState("LoginScreen"); m_roomTemplateManager= (GameObject.Instantiate(Resources.Load("RoomTemplates")) as GameObject).GetComponent<RoomTemplateManager>(); m_mobTypeManager = (GameObject.Instantiate(Resources.Load("MobTypes")) as GameObject).GetComponent<MobTypeManager>(); }
// Use this for initialization void Start() { Screen.SetResolution(GameConstants.GAME_SCREEN_PIXEL_WIDTH, GameConstants.GAME_SCREEN_PIXEL_HEIGHT, false); m_gameManager = this.gameObject.AddComponent("GameManager") as GameManager; m_gameManager.SetTargetGameState("LoginScreen"); m_roomTemplateManager = (GameObject.Instantiate(Resources.Load("RoomTemplates")) as GameObject).GetComponent <RoomTemplateManager>(); m_mobTypeManager = (GameObject.Instantiate(Resources.Load("MobTypes")) as GameObject).GetComponent <MobTypeManager>(); }
public override string ToChatString(GameWorldController gameWorldController) { string hackerName = ""; if (HackerFaction == GameConstants.eFaction.ai) { MobData mobData = gameWorldController.Model.GetMobData(HackerId); MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); hackerName = mobType.Name; } else if (HackerFaction == GameConstants.eFaction.player) { hackerName = gameWorldController.Model.GetCharacterData(HackerId).character_name; } return(base.ToChatString(gameWorldController) + " Energy Tank hacked by " + hackerName); }
public void Start() { m_instance = this; m_mobTypesDictionary = new Dictionary <string, MobType>(); if (m_mobTypesList != null && m_mobTypesList.Length > 0) { // Build the room template lookup table from the room template list foreach (MobType mobType in m_mobTypesList) { m_mobTypesDictionary.Add(mobType.Name, mobType); } if (m_debugging) { Debug.LogWarning("MobTypeManager: Dumping " + mobTypePath + ".txt"); DumpMobTypes(); } } else { Debug.LogError("MobTypeManager: Mob Types missing!"); } }
public void Start() { m_instance = this; m_mobTypesDictionary = new Dictionary<string, MobType>(); if (m_mobTypesList != null && m_mobTypesList.Length > 0) { // Build the room template lookup table from the room template list foreach (MobType mobType in m_mobTypesList) { m_mobTypesDictionary.Add(mobType.Name, mobType); } if (m_debugging) { Debug.LogWarning("MobTypeManager: Dumping " + mobTypePath + ".txt"); DumpMobTypes(); } } else { Debug.LogError("MobTypeManager: Mob Types missing!"); } }
public void OnDestroy() { m_instance = null; }
public MobWidget(WidgetGroup parentGroup, MobWidgetStyle style, MobData mobData) : base( parentGroup, style.Width, style.Height, GameConstants.ConvertRoomPositionToPixelPosition(mobData.PositionInRoom).x, GameConstants.ConvertRoomPositionToPixelPosition(mobData.PositionInRoom).y) // Gross { MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name); m_style = style; m_title = new LabelWidget( this, style.LabelWidth, // width style.LabelHeight, // height (m_style.Width / 2.0f) - (m_style.LabelWidth / 2.0f), // local x -m_style.BoundsHeight - style.LabelHeight, // local y mobType.Label); // text m_title.Alignment = TextAnchor.UpperCenter; m_energy = new LabelWidget( this, style.LabelWidth, // width style.LabelHeight, // height (m_style.Width / 2.0f) - (m_style.LabelWidth / 2.0f), // local x 0, // local y ""); // text m_energy.Alignment = TextAnchor.UpperCenter; this.Energy = mobData.energy; // Create the sprite game object { string archetype = mobType.Name; string gameObjectPath = "Gfx/Sprites/Enemies/" + archetype + "/" + archetype + "_sprite"; m_spriteObject = GameObject.Instantiate( Resources.Load <GameObject>(gameObjectPath)) as GameObject; m_spriteAnimator = m_spriteObject.GetComponent <Animator>(); UpdateWorldPosition(); } // Create the dialog label m_dialog = new LabelWidget( this, style.DialogWidth, // width style.DialogHeight, // height (m_style.Width / 2.0f) - (m_style.DialogWidth / 2.0f), // local x m_title.LocalY - style.DialogHeight, // local y ""); // text m_dialog.FontSize = 14; m_dialog.Color = Color.red; m_dialog.Alignment = TextAnchor.UpperCenter; m_dialog.Visible = false; // Set the initial animation controller parameters m_spriteAnimator.SetFloat(SPEED_FLOAT_PARAMETER, 0.0f); m_spriteAnimator.SetFloat(FACING_X_FLOAT_PARAMETER, 0.0f); m_spriteAnimator.SetFloat(FACING_Y_FLOAT_PARAMETER, -1.0f); m_spriteAnimator.SetBool(IS_ATTACKING_BOOL_PARAMETER, false); // Create the vision cone m_visionCone = new VisionConeWidget( this, mobType.Name + mobData.mob_id.ToString(), mobType.VisionConeDistance, mobType.VisionConeAngleDegrees, 0.0f, 0.0f, 0.0f); m_visionCone.ConeFacing = MathConstants.GetAngleForDirection(MathConstants.eDirection.down); }
public override string ToChatString(GameWorldController gameWorldController) { MobType mobType = MobTypeManager.GetMobTypeByName(m_mobState.mob_type_name); return(base.ToChatString(gameWorldController) + mobType.Name + " spawned"); }