Ejemplo n.º 1
0
        public static void RecalculateOrbitals(this PlayerController player)
        {
            Dictionary <int, int> tiersAndCounts = new Dictionary <int, int>();

            foreach (var o in player.orbitals)
            {
                var orbital    = (PlayerOrbital)o;
                int targetTier = PlayerOrbital.CalculateTargetTier(player, o);
                orbital.SetOrbitalTier(targetTier);
                if (tiersAndCounts.ContainsKey(targetTier)) //Count starts at 0
                {
                    int existingCount = tiersAndCounts[targetTier];
                    tiersAndCounts[targetTier] = existingCount + 1;
                }
                else
                {
                    tiersAndCounts.Add(targetTier, 0);
                }
            }
            foreach (var o in player.orbitals)
            {
                var orbital     = (PlayerOrbital)o;
                int currentTier = orbital.GetOrbitalTier();
                if (tiersAndCounts.ContainsKey(currentTier))
                {
                    int currentAmtInTier = tiersAndCounts[currentTier];
                    orbital.SetOrbitalTierIndex(tiersAndCounts[currentTier]);
                    tiersAndCounts[currentTier] = currentAmtInTier - 1;
                }
                else
                {
                    orbital.SetOrbitalTierIndex(0);
                }
            }
        }
Ejemplo n.º 2
0
 private void Start()
 {
     //you'll need code from PlayerOrbital and HoveringGunController (the base game one) to make this thing work
     //Add Lute support too
     if (owner == null)
     {
         owner = GameManager.Instance.PrimaryPlayer;
     }
     initialized = true;
     if (base.gameObject.GetComponent <tk2dSprite>() != null && !preventOutline) // needs a sprite to work!
     {
         sprite = base.gameObject.GetComponent <tk2dSprite>();
         SpriteOutlineManager.AddOutlineToSprite(sprite, outlineColor);
     }
     this.SetOrbitalTier(PlayerOrbital.CalculateTargetTier(owner, this));
     this.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(owner, orbitalTier));
     owner.orbitals.Add(this);
     ownerCenterPos = owner.CenterPosition;
     if (base.gameObject.GetComponent <SpeculativeRigidbody>() == null)
     {
         body = sprite.SetUpSpeculativeRigidbody(specBodyOffsets, specBodyDimensions);
         if (pixelColliders.Any())
         {
             body.PixelColliders.Clear();
             body.PixelColliders.AddRange(pixelColliders);
             body.CollideWithOthers = true;
         }
         else
         {
             body.PixelColliders.Clear();
             body.PixelColliders.Add(new PixelCollider
             {
                 ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                 CollisionLayer         = CollisionLayer.EnemyBlocker,
                 IsTrigger = false,
                 BagleUseFirstFrameOnly = false,
                 SpecifyBagelFrame      = string.Empty,
                 BagelColliderNumber    = 0,
                 ManualOffsetX          = specBodyOffsets.x,
                 ManualOffsetY          = specBodyOffsets.y,
                 ManualWidth            = specBodyDimensions.x,
                 ManualHeight           = specBodyDimensions.y,
                 ManualDiameter         = 0,
                 ManualLeftX            = 0,
                 ManualLeftY            = 0,
                 ManualRightX           = 0,
                 ManualRightY           = 0,
             });
             body.CollideWithOthers = false;
         }
         body.CollideWithTileMap = false;
     }
     if (projectile == null)
     {
         projectile         = ((Gun)ETGMod.Databases.Items[56]).DefaultModule.projectiles[0];
         projectile.Owner   = owner;
         projectile.Shooter = owner.specRigidbody;
     }
 }
Ejemplo n.º 3
0
 private void ResetOrbitals(PlayerController player)
 {
     if (player.orbitals != null && player.orbitals.Count > 0)
     {
         foreach (var o in Owner.orbitals)
         {
             var orbital = (PlayerOrbital)o;
             if (orbital.gameObject.GetComponent <BoostedByAlbedo>() != null)
             {
                 orbital.orbitDegreesPerSecond /= orbital.gameObject.GetComponent <BoostedByAlbedo>().currentMultiplier;
                 orbital.SetOrbitalTier(PlayerOrbital.CalculateTargetTier(player, o));
                 orbital.SetOrbitalTierIndex(PlayerOrbital.GetNumberOfOrbitalsInTier(player, orbital.gameObject.GetComponent <BoostedByAlbedo>().storedOrbitalTier));
                 UnityEngine.Object.Destroy(orbital.gameObject.GetComponent <BoostedByAlbedo>());
             }
         }
         RecalcOrbIndex();
     }
 }