public AuroraObject Nearest(AuroraLocation loc, Type t, int nth) { List <AuroraObject> objs = new List <AuroraObject>(); foreach (List <AuroraObject> list in auroraObjects.Values) { foreach (AuroraObject obj in list) { if (obj.GetType() == t || obj.GetType().IsSubclassOf(t)) { objs.Add(obj); } } } if (nth >= objs.Count) { return(null); } objs.Sort( (x, y) => Vector3.Distance(loc.GetVector(), x.transform.position).CompareTo(Vector3.Distance(loc.GetVector(), y.transform.position)) ); return(objs[nth]); }
//public AuroraCreature CreatePC() //{ // return null; // //return new AuroraCreature(null); //} //public AuroraModule CreateObject(Module mod) //{ // // Create an AuroraObject from a module // AuroraModule module = new AuroraModule(null); // module.SetModule(mod); // module.lastEntered = PC; // return module; //} //public AuroraObject CreateObject(GFFObject template, AuroraObject.AuroraObjectType auroraType) //{ // // Create an AuroraObject from a GFF template // //switch (auroraType) // //{ // // case AuroraObject.AuroraObjectType.DOOR: // // return new AuroraDoor(template); // // case AuroraObject.AuroraObjectType.PLACEABLE: // // return new AuroraPlaceable(template); // // case AuroraObject.AuroraObjectType.TRIGGER: // // return new AuroraTrigger(template); // // case AuroraObject.AuroraObjectType.AOE: // // return new AuroraAOE(template); // // case AuroraObject.AuroraObjectType.MODULE: // // throw new Exception("Modules can only be made with CreateObject(Module mod)"); // // case AuroraObject.AuroraObjectType.AREA: // // throw new Exception("Areas not yet implemented"); // // case AuroraObject.AuroraObjectType.ENCOUNTER: // // return new AuroraEncounter(template); // // case AuroraObject.AuroraObjectType.SOUND: // // return new AuroraSound(template); // //} // return null; //} public AuroraObject CreateObject(int nObjectType, string sTemplate, AuroraLocation lLocation, int bUseAppearAnimation) { Vector3 pos = new Vector3( lLocation.position.x, lLocation.position.z, lLocation.position.y ); // TODO: Implement appear animation switch ((ObjectType)nObjectType) { case ObjectType.CREATURE: Creature creature = AuroraEngine.Resources.LoadCreature(sTemplate, null); creature.gameObject.transform.position = pos; creature.transform.SetParent(GameObject.Find("Creatures").transform); return(creature); case ObjectType.PLACEABLE: Placeable placeable = AuroraEngine.Resources.LoadPlaceable(sTemplate, null); placeable.gameObject.transform.position = pos; placeable.transform.SetParent(GameObject.Find("Placeables").transform); return(placeable); default: Debug.LogWarning("CreateObject not yet implemented for " + (ObjectType)nObjectType); break; } throw new Exception("Failed to create object of type " + (ObjectType)nObjectType); }
public ActionForceMoveToLocation(AuroraObject obj, AuroraLocation lDestination, bool bRun, float fTimeout) : base(obj) { // TODO: Implement timeout loc = lDestination; timeout = fTimeout; startTime = Time.time; }
public void NewGameGlobals() { // Initialise the globals from the 2da file _2DAObject global2da = AuroraEngine.Resources.Load2DA("globalcat"); for (int i = 0; i < global2da.data.Count; i++) { string globalName = global2da[i, "name"]; string globalType = global2da[i, "type"]; switch (globalType) { case "Number": globalIntegers[globalName] = 0; break; case "Boolean": globalBooleans[globalName] = false; break; case "String": globalStrings[globalName] = ""; break; case "Location": globalLocations[globalName] = new AuroraLocation(); break; default: throw new Exception("Invalid global type " + globalType + " found"); } } }
public ActionAttack(AuroraObject obj, AuroraObject target, bool bPassive) : base(obj) { this.self = obj; this.target = target; this.passive = bPassive; location = AttackPosition(target); moveAction = new ActionMoveToLocation(obj, location, true); weapon = ((Creature)obj).GetMainWeapon(); if (weapon == null) { weaponType = Item.WeaponType.MELEE; } else { weaponType = weapon.GetWeaponType(); } if (weaponType == Item.WeaponType.MELEE) { // For melee weapons, we run up to the front of the target } else { // For ranged weapons, we run within a certain distance of the target // TODO: Use actual weapon range stats from baseitems.2da attackRange = 15f; } obj.attemptedAttackTarget = target; }
public ActionMoveToLocation(AuroraObject obj, AuroraLocation location, bool bRun) : base(obj) { this.loc = location; this.run = bRun; this.range = 0.2f; }
public AuroraLocation AttackPosition(AuroraObject target) { AuroraLocation loc = new AuroraLocation(); Vector3 pos; // Depending on if it's a ranged or melee attack, we will do different things if (weaponType == Item.WeaponType.MELEE) { // For melee weapons, we run up to the front of the target pos = target.transform.position + target.transform.forward * attackRange; } else { // For ranged weapons, we run within a certain distance of the target // TODO: Use actual weapon range stats from baseitems.2da pos = target.transform.position + target.transform.forward * 15f; } loc.position = new Vector3( pos.x, pos.z, pos.y ); return(loc); }
public void SetGlobalLocation(string name, AuroraLocation value) { globalLocations[name] = value; }
public ActionCastFakeSpellAtLocation(AuroraObject obj, int nSpell, AuroraLocation lTarget, int nProjectilePathType) : base(obj) { }
public ActionCastSpellAtLocation(AuroraObject obj, int nSpell, AuroraLocation lTargetLocation, int nMetaMagic, bool bCheat, int nProjectilePathType, bool bInstantSpell) : base(obj) { }
public ActionUseTalentAtLocation(AuroraObject obj, AuroraTalent tChosenTalent, AuroraLocation lTargetLocation) : base(obj) { }
public ActionJumpToLocation(AuroraObject obj, AuroraLocation location) : base(obj) { loc = location; }