Exemplo n.º 1
0
 public void EnterState(GameSceneManager _owner)
 {
     EchoLog.Print("----------------------");
     EchoLog.Print("Load Menu scene");
     _owner.LoadPrefabs();
     GameEventHandlers.FadeOut();
 }
Exemplo n.º 2
0
    void Update()
    {
        // Rigidbody, I use only for the correct stinging and collision.
        // Speed for player's rigidbodi, we rely only on gravity.
        // The formula for the speed of acceleration is used: v = at
        rigidbodyPlayer.velocity = new Vector3(rigidbodyPlayer.velocity.x + currentAccel.x * Time.deltaTime,
                                               rigidbodyPlayer.velocity.y + currentAccel.y * Time.deltaTime,
                                               rigidbodyPlayer.velocity.z + currentAccel.z * Time.deltaTime);

        // In order not to take into account the friction of the surface,
        // the displacement along X will be assumed proceeding from speed and acceleration.
        // The displacement formula: S = v0*t + a*t*t/2
        //transform.position = new Vector3(transform.position.x + calculateSpeed.x * Time.deltaTime + currentAccel.x * Time.deltaTime * Time.deltaTime / 2,
        //                                 transform.position.y/* + calculateSpeed.y * Time.deltaTime + currentAccel.y * Time.deltaTime * Time.deltaTime / 2*/,
        //                                 transform.position.z/* + calculateSpeed.z * Time.deltaTime + currentAccel.z * Time.deltaTime * Time.deltaTime / 2*/);

        // Calculate Speed use formula: v = S / t
        //calculateSpeed = new Vector3(
        //    (transform.position.x - lastPos.x) / Time.deltaTime,
        //    (transform.position.y - lastPos.y) / Time.deltaTime,
        //    (transform.position.z - lastPos.z) / Time.deltaTime);

        //rigidbodyPlayer.velocity = calculateSpeed;

        CalculateAcceleration();

        if (transform.position.y < dieY)
        {
            EchoLog.Print("[OPS] I fell into a hole.");
            LevelEventSystem.GameOver();
        }
    }
Exemplo n.º 3
0
 public void DestroySceneResources()
 {
     for (var i = loadedResourceInstances.Count - 1; i >= 0; i--)
     {
         Destroy(loadedResourceInstances[i]);
         loadedResourceInstances.RemoveAt(i);
     }
     EchoLog.Print("[INFO] loadedResources not destroyed: " + loadedResourceInstances.Count);
 }
Exemplo n.º 4
0
    void OnCollisionEnter(Collision collision)
    {
        var collosionLayer = LayerMask.GetMask(LayerMask.LayerToName(collision.collider.gameObject.layer));

        if (collosionLayer == groundMask)
        {
            underfoot = true;
            ChangeColor(Color.green);
        }

        if (collosionLayer == obstacleMask)
        {
            EchoLog.Print("[OPS] Touch obstacle " + collision.gameObject.name);
            ChangeColor(Color.red);
            LevelEventSystem.GameOver();
        }
    }
Exemplo n.º 5
0
    public void LoadPrefabs()
    {
        if (loadedResourceInstances == null)
        {
            loadedResourceInstances = new List <GameObject>();
        }

        foreach (var lr in loadableResources)
        {
            if (lr.forScene == currentGameScene)
            {
                foreach (var res in lr.prefabs)
                {
                    loadedResourceInstances.Add(Instantiate(res) as GameObject);
                    EchoLog.Print("[INFO] loadedResources added GameObject: " + res.name);
                }
            }
        }
    }
Exemplo n.º 6
0
 public void ExitState(GameSceneManager _owner)
 {
     _owner.DestroySceneResources();
     EchoLog.Print("Destroy Menu scene");
 }
Exemplo n.º 7
0
 public void ExitState(GameSceneManager _owner)
 {
     _owner.DestroySceneResources();
     EchoLog.Print("Destroy Choice Charapter scene");
 }