void Awake() { audioSource = GetComponent <AudioSource>(); weaponLoader = GetComponentInChildren <WeaponLoader>(); model = Instantiate(weapon.modelPrefab) as GameObject; modelHB = model.GetComponentInChildren <BoxCollider>(); }
/// <summary> /// Populate the listboxes with turret and tank models /// </summary> private void PopulateBoxes() { List <object> turrets = new List <object>(); //Populate turrets weapons = WeaponLoader.GetWeaponsAsList(); foreach (Weapon weapon in weapons) { turrets.Add(weapon.Name); } form.Turrets = turrets; form.Tanks = Utils.GetTankModels(); Renderer.SceneTools.Scene scene = ServiceManager.Scene; selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + tank.model), Vector3.Zero, 0); selectedTank = scene.Access3D(selectedTankRenderID); selectedTurretRenderID = scene.Add( ServiceManager.Resources.GetModel("weapons\\" + WeaponLoader.GetWeapon(tank.weaponID).Model), Vector3.Zero, 0); selectedTurret = scene.Access3D(selectedTurretRenderID); selectedTurret.Attach(selectedTank, Constants.TURRET_MOUNT); }
/// <summary> /// Event handler for when the user selects a different tank /// </summary> void SelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e) { if (tanks.Length > 0) { form.PlayButton.Enabled = true; form.EditButton.Enabled = true; form.DeleteButton.Enabled = true; selectedTank = tanks[form.SelectedIndex]; form.Armor = GameForms.Utils.ConvertFactorToProgressBar(selectedTank.armorFactor); form.Speed = GameForms.Utils.ConvertFactorToProgressBar(selectedTank.speedFactor); Scene scene = ServiceManager.Game.Renderer.ActiveScene; scene.ClearAll(); tankObj = new Renderer.SceneTools.Entities.Object3( ServiceManager.Resources.GetModel(@"tanks\" + selectedTank.model), Vector3.Zero); tankObj.MeshColor = Toolkit.GetColor(selectedTank.color); tank = scene.Add(tankObj, 0); turretObj = new Renderer.SceneTools.Entities.Object3( ServiceManager.Resources.GetModel(@"weapons\" + WeaponLoader.GetWeapon(selectedTank.weaponID).Model), Vector3.Zero); turretObj.MeshColor = Toolkit.GetColor(selectedTank.color); turret = scene.Add(turretObj, 0); turretObj.Attach(tankObj, Constants.TURRET_MOUNT); ApplySkin(); } }
private void SetStatistics() { form.RatioValue = Utils.ConvertFactorToProgressBar(tank.armorFactor); form.TankIndex = form.Tanks.IndexOf(tank.model); form.TurretIndex = form.Turrets.IndexOf(WeaponLoader.GetWeapon(tank.weaponID).Name); }
/// <summary> /// Populate the listboxes with turret and tank models /// </summary> private void PopulateBoxes() { //Populate turrets weapons = WeaponLoader.GetWeaponsAsList(); List <object> weaponNames = new List <object>(); foreach (Weapon weapon in weapons) { weaponNames.Add(weapon.Name); } form.Turrets = weaponNames; form.Tanks = Utils.GetTankModels(); Scene scene = ServiceManager.Game.Renderer.ActiveScene; selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[0]), Vector3.Zero, 0); selectedTank = scene.Access3D(selectedTankRenderID); selectedTurretRenderID = scene.Add( ServiceManager.Resources.GetModel("weapons\\" + weapons[0].Model), Vector3.Zero, 0); selectedTurret = scene.Access3D(selectedTurretRenderID); selectedTurret.Attach(selectedTank, "Mount"); }
public static void LoadWeapons(string weaponsFilepath) { foreach (var file in Directory.GetFiles(weaponsFilepath, "*.json")) { var weapon = WeaponLoader.LoanWeaponDefinition(file); _prototypes.Add(weapon.WeaponType, weapon); } }
/// <summary> /// Create a new Player object. /// </summary> /// <param name="_tank">Tank identifying this player.</param> public Player(GameSession.Tank _tank) { tank = _tank; MovementDirection = VTankObject.Direction.NONE; RotationDirection = VTankObject.Direction.NONE; Angle = _tank.angle; Weapon = WeaponLoader.GetWeapon(tank.attributes.weaponID); }
private PrototypeFactory() { var collectibles = new CollectibleLoader(); var weapons = new WeaponLoader(); weapons.LoadItems(ref _items); collectibles.LoadItems(ref _items); }
public Projectile(int ID, int projectileTypeId, VTankObject.Point position, double angle) { this.ID = ID; ProjectileTypeID = projectileTypeId; this.Data = WeaponLoader.GetProjectile(ProjectileTypeID); StartingPosition = position; Angle = angle; }
public SpawnEnvironmentEffectEvent(VTankBot _game, int id, int typeId, VTankObject.Point location, int ownerId) : base(_game) { this.id = id; this.typeId = typeId; this.location = location; this.ownerId = ownerId; envEffect = WeaponLoader.GetEnvironmentProperty(typeId); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); axe1 = WeaponLoader.GetInstance().Get("axe1"); Content.Unload(); }
public CreateProjectileEvent(VTankBot _game, int projectileTypeId, VTankObject.Point point, int ownerId, int projectileId) : base(_game) { this.type = WeaponLoader.GetProjectile(projectileTypeId); this.point = point; this.ownerId = ownerId; this.projectileId = projectileId; }
/// <summary> /// Check to see if any changes have been made to the tank or turret of this tank. /// </summary> private void DetectChanges() { string currentTankWeapon = WeaponLoader.GetWeapon(tank.weaponID).Name; string currentTankModel = tank.model; if (currentTankWeapon != selectedTurretName || currentTankModel != selectedTankModelName || oldSkin != form.TankSkin) { changesMade = true; } }
/// <summary> /// Returns a list of projectile models. /// </summary> /// <returns></returns> private List <string> GetProjectileModels() { List <string> result = new List <string>(); foreach (ProjectileData projectile in WeaponLoader.GetProjectiles().Values) { result.Add(projectile.Model); } return(result); }
public static void InitializeAllContentLoaders(ContentManager content) { TextureLoader.Initialize(content); FontLoader.Initialize(content); CharmLoader.Initialize(content); CreatureLoader.Initialize(content); ProjectileLoader.Initialize(content); ShieldLoader.Initialize(content); TileLoader.Initialize(content); UserInterfaceLoader.Initialize(content); WeaponLoader.Initialize(content); }
public override void DoAction() { envEffect = WeaponLoader.GetEnvironmentProperty(typeId); creationPosition = this.GetPosition(); if (Game.Players.ContainsKey(ownerId)) { envEffect.Owner = Game.Players[ownerId]; } Game.EnvironmentEffects.AddEffect(envEffect, id, creationPosition); }
/// <summary> /// Returns a list of weapon models. /// </summary> /// <returns></returns> private List <string> GetWeaponModels() { List <Weapon> weapons = WeaponLoader.GetWeaponsAsList(); List <string> result = new List <string>(); foreach (Weapon weapon in weapons) { result.Add(weapon.Model); result.Add(weapon.DeadModel); } return(result); }
// Use this for initialization void Start() { instance = GameManager.instance; Assert.IsNotNull(instance, "Can not find Game Manger."); loader = FindObjectOfType <WeaponLoader>(); Assert.IsNotNull(loader, "Can not find Rule Loader."); setter = FindObjectOfType <WeaponSetter>(); Assert.IsNotNull(setter, "Can not find Rule Setter."); ui = FindObjectOfType <WeaponUI>(); Assert.IsNotNull(ui, "Can not find Rule UI."); GetComponent <Button>().onClick.AddListener(LoadWeapon); }
// Start is called before the first frame update void Start() { instance = GameManager.instance; loader = GetComponent <WeaponLoader>(); messenger = FindObjectOfType <WeaponMessenger>(); setter = GetComponent <WeaponSetter>(); ui = GetComponent <WeaponUI>(); Assert.IsNotNull(instance, "Weapon Saver could not locate Game Manager"); Assert.IsNotNull(loader, "Weapon Saver could not locate Weapon Loader."); Assert.IsNotNull(messenger, "Weapon Saver could not locate Weapon Messenger."); Assert.IsNotNull(setter, "Weapon Saver could not locate Weapon Setter."); Assert.IsNotNull(ui, "Weapon Saver could not locate Weapon Ui."); }
// Start is called before the first frame update void Start() { Assert.IsNotNull(PanelMelee, "The Melee Panel has not been added to the Weapon UI."); Assert.IsNotNull(PanelRange, "The Range Panel has not been added to the Weapon UI."); Assert.IsNotNull(InputStrength, "The Strength Input has not been added to the Weapon UI."); Assert.IsNotNull(DropdownStrength, "The Strength Dropdown has not been added to the Weapon UI."); Assert.IsNotNull(InputAP, "The AP Input has not been added to the Weapon UI."); Assert.IsNotNull(DropdownAP, "The AP Dropdown has not been added to the Weapon UI."); Assert.IsNotNull(InputDamage, "The Damage Input has not been added to the Weapon UI."); Assert.IsNotNull(DropdownDamage, "The Damage Dropdown has not been added to the Weapon UI."); Assert.IsNotNull(InputRange, "The Range Input has not been added to the Weapon UI."); Assert.IsNotNull(DropdownRange, "The Range Dropdown has not been added to the Weapon UI."); Assert.IsNotNull(InputShots, "The Shots Input has not been added to the Weapon UI."); Assert.IsNotNull(DropdownShots, "The Shots Dropdown has not been added to the Weapon UI."); Assert.IsNotNull(panelAddRules, "The Rules Panel has not been added to the Weapon UI."); Assert.IsNotNull(contentRules, "The Rules Content ui object has not been added to the Weapon UI."); Assert.IsNotNull(buttonWeaponRule, "The Rule Button has not been added to the Weapon UI."); Assert.IsNotNull(panelRulesAdded, "The Rules Added panel has not been added to the Weapon UI."); Assert.IsNotNull(panelRemoveRule, "The Remove Rule panel has not been added to the Weapon UI."); Assert.IsNotNull(buttonSave, "The Save Button has not been added to the Weapon UI."); Assert.IsNotNull(panelNameCheck, "The Name Check Panel has not been added to the Weapon UI."); Assert.IsNotNull(buttonLoad, "The Load Button has not been added to the Weapon UI."); Assert.IsNotNull(panelLoad, "The Load Panel has not been added to the Weapon UI."); Assert.IsNotNull(contentLoad, "The Load Content ui object has not been added to the Weapon UI."); instance = GameManager.instance; Assert.IsNotNull(instance, "The Weapon UI could not find the Game Manager."); loader = gameObject.GetComponent <WeaponLoader>(); Assert.IsNotNull(loader, "The Weapon UI could not find the Weapon Loader."); manager = gameObject.GetComponent <WeaponRuleManager>(); Assert.IsNotNull(manager, "The Weapon UI could not find the Weapon Rule Manager."); messenger = FindObjectOfType <WeaponMessenger>(); Assert.IsNotNull(messenger, "The Weapon UI could not find the Weapon Messenger."); setter = gameObject.GetComponent <WeaponSetter>(); Assert.IsNotNull(setter, "The Weapon UI could not find the Weapon Setter."); defaultColor = InputRange.GetComponentInChildren <Text>().color; if (instance.Weapons.Count > 0) { buttonLoad.interactable = true; } StartCoroutine(messenger.DisplayMessage("Fill in the weapon's profile.")); }
public override void DoAction() { PlayerTank owner; if (!Game.Players.TryGetValue(ownerId, out owner)) { // Player not found. Game.Players.RefreshPlayerList(); return; } float angle = (float)Math.Atan2(owner.Position.Y - point.y, owner.Position.X - point.x); if (Game.LocalPlayer != owner) { new TurretSpinningEvent(Game, ownerId, angle, VTankObject.Direction.NONE).DoAction(); } this.type = WeaponLoader.GetProjectile(projectileTypeId); if (this.type.Name == "Laser Beam") { Vector3 startPosition = owner.Turret.MountPosition("Emitter0"); Vector3 endPosition = new Vector3((float)point.x, (float)point.y, startPosition.Z); Color color = Toolkit.GetColor(owner.Attributes.color); Game.Lazers.AddLazer(startPosition, endPosition, color); ProjectileManager.PlayProjectileSound(type, owner, angle); /* * MobileEmitter _emitter = new MobileEmitter(15000, new ParticleEmitter("LaserBeam"), startPosition, endPosition); * _emitter.RenderID = ServiceManager.Scene.Add(_emitter, 3);Game.Projectiles[projectileId] = ProjectileManager.CreateProjectileObject( * type, point, angle, owner); * Projectile proj = Game.Projectiles[projectileId]; * * ParticleEmitter p = new ParticleEmitter(type.ParticleEffect, proj.Position); * proj.ParticleEmitter = p; */ } else { Game.Projectiles[projectileId] = ProjectileManager.CreateProjectileObject( type, point, angle, owner); } }
// 导入武器数据 public void saveWeaponData() { if (excelData == null || excelData.Length == 0) { reverseData(); } string[] s1 = getOutputPath().Split('/'); string className = s1[s1.Length - 1].Split('.')[0]; Debug.Log("模式 :" + dataType); switch (dataType) { case "Weapon": Debug.Log("F**k Weapon"); WeaponLoader.exchangeData(className, excelData); break; case "Monster": MonsterLoader.exchangeData(className, excelData); break; } }
void Init() { weaponSubType = EquipWeaponType.Sword; if (CameraForWeapon == null) { CameraForWeapon = GameObject.Instantiate(ResMng.LoadPrefab("CameraForWeapon")) as GameObject; CameraForWeapon.Identity(null); WeaponModelParent = Control("WeaponParent", CameraForWeapon); wload = WeaponModelParent.GetComponent <WeaponLoader>(); wload.Init(); } WeaponRoot = Control("WeaponRoot"); Control("Equip").GetComponent <Button>().onClick.AddListener(() => { ChangeWeaponCode(); }); Control("Close").GetComponent <Button>().onClick.AddListener(OnBackPress); for (int i = 0; i < 12; i++) { string control = string.Format("Tab{0}", i); Control(control).GetComponent <UITab>().onValueChanged.AddListener(ChangeWeaponType); } if (load == null) { load = Main.Ins.StartCoroutine(AddWeapon()); } }
public static void Main(string[] args) { bool loadGUI = true; string configFile = DefaultConfigFile; if (args.Length > 1) { // Command-line arguments exist. for (int i = 0; i < args.Length; ++i) { if (args[i] == "-c" || args[i] == "--config-file") { // Argument: custom configuration file. if (args.Length >= i + 1) { PrintUsage("-c", "filename"); } configFile = args[i + 1]; ++i; } else if (args[i] == "-ng" || args[i] == "--nogui" || args[i] == "nogui") { // Argument: Hide the GUI. loadGUI = false; } } } try { WeaponLoader.LoadFiles(); BotRunner runner = new BotRunner(); if (loadGUI) { try { Application.Run(new MainWindow(configFile, runner)); } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } } else { runner.Parse(configFile); runner.Start(true); } } catch (Exception e) { Console.Error.WriteLine("Error!"); Console.Error.WriteLine(e); Console.Error.WriteLine(e.StackTrace); throw; } }
public WeaponFactory() { weaponSprites = WeaponLoader.GetInstance(); projectileSprites = ProjectileLoader.GetInstance(); }
/// <summary> /// Constructor /// </summary> /// <param name="_selectedTank">The selected tank used for editing</param> public EditTankState(VTankObject.TankAttributes _selectedTank) { tank = _selectedTank; selectedTankModelName = tank.model; selectedTurretName = WeaponLoader.GetWeapon(tank.weaponID).Name; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { IsMouseVisible = true; //Manager.Initialize(); ServiceManager.CreateResourceManager(); ServiceManager.CreateAudioManager(); ServiceManager.CreateMP3Player(); ServiceManager.CreateStateManager(); ServiceManager.CreateLogger(); base.Initialize(); PresentationParameters pp = GraphicsDevice.PresentationParameters; const int borderPadding = 20; Console = new GameConsole(new Rectangle( borderPadding, borderPadding, GraphicsDeviceManager.PreferredBackBufferWidth - borderPadding, GraphicsDeviceManager.PreferredBackBufferHeight - borderPadding)); Options.VideoOptions video = Options.Video; // Set anti-aliasing options. string antialiasing = video.AntiAliasing.ToLower(); if (antialiasing == "off") { pp.MultiSampleQuality = 0; pp.MultiSampleType = MultiSampleType.None; GraphicsDeviceManager.PreferMultiSampling = false; } else { GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>( GraphicsDeviceManager_PreparingDeviceSettings); } GraphicsDeviceManager.DeviceReset += new System.EventHandler(GraphicsDeviceManager_DeviceReset); // TODO: Don't forget other options. GraphicsDeviceManager.ApplyChanges(); //ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize; Renderer = new EntityRenderer(GraphicsDeviceManager, Content); Renderer.SceneTools.Entities.Camera cam = Renderer.ActiveScene.CurrentCamera; Camera camera = Renderer.ActiveScene.CreateCamera( new Vector3(100, 100, 60), // Position Vector3.Backward * 20, // Target cam.Projection, // Projection DefaultCameraName /* Name */); camera.CameraUp = Vector3.UnitZ; camera.Updatable = false; lastTimeStamp = Network.Util.Clock.GetTimeMilliseconds(); screenshotTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, 1, GraphicsDevice.DisplayMode.Format); WeaponLoader.LoadFiles(); ServiceManager.StateManager.ChangeState <LoginScreenState>(); ServiceManager.Game.GraphicsDevice.RenderState.PointSizeMax = ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize; Console.DebugPrint("Max Point Size: " + ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize); if (ServiceManager.MP3Player != null) { MENU_PATH = Path.Combine( ServiceManager.MP3Player.AudioDirectory, @"official\menu.wav"); if (!ServiceManager.MP3Player.Play(MENU_PATH, true)) { Console.DebugPrint("[WARNING] Cannot play file official\\menu.wav (not found)."); } } }
public void Init() { //PlayerPrefs.DeleteAll(); Debug.Log("LOAD XMLs"); GameStatsLoader gameStatsLoader = new GameStatsLoader(); GameStatsInfos = gameStatsLoader.GetDict(); PlayerLoader playerLoader = new PlayerLoader(); PlayerInfos = playerLoader.GetDict(); EnemyLoader enemyLoader = new EnemyLoader(); EnemyInfos = enemyLoader.GetDict(); WeaponLoader weaponLoader = new WeaponLoader(); WeaponInfos = weaponLoader.GetDict(); PowerUpLoader powerUpLoader = new PowerUpLoader(); PowerUpInfos = powerUpLoader.GetDict(); HatLoader hatLoader = new HatLoader(); HatInfos = hatLoader.GetDict(); SkillLoader skillLoader = new SkillLoader(); SkillInfos = skillLoader.GetDict(); if (GameStatsInfos != null) { gameStatsLoaded = true; } if (PlayerInfos != null) { playersLoaded = true; } if (EnemyInfos != null) { enemiesLoaded = true; } if (WeaponInfos != null) { weaponsLoaded = true; } if (PowerUpInfos != null) { powerUpsLoaded = true; } if (HatInfos != null) { hatsLoaded = true; } if (SkillInfos != null) { skillsLoaded = true; } }