コード例 #1
0
        private static GameObject CreateRocketBlockTemp()
        {
            GameObject RocketTemp = new GameObject("Rocket Temp");

            RocketTemp.transform.localScale = new Vector3(1f, 0.75f, 0.75f);

            GameObject vis = new GameObject("Vis");

            vis.transform.SetParent(RocketTemp.transform);
            vis.transform.localPosition         -= RocketTemp.transform.right;
            vis.transform.localScale             = RocketTemp.transform.localScale;
            vis.AddComponent <MeshFilter>().mesh = ModResource.GetMesh("RocketPod_r Mesh");
            vis.AddComponent <MeshRenderer>().material.mainTexture = ModResource.GetTexture("RocketPod_r Texture");

            GameObject collider = new GameObject("Collider");

            collider.transform.SetParent(RocketTemp.transform);
            collider.transform.localScale = RocketTemp.transform.localScale;
            CapsuleCollider capsuleCollider = collider.AddComponent <CapsuleCollider>();

            capsuleCollider.radius    = 0.15f;
            capsuleCollider.height    = 2.5f;
            capsuleCollider.direction = 0;
            capsuleCollider.isTrigger = true;

            Rigidbody rigidbody = RocketTemp.AddComponent <Rigidbody>();

            rigidbody.mass = 0.25f;

            RocketTemp.AddComponent <RocketScript>();
            RocketTemp.AddComponent <DestroyIfEditMode>();
            RocketTemp.SetActive(false);
            return(RocketTemp);
        }
コード例 #2
0
 public static void OnModLoad()
 {
     def = new Color(0.15f, 0.2f, 0.25f);
     FixVacuum();
     bundle                     = ModResource.GetAssetBundle("portal");
     normal                     = ModResource.GetMesh("portalDeviceMesh");
     shooting                   = ModResource.GetMesh("portalDeviceShotMesh");
     bundle.OnLoad             += Load;
     Events.OnSimulationToggle += ResetPortal;
 }
コード例 #3
0
        static IEnumerator ReadWheelMesh()
        {
            WheelColliderOrgin = new GameObject("Wheel Collider Orgin");
            WheelColliderOrgin.transform.SetParent(EnhancementBlockController.Instance.transform);
            ModMesh modMesh = ModResource.CreateMeshResource("Wheel Mesh", "Resources" + @"/" + "Wheel.obj");

            yield return(new WaitUntil(() => modMesh.Available));

            MeshCollider meshCollider = WheelColliderOrgin.AddComponent <MeshCollider>();

            meshCollider.sharedMesh = ModResource.GetMesh("Wheel Mesh");
            meshCollider.convex     = true;
            WheelColliderOrgin.SetActive(false);
        }
コード例 #4
0
        public override void OnPrefabCreation()
        {
            GameObject ActualCollider = new GameObject("ActualCollider");

            ActualCollider.transform.SetParent(transform.FindChild("Colliders"));
            MeshCollider colliderMesh  = ActualCollider.AddComponent <MeshCollider>();
            MeshFilter   colliderMeshF = ActualCollider.AddComponent <MeshFilter>();

            colliderMeshF.mesh                  = ModResource.GetMesh("KeepstarCollider");
            colliderMesh.sharedMesh             = colliderMeshF.mesh;
            colliderMesh.convex                 = false;
            ActualCollider.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

            this.Rigidbody.useGravity = false;
        }
