コード例 #1
0
ファイル: ExampleSpawner.cs プロジェクト: VidarVigg/GodVr
    public override void Grab(Controller123 controller, Rigidbody attach)
    {
        GameObject gameobject = Object2.Instantiate(gamePrefab);

        switch (selectObjectToSpawn)
        {
        case Thing.Rock:
            gameobject.GetComponent <Rock>().Grab(controller, attach);
            break;

        case Thing.Tree:
            gameobject.GetComponent <Treee>().Grab(controller, attach);
            break;

        case Thing.House:
            gameobject.GetComponent <HousingMaster>().Grab(controller, attach);
            break;

        case Thing.ConstructionFrame:
            gameobject.GetComponent <ConstructionFrame>().Grab(controller, attach);
            break;

        default:
            break;
        }
    }
コード例 #2
0
ファイル: Treee.cs プロジェクト: VidarVigg/GodVr
    protected override void OnTriggerEnter(Collider collider)
    {
        activateDestroyTimer = true;
        if (rigi.velocity.sqrMagnitude >= 0.05)
        {
            if (collider.gameObject.layer == 10)
            {
                if (treeeConfig.ParticleSystem)
                {
                    var obj = Object2.Instantiate <GameObject>(treeeConfig.ParticleSystem, collider.transform, true);
                    obj.transform.SetParent(null);
                    obj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                    obj.SetActive(true);
                    //ServiceLocator.TestAudioMasterService.PlayOneShot(AudioType.SFXEnemyImpact, treeeConfig.AudioSource);
                    Destroy(obj, 2f);
                    Destroy(gameObject);
                }
            }
            //treeeConfig.ParticleSystem.Play();
            //Debug.Log(collider.gameObject);

            //Debug.Log("tree was moving");
            //if (collider.gameObject.layer == 10)
            //{
            //    Debug.Log("Enemy");
            //    treeeConfig.ParticleSystem.Play();
            //    Destroy(gameObject, 1f);
            //}
        }
    }
コード例 #3
0
 public void DestroyHouse()
 {
     if (joint == null)
     {
         if (!structureData.Triggered)
         {
             structureData.Triggered = true;
             GameObject clone = Object2.Instantiate(structureConfig.DestroyFX, transform.position, Quaternion.identity);
             Destroy(clone, 2);
             Destroy(gameObject);
             //ServiceLocator.SessionMasterService.Population -= structureConfig.PopulationValue;
         }
     }
 }
コード例 #4
0
ファイル: Rock.cs プロジェクト: VidarVigg/GodVr
    protected override void OnCollisionEnter(Collision collision)
    {
        base.OnCollisionEnter(collision);
        activateDestroyTimer = true;
        //Debug.Log("Activate DestroyTimer");

        if (rigi.velocity.sqrMagnitude >= vfxSpawnThreshold)
        {
            if (particleSystem)
            {
                var obj = Object2.Instantiate <GameObject>(particleSystem, collision.GetContact(0).point, Quaternion.identity, null);
                Destroy(obj, 1.0f);
            }
        }
    }
コード例 #5
0
 public override void Grab(Controller123 controller, Rigidbody attach)
 {
     if (isGrabbable)
     {
         Regrow();
         pineParticles.Play();
         //base.Grab(attach);
         GameObject gameobject = Object2.Instantiate(treePrefab);
         gameobject.GetComponent <Treee>().Grab(controller, attach);
     }
     else
     {
         //Debug.Log("Tree is not ready yet");
     }
 }
コード例 #6
0
ファイル: ConstructionFrame.cs プロジェクト: VidarVigg/GodVr
    private void FinishConstruction()
    {
        gameObject.SetActive(false);
        var house = Object2.Instantiate <GameObject>(actualHousePrefab, transform.position, Quaternion.identity);
        var vfx   = Object2.Instantiate <GameObject>(VFX_Finish, transform.position, Quaternion.identity);

        house.transform.localScale    = transform.localScale;
        house.transform.localRotation = transform.localRotation;
        house.GetComponent <Rigidbody>().isKinematic = true;
        ServiceLocator.TestAudioMasterService.PlayOneShot(AudioType.SFXHouseDone, house.GetComponent <AudioSource>());
        Destroy(vfx, 1.1f);
        Destroy(gameObject, 0.0f);

        //TODO: Implement Place() after the house has been instantiated
        //Update: Place doesn't do anything besides removing it from your hand?
        //So maybe use this?
        //house.GetComponent<Rigidbody>().isKinematic = true;
        //Remember to disable kinematics when throwing/releasing it later on
    }
コード例 #7
0
ファイル: ConstructionFrame.cs プロジェクト: VidarVigg/GodVr
    protected override void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == 8) //Terrain
        {
            var rotation = transform.rotation;

            RaycastHit hitInfo;
            LayerMask  mask = LayerMask.GetMask("Terrain");
            Physics.Raycast(transform.position + Vector3.up, Vector3.down, out hitInfo, 100.0f, mask);

            var vfx = Object2.Instantiate <GameObject>(VFX_Place, transform.position, Quaternion.identity);
            Destroy(vfx, 1.1f);

            rigi.isKinematic = true;

            transform.position = hitInfo.point;
            var localYRotation = rotation.eulerAngles.y;
            rotation.eulerAngles = (new Vector3(0.0f, localYRotation, 0.0f));
            transform.rotation   = rotation;
        }

        if (collision.collider.name == "Tree_05_Downscaled_LOD")
        {
            if (resourceCurrent < resourceRequired)
            {
                InteractableWorldObject worldObject = collision.gameObject.GetComponent <InteractableWorldObject>();
                if (worldObject)
                {
                    if (worldObject.joint)
                    {
                        worldObject.Drop();
                    }
                }

                Destroy(collision.gameObject);
                IncreaseBuildingProgression();
            }
        }
    }
コード例 #8
0
    private void Spawn(SpawnStruct[] spawnStruct)
    {
        int rand = UnityEngine.Random.Range(0, enemySpawnerConfig.SpawnPoints.Length);

        enemySpawnerConfig.WaveAmt++;

        if (enemySpawnerConfig.WaveAmt <= enemySpawnerConfig.HowManyWavesAreAllowed)
        {
            for (int i = 0; i < spawnStruct.Length; i++)
            {
                for (int j = 0; j < spawnStruct[i].rows; j++)
                {
                    for (int k = 0; k < spawnStruct[i].columns; k++)
                    {
                        enemySpawnerConfig.EnemyClone = Object2.Instantiate(enemySpawnerConfig.EnemyPrefab,
                                                                            enemySpawnerConfig.SpawnPoints[rand].position + (new Vector3((float)k / 2, 0, (float)j / 2)),
                                                                            Quaternion.identity);

                        enemySpawnerData.LastWave = spawnStruct[i].rows * spawnStruct[i].columns;
                    }
                }
            }
        }
    }
コード例 #9
0
ファイル: ProgramController.cs プロジェクト: VidarVigg/GodVr
 public WorldObject Spawn(WorldObject worldObject)
 {
     return(Object2.Instantiate(worldObject));
 }