void Start() { _acceleration = this.AccelerationDuration > 0 ? this.MaxSpeed / this.AccelerationDuration : this.MaxSpeed * 1000; _weapon = this.GetComponent <Weapon>(); _weapon.ShotFiredCallback = shotFired; _aimAxis = Vector2.zero; this.ControllerAimerSpeed = PlayerPrefs.GetFloat(OptionsMenu.CONTROLLER_AIM_SPEED_KEY, OptionsMenu.DEFAULT_CONTROLLER_AIM_SPEED); if (PlayerPrefs.GetInt(OptionsMenu.CONTROLLER_AIM_LAST_DIR_KEY, OptionsMenu.DEFAULT_CONTROLLER_AIM_LAST_DIR) == 0) { this.ControllerMinAimAmt = 0.0f; } this.Reticle.PlayerIndex = this.PlayerIndex; _damagable = this.GetComponent <Damagable>(); _damagable.OnDeathCallbacks.Add(died); this.localNotifier.Listen(CollisionEvent.NAME, this, this.OnCollide); updateSlots(); if (this.PlayerIndex != 0) { AllegianceColorizer colorizer = this.GetComponent <AllegianceColorizer>(); AllegianceInfo info = colorizer.AllegianceInfo; info.MemberId = this.PlayerIndex; colorizer.UpdateVisual(info); _weapon.AllegianceInfo = info; this.spriteRenderer.sprite = this.SpriteAtlas.GetSprites()["player_body_" + this.PlayerIndex]; } if (_initialHealth > 0) { _damagable.DirectSetHealth(_initialHealth); } }
public LaserCastEvent(CollisionManager.RaycastResult raycastResult, IntegerVector origin, AllegianceInfo allegianceInfo) { this.Name = NAME; this.RaycastResult = raycastResult; this.Origin = origin; this.AllegianceInfo = allegianceInfo; }
public static void CreateExplosionEntity(Vector3 position, string explosionKey, AllegianceInfo allegianceInfo, int layer, LayerMask damagableLayers, WeaponType weaponType) { GameObject explosion = ObjectPools.GetPooledObject(explosionKey); explosion.transform.position = position; explosion.GetComponent <Explosion>().DetonateWithWeaponType(weaponType, layer, damagableLayers, allegianceInfo); }
private void onDeath(Damagable damagable) { if (this.CollisionWeaponType != null && this.CollisionWeaponType.SpecialEffect == WeaponType.SPECIAL_EXPLOSION) { AllegianceInfo info = this.GetComponent <AllegianceColorizer>().AllegianceInfo; LayerMask damagableLayers = this.GetComponent <Damager>().DamagableLayers; Bullet.CreateExplosionEntity(this.transform.position, this.ExplosionPoolKey, info, this.gameObject.layer, damagableLayers, this.CollisionWeaponType); } }
public static Color GetColorForAllegiance(AllegianceInfo allegianceInfo, ColorPaletteState colorClass) { string colorClassAddition = ""; switch (colorClass) { default: case ColorPaletteState.Main: colorClassAddition = ""; break; case ColorPaletteState.Projectile: colorClassAddition = "_projectile"; break; case ColorPaletteState.Explosion: colorClassAddition = "_explosion"; break; case ColorPaletteState.Damaged: colorClassAddition = "_damaged"; break; case ColorPaletteState.Gibs: colorClassAddition = "_gibs"; break; case ColorPaletteState.UIPrimary: colorClassAddition = "_uiprimary"; break; case ColorPaletteState.UISecondary: colorClassAddition = "_uisecondary"; break; } switch (allegianceInfo.Allegiance) { case Allegiance.Player: return(GetColorFromTag("player" + colorClassAddition, allegianceInfo.MemberId)); case Allegiance.Enemy: return(GetColorFromTag("enemy" + colorClassAddition, allegianceInfo.MemberId)); default: return(Color.white); } }
public void UpdateVisual(AllegianceInfo allegianceInfo, ColorPaletteState colorState) { this.AllegianceInfo = allegianceInfo; if (this.DependentColorizers != null) { foreach (AllegianceColorizer dependent in this.DependentColorizers) { AllegianceInfo info = dependent.AllegianceInfo; info.Allegiance = allegianceInfo.Allegiance; info.MemberId = allegianceInfo.MemberId; dependent.UpdateVisual(info); } } if (_colorSetter != null) _colorSetter(GameplayPalette.GetColorForAllegiance(allegianceInfo, colorState)); }
public void LaunchWithWeaponType(Vector2 direction, WeaponType weaponType, AllegianceInfo allegianceInfo, bool ignoreExplosion = false) { this.WeaponType = weaponType; _ignoreExplosion = ignoreExplosion; this.Velocity = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER ? Vector2.zero : new Vector2(direction.x * weaponType.ShotSpeed, direction.y * weaponType.ShotSpeed); _allegianceInfo = allegianceInfo; AllegianceColorizer allegianceColorizer = this.GetComponent<AllegianceColorizer>(); if (allegianceColorizer != null) allegianceColorizer.UpdateVisual(allegianceInfo); _bouncesRemaining = weaponType.MaximumBounces; this.localNotifier.Listen(CollisionEvent.NAME, this, this.OnCollide); string allegianceString = allegianceInfo.LayerString; int ourLayer = LayerMask.NameToLayer(allegianceString + " Missile"); this.gameObject.layer = ourLayer; LayerMask alliedVulnerable = (1 << LayerMask.NameToLayer(allegianceString + " Vulnerable")); LayerMask levelGeometryMask = (1 << LayerMask.NameToLayer("Level Geometry")); LayerMask nothing = 0; _damager = this.GetComponent<Damager>(); _damager.DamagableLayers = (~alliedVulnerable) & GetVulnerableLayers(); _damager.Damage = weaponType.Damage; _damager.Knockback = weaponType.Knockback; _damager.HitInvincibilityDuration = weaponType.HitInvincibilityDuration; //TODO - Only do this in campaign mode!! if (_allegianceInfo.Allegiance == Allegiance.Player) _damager.AddAttackLandedCallback(landedAttack); this.BounceLayerMask = weaponType.MaximumBounces > 0 ? levelGeometryMask : nothing; this.CollisionMask = _damager.DamagableLayers | levelGeometryMask; this.HaltMovementMask = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER ? levelGeometryMask : this.CollisionMask; _explosionRemaining = this.WeaponType.SpecialEffect == WeaponType.SPECIAL_EXPLOSION; _isLaser = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER; if (_isLaser) handleLaserCast(direction); }
public void UpdateVisual(AllegianceInfo allegianceInfo, ColorPaletteState colorState) { this.AllegianceInfo = allegianceInfo; if (this.DependentColorizers != null) { foreach (AllegianceColorizer dependent in this.DependentColorizers) { AllegianceInfo info = dependent.AllegianceInfo; info.Allegiance = allegianceInfo.Allegiance; info.MemberId = allegianceInfo.MemberId; dependent.UpdateVisual(info); } } if (_colorSetter != null) { _colorSetter(GameplayPalette.GetColorForAllegiance(allegianceInfo, colorState)); } }
public void DetonateWithWeaponType(WeaponType weaponType, int layer, LayerMask damagableLayers, AllegianceInfo allegianceInfo) { this.gameObject.layer = layer; _finalRadius = this.RadiusToPowerMultiplier * weaponType.SpecialEffectParameter1; _growthRate = _finalRadius / this.ExplosionDuration; _circleRenderer = this.GetComponent<CircleRenderer>(); _damager = this.GetComponent<Damager>(); _damager.DamagableLayers = damagableLayers; _damager.Damage = weaponType.Damage; _damager.Knockback = weaponType.Knockback; _damager.HitInvincibilityDuration = weaponType.HitInvincibilityDuration; _allegianceInfo = allegianceInfo; if (allegianceInfo.Allegiance == Allegiance.Player) _damager.AddAttackLandedCallback(landedAttack); this.GetComponent<AllegianceColorizer>().UpdateVisual(allegianceInfo); ExplosionSounder.Detonate(); }
public void DetonateWithWeaponType(WeaponType weaponType, int layer, LayerMask damagableLayers, AllegianceInfo allegianceInfo) { this.gameObject.layer = layer; _finalRadius = this.RadiusToPowerMultiplier * weaponType.SpecialEffectParameter1; _growthRate = _finalRadius / this.ExplosionDuration; if (_circleRenderer == null) { _circleRenderer = this.GetComponent <CircleRenderer>(); } if (_damager == null) { _damager = this.GetComponent <Damager>(); } _damager.DamagableLayers = damagableLayers; _damager.Damage = weaponType.Damage; _damager.Knockback = weaponType.Knockback; _damager.HitInvincibilityDuration = weaponType.HitInvincibilityDuration; _allegianceInfo = allegianceInfo; if (allegianceInfo.Allegiance == Allegiance.Player) { _damager.AddAttackLandedCallback(landedAttack); } this.GetComponent <AllegianceColorizer>().UpdateVisual(allegianceInfo); if (_collider == null) { _collider = this.GetComponent <IntegerCollider>(); } else { _collider.AddToCollisionPool(); } ExplosionSounder.Detonate(); }
void Update() { if (!_setup) { for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i) { SessionPlayer p = DynamicData.GetSessionPlayer(i); if (p.HasJoined) { if (ReInput.players.GetPlayer(p.RewiredId).controllers.hasMouse) { _player = p; AllegianceColorizer colorizer = this.GetComponent <AllegianceColorizer>(); AllegianceInfo info = colorizer.AllegianceInfo; info.MemberId = i; colorizer.UpdateVisual(info); break; } } } _setup = true; } if (_player != null) { if (PauseController.IsPaused()) { _rectTransform.position = new Vector3(-99999, -99999, _rectTransform.position.z); } else { Player rewiredP = ReInput.players.GetPlayer(_player.RewiredId); Vector2 screenPos = rewiredP.controllers.Mouse.screenPosition; _rectTransform.position = new Vector3(screenPos.x, screenPos.y, _rectTransform.position.z); } } }
public void UpdateVisual(AllegianceInfo allegianceInfo) { this.UpdateVisual(allegianceInfo, this.DefaultColorState); }
public static Color GetColorForAllegiance(AllegianceInfo allegianceInfo, ColorPaletteState colorClass) { string colorClassAddition = ""; switch (colorClass) { default: case ColorPaletteState.Main: colorClassAddition = ""; break; case ColorPaletteState.Projectile: colorClassAddition = "_projectile"; break; case ColorPaletteState.Explosion: colorClassAddition = "_explosion"; break; case ColorPaletteState.Damaged: colorClassAddition = "_damaged"; break; case ColorPaletteState.Gibs: colorClassAddition = "_gibs"; break; case ColorPaletteState.UIPrimary: colorClassAddition = "_uiprimary"; break; case ColorPaletteState.UISecondary: colorClassAddition = "_uisecondary"; break; } switch (allegianceInfo.Allegiance) { case Allegiance.Player: return GetColorFromTag("player" + colorClassAddition, allegianceInfo.MemberId); case Allegiance.Enemy: return GetColorFromTag("enemy" + colorClassAddition, allegianceInfo.MemberId); default: return Color.white; } }
public void LaunchWithWeaponType(Vector2 direction, WeaponType weaponType, AllegianceInfo allegianceInfo, bool ignoreExplosion = false) { this.WeaponType = weaponType; _ignoreExplosion = ignoreExplosion; this.Velocity = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER ? Vector2.zero : new Vector2(direction.x * weaponType.ShotSpeed, direction.y * weaponType.ShotSpeed); _allegianceInfo = allegianceInfo; AllegianceColorizer allegianceColorizer = this.GetComponent <AllegianceColorizer>(); if (allegianceColorizer != null) { allegianceColorizer.UpdateVisual(allegianceInfo); } _bouncesRemaining = weaponType.MaximumBounces; if (!_listeningToCollisions) { _listeningToCollisions = true; this.localNotifier.Listen(CollisionEvent.NAME, this, this.OnCollide); } string allegianceString = allegianceInfo.LayerString; int ourLayer = LayerMask.NameToLayer(allegianceString + " Missile"); this.gameObject.layer = ourLayer; LayerMask alliedVulnerable = (1 << LayerMask.NameToLayer(allegianceString + " Vulnerable")); LayerMask levelGeometryMask = (1 << LayerMask.NameToLayer("Level Geometry")); LayerMask nothing = 0; if (_damager == null) { _damager = this.GetComponent <Damager>(); } _damager.DamagableLayers = (~alliedVulnerable) & GetVulnerableLayers(); _damager.Damage = weaponType.Damage; _damager.Knockback = weaponType.Knockback; _damager.HitInvincibilityDuration = weaponType.HitInvincibilityDuration; //TODO - Only do this in campaign mode!! if (_allegianceInfo.Allegiance == Allegiance.Player) { _damager.AddAttackLandedCallback(landedAttack); } this.BounceLayerMask = weaponType.MaximumBounces > 0 ? levelGeometryMask : nothing; this.CollisionMask = _damager.DamagableLayers | levelGeometryMask; this.HaltMovementMask = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER ? levelGeometryMask : this.CollisionMask; _explosionRemaining = this.WeaponType.SpecialEffect == WeaponType.SPECIAL_EXPLOSION; _isLaser = weaponType.TravelType == WeaponType.TRAVEL_TYPE_LASER; if (_collider == null) { _collider = this.GetComponent <IntegerCollider>(); } else { _collider.AddToCollisionPool(); } if (_isLaser) { handleLaserCast(direction); } }
public static void CreateExplosionEntity(Vector3 position, GameObject explosionPrefab, AllegianceInfo allegianceInfo, int layer, LayerMask damagableLayers, WeaponType weaponType) { GameObject explosion = Instantiate(explosionPrefab, position, Quaternion.identity) as GameObject; explosion.GetComponent<Explosion>().DetonateWithWeaponType(weaponType, layer, damagableLayers, allegianceInfo); }