コード例 #5
0
        private GameObject CreateBulletTemp()
        {
            GameObject temp = new GameObject("Bullet Temp");

            temp.AddComponent <DestroyIfEditMode>();

            GameObject vis = new GameObject("Vis");

            vis.transform.SetParent(temp.transform);
            vis.transform.position    = temp.transform.position;
            vis.transform.rotation    = temp.transform.rotation;
            vis.transform.localScale *= 0.025f;

            vis.AddComponent <MeshFilter>().mesh = ModResource.GetMesh("Bullet Mesh");
            MeshRenderer meshRenderer = vis.AddComponent <MeshRenderer>();

            meshRenderer.material.mainTexture = ModResource.GetTexture("Bullet Texture");

            Rigidbody rigidbody = temp.AddComponent <Rigidbody>();

            rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
            rigidbody.mass = 0.5f;
            rigidbody.drag = 0.25f;

            TrailRenderer trailRenderer = temp.AddComponent <TrailRenderer>();

            trailRenderer.startWidth      = 0.08f;
            trailRenderer.endWidth        = 0f;
            trailRenderer.time            = 0.05f;
            trailRenderer.material.shader = Shader.Find("Particles/Additive");
            trailRenderer.material.SetColor("_TintColor", Color.yellow);

            BoxCollider boxCollider = temp.AddComponent <BoxCollider>();

            boxCollider.size = new Vector3(0.1f, 0.1f, 0.25f);
            boxCollider.material.bounciness = 0f;

            BulletScript bulletScript = temp.AddComponent <BulletScript>();

            bulletScript.Direction          = Vector3.forward;
            bulletScript.ColliderEnableTime = 1f;

            TimedSelfDestruct tsd = temp.AddComponent <TimedSelfDestruct>();

            temp.SetActive(false);
            return(temp);
        }
        public override void OnSimulateStart()
        {
            BulletCurrentNumber = BulletMaxNumber = (int)BulletNumberSlider.Value;
            Strength            = StrengthSlider.Value * 120f;
            KnockBack           = KnockBackSlider.Value * Strength * 0.75f;
            Rate = RateSlider.Value;

            var yd = CJ.yDrive;

            yd.positionDamper = 500f * damperSlider.Value * StrengthSlider.Value;
            yd.positionSpring = 3000f * StrengthSlider.Value;
            CJ.yDrive         = yd;

            initBullet();
            initVFX();

            void initBullet()
            {
                BulletObject = new GameObject("Bullet");
                BulletObject.transform.localScale = transform.localScale * 0.05f;
                BulletObject.AddComponent <DestroyIfEditMode>();

                var mf = BulletObject.AddComponent <MeshFilter>();

                mf.mesh = ModResource.GetMesh("Bullet Mesh");

                var mr = BulletObject.AddComponent <MeshRenderer>();

                mr.material.mainTexture = ModResource.GetTexture("Bullet Texture");

                var rigidbody = BulletObject.AddComponent <Rigidbody>();

                rigidbody.mass = bulletMassSlider.Value;
                rigidbody.drag = bulletDragSlider.Value;
                rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;

                var collider = BulletObject.AddComponent <BoxCollider>();

                var tsd = BulletObject.AddComponent <TimedSelfDestruct>();

                var bs = BulletObject.AddComponent <BulletScript>();

                bs.Setup(Strength, bulletCollisionEnableTimeSlider.Value, Direction);

                var tr = BulletObject.AddComponent <TrailRenderer>();

                tr.startWidth = BulletObject.transform.localScale.magnitude * bulletTrailWidthSlider.Value;
                tr.endWidth   = BulletObject.transform.localScale.magnitude * 0.5f * bulletTrailWidthSlider.Value;
                tr.material   = new Material(Shader.Find("Particles/Additive"));
                tr.material.SetColor("_TintColor", bulletColorSlider.Value);
                tr.time = Mathf.Clamp(bulletTrailLengthSlider.Value, 0f, 1f);

                BulletObject.SetActive(false);
            }

            void initVFX()
            {
                EffectsObject = EffectsObject ?? (GameObject)Instantiate(AssetManager.Instance.MachineGun.fireEffect, transform);
                EffectsObject.transform.position         = transform.TransformPoint(SpawnPoint);
                EffectsObject.transform.localEulerAngles = new Vector3(0, 180f, 0);
                EffectsObject.transform.localScale       = Vector3.one * 0.65f;
                EffectsObject.GetComponent <Reactivator>().TimeDelayToReactivate = Rate;
                EffectsObject.SetActive(false);
            }
        }