Exemplo n.º 1
0
    void FixedUpdate()
    {
        playerCollider.isTrigger = Swipe.IsDrawing;

        if (MenuManager.Paused || Swipe.IsDrawing)
        {
            playerRigidbody.velocity = new Vector3(0, 0, 0);
        }
        else
        {
            playerRigidbody.velocity = new Vector3(0, -DownwardMovementSpeed, 0);

            //Rotate on slide
            if (startPositionX != float.MaxValue)
            {
                if (transform.position.x < startPositionX)
                {
                    RotateLeft();
                    startPositionX = float.MaxValue;
                }
                else if (transform.position.x > startPositionX)
                {
                    RotateRight();
                    startPositionX = float.MaxValue;
                }
            }

            if (tick.IsAction())
            {
                //Debug.Log(Vector3.Distance(oldPosition, transform.position));
                if (oldPosition != null && Vector3.Distance(oldPosition, transform.position) < 5)
                {
                    SamePositionCount++;
                }
                else
                {
                    SamePositionCount    = 0;
                    meterSinceLastScore += Math.Abs(transform.position.y) - Math.Abs(oldPosition.y);
                    oldPosition          = transform.position;
                }

                if (SamePositionCount >= 3)
                {
                    Debug.Log("We must break!");
                    if (currentCollidingLine != null)
                    {
                        Destroy(currentCollidingLine);
                    }
                }

                //Score a point while meters way done
                if (meterSinceLastScore > OneScorePerMeters)
                {
                    ScoreManager.Instance.CurrentScore += 1;
                    meterSinceLastScore = 0;
                }
            }
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //New Wave starts
        if (waveActionTick != null && waveActionTick.IsAction())
        {
            waveDurationActionTick = new ActionTick(WaveDuration, false);
            spawnEnemyActionTick   = new ActionTick(1000, true);
            waveDurationActionTick.IsAction(); //First call starts thread
            waveActionTick = null;

            WaveDisplay.Find("Text").GetComponent <Text>().text = "Wave " + Wave + " starts ...";
            WaveDisplay.gameObject.SetActive(true);
        }

        //Disable wave display after 3 seconds
        if (waveDurationActionTick != null && waveDurationActionTick.TimeToNextTick < WaveDuration - 3000 &&
            WaveDisplay.gameObject.activeInHierarchy)
        {
            WaveDisplay.gameObject.SetActive(false);
        }


        //Execute enemy spawning during wave
        if (waveDurationActionTick != null && spawnEnemyActionTick != null &&
            waveDurationActionTick.IsRunning() && spawnEnemyActionTick.IsAction())
        {
            System.Random r = new System.Random();
            spawnEnemyActionTick = new ActionTick(r.Next(4000, 8000), false);

            SpawnEnemy(r.Next(0, 5));
        }

        //Wave ends
        if (waveDurationActionTick != null && !waveDurationActionTick.IsRunning())
        {
            spawnEnemyActionTick   = null;
            waveDurationActionTick = null;
            waveActionTick         = new ActionTick(WaveTick, false);
        }

        //Displaying wave status
        if (waveActionTick != null && waveActionTick.TimeToNextTick < 30000 &&
            waveActionTick.TimeToNextTick > 27000 && !WaveDisplay.gameObject.activeInHierarchy)
        {
            WaveDisplay.Find("Text").GetComponent <Text>().text = "Next Wave in 30 seconds";
            WaveDisplay.gameObject.SetActive(true);
        }
        else if (waveActionTick != null && waveActionTick.TimeToNextTick < 27000)
        {
            WaveDisplay.gameObject.SetActive(false);
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (destructibleInFront != null)
        {
            try                                                          //TODO: remove try catch and return bool if player is death
            {
                if (currentTile.GetGameObject(-Vector3.forward) == null) //Gameobject is not there anymore ?? NOT WORKING TODO
                {
                    destructibleInFront = null;
                }
                else if (actionTick.IsAction())
                {
                    destructibleInFront.TakeDamage(Damage);
                }
            }
            catch
            {
                destructibleInFront = null;
            }
        }
        else if (!moving)
        {
            FindSelectableTiles(true);

            GetMoveOrAttackTile();//Moves the enemy or sets the destructibleInFront

            if (currentTile.tag == "BaseTile")
            {
                Gameover();
            }
        }
        else
        {
            Move();
        }

        if (CurrentHealth <= 0)
        {
            Die();
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        Debug.DrawRay(transform.position, transform.forward);
        if (!moving)
        {
            FindSelectableTiles();
            CheckSwipe();
            CheckTab();

            if (currentTile == null)//Object is deleted (Wall)
            {
                MoveToTile(wallGround);
            }
            else
            {
                switch (currentTile.tag)
                {
                case "WallTile":
                    break;

                case "StoneResourceTile":
                    if (resourceActionTick.IsAction())
                    {
                        Resources.AddStone();
                        OnInformationUpdated();
                        animator.SetTrigger("PickUp");
                    }
                    break;

                case "AmmoResourceTile":
                    if (resourceActionTick.IsAction())
                    {
                        Resources.AddAmmo();
                        OnInformationUpdated();
                        animator.SetTrigger("PickUp");
                    }
                    break;

                case "RepairTile":
                    if (repairActionTick.IsAction())
                    {
                        var go = currentTile.GetGameObject(Vector3.forward); //Get Gameobject in front (Wall)

                        if (go != null)                                      //Wall already down when wall is null
                        {
                            var wall = go.GetComponent <Tile>();

                            if (wall != null && Resources.Stone > 0)    //Avoid enemy attack and stones available
                            {
                                if (wall.Repair(RepairEfficiencyPerStone))
                                {
                                    Resources.UseStone();
                                    OnInformationUpdated();
                                    animator.SetTrigger("Repair");
                                }
                            }
                        }
                    }
                    break;

                case "BaseTile":
                    break;

                case "Wall":
                    if (shootActionTick.IsAction())
                    {
                        if (Resources.Ammo > 0)
                        {
                            int row = Int32.Parse(currentTile.transform.parent.name.Split('(')[1].Split(')')[0]);    //TODO refactor read of row

                            if (transform.GetComponent <Shoot>().Shooting(row, damage))
                            {
                                Resources.UseAmmo();
                                OnInformationUpdated();
                            }
                        }
                    }

                    wallGround = currentTile.GetWallGroundOfRow();
                    break;
                }
            }
        }
        else
        {
            Move();
            animator.Play("Run");
        }
    }