Beispiel #1
0
        protected override void DoEffect(PlayerController user)
        {
            Vector2 position = user.PositionInDistanceFromAimDir(1);
            //Vector2 pos2 = position.GetCenteredLookingPosForObj(TackShooterObject.GetComponent<SpeculativeRigidbody>());
            //LootEngine.DoDefaultItemPoof(position);
            GameObject tackShooter = UnityEngine.Object.Instantiate <GameObject>(TackShooterObject, position, Quaternion.identity);

            tackShooter.GetComponent <tk2dSprite>().PlaceAtLocalPositionByAnchor(position, tk2dBaseSprite.Anchor.MiddleCenter);
            TackShooterBehaviour shooterComp = tackShooter.GetComponent <TackShooterBehaviour>();

            if (shooterComp)
            {
                shooterComp.owner = user;
            }
        }
Beispiel #2
0
        private static GameObject SetupTackShooter()
        {
            //Make Tack
            Projectile projectile = UnityEngine.Object.Instantiate <Projectile>((PickupObjectDatabase.GetById(26) as Gun).DefaultModule.projectiles[0]);

            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            projectile.baseData.damage = 8f;
            projectile.baseData.range  = 5f;
            projectile.hitEffects.overrideMidairDeathVFX = (PickupObjectDatabase.GetById(28) as Gun).DefaultModule.projectiles[0].hitEffects.tileMapVertical.effects[0].effects[0].effect;

            //Setup the Tack Shooter Object
            GameObject prefab = CompanionBuilder.BuildPrefab("Tack Shooter", "Tack_Shooter_GUID", TackShooter.RegTackShooterSprites[0], new IntVector2(6, 2), new IntVector2(7, 14));//SpriteBuilder.SpriteFromResource("Planetside/Resources2/testturret/testturret_idle_001");

            prefab.name = "Tack Shooter";
            var body = prefab.GetComponent <tk2dSprite>().SetUpSpeculativeRigidbody(new IntVector2(6, 2), new IntVector2(7, 14));
            TackShooterBehaviour shooter = prefab.AddComponent <TackShooterBehaviour>();

            shooter.ProjectileToShoot = projectile;


            AIAnimator aiAnimator = prefab.GetOrAddComponent <AIAnimator>();

            aiAnimator.IdleAnimation = new DirectionalAnimation
            {
                Type      = DirectionalAnimation.DirectionType.Single,
                Flipped   = new DirectionalAnimation.FlipType[1],
                Prefix    = "idle",
                AnimNames = new string[]
                { "idle" }
            };

            aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> {
                //Spawn
                new AIAnimator.NamedDirectionalAnimation {
                    name = "appear",
                    anim = new DirectionalAnimation {
                        Prefix    = "appear",
                        Type      = DirectionalAnimation.DirectionType.Single,
                        Flipped   = new DirectionalAnimation.FlipType[1],
                        AnimNames = new string[]
                        { "appear" }
                    }
                },
                //Shoot
                new AIAnimator.NamedDirectionalAnimation {
                    name = "shoot",
                    anim = new DirectionalAnimation {
                        Prefix    = "shoot",
                        Type      = DirectionalAnimation.DirectionType.Single,
                        Flipped   = new DirectionalAnimation.FlipType[1],
                        AnimNames = new string[]
                        { "shoot" }
                    }
                },
            };
            tk2dSpriteAnimator       spriteAnimator        = prefab.GetOrAddComponent <tk2dSpriteAnimator>();
            tk2dSpriteCollectionData tackShooterCollection = SpriteBuilder.ConstructCollection(prefab, "TackShooterCollection");

            UnityEngine.Object.DontDestroyOnLoad(tackShooterCollection);
            for (int i = 0; i < RegTackShooterSprites.Length; i++)
            {
                SpriteBuilder.AddSpriteToCollection(RegTackShooterSprites[i], tackShooterCollection);
            }
            SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> {
                0
            }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 12;
            SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> {
                1, 2
            }, "shoot", tk2dSpriteAnimationClip.WrapMode.Once).fps = 12;
            SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> {
                3, 4, 5, 6, 7
            }, "appear", tk2dSpriteAnimationClip.WrapMode.Once).fps = 12;

            body.PixelColliders.Clear();
            body.PixelColliders.Add(new PixelCollider
            {
                ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual,
                CollisionLayer         = CollisionLayer.PlayerHitBox,
                IsTrigger = false,
                BagleUseFirstFrameOnly = false,
                SpecifyBagelFrame      = string.Empty,
                BagelColliderNumber    = 0,
                ManualOffsetX          = 6,
                ManualOffsetY          = 2,
                ManualWidth            = 7,
                ManualHeight           = 14,
                ManualDiameter         = 0,
                ManualLeftX            = 0,
                ManualLeftY            = 0,
                ManualRightX           = 0,
                ManualRightY           = 0
            });
            body.CollideWithOthers = false;

            prefab.SetActive(false);
            FakePrefab.MarkAsFakePrefab(prefab);
            UnityEngine.Object.DontDestroyOnLoad(prefab);

            return(prefab);
        }