Пример #1
0
 // Update is called once per frame
 override public bool Update()
 {
     if (phase == 0)
     {
         sfControl = OverworldController.Partner.GetComponent <SpriteFlipper>();
         rotated   = sfControl.rotated;
         OverworldController.Partner.GetComponent <PartnerBaseScript>().exitSpin = true;
         phase += 1;
     }
     if (phase == 1)
     {
         if (sfControl.rotated == 90)
         {
             OverworldController.SwapPartner(partner_id);
             sfControl = OverworldController.Partner.GetComponent <SpriteFlipper>();
             sfControl.setSpecificGoalInstant(90);
             if (rotated > 90)
             {
                 sfControl.setFacingLeft();
             }
             else
             {
                 sfControl.setFacingRight();
             }
             sfControl.ForceUpdate();
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
    private void Awake()
    {
        Manager.instance.StateController.OnGameStateChanged += GameStateChanged;
        //camera = transform.GetChild(0).gameObject;
        settings = SettingsLoader.Instance.CurrentSettings;

        overworldController = GameObject.FindGameObjectWithTag("Player").GetComponent <OverworldController>();
    }
Пример #3
0
    public void SwitchPartner(int partner_id)
    {
        SwitchPartner sp = ScriptableObject.CreateInstance <SwitchPartner>();

        sp.partner_id = partner_id;
        CutsceneController.addCutsceneEvent(sp, gameObject, true, GameDataTracker.cutsceneModeOptions.Mobile);
        OverworldController.ChangePauseState();
    }
Пример #4
0
 void Awake()
 {
     if (control == null)
     {
         control = this;
     }
     else if (control != this)
     {
         Destroy(gameObject);
     }
 }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         GameManager.Instance.SetSelectingLevelState();
     }
     else
     {
         Debug.LogWarning("Only one overworld controller should be in the scene!");
     }
 }
 private void Start()
 {
     #region Testing
     doesPlayerHaveControl = false;
     isInCombat            = false;
     isInDigitalWorld      = false;
     currentFile           = GameDataFile.Aplha;
     GameData.Instance.InitializeGameData();
     overworldPlayer = GameObject.FindGameObjectWithTag("Overworld_Controller").GetComponent <OverworldController>();
     inputState      = InputStates.Overworld;
     #endregion
 }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        if (!instance)
        {
            instance         = this;
            currentSceneName = SceneManager.GetActiveScene().name;
        }

        _playerReference = GameObject.FindGameObjectWithTag("Player");
        Debug.Assert(_playerReference, "The player should be tagged as 'Player'");
        _cameraReference = GameObject.FindGameObjectWithTag("MainCamera");
        Debug.Assert(_playerReference, "Need a Main Camera to reference in Overworld Controller");
        _bgmSource = GetComponent <AudioSource>();
        _bgmSource.Play();
    }
Пример #8
0
    void SetOverWorldActive(Scene scene, LoadSceneMode mode)
    {
        overworldScene = scene;
        SceneManager.SetActiveScene(overworldScene);
        SceneManager.sceneLoaded -= SetOverWorldActive;

        UIController.Instance.gameObject.SetActive(false);

        cam = Camera.main;
        overworldController = cam.GetComponent <OverworldController>();
        overworldController.ClearWorld();
        overworldController.SendToBottom();
        overworldController.HideThermometer();
        overworldController.HideNavBar();
        // StartCoroutine(SlideUp());
    }
Пример #9
0
 void Start()
 {
     overworldController = GetComponent <OverworldController>();
     //get the rigidbody component
     rb = GetComponent <Rigidbody2D>();
     //create a ground state class
     groundState = new GroundState(transform.gameObject, jumpLayer);
     //turn the sprite to face the player in the chosen direction
     if (!charFacingLeft)
     {
         transform.localRotation = Quaternion.Euler(0, 180, 0);
     }
     //update the sprite direction control bool
     spriteFacingLeft = charFacingLeft;
     upToEnter        = GameObject.Find("Up To Enter");
     upToEnter.SetActive(false);
 }
