Exemple #1
0
    public void LoadnextLevel()
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        int nextSceneIndex    = currentSceneIndex + 1;

        SceneManager.LoadScene(nextSceneIndex);
        ship = shipStatus.started;
    }
Exemple #2
0
    public void spawnActiveShip()
    {
        GameObject test       = GameObject.Find("ShipSelector");
        GameObject spawnPoint = GameObject.Find("SpawnPoint");

        Ship = test.GetComponent <ShipSelector>().activeShip;
        Instantiate(Ship, spawnPoint.transform);
        ship = shipStatus.notStarted;
    }
    private void Start()
    {
        _sm = GameObject.Find("SessionManager").GetComponent <SessionManager>();
        currentShipStatus = shipStatus.Waiting;
        StartCoroutine(RandomTimeArrival());

        red    = Resources.Load("LedRed", typeof(Material)) as Material;
        blue   = Resources.Load("LedBlue", typeof(Material)) as Material;
        yellow = Resources.Load("LedYellow", typeof(Material)) as Material;
        black  = Resources.Load("LedBlack", typeof(Material)) as Material;
    }
    // Update is called once per frame
    void Update()
    {
        //checkShipsOut = shipSpawn.shipsOut;
        RaycastHit hit;

        //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.up * -1) * 50, Color.red);

        //if (Physics.Raycast(this.transform.position, this.transform.up * -1, out hit, .5f) && currentShipStatus != shipStatus.headHome)

        if (Physics.SphereCast(this.transform.position, 0.3f, this.transform.up * -1, out hit, .3f) && currentShipStatus != shipStatus.headHome)
        {
            //Debug.Log(this.gameObject.name + " DETECT WALL");
            if (hit.collider.gameObject.tag == "Wall" ^ hit.collider.gameObject.tag == "WallScript")
            {
                //DO THIS ONCE ON WALL HIT
                if (!hasDocked)
                {
                    createShipNeeds();
                    currentShipStatus = shipStatus.waitingOnLoad;
                    isGoingHome       = false;
                    hasDocked         = true;
                }
            }
        }
        else
        {
            if (currentShipStatus == shipStatus.goingToStation)
            {
                transform.position = Vector3.MoveTowards(transform.position, center, shipSpeed);
            }
        }

        if (currentShipStatus == shipStatus.headHome)
        {
            isGoingHome = true;

            if (transform.position != startPosition)
            {
                transform.position = Vector3.MoveTowards(transform.position, startPosition, 0.5f);
                //Debug.Log("Going Home");
            }
            else
            {
                // shipSpawn.degrementValue();
                //currentShipStatus = shipStatus.goingToStation;
            }
        }

        //!!! DON'T FORGET TO CHANGE FROM || to &&
        if (isFoodLoaded == true && isWaterLoaded == true && isFluidLoaded == true && hasDocked == true)
        {
            currentShipStatus = shipStatus.headHome;
            StartCoroutine(ReturnForLoad());
            isFluidLoaded = false;
            isWaterLoaded = false;
            isFoodLoaded  = false;

            _localscore += (50 * scoreMultiplier);
            _sm.IncreaseScore(_localscore);

            scoreMultiplier = 0;
            isGoingHome     = true;
            hasDocked       = false;
        }

        /*
         * if (checkShipsOut < 1)
         * {
         *  shipSpawn.waveLaunch();
         * }
         */
    }
    IEnumerator RandomTimeArrival()
    {
        yield return(new WaitForSeconds(Random.Range(0f, 10f)));

        currentShipStatus = shipStatus.goingToStation;
    }
    IEnumerator ReturnForLoad()
    {
        yield return(new WaitForSeconds(Random.Range(20f, 50f)));

        currentShipStatus = shipStatus.goingToStation;
    }
 public void goingHome()
 {
     currentShipStatus = shipStatus.headHome;
     //Debug.Log("going home");
     isGoingHome = true;
 }