Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            EndGame();
            StartGame();
        }


        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
        {
            if (!gameOverPanel)
            {
                panels.mainGroupButton.Select();
            }
            else
            {
                panels.gameOverGroupButton.Select();
            }
        }

        if (playing)
        {
            StaticComponent.SetCurrentSpeed(Mathf.SmoothStep(minSpeed, maxSpeed, score / scoreToMaxSpeed));
            score += 10 * Time.deltaTime;
            texts.scoreText.text = ((int)Math.Floor(score)).ToString("G");
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        timeEstantes -= Time.deltaTime;
        timeJuguetes -= Time.deltaTime;

        if (instantiatedObjects.Count <= 5 && timeEstantes <= 0)
        {
            intEstanterias = Random.Range(0, 2);

            instantiatedObjects.Add(Instantiate(estanterias[intEstanterias], spawns.spawnEstanteria.transform.position, spawns.spawnEstanteria.transform.rotation, cosasMoviles));
            timeEstantes = Random.Range(initialRandomEstantes / StaticComponent.GetCurrentSpeed(), endRandomEstantes / StaticComponent.GetCurrentSpeed());
        }

        if (instantiatedJuguetes.Count <= 0 && timeJuguetes <= 0)
        {
            int     juegueteAInstanciar = Random.Range(0, juguetes.Count);
            Vector3 spawnPositionJuguete;
            if (juegueteAInstanciar <= 1)
            {
                spawnPositionJuguete = spawns.spawnJuguetes.transform.position + Random.Range(2f, 4f) * Vector3.up;
            }
            else
            {
                spawnPositionJuguete = spawns.spawnJuguetes.transform.position;
            }
            instantiatedJuguetes.Add(Instantiate(juguetes[juegueteAInstanciar], spawnPositionJuguete, juguetes[juegueteAInstanciar].transform.rotation, cosasMoviles));

            timeJuguetes = Random.Range(initialRandomPelotas / StaticComponent.GetCurrentSpeed(), endRandomPelotas / StaticComponent.GetCurrentSpeed());
        }

        instantiatedObjects.TrimExcess();
        instantiatedJuguetes.TrimExcess();
    }
Exemplo n.º 3
0
        public void Compose()
        {
            var staticComponent = new TestComponent();
            var component       = new StaticComponent <ITestComponent>(staticComponent);
            var composeResult   = component.Compose(this.Composer, true, this.ConstructorSelector);

            Assert.Equal(staticComponent, composeResult);
        }
Exemplo n.º 4
0
        public void PrepareComposition()
        {
            var staticComponent = new TestComponent();
            var component       = new StaticComponent <ITestComponent>(staticComponent);

            Assert.Throws <NotImplementedException>(() =>
                                                    component.PrepareComposition(this.Composer, this.ConstructorSelector));
        }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     //Cursor.lockState = CursorLockMode.Locked;
     //Cursor.visible = false;
     OpenPanel(panels.mainGroup, true);
     OpenPanel(panels.interfaceGroup, false);
     OpenPanel(panels.gameOverGroup, false);
     StaticComponent.SetCurrentSpeed(minSpeed);
 }
Exemplo n.º 6
0
    private void Update()
    {
        if (Math.Abs(personageRB.velocity.y) >= 0.1f)
        {
            onAir = true;
        }
        else
        {
            onAir = false;
        }

        if (vidas.currentLives > 0)
        {
            if (Input.GetKeyDown(KeyCode.Space) && !onAir)
            {
                personageRB.AddForce(new Vector2(0, velocidadSalto), ForceMode.Impulse);
                personageRB.velocity = new Vector2(personageRB.velocity.x / 2, personageRB.velocity.y);
                playerAudio.PlayAudio(0);
                aController.ActivateJump();
            }

            float impulsoActual = impulsoHorizontal;

            if (onAir)
            {
                impulsoActual /= 10;
            }

            if (Input.GetKey(KeyCode.RightArrow))
            {
                transform.eulerAngles = new Vector3(0, 90, 0);

                if (personageRB.velocity.x < velocidadHorizontal)
                {
                    personageRB.AddForce(new Vector2(impulsoActual * StaticComponent.GetCurrentSpeed(), 0), ForceMode.Force);
                }
            }
            else if (Input.GetKey(KeyCode.LeftArrow))
            {
                transform.eulerAngles = new Vector3(0, -90, 0);

                if (personageRB.velocity.x > -velocidadHorizontal)
                {
                    personageRB.AddForce(new Vector2(-impulsoActual * StaticComponent.GetCurrentSpeed(), 0), ForceMode.Force);
                }
            }
            else
            {
                personageRB.AddForce(new Vector2(-4 * personageRB.velocity.x, 0), ForceMode.Force);
            }
        }
        else
        {
            personageRB.AddForce(new Vector2(-4 * personageRB.velocity.x, 0), ForceMode.Force);
        }
    }
