Inheritance: MonoBehaviour
Example #1
0
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Edge"))
        {
            status.atEdge = false;
        }

        if (other.CompareTag("LadderArea"))
        {
            status.onLadder = false;


            ladder = other.gameObject.GetComponentInParent <LadderScript>();

            ladder.iconOff();
        }

        if (other.CompareTag("DoorAreaOut"))
        {
            status.inFrontOfDoorOutside = false;

            door = other.gameObject.GetComponentInParent <Door>();

            door.iconOutOff();
        }

        if (other.CompareTag("DoorAreaIn"))
        {
            status.inFrontOfDoorInside = false;

            door = other.gameObject.GetComponentInParent <Door>();

            door.iconInOff();
        }
    }
Example #2
0
    private IEnumerator InteractWithLadder()
    {
        LadderScript ladderScript = _ladder.GetComponent <LadderScript>();

        //animaitons
        _animationsController.ClimbBottomLadderIK.LadderIKHands = ladderScript.BottomLadderIKHands;
        _animationsController.ClimbTopLadderPart1IK.Ladder      = ladderScript;
        _animationsController.ClimbTopLadderPart2IK.SetBehaviour(_enemyBehaviour, _enemyMotor, _animationsController);

        //physics
        _enemyMotor.UpdateTransformToNavmesh = false;
        _enemyMotor.RigidBody.isKinematic    = false;
        _enemyMotor.RigidBody.useGravity     = false;

        while (ladderScript.IsPersonClimbing)
        {
            yield return(null);
        }

        _isClimbing = true;
        _enemyBehaviour.HolsterGun();
        ladderScript.IsPersonClimbing    = true;
        _enemyBehaviour.gameObject.layer = LayerMask.NameToLayer("NoCollisionWithEnemy");
        _climbLadder = _enemyBehaviour.StartCoroutine(RotateToLadder());
    }
Example #3
0
 public void LadderInteraction(LadderScript ladder)
 {
     if (!ladder.IsPersonClimbing)
     {
         _playerController.SwitchState <ClimbingState>(ladder);
     }
 }
Example #4
0
    public override void Initialize()
    {
        base.Initialize();
        cam    = CameraScript.Instance;
        ladder = LadderScript.Instance;
        player = PlayerController.Instance;
        boss   = BossScript.Instance;

        cam.transform.position    = new Vector3(0.0f, 0.0f, -10.0f);
        player.transform.position = new Vector3(-7.611201f, -6.845f, 0.0f);

        started     = false;
        cam.rising  = false;
        isDead      = false;
        bossStarted = false;
        ladder.Initialize(cam.deathBox.transform.position);
        lives             = 3;
        player.isAlone    = false;
        player.canControl = true;
        player.autoMove   = false;
        cam.FadeClear(1.0f);
        GameEngine.Instance.invisibleWall.SetActive(true);

        source = Camera.main.GetComponent <AudioSource>();
    }
    public override void ResetState(IInteractable ladder)
    {
        _ladderScript = (LadderScript)ladder;

        _animationsController.ClimbBottomLadderIK.LadderIKHands = _ladderScript.BottomLadderIKHands;
        _animationsController.ClimbTopLadderPart1IK.Ladder      = _ladderScript;
        _animationsController.ClimbTopLadderPart2IK.SetBehaviour(_playerController, _physicsController, _animationsController);
    }
Example #6
0
 public void LadderInteraction(LadderScript ladder)
 {
     if (GetGunInHolster() == null)
     {
         if (!ladder.IsPersonClimbing)
         {
             HolsterGun();
             _playerController.SwitchState <ClimbingState>(ladder);
         }
     }
 }
Example #7
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Edge"))
        {
            status.atEdge = true;

            edgeEnterBehaviour();
        }

        if (other.CompareTag("LadderArea"))
        {
            status.onLadder = true;



            ladder = other.gameObject.GetComponentInParent <LadderScript>();

            ladder.iconOn(this.transform.position.y + 1.5F);
        }

        if (other.CompareTag("DoorAreaOut"))
        {
            status.inFrontOfDoorOutside = true;

            door = other.gameObject.GetComponentInParent <Door>();

            status.setDoor(door);

            door.iconOutOn(this.transform.position.y + 1.5F);
        }

        if (other.CompareTag("DoorAreaIn"))
        {
            status.inFrontOfDoorInside = true;

            door = other.gameObject.GetComponentInParent <Door>();

            status.setDoor(door);

            door.iconInOn(this.transform.position.y + 1.5F);
        }

        if (other.CompareTag("WinZone"))
        {
            win.SetActive(true);
        }
    }
Example #8
0
        public override void Enter()
        {
            ladder = player.currentLadder.GetComponent <LadderScript>();

            player.movementAditionAction += player.SetHorizontalMovement;
            player.movementAditionAction += SetVerticalMovement;

            player.rigidbody.gravityScale = 0;

            foreach (var groundCollider in GroundColliders)
            {
                Physics2D.IgnoreCollision(player.collider, groundCollider, true);
            }

            player.animator.SetTrigger(Climb);

            player.flashLight.SetActive(false);

            var playerPosition = player.transform.position;

            playerPosition.x          = player.currentLadder.transform.position.x;
            player.transform.position = playerPosition;
        }
Example #9
0
 void Awake()
 {
     instance = this;
     list     = new List <Ladder>(ladder_count);
 }
