Beispiel #1
0
        private static Sprite LoadProjectileSprite(MonoBehaviour projectile)
        {
            IModProjectile modProj = (IModProjectile)projectile;
            string         projID  = Lizard.GetID(projectile);

            return(LoadObjectSprite(projectile, projID, "Projectile", modProj.ProjectileImage));
        }
Beispiel #2
0
        public static void OnAwakeProjectile(Projectile projectile)
        {
            IModProjectile modProjectile = projectile as IModProjectile;

            if (modProjectile == null)
            {
                return;
            }

            GameObject projGO = projectile.gameObject;
            Transform  projTr = projGO.transform;

            Animator anim = projGO.AddComponent <Animator>();

            anim.feetPivotActive = 0.0f;
            anim.enabled         = modProjectile.Metadata.usesAnimator;

            Rigidbody2D rigidbody = projGO.AddComponent <Rigidbody2D>();

            rigidbody.angularDrag            = 0.0f;
            rigidbody.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
            rigidbody.constraints            = RigidbodyConstraints2D.FreezeRotation;
            rigidbody.freezeRotation         = modProjectile.Metadata.fixedRotation;
            rigidbody.gravityScale           = 0.0f;
            rigidbody.sleepMode = RigidbodySleepMode2D.NeverSleep;

            string         projId         = Lizard.GetID(projectile.GetType());
            SpriteRenderer spriteRenderer = Lizard.CreateProjectileSprite(projId, projTr, modProjectile.Metadata);

            Lizard.CreateAttackBox(projTr, modProjectile.Metadata.attackBoxShape);

            if (modProjectile.Metadata.collidesWithWalls)
            {
                Lizard.CreateWallCollider(projTr, modProjectile.Metadata.wallColliderShape);
            }
        }