Exemplo n.º 7
0
        public void Dispose()
        {
            var staticComponent = new TestComponent();
            var component       = new StaticComponent <ITestComponent>(staticComponent);

            component.Dispose();
            component.Dispose();

            Assert.Throws <ObjectDisposedException>(
                () => component.Compose(this.Composer, true, this.ConstructorSelector));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Remove a component to this GameObject
        /// </summary>
        /// <param name="c">the component to remove</param>
        public void RemoveComponent(StaticComponent c)
        {
            if (scene != null)
            {
                c.OnRemovedFromScene(scene);
            }

            components.Remove(c);
            if (c is IUpdatable)
            {
                updatables.Remove(c as IUpdatable);
            }
            if (c is IRenderable)
            {
                renderables.Remove(c as IRenderable);
            }
            c.gameObject = null;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Add a component to this GameObject
        /// </summary>
        /// <param name="c">the component to add</param>
        public void AddComponent(StaticComponent c)
        {
            components.Add(c);
            if (c is IUpdatable)
            {
                updatables.Add(c as IUpdatable);
            }
            if (c is IRenderable)
            {
                renderables.Add(c as IRenderable);
            }
            c.gameObject = this;

            if (scene != null)
            {
                c.OnAddedToScene(scene);
            }
        }
Exemplo n.º 10
0
        public bool Line(Direction direction, Side side, Operation operation)
        {
            StaticComponent block1 = null;
            StaticComponent block2 = null;

            switch (direction)
            {
            case Direction.Left:
                block1 = Get(Corner.TopLeft, side == Side.Out ? Direction.Left : Direction.None);
                block2 = Get(Corner.BottomLeft, side == Side.Out ? Direction.Left : Direction.None);
                break;

            case Direction.Right:
                block1 = Get(Corner.TopRight, side == Side.Out ? Direction.Right : Direction.None);
                block2 = Get(Corner.BottomRight, side == Side.Out ? Direction.Right : Direction.None);
                break;

            case Direction.Up:
                block1 = Get(Corner.TopLeft, side == Side.Out ? Direction.Up : Direction.None);
                block2 = Get(Corner.TopRight, side == Side.Out ? Direction.Up : Direction.None);
                break;

            case Direction.Down:
                block1 = Get(Corner.BottomLeft, side == Side.Out ? Direction.Down : Direction.None);
                block2 = Get(Corner.BottomRight, side == Side.Out ? Direction.Down : Direction.None);
                break;
            }

            switch (operation)
            {
            case Operation.Or:
                return(block1 == null || block2 == null);

            case Operation.And:
                return(block1 == null && block2 == null);
            }

            return(false);
        }
Exemplo n.º 11
0
    public void StartGame()
    {
        if (player != null)
        {
            player.AutoDestruccion();
        }

        player = Instantiate(playerPrefab, startPoint).GetComponent <Scroll>();
        iObjects.Initialize();

        OpenPanel(panels.mainGroup, false);
        OpenPanel(panels.gameOverGroup, false);
        OpenPanel(panels.interfaceGroup, true);

        panels.mainGroupButton.Select();
        gameOverPanel = false;
        playing       = true;
        score         = 0;

        StaticComponent.SetCurrentSpeed(minSpeed);
        gameAudio.audioSource.Stop();
        gameAudio.audioSource.clip = gameAudio.sounds[1];
        gameAudio.audioSource.Play();
    }
        public void To(TComponentType instance)
        {
            var component = new StaticComponent <TComponentType>(instance);

            this.RegisterOrReplace(component);
        }
Exemplo n.º 13
0
 // Update is called once per frame
 void Update()
 {
     transform.Translate(-baseSpeed * StaticComponent.GetCurrentSpeed() * Time.deltaTime, 0, 0, Space.World);
 }