Beispiel #1
0
    public void IntegrateNewBlock(TempleWallBlock newBlock, WallBlockType blockType, WallBlockPosition wallPos)
    {
        Transform oldBlockTransform = GetBlockTransform(wallPos);

        CodeTools.CopyTransform(oldBlockTransform, newBlock.transform, true, true, false);

        DisableBlock(wallPos);

        AssignBlockToPosition(newBlock, wallPos);
    }
Beispiel #2
0
    protected virtual void StartEmerging()
    {
        blockState    = WallBlockState.Emerging;
        nextStateTime = Time.time + GameplayManager.blockEmergeDuration;

        // EmergeFX are assumed to be on&animating by default when they spawn
        GameObject fx = (GameObject)Instantiate(emergeFXPrefab) as GameObject;

        CodeTools.CopyTransform(transform, fx.transform, true, true, false);
        fx.transform.parent = transform;
        Destroy(fx, (GameplayManager.blockEmergeDuration + 2f));

        AudioSource audio = GetComponent <AudioSource>();

        if ((emergeSFX != null) && (audio != null))
        {
            audio.clip = emergeSFX;
            audio.PlayOneShot(emergeSFX, 0.3f);
        }
    }
Beispiel #3
0
    // change the Player root object's position and rotation
    // change the playerCollider's scale (and only change that scale, no other scales)
    private void UpdateCollider()
    {
        // copy them over, but we're going to modify them from there
        CodeTools.CopyTransform(hmd, transform, true, true, false);

        // used for both y position and y scale
        float top = hmd.position.y + playerHeightOffset;

        transform.position = new Vector3(transform.position.x, (top / 2f), transform.position.z);
        playerCollider.transform.localScale = new Vector3(playerCollider.transform.localScale.x, top, playerCollider.transform.localScale.z);

        // don't rotate around X or Z, only Y
        Quaternion rotQ = transform.rotation;
        Vector3    rotE = rotQ.eulerAngles;

        rotE.x             = 0;
        rotE.z             = 0;
        transform.rotation = Quaternion.Euler(rotE.x, rotE.y, rotE.z);

        // move player Eyes to be the height of the hmd
        playerEyes.transform.position = new Vector3(transform.position.x, hmd.position.y, transform.position.z);
    }
Beispiel #4
0
    // called by external scripts to select a procedural config for this container
    // TODO - this whole thing is garbage and needs to be rewritten, maybe when i know more about what GameplayManager wants to do
    public void InitializeContainerConfiguration()
    {
        // figure out which objectSpots we're going to use
        List <int> indices = CodeTools.MultipleWeightedRandomSelections(spots_randWeights, numSpotsToFill, false);

        if (indices.Count == 0)
        {
            return;
        }

        int usedByGoalObject = -1;

        if (gameplayManager.readyForInsertion != null)
        {
            usedByGoalObject = GetIndexForGoalObject();
            CodeTools.CopyTransform(objectSpots[usedByGoalObject].transform, gameplayManager.readyForInsertion.transform, true, true, false);
//            Debug.Log(gameplayManager.readyForInsertion + " teleported to newly-emerging alcove.");
            gameplayManager.readyForInsertion = null;
        }

        // spawn treasures at each of those spots
        foreach (int index in indices)
        {
            if (index != usedByGoalObject)  // if a goal object has been placed in this slot, then skip it
            {
                GameObject    spot = objectSpots[index].gameObject;
                TreasureTable tt   = CodeTools.GetComponentFromNearestAncestor <TreasureTable>(spot);
                if (tt == null)
                {
                    Debug.LogError("No TreasureTable found on " + spot + " nor any of its ancestors.");
                }

                // pick a treasure that fits in the chosen spot
                // TODO - this logic should go more like:  there's a method that finds an unused spot this treasure will fit and puts it there.  iterating over treasures, not spots.

                GameObject treasurePrefab = null;
                bool       itFitsHere     = false;
                int        tries          = 0;
                GameObject newTreasure    = null;

                while ((!itFitsHere) && (tries < 20))  // TODO - this is an unacceptable amount of sweeptests for performance
                {
                    tries++;

                    treasurePrefab = tt.GetRandomTreasure();
                    newTreasure    = (GameObject)Instantiate(treasurePrefab) as GameObject;
                    CodeTools.CopyTransform(spot.transform, newTreasure.transform, false, true, false);  // rotate the object to match the spot

                    itFitsHere = CodeTools.TestForCollision(newTreasure, spot.transform.position);

                    if (itFitsHere)
                    {
                        Debug.Log(newTreasure + " fits without collision at " + spot.transform.position);
                        if (spot.transform.position == Vector3.zero)
                        {
                            Debug.Log("Why is it zero?");
                        }
                    }
                    else
                    {
                        Debug.Log(newTreasure + " does not fit at " + spot.transform.position);
                        DestroyImmediate(newTreasure);  // TODO - needless to say this is terrible
                    }
                }

                if (itFitsHere)
                {
                    // now you can teleport it there
                    CodeTools.CopyTransform(spot.transform, newTreasure.transform, true, true, false);
                    newTreasure.transform.parent = (environment.propsFolder != null) ? environment.propsFolder.transform : null;
                }
                else
                {
                    Debug.LogError("Couldn't find any treasures that will fit in spot " + spot.gameObject + " which is at " + spot.transform.position);
                }
            }
        }
    }