Example #10
0
 public void ResetAction(Transform actionTrigger)
 {
     _ladder       = actionTrigger;
     _ladderScript = _ladder.GetComponent <LadderScript>();
 }
    void animateLight()
    {
        t += lightspeed * Time.deltaTime;
        if (t > 1f)
        {
            t = 1f;
            if (toAddOn > 0)
            {
                currentSquareId++;
                toAddOn--;
                if (currentSquareId > 99)
                {
                    currentSquareId = 99;
                    toAddOn         = 0;
                }
                lightOldPos = PlayerBox.transform.localPosition;
                lightNewPos = PlayerBox.transform.parent.InverseTransformPoint(SquareBox[currentSquareId].transform.position);
                t           = 0f;
            }
            else
            {
                if (beenOn.Contains(currentSquareId))
                {
                    moveXSquares();
                    return;
                }
                for (int i = 0; i < ladders.Length; i++)
                {
                    if (!showLadders.Contains(i))
                    {
                        continue;
                    }
                    LadderScript ls = ladders[i].GetComponent <LadderScript>();
                    if (ls.start == currentSquareId + 1)
                    {
                        int rando = Random.Range(0, 3);
                        if (rando == 0)
                        {
                            BombAudio.PlaySoundAtTransform("ladder1", SquareBox[currentSquareId].transform);
                        }
                        else if (rando == 1)
                        {
                            BombAudio.PlaySoundAtTransform("ladder2", SquareBox[currentSquareId].transform);
                        }
                        else if (rando == 2)
                        {
                            BombAudio.PlaySoundAtTransform("ladder3", SquareBox[currentSquareId].transform);
                        }
                        currentSquareId = ls.end - 1;
                        lightOldPos     = PlayerBox.transform.localPosition;
                        lightNewPos     = PlayerBox.transform.parent.InverseTransformPoint(SquareBox[currentSquareId].transform.position);
                        t = 0f;
                        animateLight();
                        return;
                    }
                }
                for (int i = 0; i < snakes.Length; i++)
                {
                    if (!showSnakes.Contains(i))
                    {
                        continue;
                    }
                    SnakeScript ss = snakes[i].GetComponent <SnakeScript>();
                    if (ss.start == currentSquareId + 1)
                    {
                        int rando = Random.Range(0, 3);
                        if (rando == 0)
                        {
                            BombAudio.PlaySoundAtTransform("snake1", SquareBox[ss.end - 1].transform);
                        }
                        else if (rando == 1)
                        {
                            BombAudio.PlaySoundAtTransform("snake2", SquareBox[ss.end - 1].transform);
                        }
                        else if (rando == 2)
                        {
                            BombAudio.PlaySoundAtTransform("snake3", SquareBox[ss.end - 1].transform);
                        }
                        currentSquareId = ss.end - 1;
                        lightOldPos     = PlayerBox.transform.localPosition;
                        lightNewPos     = PlayerBox.transform.parent.InverseTransformPoint(SquareBox[currentSquareId].transform.position);
                        t = 0f;
                        animateLight();
                        return;
                    }
                }
                t                  = 1f;
                moveSquare         = false;
                preventModuleUsage = false;
                beenOn.Add(currentSquareId);
                CalculateNextAnswer();
            }
        }
        Vector3 p = lightOldPos;
        Vector3 n = lightNewPos;

        PlayerBox.transform.localPosition = Vector3.Lerp(p, n, t);
    }
Example #12
0
 void Start()
 {
     tooltip.SetActive(false);
     animator   = dancer.GetComponent <Animator>();
     actionable = ladder.GetComponent <LadderScript>();
 }
Example #13
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     _instance = this;
 }
    void animateLight()
    {
        t += 2f * Time.deltaTime;
        if (t > 1f)
        {
            t = 1f;
            if (toAddOn > 0)
            {
                currentSquareId++;
                toAddOn--;
                if (currentSquareId > 99)
                {
                    currentSquareId = 99;
                    toAddOn         = 0;
                }
                lightOldPos = PlayerBox.transform.position;
                lightNewPos = SquareBox[currentSquareId].transform.position;
                t           = 0f;
            }
            else
            {
                if (beenOn.Contains(currentSquareId))
                {
                    moveXSquares();
                    return;
                }
                for (int i = 0; i < ladders.Length; i++)
                {
                    if (!showLadders.Contains(i))
                    {
                        continue;
                    }
                    LadderScript ls = ladders[i].GetComponent <LadderScript>();
                    if (ls.start == currentSquareId + 1)
                    {
                        currentSquareId = ls.end - 1;
                        lightOldPos     = PlayerBox.transform.position;
                        lightNewPos     = SquareBox[currentSquareId].transform.position;
                        t = 0f;
                        animateLight();
                        return;
                    }
                }
                for (int i = 0; i < snakes.Length; i++)
                {
                    if (!showSnakes.Contains(i))
                    {
                        continue;
                    }
                    SnakeScript ss = snakes[i].GetComponent <SnakeScript>();
                    if (ss.start == currentSquareId + 1)
                    {
                        currentSquareId = ss.end - 1;
                        lightOldPos     = PlayerBox.transform.position;
                        lightNewPos     = SquareBox[currentSquareId].transform.position;
                        t = 0f;
                        animateLight();
                        return;
                    }
                }
                t                  = 1f;
                moveSquare         = false;
                preventModuleUsage = false;
                beenOn.Add(currentSquareId);
                CalculateNextAnswer();
            }
        }
        Vector3 p = lightOldPos;
        Vector3 n = lightNewPos;

        PlayerBox.transform.position = new Vector3(Lerp(n.x, p.x, t), Lerp(n.y, p.y, t), Lerp(n.z, p.z, t));
    }