Пример #10
0
 private void Awake()
 {
     Instance = this;
 }
Пример #11
0
 void Start()
 {
     m_Controller = GameObject.Find("Controller").GetComponent<OverworldController>();
 }
Пример #12
0
    // Use this for initialization
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        Get = this;
    }
    // Update is called once per frame
    void Update()
    {
        bool  movingDown = false;
        float yDelta     = transform.position.y - prevY;

        if (yDelta < 0)
        {
            movingDown = true;
        }
        prevY = transform.position.y;
        if (GameDataTracker.cutsceneMode != GameDataTracker.cutsceneModeOptions.Cutscene)
        {
            NavMeshAgent agent = GetComponent <NavMeshAgent>();
            agent.enabled = false;
        }
        //Check if grounded--------------------
        //Check at two different spots to make sure.
        bool       hitGround = false;
        RaycastHit hit;
        GameObject bestObject    = null;
        Vector3    hitPoint      = Vector3.zero;
        float      bestHitHeight = 0;
        float      closestCast   = 10000.0f;

        float next_jump;

        //Update jump and check if you will collide.
        if (controls.OverworldControls.MainAction.phase == UnityEngine.InputSystem.InputActionPhase.Performed)
        {
            next_jump = jump + (gravity * Time.deltaTime);
        }
        else
        {
            next_jump = jump + (gravity * 2.5f * Time.deltaTime);
        }
        float maxPossibleVerticleDistance = 0.05f + maxStepSize + Time.deltaTime * Mathf.Abs(next_jump);

        //Rotation
        Quaternion rayRotation = Quaternion.AngleAxis(OverworldController.CameraHeading, Vector3.up);

        //GroundScan
        for (int i = 0; i < scanWidthCount; i++)
        {
            for (int j = 0; j < scanLengthCount; j++)
            {
                Vector3 rayOrgin = transform.position + rayRotation * new Vector3(-width / 2f + i * scanWidthSize, -full_height / 2f + maxStepSize, -length / 2f + j * scanLengthSize);
                if (Physics.Raycast(rayOrgin, Vector3.down, out hit, maxPossibleVerticleDistance, ~ignoreLayer))
                {
                    Debug.DrawRay(rayOrgin, Vector3.down * maxPossibleVerticleDistance, Color.green);
                    int layer = hit.collider.gameObject.layer;
                    if (layer == 6)
                    {
                        if (checkAppearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    //7 is the disappear layer.
                    if (layer == 7)
                    {
                        if (checkDisapearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    if ((closestCast > hit.distance) && (hit.distance > 0))
                    {
                        closestCast   = hit.distance;
                        bestHitHeight = hit.point.y;
                        bestObject    = hit.collider.gameObject;
                        hitPoint      = hit.point;
                    }
                }
            }
        }
        Debug.DrawRay(hitPoint, new Vector3(0, width / 2f, 0), Color.red);
        if (closestCast <= maxPossibleVerticleDistance)
        {
            hitGround = true;
        }
        //UPDATE FALL------------------------------
        if (hitGround == true)
        {
            spriteAnimate.SetTrigger("Land");
            if (movingDown && transform.parent == null)
            {
                groundPlayerRaycast(bestHitHeight);
                jumped     = false;
                jump       = 0;
                lastground = transform.position;
                if (bestObject.tag == "MovingObject")
                {
                    transform.parent = bestObject.transform;
                }
            }
            if (controls.OverworldControls.SecondaryAction.triggered)
            {
                hitDirection = controls.OverworldControls.Movement.ReadValue <Vector2>();
                spriteAnimate.SetTrigger("StickHit");
                StartCoroutine(HitWithStick(hitDirection));
            }
            if (jump == 0)
            {
                if (closestCast < maxStepSize && transform.parent == null)
                {
                    groundPlayerRaycast(bestHitHeight);
                }
                OverworldController.updateTrackingCameraY(transform.position.y);
            }
        }
        else
        {
            jump             = next_jump;
            transform.parent = null;
            spriteAnimate.SetTrigger("Jump");
        }
        //JUMP---------------------------------
        if (GameDataTracker.cutsceneMode == GameDataTracker.cutsceneModeOptions.Mobile && GameDataTracker.dialogueReady == false)
        {
            if (jumped == false)
            {
                if (controls.OverworldControls.MainAction.triggered)
                {
                    jump   = jumpForce;
                    jumped = true;
                }
            }
        }
        //MOVEMENT START---------------------------------------------------------------------------------
        if (!movementLock)
        {
            if (GameDataTracker.cutsceneMode != GameDataTracker.cutsceneModeOptions.Cutscene && !GameDataTracker.stickActive && !GameDataTracker.paintgunActive)
            {
                Vector2 stickPosition = controls.OverworldControls.Movement.ReadValue <Vector2>();
                moveHorizontal = stickPosition[0];
                moveVertical   = stickPosition[1];
            }
            else
            {
                moveHorizontal = 0;
                moveVertical   = 0;
            }
        }
        if (moveHorizontal != 0 || moveVertical != 0)
        {
            lastNonZeroDirection = new Vector2(moveHorizontal, moveVertical);
        }
        Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);

        movement = movement * Time.deltaTime * speed;

        closestCast = 10000.0f;
        for (int i = 0; i < scanWidthCount; i++)
        {
            for (int j = 0; j < scanHeightCount; j++)
            {
                Vector3 rayOrgin = transform.position + rayRotation * new Vector3(-width / 2f + i * scanWidthSize, -full_height / 2f + maxStepSize + j * scanHeightSize, 0);
                if (Physics.Raycast(rayOrgin, rayRotation * new Vector3(0, 0, movement.z), out hit, 2f, ~ignoreLayer))
                {
                    Debug.DrawRay(rayOrgin, rayRotation * new Vector3(0, 0, movement.z) * 10f, Color.red);
                    int layer = hit.collider.gameObject.layer;
                    //8 is the appear layer.
                    if (layer == 6)
                    {
                        if (checkAppearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    //7 is the disappear layer.
                    if (layer == 7)
                    {
                        if (checkDisapearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    if ((closestCast > hit.distance) && (hit.distance > 0))
                    {
                        closestCast = hit.distance;
                    }
                }
            }
        }

        if (closestCast < 0.3)
        {
            movement.z = 0;
        }
        closestCast = 10000.0f;
        for (int j = 0; j < scanHeightCount; j++)
        {
            for (int k = 0; k < scanLengthCount; k++)
            {
                Vector3 rayOrgin = transform.position + rayRotation * new Vector3(0, -full_height / 2f + maxStepSize + j * scanHeightSize, -length / 2f + k * scanLengthSize);
                if (Physics.Raycast(rayOrgin, rayRotation * new Vector3(movement.x, 0, 0), out hit, 2f, ~ignoreLayer))
                {
                    Debug.DrawRay(rayOrgin, rayRotation * new Vector3(movement.x, 0, 0) * 10f, Color.red);
                    int layer = hit.collider.gameObject.layer;
                    //8 is the appear layer.
                    if (layer == 6)
                    {
                        if (checkAppearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    //7 is the disappear layer.
                    if (layer == 7)
                    {
                        if (checkDisapearTorches(hit.point))
                        {
                            continue;
                        }
                    }
                    if ((closestCast > hit.distance) && (hit.distance > 0))
                    {
                        closestCast = hit.distance;
                    }
                }
            }
        }

        if (closestCast < 0.5)
        {
            movement.x = 0;
        }

        movement += new Vector3(0, jump * Time.deltaTime, 0);
        transform.Translate(movement);

        if ((moveVertical != 0) || (moveHorizontal != 0))
        {
            spriteAnimate.SetTrigger("Go");
        }
        else
        {
            spriteAnimate.SetTrigger("Stop");
        }
        //MOVEMENT END---------------------------------------------------------------------------------

        //SetRotationGoals=================================================================================
        if ((moveHorizontal > 0))
        {
            spriteFlipper.setFacingRight();
        }
        if ((moveHorizontal < 0))
        {
            spriteFlipper.setFacingLeft();
        }

        /*
         */
    }