public void UpdateButtonNames() { if (weaponSystem == null) { weaponSystem = FindObjectOfType <WeaponSystem>(); } for (int i = 0; i < buttons.Length; i++) { int indexer = i; if (weaponSystem.allWeapons[indexer] != null) { buttons[indexer].GetComponentInChildren <Text>().text = weaponSystem.allWeapons[indexer].GetComponent <Weapon>().Namy; buttons[indexer].interactable = true; } else { buttons[indexer].GetComponentInChildren <Text>().text = ""; buttons[indexer].interactable = false; } } }
protected override void ServerInitializeCharacter(ServerInitializeData data) { // don't call the base initialize // base.ServerInitializeCharacter(data); var character = data.GameObject; var publicState = data.PublicState; var privateState = data.PrivateState; this.ServerInitializeCharacterMob(data); SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache( this.ProtoCharacterDefaultEffects, data.PublicState, privateState, // always rebuild the mob character state // as the game doesn't store current HP for mobs isFirstTime: true); var weaponState = privateState.WeaponState; WeaponSystem.SharedRebuildWeaponCache(character, weaponState); privateState.AttackRange = weaponState.WeaponCache?.RangeMax ?? 0; if (data.IsFirstTimeInit) { privateState.SpawnPosition = character.TilePosition; } else if (publicState.IsDead) { // should never happen as the ServerCharacterDeathMechanic should properly destroy the character Logger.Error("(Should never happen) Destroying dead mob character: " + character); this.ServerOnDeath(character); } }
protected override void ProcessFire(WeaponSystem fireSystem) { if (Input.GetKey(KeyCode.Space) || autofire) { fireSystem.TriggerFire(); } }
// Update is called once per frame void Update() { WeaponSystem indexRef = gameObject.GetComponent <WeaponSystem>(); currentWeapon = equippedWeapons[indexRef.weaponIndex]; if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out interaction, interactionDistance)) { if (Input.GetKeyDown(KeyCode.E) || Input.GetButtonDown("gUse")) { // IF we hit an object that is interactable if (interaction.collider.gameObject.layer == LayerMask.NameToLayer("Interactable")) { string objName = interaction.transform.gameObject.name; if (objName == "Altar") { Altar altrRef = interaction.collider.gameObject.GetComponent <Altar>(); Debug.Log(interaction.transform.name); if (currentWeapon.blessedWeapon == false) { altrRef.BlessWeapon(currentWeapon); } } } } } }
protected override void ServerInitializeCharacter(ServerInitializeData data) { // don't call the base initialize // base.ServerInitializeCharacter(data); this.ServerInitializeCharacterMob(data); var character = data.GameObject; var privateState = data.PrivateState; SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache(this.ProtoCharacterDefaultEffects, data.PublicState, privateState, isFirstTime: data.IsFirstTimeInit); var weaponState = privateState.WeaponState; WeaponSystem.RebuildWeaponCache(character, weaponState); privateState.AttackRange = weaponState.WeaponCache?.RangeMax ?? 0; if (data.IsFirstTimeInit) { privateState.SpawnPosition = character.TilePosition; } }
void Awake() { playerState = GameObject.Find("Player").GetComponentInChildren<PlayerState>(); gameState = GameObject.Find("GameController").GetComponentInChildren<GameState>(); weaponSystem = GameObject.Find("Player").GetComponentInChildren<WeaponSystem>(); thirdPersonController = GameObject.Find("Player").GetComponentInChildren<ThirdPersonController>(); }
protected sealed override void ServerUpdate(ServerUpdateData data) { var character = data.GameObject; var privateState = data.PrivateState; var publicState = data.PublicState; if (publicState.IsDead) { // should never happen as the ServerCharacterDeathMechanic should properly destroy the character Logger.Error("(Should never happen) Destroying dead mob character: " + character); ServerWorld.DestroyObject(character); return; } this.ServerRebuildFinalCacheIfNeeded(character, privateState, publicState); ServerUpdateAgroState(privateState, data.DeltaTime); this.ServerUpdateMob(data); this.ServerUpdateMobDespawn(character, privateState, data.DeltaTime); // update weapon state (fires the weapon if needed) WeaponSystem.SharedUpdateCurrentWeapon( character, privateState.WeaponState, data.DeltaTime); }
void Start() { _player = FindObjectOfType <PlayerControl>(); _character = GetComponent <Character>(); _weaponSystem = GetComponent <WeaponSystem>(); _health = GetComponent <Health>(); }
private void Update() { if (Input.GetButtonDown("Escape")) { SceneManager.LoadScene("Building"); if (NetworkClient.Initialized) { NetworkClient.Stop(); } if (NetworkServer.Initialized) { NetworkServer.Stop(); } } if (Input.GetButtonDown("Fire1")) { NetworkClient.SendTcp(TcpPacketType.Client_System_StartFiring, buffer => { }); } if (Input.GetButtonUp("Fire1") && !WeaponSystem.IsSingleFiringType(_structure.WeaponType)) { NetworkClient.SendTcp(TcpPacketType.Client_System_StopFiring, buffer => { }); } if (Input.GetButtonDown("Ability")) { //TODO use ability } Ray ray = _camera.ScreenPointToRay(Input.mousePosition); _networkedPhysics.UpdateLocalInput(Physics.Raycast(ray, out RaycastHit hit) ? hit.point : ray.origin + ray.direction * 500); }
private DamageResult ResolveWeaponAttack(WeaponSystem weapon, int range, ScreenRating screenRating, int evasion = 0, int otherDRM = 0, Constants.DamageType damageTypeModifier = Constants.DamageType.None, AttackSpecialProperties attackPropertiesModifier = AttackSpecialProperties.None) { AttackSpecialProperties effectiveAttackProperties = weapon.FinalizeAttackProperties(attackPropertiesModifier); // Weapons with a hight TrackRating can ignore Evasion, offsetting up to the full Evasion DRM int totalDRM = weapon.FinalizeEvasionDRM(evasion) + otherDRM; // Weapons can ignore certain kinds of shields but not others int totalScreenRating = weapon.FinalizeScreenValue(screenRating, effectiveAttackProperties); Constants.DamageType effectiveDamageType = weapon.FinalizeDamageType(weapon.GetDamageType(), damageTypeModifier, effectiveAttackProperties.HasFlag(AttackSpecialProperties.Overrides_Weapon_DamageType)); // Roll dice here this.Logger.LogInformation($"Attack roll! {weapon.SystemName} -- range {range} | screen {screenRating.ToString()} | net DRM {totalDRM} | {effectiveDamageType.ToString()}-type damage | rating {weapon.Rating}"); /* "Basic" weapon behavior is to shoot like a non-penetrating beam: * 1D per Rating, diminishing with range * 1 damage on a 4 unless screened * 1 damage on a 5, always * 2 damage on a 6, unless double-screened -- then 1 */ DamageResult damageMatrix = FullThrustDieRolls.RollFTDamage(this.DiceUtility, weapon.GetAttackDice(), totalDRM, totalScreenRating, effectiveDamageType.HasFlag(Constants.DamageType.Penetrating)); return(damageMatrix); }
public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); productionSystems = new ProductionSystem(log, Me.CubeGrid, shipComponents); storageSystem = new StorageSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(SensorScan)); operatingOrder.AddLast(new TaskInfo(AnalyzePlanetaryData)); operatingOrder.AddLast(new TaskInfo(InternalSystemScan)); //operatingOrder.AddLast(new TaskInfo(MaintainAltitude)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 100; }
public void Setup(float _pullForce, float _pullRadius, WeaponSystem weaponSystem) { pullForce = _pullForce; pullRadius = _pullRadius; weaponSystemFiredFrom = weaponSystem; weaponSystemFiredFrom.onRightClick += Explode; }
protected override void ServerUpdate(ServerUpdateData data) { var character = data.GameObject; var publicState = data.PublicState; var privateState = data.PrivateState; publicState.IsOnline = character.IsOnline; // update selected hotbar item SharedRefreshSelectedHotbarItem(character, privateState); if (publicState.IsDead) { // dead - stops processing character Server.Characters.SetMoveSpeed(character, 0); Server.Characters.SetVelocity(character, Vector2D.Zero); return; } // character is alive this.ServerRebuildFinalCacheIfNeeded(privateState, publicState); this.SharedApplyInput(character, privateState, publicState); // update weapon state (fires the weapon if needed) WeaponSystem.SharedUpdateCurrentWeapon(character, privateState.WeaponState, data.DeltaTime); // update current action state (if any) privateState.CurrentActionState?.SharedUpdate(data.DeltaTime); // update crafting queue CraftingMechanics.ServerUpdate(privateState.CraftingQueue, data.DeltaTime); // consumes/restores stamina CharacterStaminaSystem.SharedUpdate(character, publicState, privateState, (float)data.DeltaTime); }
protected override void ProcessFire(WeaponSystem fireSystem) { if (mouseControl == false && Input.GetKey(KeyCode.Space)) { fireSystem.TriggerFire(); } if (mouseControl && Input.GetKey(KeyCode.Mouse0)) { fireSystem.TriggerFire(); } if (mouseControl == false && Input.GetKey(KeyCode.R)) { fireSystem.TriggerRocketFire(); } if (mouseControl && Input.GetKey(KeyCode.Mouse1)) { fireSystem.TriggerRocketFire(); } if (Input.GetKeyDown(KeyCode.Q)) { if (mouseControl == false) { mouseControl = true; } else { mouseControl = false; } } }
void SE_UpdateEnemyAI() { distanceToPlayer = Vector3.Distance(player.transform.position, transform.position); WeaponSystem weaponSystem = GetComponent <WeaponSystem>(); currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange(); bool inWeaponCircle = distanceToPlayer <= currentWeaponRange; bool inChaseRing = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius; bool outsideChaseRing = distanceToPlayer > chaseRadius; if (outsideChaseRing) { StopAllCoroutines(); weaponSystem.StopAttacking(); StartCoroutine(Patrol()); } if (inChaseRing) { StopAllCoroutines(); weaponSystem.StopAttacking(); StartCoroutine(ChasePlayer()); } if (inWeaponCircle) { StopAllCoroutines(); state = State.attacking; weaponSystem.AttackTarget(player.gameObject); } }
private void Awake() { _initialized = true; _rigidbody = gameObject.GetComponent <Rigidbody>(); _navMeshAgent = gameObject.GetComponent <NavMeshAgent>(); _healthSystem = gameObject.GetComponent <HealthSystem>(); _weaponSystem = gameObject.GetComponentInChildren <WeaponSystem>(); _animator = gameObject.GetComponentInChildren <Animator>(); if (_weaponSystem != null) { _weaponSystem.character = this; } OnAwake(); if (spawnOnAwake) { Spawn(); } else { gameObject.SetActive(false); } }
public void Initialize(GameObject primary, GameObject melee, GameObject secondary) { LowerController.LoadStats(Stats); currentHp = Stats.MaxHealth; Weapons = this.GetComponentInChildren <WeaponSystem>(); Weapons.LoadPrimary(primary); Weapons.LoadSecondary(secondary); Weapons.LoadMelee(melee); var res = GameObject.Find("PlayerLoader").GetComponent <PlayerResources>(); var face = res.GetFace(Country); uiController = GetComponent <BotUIController>(); uiController.Initialize(Stats, primary.GetComponent <PrimaryWeaponBase>().GetStats, secondary.GetComponent <SecondaryWeaponBase>().GetStats, PlayerId, face); uiController.UpdateHp(currentHp); director = GameObject.Find("GameDirector").GetComponent <GameDirector>(); director.AddPlayer(this); PlayerRing.color = res.GetColor(PlayerId); effect = this.GetComponent <EffectManager>(); }
public override void Use(WeaponSystem weaponSystem, int abilityIndex) { weaponSystem.SetCooldown(abilityIndex, cooldown); GameObject instance = Instantiate(shieldObject, weaponSystem.transform.position + (weaponSystem.GetCamera().transform.forward / 2), weaponSystem.GetCamera().transform.rotation, weaponSystem.GetCamera().transform) as GameObject; instance.GetComponent <EnergyShieldObject>().Setup(duration); }
private void Awake() { _rb = GetComponent <Rigidbody>(); _bulletPool = GetComponentInChildren <BulletsPool>(); _weaponSystem = GetComponentInChildren <WeaponSystem>(); _player = GameObject.FindWithTag("Player").transform; }
// Passes player input to weapon system protected override void ProcessFire(WeaponSystem fireSystem) { if (Input.GetKey(_fire)) { fireSystem.TriggerFire(); } }
public bool AddWeapon(WeaponData weapon, int index = -1) { if ((index == -1 || index == 0) && weaponPrimary == null) { weaponPrimary = Instantiate(weapon.prefab).GetComponent <WeaponSystem>(); weaponPrimary.name = weapon.name; weaponPrimary.Initialize(weapon); weaponPrimary.PickupWeapon(defaultWeaponPos, 0); LoadoutManager.instance.InitializeWeapon(weaponPrimary, 0); SetWeaponActive(weaponPrimary, false); } else if ((index == -1 || index == 1) && weaponSecondary == null) { weaponSecondary = Instantiate(weapon.prefab).GetComponent <WeaponSystem>(); weaponSecondary.name = weapon.name; weaponSecondary.Initialize(weapon); weaponSecondary.PickupWeapon(defaultWeaponPos, 1); LoadoutManager.instance.InitializeWeapon(weaponSecondary, 1); SetWeaponActive(weaponSecondary, false); } else if ((index == -1 || index == 2) && weaponSidearm == null) { weaponSidearm = Instantiate(weapon.prefab).GetComponent <WeaponSystem>(); weaponSidearm.name = weapon.name; weaponSidearm.Initialize(weapon); weaponSidearm.PickupWeapon(defaultWeaponPos, 2); LoadoutManager.instance.InitializeWeapon(weaponSidearm, 2); SetWeaponActive(weaponSidearm, false); } else { return(false); } return(true); }
private void Start() { stats = GetComponent <StatsHolder>(); stats.OnZeroHealth = OnDeath; weapsys = GetComponent <WeaponSystem>(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Create game systems InputSystem = new InputSystem(this); NetworkSystem = new NetworkSystem(this); RenderingSystem = new RenderingSystem(this); MovementSystem = new MovementSystem(this); WeaponSystem = new WeaponSystem(this); EnemyAISystem = new EnemyAISystem(this); NpcAISystem = new NpcAISystem(this); GarbagemanSystem = new GarbagemanSystem(this); CollisionSystem = new Systems.CollisionSystem(this); RoomChangingSystem = new RoomChangingSystem(this); QuestLogSystem = new QuestLogSystem(this); SpriteAnimationSystem = new SpriteAnimationSystem(this); SkillSystem = new SkillSystem(this); TextSystem = new TextSystem(this); // Testing code. LevelManager.LoadContent(); LevelManager.LoadLevel("D01F01R01"); //End Testing Code }
public static void TrySetWeapon( ICharacter character, IProtoItemWeapon protoWeapon, bool rebuildWeaponsCacheNow) { var privateState = character.GetPrivateState <CharacterMobPrivateState>(); var publicState = character.GetPublicState <CharacterMobPublicState>(); var weaponState = privateState.WeaponState; if (ReferenceEquals(weaponState.ProtoWeapon, protoWeapon)) { return; } if (weaponState.CooldownSecondsRemains > 0.001 || weaponState.DamageApplyDelaySecondsRemains > 0.001) { //Api.Logger.Dev("Weapon cooldown remains: " + weaponState.CooldownSecondsRemains); return; } weaponState.SharedSetWeaponProtoOnly(protoWeapon); publicState.SharedSetCurrentWeaponProtoOnly(protoWeapon); // can use the new selected mob weapon instantly weaponState.ReadySecondsRemains = weaponState.CooldownSecondsRemains = 0; if (!rebuildWeaponsCacheNow) { return; } WeaponSystem.SharedRebuildWeaponCache(character, weaponState); privateState.AttackRange = weaponState.WeaponCache.RangeMax; }
protected override void ServerInitializeCharacter(ServerInitializeData data) { // don't call the base initialize // base.ServerInitializeCharacter(data); var character = data.GameObject; var privateState = data.PrivateState; data.PrivateState.WeaponState.SharedSetWeaponProtoOnly(this.protoItemWeaponTurret); data.PublicState.SharedSetCurrentWeaponProtoOnly(this.protoItemWeaponTurret); this.ServerInitializeCharacterTurret(data); SharedCharacterStatsHelper.RefreshCharacterFinalStatsCache( this.ProtoCharacterDefaultEffects, data.PublicState, privateState, // always rebuild the mob character state // as the game doesn't store current HP for mobs isFirstTime: true); var weaponState = privateState.WeaponState; WeaponSystem.SharedRebuildWeaponCache(character, weaponState); privateState.AttackRange = weaponState.WeaponCache?.RangeMax ?? 0; if (data.IsFirstTimeInit) { privateState.SpawnPosition = character.TilePosition; } }
public virtual void OnRemovedFromGroup(MyGridLogicalGroupData group) { Debug.Assert(TerminalSystem == group.TerminalSystem, "Removing grid from diferent group then it was added to!"); if (m_blocksRegistered) { ProfilerShort.Begin("Removing block groups from grid group"); TerminalSystem.GroupAdded -= m_terminalSystem_GroupAdded; TerminalSystem.GroupRemoved -= m_terminalSystem_GroupRemoved; foreach (var g in m_cubeGrid.BlockGroups) { TerminalSystem.RemoveGroup(g); } ProfilerShort.End(); foreach (var block in m_cubeGrid.GetFatBlocks()) { var functionalBlock = block as MyTerminalBlock; if (functionalBlock != null) { TerminalSystem.Remove(functionalBlock); } var producer = block.Components.Get <MyResourceSourceComponent>(); if (producer != null) { ResourceDistributor.RemoveSource(producer); } var consumer = block.Components.Get <MyResourceSinkComponent>(); if (consumer != null) { ResourceDistributor.RemoveSink(consumer, resetSinkInput: false, markedForClose: block.MarkedForClose); } var socketOwner = block as IMyRechargeSocketOwner; if (socketOwner != null) { socketOwner.RechargeSocket.ResourceDistributor = null; } var weapon = block as IMyGunObject <MyDeviceBase>; if (weapon != null) { WeaponSystem.Unregister(weapon); } } } ConveyorSystem.ResourceSink.IsPoweredChanged -= ResourceDistributor.ConveyorSystem_OnPoweredChanged; group.ResourceDistributor.RemoveSink(ConveyorSystem.ResourceSink, resetSinkInput: false); group.ResourceDistributor.RemoveSink(GyroSystem.ResourceSink, resetSinkInput: false); group.ResourceDistributor.UpdateBeforeSimulation10(); m_cubeGrid.OnBlockAdded -= ResourceDistributor.CubeGrid_OnBlockAddedOrRemoved; m_cubeGrid.OnBlockRemoved -= ResourceDistributor.CubeGrid_OnBlockAddedOrRemoved; ResourceDistributor = null; TerminalSystem = null; WeaponSystem = null; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Create game systems InputSystem = new InputSystem(this); NetworkSystem = new NetworkSystem(this); RenderingSystem = new RenderingSystem(this); MovementSystem = new MovementSystem(this); WeaponSystem = new WeaponSystem(this); EnemyAISystem = new EnemyAISystem(this); NpcAISystem = new NpcAISystem(this); GarbagemanSystem = new GarbagemanSystem(this); CollisionSystem = new Systems.CollisionSystem(this); RoomChangingSystem = new RoomChangingSystem(this); QuestLogSystem = new QuestLogSystem(this); SpriteAnimationSystem = new SpriteAnimationSystem(this); SkillSystem = new SkillSystem(this); TextSystem = new TextSystem(this); EngineeringOffenseSystem = new EngineeringOffenseSystem(this); HUDSystem = new HUDSystem(this); InputHelper.Load(); HUDSystem.LoadContent(); // Testing code. LevelManager.LoadContent(); LevelManager.LoadLevel("D01F01R01"); //Song bg = Content.Load<Song>("Audio/Main_Loop"); //MediaPlayer.Stop(); //MediaPlayer.IsRepeating = true; //MediaPlayer.Play(bg); //End Testing Code }
public void Initialize() { sectionManager = GetComponent <SectionManager>(); weaponSystem = GetComponent <WeaponSystem>(); outlineHandler = GetComponent <OutlineHandler>(); }
public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, false); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(InternalSystemCheck)); operatingOrder.AddLast(new TaskInfo(NavigationCheck)); operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages)); operatingOrder.AddLast(new TaskInfo(SendPendingMessages)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(ScanLocalArea)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); SetupFleetListener(); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 150; InitialBlockCount = shipComponents.AllBlocks.Count(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
/// <summary> /// Called by client component every tick. /// </summary> public override void Update(double deltaTime) { if (!(IsEnabled && CheckPrecondition())) { Stop(); return; } if (attackInProgress) { if (currentTargetObject?.PhysicsBody != null && ValidateTarget(currentTargetObject, out Vector2D targetPoint)) { MovementManager.RotationTargetPos = targetPoint; if (!PlayerCharacter.GetPrivateState(CurrentCharacter).WeaponState.IsFiring) { // On mouse button release firing is stopped, set it on again WeaponSystem.ClientChangeWeaponFiringMode(true); } } else { StopAttack(); FindAndAttackTarget(); } } }
public virtual void OnRemovedFromGroup(MyGridLogicalGroupData group) { if (m_blocksRegistered) { ProfilerShort.Begin("Removing block groups from grid group"); TerminalSystem.GroupAdded -= m_terminalSystem_GroupAdded; TerminalSystem.GroupRemoved -= m_terminalSystem_GroupRemoved; foreach (var g in m_cubeGrid.BlockGroups) { TerminalSystem.RemoveGroup(g); } ProfilerShort.End(); foreach (var block in m_cubeGrid.GetBlocks()) { if (block.FatBlock == null) { continue; } var functionalBlock = block.FatBlock as MyTerminalBlock; if (functionalBlock != null) { TerminalSystem.Remove(functionalBlock); } var producer = block.FatBlock as IMyPowerProducer; if (producer != null) { PowerDistributor.RemoveProducer(producer); } var consumer = block.FatBlock as IMyPowerConsumer; if (consumer != null) { PowerDistributor.RemoveConsumer(consumer, resetConsumerInput: false, markedForClose: block.FatBlock.MarkedForClose); } var socketOwner = block.FatBlock as IMyRechargeSocketOwner; if (socketOwner != null) { socketOwner.RechargeSocket.PowerDistributor = null; } var weapon = block.FatBlock as IMyGunObject <MyDeviceBase>; if (weapon != null) { WeaponSystem.Unregister(weapon); } } } PowerDistributor.RemoveConsumer(ConveyorSystem, resetConsumerInput: false); PowerDistributor.RemoveConsumer(GyroSystem, resetConsumerInput: false); PowerDistributor.RemoveConsumer(ThrustSystem, resetConsumerInput: false); PowerDistributor = null; TerminalSystem = null; WeaponSystem = null; }
public static WeaponSystem getInstance() { if (instance==null) { instance = new WeaponSystem(); } return instance; }
public void Update(WeaponSystem ws) { NextWeapon.Update(); PrevWeapon.Update(); DropWeapon.Update(); if (NextWeapon.isDown) { ws.WeaponHands[Hand].NextWeapon(); } else if (PrevWeapon.isDown) { ws.WeaponHands[Hand].PrevWeapon(); } else if (DropWeapon.isDown) { ws.WeaponHands[Hand].DropWeapon(ws.WeaponHands[Hand].CurrentWeapon); } else { for (int slot = SelectWeaponSlot.Length - 1; slot >= 0; slot--) { SelectWeaponSlot[slot].Update(); if (SelectWeaponSlot[slot].isDown) { ws.WeaponHands[Hand].SetWeapon(slot); return; } } //check all defined fire modes for (int fMode = Fire.Length - 1; fMode >= 0; fMode--) { Fire[fMode].Update(); if (Fire[fMode].isDown) { ws.FirePressed(Hand,fMode); } if (Fire[fMode].isUp) { ws.FireReleased(Hand,fMode); } if (Fire[fMode].isPressed) { ws.ConstantFire(Hand,fMode); if (FireModeExclusive) { //if only one firemode is allowed at a time, break here. //Higher numbered firemodes will have priority over lower ones. return; } } } } }
public void Start() { engines = GetComponent<EngineSystem>(); weaponSystem = GetComponent<WeaponSystem>(); flightControls = new FlightControls(yawDamp, pitchDamp, rollDamp); engines.SetFlightControls(flightControls); flightControls.SetStickInputs(0f, 0f, 0f, startThrottle); EventManager.Instance.AddListener<Event_EntityDespawned>(OnEntityDespawned); PlayerManager.PlayerEventManager.AddListener<Event_EntityDamaged>(OnDamageTaken); cameraEye = GetComponentInChildren<CameraEye>(); }
public AIState(string name, AIPilot pilot) { this.name = name; this.pilot = pilot; this.entity = pilot.entity; this.transform = entity.transform; this.sensorSystem = entity.sensorSystem; this.engineSystem = entity.engineSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; }
public AISubstate(AIState parentState) { this.parentState = parentState; this.pilot = parentState.pilot; this.entity = parentState.pilot.entity; this.transform = entity.transform; this.sensorSystem = entity.sensorSystem; this.engineSystem = entity.engineSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; }
public override void OnInspectorGUI() { weaponSystem = target as WeaponSystem; serializedObject.Update(); groupList.DoLayoutList(); firepointList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); if (GUILayout.Button("Refresh Firepoints")) { weaponSystem.CollectWeaponGroups(); } if (GUILayout.Button("Sort Firepoints")) { weaponSystem.firepoints.Sort(delegate(Firepoint a, Firepoint b) { return a.name.CompareTo(b.name); }); } }
// Use this for initialization void Awake () { m_weaponSystem = GetComponent<WeaponSystem>(); }
public override void OnAwake() { pilot = GetComponent<Pilot>(); weapons = GetComponent<WeaponSystem>(); }
public virtual void Start() { entity = GetComponent<Entity>(); engines = GetComponentInChildren<EngineSystem>(); weaponSystem = GetComponent<WeaponSystem>(); flightControls = new FlightControls(); engines.SetFlightControls(flightControls); rigidbody = GetComponent<Rigidbody>(); EventManager.Instance.AddListener<Event_EntityDespawned>(OnEntityDespawned); SelectWeapon(); }
protected void SwitchWeapon() { // create new, or recreate if main weapon changed if (mainWeapon == null || prevSelectedMainWeapon != mainWeaponSelected) { if (mainWeapon != null) // recycle old weapon mainWeapon.Destroy (); mainWeapon = InstantiateWeapon (mainWeaponTypes [mainWeaponSelected], mainWeaponPosition); mainWeapon.tag = gameObject.tag; } WeaponSystemBuilder builder = new WeaponSystemBuilder (mainWeapon); // create new, or reacreate if side weapons changed if (sideWeapons == null || prevSelectedSideWeapon != sideWeaponsSelected) { if (sideWeapons != null) { // recycle old weapons foreach (Weapon w in sideWeapons) w.Destroy (); } if (sideWeaponsPositions.Length > 0) { sideWeapons = new Weapon[sideWeaponsPositions.Length]; for (int i=0; i< sideWeaponsPositions.Length; i++) { sideWeapons [i] = InstantiateWeapon (sideWeaponsTypes [sideWeaponsSelected], sideWeaponsPositions [i]); sideWeapons [i].tag = gameObject.tag; } } } if (sideWeapons != null) builder.SetSideWeapons (sideWeapons); weaponSystem = builder.WeaponSystem; }
public WeaponSystemBuilder(Weapon weapon) { weaponSystem = new BasicWeaponSystem (weapon); }
public void SetSideWeapons(Weapon[] weapons) { weaponSystem = new SideWeaponSystem (weapons, weaponSystem); }
public static bool TryGetWeaponSystem(Item item, out WeaponSystem weaponSystem) { const int ENERGY_WEAPON_GROUP_ID = 53; const int PROJECTILE_WEAPON_GROUP_ID = 55; const int HYBRID_WEAPON_GROUP_ID = 74; const int SMARTBOMB_ID = 72; const int COMBAT_DRONE_ID = 100; switch (item.GroupId) { case ENERGY_WEAPON_GROUP_ID: case PROJECTILE_WEAPON_GROUP_ID: case HYBRID_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Turret; return true; case Ammo.ROCKET_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case Ammo.LIGHT_MISSILE_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case Ammo.HEAVY_MISSILE_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case Ammo.HEAVY_ASSAULT_MISSILE_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case Ammo.RAPID_LIGHT_MISSILE_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case Ammo.RAPID_HEAVY_MISSILE_WEAPON_GROUP_ID: weaponSystem = WeaponSystem.Missile; return true; case COMBAT_DRONE_ID: weaponSystem = WeaponSystem.Drone; return true; case SMARTBOMB_ID: weaponSystem = WeaponSystem.Smartbomb; return true; default: weaponSystem = WeaponSystem.None; return false; } }
private static bool IsNeedingAmmo(WeaponSystem weaponSystem) { return weaponSystem == WeaponSystem.Turret || weaponSystem == WeaponSystem.Missile; }
private void OnEnable() { weaponSystem = target as WeaponSystem; weaponSystem.CollectWeaponGroups(); firepointList = new ReorderableList(serializedObject, serializedObject.FindProperty("firepoints"), true, true, true, true); firepointList.drawElementCallback += DrawFirepoint; firepointList.drawHeaderCallback += DrawHeaderCallback; firepointList.onAddCallback += AddFirepoint; firepointList.onSelectCallback += SelectFirepoint; groupList = new ReorderableList(serializedObject, serializedObject.FindProperty("weaponGroups"), true, true, true, true); groupList.elementHeight = EditorGUIUtility.singleLineHeight; groupList.drawElementCallback += DrawWeaponGroup; groupList.drawHeaderCallback += DrawWeaponGroupHeader; groupList.onAddCallback += AddGroup; groupList.onCanRemoveCallback += CanRemoveGroup; groupList.onRemoveCallback += RemoveGroup; weaponGroupNames = new List<string>(); for (int i = 0; i < weaponSystem.weaponGroups.Count; i++) { weaponGroupNames.Add(weaponSystem.weaponGroups[i].groupId); } }
public void Awake() { if (radius <= 0) radius = 10f; //todo do this better, use collider bounds weaponSystem = GetComponentInChildren<WeaponSystem>(); engineSystem = GetComponentInChildren<EngineSystem>(); }
//todo -- probably takes a descriptor to read pilot stats out of public void Start() { this.entity = GetComponent<Entity>(); this.engines = GetComponentInChildren<EngineSystem>(); this.controls = engines.FlightControls; this.sensorSystem = entity.sensorSystem; this.weaponSystem = entity.weaponSystem; this.commSystem = entity.commSystem; this.navSystem = entity.navSystem; Assert.IsNotNull(this.entity, "AIPilot needs an entity " + transform.name); Assert.IsNotNull(this.engines, "AIPilot needs an engine system"); Assert.IsNotNull(this.sensorSystem, "AIPilot needs a sensor system"); goals = new List<AIGoal>(5); AddGoal(new AIGoal_Idle()); AIGoalDescriptor desc = new AIGoalDescriptor(0.5f); AddGoal(new AIGoal_GoTo(desc, new Vector3(0, 0, 42f), 5f)); aiStates = CreateAIStates(this); SetAIState(); }
public WeaponDecor(WeaponSystem weaponSystem) { this.weaponSystem = weaponSystem; }
// Use this for initialization void Start() { playerState = GetComponent<PlayerState>(); weaponSystem = GetComponent<WeaponSystem> (); gameState = GameObject.Find("GameController").GetComponent<GameState>(); upgradeGUI = GameObject.Find("GUIController").GetComponentInChildren<UpgradeGUI>(); }
void Start() { //Get the current scene and save it in the gamestate currentScene = Application.loadedLevelName; //Get reno level start variables if(currentScene == newReno) { //Getting gamestate and player state and gui variables gameState = GameObject.Find("GameController").GetComponent<GameState>(); playerState = GameObject.Find("Player").GetComponent<PlayerState>(); weaponSystem = GameObject.Find("Player").GetComponent<WeaponSystem>(); } }
public SideWeaponSystem(Weapon[] weapons, WeaponSystem system) : base(system) { this.weapons = weapons; }