Пример #1
0
 public override void OnTriggerEnter(Collider other)
 {
     base.OnTriggerEnter(other);
     //Debug.Log("In trigger");
     if (other.gameObject.name == "DropPanel" && descendStage == DescendStage.None)
     {
         waitToLowerStartTime = Time.time;
         descendStage         = DescendStage.WaitToLower;
         ((SpiderLevelTen)(levelManager)).ToggleCeilingMaze(false);
     }
 }
Пример #2
0
    public new void Start()
    {
        base.Start();

        paused = false;

        descendLimitY     = descendLimitGO.transform.position.y;
        motionCorrectionY = motionCorrectionBarrierGO.transform.position.y;

        rb          = gameObject.GetComponent <Rigidbody>();
        grabHandler = gameObject.GetComponent <SpiderGrabHandler>();
        silkManager = gameObject.GetComponent <SilkManager>();

        descendStage = DescendStage.None;
        ToggleNonTriggerColliders(false);
    }
Пример #3
0
    public override void Respawn()
    {
        rb.useGravity = false;

        descentStartTime = lowerStartTime = randomPathWaitStartTime = waitToLowerStartTime = dropStartTime = -1;
        descendStage     = DescendStage.None;

        ((SpiderLevelTen)(levelManager)).ToggleCeilingMaze(true);

        SetIdleAnim(true);

        silkManager.DeactivateSilk();
        grabHandler.enabled = false;
        ToggleNonTriggerColliders(false);

        base.Respawn();
    }
Пример #4
0
    public void HandleDescent()
    {
        switch (descendStage)
        {
        case DescendStage.WaitToLower:
            if (Time.time > waitToLowerStartTime + WAIT_TO_LOWER_TIME)
            {
                waitToLowerStartTime = -1;

                silkManager.ActivateSilk();

                lowerStartTime = Time.time;
                descendStage   = DescendStage.LowerFromCeiling;
                SetLowerAnim();
            }
            break;

        case DescendStage.LowerFromCeiling:

            if (Time.time - LOWER_DURATION > lowerStartTime)
            {
                lowerStartTime = -1;

                descentStartTime = Time.time;
                descendStage     = DescendStage.Descend1;
                SetDescendAnim();
            }
            break;

        case DescendStage.Descend1:
            transform.position += new Vector3(0, -DESCEND_SPEED * Time.deltaTime);

            if (Time.time > descentStartTime + TIME_BETWEEN_CHANGING_DESCENT_TYPES)
            {
                descentStartTime = -1;

                preDescendChangeZ         = transform.position.z;
                firstFrameOfDescendChange = true;

                grabHandler.enabled            = true; //TODO why?
                grabHandler.checkForCollisions = false;
                descendStage = DescendStage.Descend2;
                SetDescend2Anim();

                if (Random.Range(0, 2) == 0)
                {
                    //Debug.Log("Random 0");
                    descendDirectionMultiplier = 1;
                }
                else
                {
                    descendDirectionMultiplier = -1;
                    //Debug.Log("Random 1");
                }

                //Descend2 uses the inverted of the descend animation, so flip by 180
                gameObject.transform.Rotate(Vector3.right, 180);

                ToggleNonTriggerColliders(true);
            }
            break;

        case DescendStage.Descend2:
            transform.position += new Vector3(0, -DESCEND_SPEED * Time.deltaTime);

            if (transform.position.y < descendLimitY)
            {
                initialDepth = modelPositionCheckGO.transform.position.z;
                targetHeight = modelPositionCheckGO.transform.position.y;

                grabHandler.ToggleGrabbable(false);
                descendStage = DescendStage.DropToTable;
                SetDropAnim();
                dropStartTime = Time.time;
            }
            else
            {
                gameObject.transform.Rotate(Vector3.down, ROTATE_DURING_DESCENT_SPEED * Time.deltaTime * descendDirectionMultiplier);
            }

            break;

        case DescendStage.DropToTable:

            //Correct the absolute WHACK translations while transitioning to the drop animation
            if (transform.position.y > motionCorrectionY)
            {
                targetHeight -= DESCEND_SPEED * Time.deltaTime;

                float depthDifference  = modelPositionCheckGO.transform.position.z - initialDepth;
                float heightDifference = modelPositionCheckGO.transform.position.y - targetHeight;

                transform.position += new Vector3(0, -heightDifference, -depthDifference);
            }

            //Once we land on the table, switch to random pathing (after a small wait)
            if (Time.time > dropStartTime + DROP_TIME)
            {
                //Debug.Log("WE JUST LEFT DROP");
                randomPathWaitStartTime = Time.time;

                silkManager.FadeSilk();

                grabHandler.enabled = true;
                grabHandler.ToggleGrabbable(true);

                SetIdleAnim();
                descendStage = DescendStage.WaitToPath;
            }
            break;

        case DescendStage.WaitToPath:

            if (Time.time > randomPathWaitStartTime + RANDOM_PATH_WAIT_TIME)
            {
                randomPathWaitStartTime = -1;

                descendStage = DescendStage.None;
                SwitchToRandomPathing();
            }
            break;
        }
    }