/// <summary> /// Creates a missile with homing and target finding capabilities. /// </summary> public GuidedMissile(IMyEntity missile, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null, bool isSlave = false) : base(missile, firedBy) { myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString()); myAmmo = ammo; myDescr = ammo.Description; if (ammo.Description.HasAntenna) myAntenna = new MissileAntenna(missile); TryHard = true; AllGuidedMissiles.Add(this); missile.OnClose += missile_OnClose; if (myAmmo.IsCluster && !isSlave) myCluster = new Cluster(myAmmo.MagazineDefinition.Capacity - 1); accelerationPerUpdate = (myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration) / 60f; addSpeedPerUpdate = myDescr.Acceleration / 60f; Options = opt; Options.TargetingRange = ammo.Description.TargetRange; myTargetSeen = initialTarget; myLogger.debugLog("Options: " + Options, "GuidedMissile()"); //myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()"); }
void Awake() { anim = GetComponent<Animator>(); ammoScript = GetComponent<Ammo>(); Weapon weap = (Weapon) Instantiate(spawnWeapon, Vector3.zero, Quaternion.identity); PickUpWeapon(weap); }
public void updateAmmo(GunUIObject selected, int ammoIndex) { if( itemLocale == SuppliesUIObject._ItemLocale.StashBottom ) { switch( gameObject.name ) { case "Ammo Type 1": ammo = selected.gunObj.compatibleAmmo[1]; mWidget.spriteName = ammo.spriteName; mWidget.alpha = ( ammo.amountOwned > 0 && ammo.isPurchased) ? 1f : 0.5f; break; case "Ammo Type 2": ammo = selected.gunObj.compatibleAmmo[2]; mWidget.spriteName = ammo.spriteName; mWidget.alpha = ( ammo.amountOwned > 0 && ammo.isPurchased) ? 1f : 0.5f; break; case "Ammo Type 3": ammo = selected.gunObj.compatibleAmmo[3]; mWidget.spriteName = ammo.spriteName; mWidget.alpha = ( ammo.isPurchased ) ? 1f : 0.5f; break; default: break; } } if( itemLocale == SuppliesUIObject._ItemLocale.StoreGridItem ) { SupplyGrid parentGrid = transform.parent.GetComponent<SupplyGrid>(); switch( gameObject.name ) { case "Ammo0": ammo = selected.gunObj.compatibleAmmo[1]; mWidget.spriteName = ammo.spriteName; if( parentGrid.isActive ) mWidget.alpha = ( ammo.amountOwned > 0 & ammo.isPurchased) ? 1f : 0.5f; break; case "Ammo1": ammo = selected.gunObj.compatibleAmmo[2]; mWidget.spriteName = ammo.spriteName; if( parentGrid.isActive ) mWidget.alpha = ( ammo.amountOwned > 0 && ammo.isPurchased) ? 1f : 0.5f; break; case "Ammo2": ammo = selected.gunObj.compatibleAmmo[3]; mWidget.spriteName = ammo.spriteName; if( parentGrid.isActive ) mWidget.alpha = ( ammo.isPurchased) ? 0.5f : 1f; break; default: break; } } }
public override GameObject DropOneAmmo(Ammo a) { if (bulletAmmo.Contains(a)) { DropAmmo(); UpdateAmmoGraphics(); return(NumberManager.inst.CreateNumber(a.ammoValue, Player.inst.transform.position)); // create a brand new number that something was asking for } else { return(null); } }
/// <summary> /// Creates a missile with homing and target finding capabilities. /// </summary> public GuidedMissile(IMyEntity missile, GuidedMissileLauncher launcher, out Target initialTarget) : base(missile, launcher.CubeBlock) { myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString()); m_launcher = launcher; myAmmo = launcher.loadedAmmo; m_owner = launcher.CubeBlock.OwnerId; if (myAmmo.Description.HasAntenna) myAntenna = new RelayNode(missile, () => m_owner, ComponentRadio.CreateRadio(missile, 0f)); TryHard = true; SEAD = myAmmo.Description.SEAD; AllGuidedMissiles.Add(this); MyEntity.OnClose += MyEntity_OnClose; acceleration = myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration; addSpeedPerUpdate = myDescr.Acceleration * Globals.UpdateDuration; if (!(launcher.CubeBlock is Sandbox.ModAPI.Ingame.IMyLargeTurretBase)) m_rail = new RailData(Vector3D.Transform(MyEntity.GetPosition(), CubeBlock.WorldMatrixNormalizedInv)); Options = m_launcher.m_weaponTarget.Options.Clone(); Options.TargetingRange = myAmmo.Description.TargetRange; RelayStorage storage = launcher.m_relayPart.GetStorage(); if (storage == null) { myLogger.debugLog("failed to get storage for launcher", Logger.severity.WARNING); } else { myLogger.debugLog("getting initial target from launcher", Logger.severity.DEBUG); GetLastSeenTarget(storage, myAmmo.MissileDefinition.MaxTrajectory); } initialTarget = CurrentTarget; if (myAmmo.RadarDefinition != null) { myLogger.debugLog("Has a radar definiton"); m_radar = new RadarEquipment(missile, myAmmo.RadarDefinition, launcher.CubeBlock); if (myAntenna == null) { myLogger.debugLog("Creating node for radar"); myAntenna = new RelayNode(missile, () => m_owner, null); } } Registrar.Add(missile, this); myLogger.debugLog("Options: " + Options + ", initial target: " + (myTarget == null ? "null" : myTarget.Entity.getBestName())); //myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()"); }
// Update is called once per frame void Update() { if ((Input.GetButton("Fire1") || Input.GetAxis("Fire1") < -0.1) && playerGUI.alive) { currentAction.GetComponent <Weapon>().Shoot(); } if (Input.GetButtonDown("Reload")) { currentAction.GetComponent <Weapon>().Reload(); } if (Input.GetButtonDown("Interact")) { RaycastHit hit; if (Physics.Raycast(PlayerCamera.transform.position, PlayerCamera.transform.forward, out hit)) { if (Vector3.Distance(hit.collider.transform.position, transform.position) < 5) { Ammo a = hit.collider.gameObject.GetComponent <Ammo>(); if (a != null) { currentAction.GetComponent <Weapon>().AddAmmo(a.ammo); if (a.isMissionPickup) { GetComponent <PlayerGUI>().Pickup(); } a.despawn(); } Health h = hit.collider.gameObject.GetComponent <Health>(); if (h != null) { GetComponent <PlayerGUI>().AddHealth(h.health); if (h.isMissionPickup) { GetComponent <PlayerGUI>().Pickup(); } h.despawn(); } } } } if (Input.GetButtonDown("Grenade")) { if (g == null) { PlayerPrefs.SetInt("Shots", PlayerPrefs.GetInt("Shots") + 1); g = Instantiate(grenade, new Vector3(PlayerCamera.transform.position.x + 0.5f, PlayerCamera.transform.position.y, PlayerCamera.transform.position.z), PlayerCamera.transform.rotation) as GameObject; g.GetComponent <Rigidbody>().AddForce(g.transform.forward * 750); g.GetComponent <Grenade>().SetAI(ais); } } }
private void Start() { PreSpawnLogic(); owner = Player.Get(gameObject); owner.Role = Role; Timing.CallDelayed(0.1f, () => { if (Health > 0) { owner.Health = Health; owner.MaxHealth = Health; } if (!Tag.IsEmpty()) { owner.PlayerInfoArea &= ~PlayerInfoArea.Role; owner.CustomPlayerInfo = Tag; } if (!Ammo.IsEmpty() && Ammo.Length == 3) { owner.Ammo[(int)AmmoType.Nato556] = Ammo[0]; owner.Ammo[(int)AmmoType.Nato762] = Ammo[1]; owner.Ammo[(int)AmmoType.Nato9] = Ammo[2]; } if (!Inventory.IsEmpty()) { owner.ClearInventory(); foreach (ItemType itm in Inventory) { owner.AddItem(itm); } } if (Spawnpoint != RoomType.Unknown) { owner.Position = Map.Rooms.Where(r => r.Type == Spawnpoint).FirstOrDefault().Position; } if (!Broadcast.IsEmpty()) { owner.Broadcast(5, Broadcast); } if (!ConsoleMessage.IsEmpty()) { owner.SendConsoleMessage(ConsoleMessage, "yellow"); } if (!GlobalBroadcast.IsEmpty()) { Map.Broadcast(5, GlobalBroadcast); } PostSpawnLogic(); Initialized = true; }); }
void Fire() { Transform player = transform.parent.parent; Ammo playerScript = player.GetComponent <Ammo>(); playerScript.ammo--; Rigidbody2D bPrefab = Instantiate(bulletPrefab, new Vector3(transform.position.x + xValue, transform.position.y + yValue, transform.position.z), transform.rotation) as Rigidbody2D; bPrefab.GetComponent <Rigidbody2D>().AddForce(transform.right * bulletSpeed); AudioSource audio = GetComponent <AudioSource>(); audio.Play(); coolDown = Time.time + attackSpeed; }
private bool IsValidAmmoFireSpawnPoint(Ammo currentAmmo, Transform enemyFireSpawPoint) { bool validSpawnPoint = false; if (enemyFireSpawPoint.CompareTag(currentAmmo.GetAmmoChildTag())) { validSpawnPoint = true; return(validSpawnPoint); } else { return(validSpawnPoint); } }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); ammoObjectList = new List <GameObject>(); for (int i = 0; i < 10; i++) { ammoObjectList.Add((GameObject)Instantiate(ammoObject, transform.position, Quaternion.identity)); } foreach (GameObject Ammo in ammoObjectList) { Ammo.SetActive(false); } }
private void SwitchAmmo() // sprwadzic te metode { int activeAmmoIndex = GetIndexOfActiveAmmo(); if (activeAmmoIndex == ActiveWeapon.Ammo.Count - 1) { ActiveAmmo = ActiveWeapon.Ammo[0]; } else { ActiveAmmo = ActiveWeapon.Ammo[activeAmmoIndex + 1]; } SetAmmo(ActiveAmmo); }
protected void UseAmmo() { if (currentAmmo == Ammo.RedShell) { return; } else { if (--AmmoCount <= 0) { currentAmmo = Ammo.RedShell; } } }
IEnumerator Weapon_Reload() { On_Reload_Delay = true; NowTime = 0; Debug.Log(On_Reload_Delay); yield return(new WaitForSeconds(ReloadTime)); Ammo = Magazine; AmmoText.text = Ammo.ToString() + " / " + Magazine.ToString(); On_Reload_Delay = false; Debug.Log(On_Reload_Delay); }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- // Called when the item is added to the inventory list. public override void OnAdded(Inventory inventory) { base.OnAdded(inventory); currentAmmo = 0; ammo = new Ammo[] { inventory.GetAmmo("ammo_ember_seeds"), inventory.GetAmmo("ammo_scent_seeds"), inventory.GetAmmo("ammo_pegasus_seeds"), inventory.GetAmmo("ammo_gale_seeds"), inventory.GetAmmo("ammo_mystery_seeds"), }; }
private void PoolAmmo(WeaponType weaponType, Ammo ammo, int poolSize) { PooledObject pooledObject = ammo?.GetComponent <PooledObject>(); if (null != pooledObject) { ObjectPoolManager.Instance.InitializePool(GetAmmoPool(weaponType), pooledObject, poolSize); } if (null != ammo?.ImpactPrefab) { PoolImpact(weaponType, ammo.ImpactPrefab, poolSize); } }
static void Prefix(Ammo __instance, Identifiable.Id id) { PlortMarket.Log("[AncientWater-Prefix] id: " + id.ToString()); if (id == Identifiable.Id.MAGIC_WATER_LIQUID) { PlortMarket.Log("[AncientWater-Prefix] ID == MAGIC_WATER_LIQUID"); isAncientWater = true; } else { //PlortMarket.Log("[AncientWater-Prefix] ID != MAGIC_WATER_LIQUID"); isAncientWater = false; } }
/* para que cada municao seja atirada apenas no ponto de origem desejado, * cada ponto de origem DO OBJETO UPGRADEPART tera filhos indicando * quais das municoes A,B OU C OU A,B E C poderão ser disparadas dela ;D */ private bool IsValidAmmoFireSpawnPoint(Ammo currentAmmo, Transform WeaponFireSpawPoint) { bool validSpawnPoint = false; foreach (Transform fireSpawPointChild in WeaponFireSpawPoint) { if (fireSpawPointChild.CompareTag(currentAmmo.GetAmmoChildTag())) { validSpawnPoint = true; return(validSpawnPoint); } } return(validSpawnPoint); }
public override void OnMiss(Mobile attacker, Mobile defender) { double arrowChance = 0.4; if (!ArenaFight.AllowFreeConsume(attacker, typeof(Arrow))) { if (attacker.Player && arrowChance >= Utility.RandomDouble()) { Ammo.MoveToWorld(new Point3D(defender.X + Utility.RandomMinMax(-1, 1), defender.Y + Utility.RandomMinMax(-1, 1), defender.Z), defender.Map); } } base.OnMiss(attacker, defender); }
private void Update() { ammo = FindObjectOfType <Ammo>(); shotCounter -= Time.deltaTime; if (isFiring) { Shoot(); } if (Input.GetKeyDown(KeyCode.M)) { SwitchGunMode(); } }
public void Reload_CurrentMaxAmmoLessThanMaxAmmoPerClip_CurrentMaxAmmoReturnsZero() { const int maxAmmo = 5; const int maxAmmoPerClip = 10; _ammo = new Ammo(maxAmmo, maxAmmoPerClip); const int reduceAmount = 8; _ammo.ReduceCurrentAmmo(reduceAmount); _ammo.Reload(); Assert.AreEqual(0, _ammo.CurrentMaxAmmo); }
public void AddItemToInventory(int index) { if (chestContents.contents[index].itemType == Item.ItemType.Ammo) { Ammo ammo = (Ammo)chestContents.contents[index]; playerInventory.GetComponent <PlayerAmmo>().AddAmmo(chestContents.itemNumberInStack[index], ammo.ammoType); chestContents.contents.RemoveAt(index); chestContents.itemNumberInStack.RemoveAt(index); } else { playerInventory.AddItemToInventory(chestContents.contents[index], chestContents, index); } }
void Start() { //Update ammo. Ammo.AmmoUpdate(); //If in challenge mode make gun to rise from bottom. if (ChallengeMenu.challengeMode) { transform.position = new Vector2(0, -4); } //First time gun will fly up automatically. StartCoroutine(ShootVerticallyUp(1f)); }
public override void OnMiss(Mobile attacker, Mobile defender) { if (attacker == null || defender == null) { return; } if (attacker.Player && 0.4 >= Utility.RandomDouble()) { Ammo.MoveToWorld(new Point3D(defender.X + Utility.RandomMinMax(-1, 1), defender.Y + Utility.RandomMinMax(-1, 1), defender.Z), defender.Map); } base.OnMiss(attacker, defender); }
public override void handleAttackBuilding(Building attacked, Ammo attacker) { if (attacked.State == Building.BuildingState.destroyed) { // handles stack overflow;P return; } attacked.Health -= attacker.Damage; if (attacked.Health <= 0) { InfoLog.WriteInfo("destroying building ", EPrefix.SimulationInfo); destroyBuilding(attacked); OnBuildingDestroyed(attacked); } }
public override void handleAttackUnit(Unit attacked, Ammo attacker) { if (attacked.State == Unit.UnitState.destroyed) { // handles stack overflow;P return; } attacked.Health -= attacker.Damage; if (attacked.Health <= 0) { InfoLog.WriteInfo("Destroying unit ", EPrefix.SimulationInfo); destroyUnit(attacked); OnUnitDestroyed(attacked); } }
void Awake() { // object pool if (ammoPool == null) { ammoPool = new List <Ammo>(); } for (int i = 0; i < poolSize; i++) { Ammo ammoObject = Instantiate(ammoPrefab); ammoObject.gameObject.SetActive(false); ammoPool.Add(ammoObject); } }
/// <summary> /// Active the UI of the ammo equiped /// </summary> /// <param name="ammoType">The ammo equiped in this moment</param> public void EquipAmmo(Constants.AMMO_TYPE ammoType) { foreach (Ammo ammo in ammoList) { if (ammo.info.ammoType == ammoType) { ammo.ammoUIEquiped.SetActive(true); actualAmmo = ammo; } else { ammo.ammoUIEquiped.SetActive(false); } } }
public void FireAmmo() { GameObject ammo = Instantiate(ammoPrefab, theTransform.position, theTransform.rotation) as GameObject; Ammo ammoComponent = ammo.GetComponent <Ammo> (); Movement movementComponent = ammo.GetComponent <Movement> (); ammoComponent.damage = ammoDamage; ammoComponent.lifetime = ammoLifetime; movementComponent.speed = ammoSpeed; Invoke("FireAmmo", Random.Range(timeDelayRange.x, timeDelayRange.y)); }
/* * Adding ammo based on type. */ public bool AddAmmo(AmmoType type, int amountToAdd) { for (int i = 0; i < ammos.Length; i++) { Ammo a = ammos[i]; if (a.type == type) { inventoryUpdated = true; return(a.AddAmmo(amountToAdd)); } } print($"Cannot add ammo of type {type.ToString()} as it doesn't exist in our inventory!"); return(false); }
// Shooting on ammo private IEnumerator Shooting(Vector3 direction) { for (int i = 0; i < countAmmo; i++) { Ammo ammoObject = PoolManager.Singleton.GetObject(Ammo).GetComponent <Ammo>(); ammoObject.MyTransform.position = Ball.position + direction * 0.4f; float d = Mathf.Lerp(14f, 16.5f, сountBоll / 100f); ammoObject.Push(direction * d); shootingCountAmmo++; сountBоll--; UpdateCountBall(); yield return(null); } }
void FireAmmo(Vector3 target) { GameObject ammo = SpawnAmmo(transform.position); if (ammo != null) { ammo.transform.rotation = Quaternion.Euler(0, 0, calculate_angle(enemyAIChasing.target.position, this.transform.position) * Mathf.Rad2Deg); ammo.transform.position += Vector3.up * 0.1f; StandardBullet bulletScript = ammo.GetComponent <StandardBullet>(); Ammo ammoScript = ammo.GetComponent <Ammo>(); ammoScript.piercing = false; ammoScript.damageInflicted = 1; bulletScript.StartTravelBullet(target, weaponVelocity); } }
private void AddAmmo(Ammo ammo) { int weaponIdx = 0; if (ammo.WeaponType.Equals(typeof(Machinegun))) { weaponIdx = 1; } else if (ammo.WeaponType.Equals(typeof(Shotgun))) { weaponIdx = 2; } weapons[weaponIdx].AddAmmo(ammo.Amount); }
/// <summary> /// Subscribe to input events. /// </summary> private void Awake() { controls = new GameControls(); shoot = GetComponent <Shoot>(); ammo = GetComponent <Ammo>(); controls.Gameplay.Shoot.performed += context => shoot.StartCharge(); controls.Gameplay.Shoot.performed += context => ammo.OnShootPressed(); controls.Gameplay.Shoot.canceled += context => shoot.OnShoot(); controls.Gameplay.Shoot.canceled += context => ammo.OnShootReleased(); controls.Gameplay.Move.performed += context => move = context.ReadValue <Vector2>(); controls.Gameplay.Move.canceled += context => move = Vector2.zero; }
public void AmmoPickupTest() { Ammo moneyPickup = new Ammo() { Bullets = 4, Grenades = 1 }; map[0, 0].placeObject(moneyPickup); int playerBullets = player.RangedWeapon.Ammo; int playerGrenades = player.GrenadeWeapon.Ammo; new PickupCommand(player).execute(); Assert.AreEqual(player.RangedWeapon.Ammo, playerBullets + 4); Assert.AreEqual(player.GrenadeWeapon.Ammo, playerGrenades + 1); }
// Update is called once per frame protected override void Update() { base.Update(); float percentLeft = (float)amountLeft / (float)capacity; if (percentLeft < 0) { percentLeft = 0; } if (percentLeft == 0) { Destroy(this.gameObject); } int numCasesToShow = (int)(percentLeft * numCases); Ammo[] cases = GetComponentsInChildren<Ammo>(); if (numCasesToShow >= 0 && numCasesToShow < cases.Length) { Ammo[] sortedCases = new Ammo[cases.Length]; //sortiert liste von höchstem zu niedrigstem foreach (Ammo ammo in cases) { sortedCases[cases.Length - int.Parse(ammo.name)] = ammo; } for (int i = numCasesToShow+1; i < sortedCases.Length; i++) //+1 damit Kisten erst verschwinden nachdem sie "leer" sind { sortedCases[i].GetComponent<Renderer>().enabled = false; CalculateBounds(); } } }
public GuidedMissile(Cluster missiles, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null) : this (missiles.Master, firedBy, opt, ammo, initialTarget) { myCluster = missiles; }
public virtual void Reload(Ammo newAmmo) { if (currentAmmo == null) { if (newAmmo == null) { newAmmo = ((GameObject) GameObject.Instantiate(currentLevel.ammoPrefab, launchFrom.position, currentLevel.ammoPrefab.transform.rotation)).GetComponent<Ammo>(); } newAmmo.flightTime = currentLevel.rateOfFire; newAmmo.launchFrom = launchFrom; newAmmo.transform.parent = launchFrom; newAmmo.transform.localPosition = Vector3.zero; newAmmo.transform.localRotation = Quaternion.identity; currentAmmo = newAmmo; } }
public AmmoCollection(Ammo arrows, Ammo bombs) { this.arrows = arrows; this.bombs = bombs; }
void ReloadPartial(Ammo ammo, int amount) { DecrementAmmo(ammo, amount); currentAmmo += amount; }
int GetAmmoCount(Ammo ammo) { int ammount = 0; int slotID = inventory.GetItemPosition(itemDatabase.GetItemByTitle(ammo.Title)); if (slotID != -1) { ammount = GetItemDataBySlot(slotID).amount; } return ammount; }
public void populateCompatibleAmmo() { /** This below population of compatibleAmmo is a workaroud. Tried creating new Ammo[3] * inside of DBAccess.getCompatibleAmmo to return directly, but was constantly getting * null reference exceptions when setting the values through query.Step(). For some * reason, creating a new Ammo() instance during Awake() / Start() cycles does not * allocate the Ammo() correctly, so System.Object[,] was used instead */ System.Object[,] buffer = DBAccess.instance.getCompatibleAmmo(_gunID); for( int i = 0; i < 4; i++ ) { Ammo a = new Ammo(); a.ammoName = Convert.ToString(buffer[i,0]); a.dmgModifier = Convert.ToSingle(buffer[i,1]); a.recoilModifier = Convert.ToSingle(buffer[i,2]); a.magSize = Convert.ToInt32(buffer[i,3]); a.spriteName = Convert.ToString(buffer[i,4]); a.price = Convert.ToInt32(buffer[i,5]); a.isPurchased = ( Convert.ToInt32(buffer[i,6]) == 1 ) ? true : false; a.unlockLevel = Convert.ToInt32(buffer[i,7]); a.amountOwned = Convert.ToInt32(buffer[i,8]); a.ammoID = Convert.ToInt32(buffer[i,9]); compatibleAmmo.Insert(i,a); } loadedAmmo = compatibleAmmo[0]; }
/// <summary> /// Creates a missile with homing and target finding capabilities. /// </summary> public GuidedMissile(IMyEntity missile, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null) : base(missile, firedBy) { myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString()); myAmmo = ammo; myDescr = ammo.Description; if (ammo.Description.HasAntenna) myAntenna = new MissileAntenna(missile); TryHard = true; AllGuidedMissiles.Add(this); AddMissileOwner(MyEntity, CubeBlock.OwnerId); MyEntity.OnClose += MyEntity_OnClose; accelerationPerUpdate = (myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration) / 60f; addSpeedPerUpdate = myDescr.Acceleration / 60f; Options = opt; Options.TargetingRange = ammo.Description.TargetRange; myTargetSeen = initialTarget; myLogger.debugLog("Options: " + Options + ", initial target: " + (initialTarget == null ? "null" : initialTarget.Entity.getBestName()), "GuidedMissile()"); //myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()"); }
private static int getArrowAmount(Player p, Ammo item) { if (item == null || p == null) { return 0; } int amt = item.isBolt() ? 12 : 15; int itemOneAmount = p.getInventory().getItemAmount(item.getItemOne()); int itemTwoAmount = p.getInventory().getItemAmount(item.getItemTwo()); int lowestStack = itemOneAmount > itemTwoAmount ? itemTwoAmount : itemOneAmount; int finalAmount = lowestStack > amt ? amt : lowestStack; return finalAmount; }
private static string getMessage(Ammo item, int amount) { string s = amount > 1 ? "s" : ""; string s1 = amount > 1 ? "some" : "a"; string s2 = amount > 1 ? "some" : "an"; if (!item.isBolt()) { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some" : "a"; s2 = amount > 1 ? "some" : "an"; if (item.getItemType() == 0) { return "You attach Feathers to " + s1 + " of your Arrow shafts, you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."; } else { return "You attach " + s2 + " Arrowtip" + s + " to " + s1 + " Headless arrow" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + s + "."; } } else { s = amount > 1 ? "s" : ""; s1 = amount > 1 ? "some of your bolts" : "a bolt"; s2 = amount > 1 ? "some" : "a"; if (item.getItemType() < 8) { return "You attach Feathers to " + s1 + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName()+"."; } else { s = amount > 1 ? "s" : ""; s2 = amount > 1 ? "some" : "a"; return "You attach " + s2 + " bolt tip" + s + " to " + s2 + " headless bolt" + s + ", you make " + amount + " " + ItemData.forId(item.getFinishedItem()).getName() + "."; } } }
public virtual void Launch(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { currentAmmo.LaunchAt(foundTarget); currentAmmo = null; }
//************************************************************** //*************************************************************** //**************8 MAIN LOOP 8*********************************** //*************************************************************** void gameLoop_Tick(object sender, EventArgs e) { double timeElapsedsec = stopwatch.ElapsedMilliseconds / 1000; canvas.Children.Remove(title); canvas.Children.Remove(display); canvas.Children.Remove(magic); canvas.Children.Remove(lives); canvas.Children.Remove(scoreText); //if(ammoCount == 100) //{ // ammoCount = 0; //} if(timeElapsedsec < 60 && !(timeElapsedsec > 60)) { enemies[0].update(); enemies[1].update(); enemies[2].update(); enemies[3].update(); enemies[4].update(); enemies[5].update(); enemies[6].update(); enemies[7].update(); //enemies[i].setPosition = random(0, sizeofwindow); //timer has to check for collision between bullet and monster //fucntion collision needs to return the index of the enemy } else if(timeElapsedsec < 120 && !(timeElapsedsec >120)) { enemies[0].update(); enemies[1].update(); enemies[2].update(); enemies[3].update(); enemies[4].update(); enemies[5].update(); enemies[6].update(); enemies[7].update(); enemies[8].update(); enemies[9].update(); enemies[10].update(); enemies[11].update(); } else { enemies[0].update(); enemies[1].update(); enemies[2].update(); enemies[3].update(); enemies[4].update(); enemies[5].update(); enemies[6].update(); enemies[7].update(); enemies[8].update(); enemies[9].update(); enemies[10].update(); enemies[11].update(); enemies[12].update(); enemies[13].update(); enemies[14].update(); enemies[15].update(); enemies[16].update(); enemies[17].update(); enemies[18].update(); enemies[19].update(); } for (int i = 0; i < 20; i++) { lifeUnit -= enemies[i].enemyOnTarget; if (enemies[i].enemyOnTarget == 15) { enemies[i].canvasRemove = canvas; enemies[i].element = enemies[i].drawEnemy(); Stream std = Properties.Resources.Pain_SoundBible_com_1883168362; SoundPlayer sn = new SoundPlayer(std); sn.Play(); enemies[i].enemyOnTarget = 0; } } wizard.update(); if(magicUnit < 10) { overheat = true; } if(!overheat) { if (Keyboard.IsKeyDown(Key.Space)) { // ammunition[ammoCount].currentAngle = wizard.currentAngle; //ammunition[ammoCount].element = ammunition[ammoCount].drawAmmo; Ammo ammo = new Ammo(); ammunition.Add(ammo); if (ammunition[ammoCount].available) { ammunition[ammoCount].element = ammunition[ammoCount].drawAmmo; ammunition[ammoCount].canvas = canvas; ammunition[ammoCount].available = false; ammoCount++; } magicUnit -= 5.0; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++UPDATE AMMO +++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++ for (int i = ii; i < ammunition.Count; i++) { if (!ammunition[i].available) { ammunition[i].updateAmmo(); } if(ammunition[i].X <= -150 || ammunition[i].X >=650) { ammunition[i].canvasRemove = canvas; ammunition[i].available = true; //ammunition[i].reloaded = true; ii++; } if(ammunition[i].Y <=-150 || ammunition[i].Y >= 750) { ammunition[i].canvasRemove = canvas; ammunition[i].available = true; //ammunition[i].reloaded = true; ii++; } } //+++++++++++++++++++++++++++++++++++++++++++++++++ //++++CHECK ENEMIES++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++ for (int i = 0; i < 20; i++) { if (enemies[i].destroyed) { enemies[i].element = enemies[i].drawEnemy(); //enemies[i].canvas = canvas; enemies[i].destroyed = false; score += 10; } } //************************************************************* //***************DESTROY ENEMIES****************************** //********************************************************* for (int i = ii; i < ammunition.Count;i++ ) { if (!ammunition[i].available) { for (int k = 0; k < 20;k++) { if((ammunition[i].X >= enemies[k].X - 30 && ammunition[i].X <= enemies[k].X + 30) && (ammunition[i].Y >= enemies[k].Y - 30 && ammunition[i].Y <= enemies[k].Y + 30)) { enemies[k].canvasRemove = canvas; enemies[k].destroyed = true; ammunition[i].available = true; ammunition[i].canvasRemove = canvas; Stream str = Properties.Resources.Spacecraft_Hatch_Opening_SoundBible_com_1577619787; SoundPlayer snd = new SoundPlayer(str); snd.Play(); } } } } //********************************************************** //*************** TEXT CHECK******************************* //display.Text = Canvas.GetTop(enemies[0].element).ToString(); display.Text = "Magic"; display.FontSize = 20.0; display.Foreground = new SolidColorBrush(Colors.White); display.Margin = new Thickness(5, 5, 40, 20); canvas.Children.Add(display); //positionX = Mouse.GetPosition(canvas).ToString(); //title.Text = positionX; //canvas.Children.Add(title); title.Text = "Life"; title.Margin = new Thickness(5, 35, 70, 30); canvas.Children.Add(title); lives.Height = 5.0; lives.Width = lifeUnit; Canvas.SetTop(lives, 60); Canvas.SetLeft(lives, 5); lives.Fill = Brushes.Red; canvas.Children.Add(lives); magic.Height = 5.0; magic.Width = magicUnit; Canvas.SetTop(magic, 30); Canvas.SetLeft(magic, 5); magic.Fill = Brushes.Aqua; canvas.Children.Add(magic); scoreText.Text = "Score: " + score.ToString(); scoreText.FontSize = 20.0; scoreText.Foreground = new SolidColorBrush(Colors.White); scoreText.Margin = new Thickness(270, 5, 310, 20); canvas.Children.Add(scoreText); //************************************************************* if (magicUnit < 200.0) { magicUnit++; } if(magicUnit == 200) { overheat = false; } if(lifeUnit <= 10) { Stream s = Properties.Resources.Scream_And_Die_Fx_SoundBible_com_299479967; SoundPlayer snt = new SoundPlayer(s); snt.Play(); canvas.Children.Remove(title); canvas.Children.Remove(display); canvas.Children.Remove(magic); canvas.Children.Remove(lives); canvas.Children.Remove(scoreText); wizard.canvasRemove = canvas; stopwatch.Stop(); gameLoop.Stop(); for (int i = 0; i < 20; i++) { enemies[i].canvasRemove = canvas; enemies[i].element = enemies[i].drawEnemy(); enemies[i].enemyOnTarget = 0; } for (int i = ammunition.Count - 1; i > 0; i--) { //ammunition[i].canvasRemove = canvas; //ammunition[i].available = true; ammunition.Remove(ammunition[i]); } restart = true; pgSafeCheck = false; lifeUnit = 200.0; magicUnit = 200.0; ii = 0; score = 0; ammoCount = 0; overheat = false; DisplayMainMenu(); } }
public virtual void Reload( Ammo ammo ) { /** Prevent loading of an inferior ammo when a greater ammo is loaded. * * The or signifies if it is a lesser ammo and it's magsize is greater than current capacity * then it is ok to reload * */ if( compatibleAmmo.IndexOf( ammo ) >= compatibleAmmo.IndexOf( loadedAmmo ) || ammo.magSize > capacity ) { float reloadTime = ( ammo.magSize * 0.05f ) - ( capacity * 0.05f ); isReloading = true; loadedAmmo = ammo; // If not infinite lead ammo, decrement if( compatibleAmmo.IndexOf( ammo ) > 0 ) { loadedAmmo.amountOwned--; //Debug.Log("amountOwned--"); } onReloadStart( reloadTime, this ); } }
void Start() { isFiring = false; firstShot = true; active = true; shootTimer = 0; shotTimer = new ShotTimer [WeaponInfo.getWeaponCount () + 1]; ammo = new Ammo[WeaponInfo.getWeaponCount () + 1]; for (int i = 0; i < WeaponInfo.getWeaponCount(); i++) { shotTimer [i] = new ShotTimer (); ammo [i] = new Ammo (100, 100); } }
//private void ClusterMain_OnClose(IMyEntity obj) //{ // myLogger.debugLog("clusterMain closed, on cooldown", "ClusterMain_OnClose()", Logger.severity.DEBUG); // StartCooldown(); //} private void UpdateLoadedMissile() { if (myInventory.CurrentMass == prev_mass && myInventory.CurrentVolume == prev_volume && nextCheckInventory > DateTime.UtcNow) return; nextCheckInventory = DateTime.UtcNow + checkInventoryInterval; prev_mass = myInventory.CurrentMass; prev_volume = myInventory.CurrentVolume; Ammo newAmmo = Ammo.GetLoadedAmmo(CubeBlock); if (newAmmo != null && newAmmo != loadedAmmo) { loadedAmmo = newAmmo; myLogger.debugLog("loaded ammo: " + loadedAmmo.AmmoDefinition, "UpdateLoadedMissile()"); } }
public void findAmmoAndSetAsPurchased( Ammo a ) { Debug.Log("findAmmoAndSetAsPurchased"); for( int i = 0; i < _allGuns.Count; i++ ) { for( int j = 0; j < _allGuns[i].compatibleAmmo.Count; j++ ) { if( a.ammoID == _allGuns[i].compatibleAmmo[j].ammoID ) { _allGuns[i].compatibleAmmo[j].isPurchased = true; _allGuns[i].compatibleAmmo[j].amountOwned++; _allGuns[i].compatibleAmmo[j].CommitToDB(); CommitToDB(true); } } } }
private static bool canFletch(Player p, Ammo item) { if (item == null || item.getAmount() <= 0) { return false; } string s = item.getItemOne() == HEADLESS_ARROW ? "s." : "."; string s1 = item.getItemTwo() == HEADLESS_ARROW ? "s." : "."; if (p.getSkills().getGreaterLevel(Skills.SKILL.FLETCHING) < item.getLevel()) { p.getPackets().sendMessage("You need a Fletching level of " + item.getLevel() + " to make that."); return false; } if (!p.getInventory().hasItem(item.getItemOne())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemOne()).getName() + s); return false; } if (!p.getInventory().hasItem(item.getItemTwo())) { p.getPackets().sendMessage("You don't have any " + ItemData.forId(item.getItemTwo()).getName() + s1); return false; } return true; }
void Start() { anim = GetComponent<Animator>(); ammoScript = GetComponent<Ammo>(); setCheckpoint(); }
public override void Init( Unit owner ) { base.Init( owner ); actions.Add( new ActionsBook.Reload( owner, this ) ); if( ammoHolder && ammoClip ) { ammoClip = Instantiate( ammoClip, ammoHolder.position, ammoHolder.rotation ) as Ammo; ammoClip.transform.parent = ammoHolder; ammoClip.transform.localScale = Vector3.one; } Reload(); shotLine.enabled = false; }
void ReloadFull(Ammo ammo) { DecrementAmmo(ammo, playerWeapon.Mag); currentAmmo += playerWeapon.Mag; }
void SwitchAmmo() { if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl)) { m_Sound.PlaySwitchAmmoSound(); if (m_SelectedAmmo == Ammo.DestroyWave) { m_SelectedAmmo = Ammo.PushWave; Debug.Log("Ammo switched to Push Wave"); } else { m_SelectedAmmo = Ammo.DestroyWave; Debug.Log("Ammo switched to Destroy Wave"); } } }
void DecrementAmmo(Ammo ammo, int amount) { for (int i = 0; i < amount; i++) { inventory.RemoveItem(itemDatabase.GetItemByTitle(ammo.Title).ID); } }
void Start() { m_playerState = PlayerState.Idle; m_rgbd = GetComponent<Rigidbody2D>(); m_boxColl = GetComponent<BoxCollider2D>(); m_FacingRight = true; m_Animator = GetComponentInChildren<Animator>(); m_SelectedAmmo = Ammo.PushWave; m_Pv = 3; m_MaxPV = 3; m_IsVulnerable = true; m_IsShooting = false; m_RendList = gameObject.GetComponentsInChildren<SpriteRenderer>(true); m_Sound = GetComponent<CharacterSound>(); }
public override void Reload(Ammo newAmmo) { }
public turboLaser(string gas) { ammo = new Ammo(gas); }