Пример #1
0
 public void Fire()
 {
     shot();
     fireController.RemoveFireContoller();
     fireController = null;
     TimersManager.SetTimer(this, WeaponReloadTime, () => { SetFireController(); });
 }
Пример #2
0
 private void OnRecivedSystemTxtHandler(object value)
 {
     txtTips.gameObject.SetActive(true);
     txtTips.text = value.ToString();
     //  Invoke("OnDelayTimeHandler", 2);
     TimersManager.SetTimer(this, 2, OnDelayTimeHandler);
 }
Пример #3
0
    IEnumerator TimeOver()
    {
        yield return(new WaitForSeconds(3));

        TimersManager.SetTimer(this, 1f, 60, Timer);
        TimersManager.SetPaused(Timer, true);
    }
Пример #4
0
    // Start is called before the first frame update
    private void Start()
    {
        isMenu = SceneManager.GetActiveScene().name == "Menu";

        if (!isMenu)
        {
            timerEnemySpawn = new Timer(1 / enemyPerSecond, Timer.INFINITE, spawnEnemy);
            TimersManager.SetTimer(this, timerEnemySpawn);

            GameObject[] aux = GameObject.FindGameObjectsWithTag("Player");

            for (int i = 0; i < aux.Length; i++)
            {
                if (i >= players_Ref.Length)
                {
                    break;
                }

                players_Ref[i] = aux[i].GetComponent <Player>();
            }

            if (!twoPlayers)
            {
                players_Ref[1].gameObject.SetActive(false);
            }

            if (!gameOverText || gameOverText == null)
            {
                gameOverText         = GameObject.Find("Game Over Text").GetComponent <TextMeshProUGUI>();
                gameOverText.enabled = false;
            }
        }
    }
Пример #5
0
 public void gameFinish()
 {
     GameManager.Instance.gameTrigger = false;
     TimersManager.SetPaused(timeCount, true);
     winPanel.SetActive(true);
     goblin.SetActive(false);
 }
Пример #6
0
    // Start is called before the first frame update
    void Start()
    {
        timerSelfDestruct = Time.time;

        TimersManager.SetLoopableTimer(this, 0.5f, rotacionar);

        transform.LookAt(player.transform);
    }
Пример #7
0
    private void Spawn()
    {
        GameObject go = GameObject.Instantiate(objectsToSpawn[Random.Range(0, objectsToSpawn.Length)], cachedTransform);

        go.transform.localPosition = Vector3.zero;
        npcRuntimeSet.KeyPair[go.GetInstanceID()].navigation.SetTarget(initialDestination);
        TimersManager.SetTimer(this, Random.Range(minSpawnInterval.value, maxSpawnInterval.value), Spawn);
    }
Пример #8
0
    void Start()
    {
        m_PointLight = gameObject.GetComponent <Light>();

        // set a timer that calls ChangeIntensity() every 0.1 seconds
        TimersManager.SetLoopableTimer(this, 0.1f, ChangeIntensity);
        TimersManager.SetTimer(this, 5f, delegate { Destroy(this); });
    }
Пример #9
0
 private void EndScene()
 {
     sceneOngoing = false;
     for (int i = 0; i < sceneRoles.Length; i++)
     {
         sceneRoles[i].ReleaseAllRoles();
     }
     onSceneEnd.Invoke();
     TimersManager.SetTimer(this, reactivationTime.value, ReactivateScene);
 }
Пример #10
0
    public void UpdateEnemyByState()
    {
        if (!dieAlready)
        {
            switch (enemyState)
            {
            case BasicInfo.enemyStates.Walk:
            {
                pathMoveTween.Play();
                //modelAnim.Play("walk");



                if (enemyLastState == BasicInfo.enemyStates.Attack)
                {
                    transform.DOLookAt(pathList[nextWayPointIndex], 0.3f, AxisConstraint.Y, Vector3.up);
                }
                break;
            }

            case BasicInfo.enemyStates.Stop:
            {
                pathMoveTween.Pause();
                //modelAnim.Play("idle");

                break;
            }

            case BasicInfo.enemyStates.Attack:
            {
                pathMoveTween.Pause();

                transform.DOLookAt(detectedTowerList[0].transform.position, 0.3f, AxisConstraint.Y, Vector3.up);

                modelAnim.Play("attack");



                //Debug.Log("检测到塔");
                //Debug.Log (2 / enemyAttackSpeed);
                if (TimersManager.GetTimerByName(AttackTimer) == null)
                {
                    TimersManager.SetTimer(this, 1f, AttackTimer);
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }
Пример #11
0
    // Start is called before the first frame update
    void Start()
    {
        timerSelfDestruct = Time.time;

        if (!player || player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }

        TimersManager.SetLoopableTimer(this, 2f, shootAt);
    }
Пример #12
0
    private void StartZone()
    {
        for (int i = 0; i < sceneRoles.Length; i++)
        {
            sceneRoles[i].StartScene();
        }

        if (!sceneOngoing)
        {
            sceneOngoing = true;
            TimersManager.SetTimer(this, sceneDuration.value, EndScene);
        }
    }
Пример #13
0
 void Update()
 {
     if (TimersManager.RemainingTime(Timer) == -1)
     {
         TimersManager.SetTimer(this, 0f, delegate { Destroy(this); });
         TB.GetComponent <Text>().text = "Time Over";
         StartCoroutine("TimeOver");
     }
     else
     {
         TB.GetComponent <Text>().text = "残り時間:" + (int)TimersManager.RemainingTime(Timer) + "秒";
     }
 }
Пример #14
0
 public void timerSetting()
 {
     gameTrigger = true;
     foreach (var towers in  TowerManager.Instance.towers)
     {
         towers.shootOnce();
         towers.target = TowerManager.Instance.enemyGround.tileArr[Random.Range(0, 24)].transform;
     }
     activeCount = m_activeCount;
     UIManager.Instance.moveCountChange(m_activeCount);
     UIManager.Instance.timerCount = timerCount;
     TimersManager.SetLoopableTimer(this, 1f, UIManager.Instance.timeCount);
     TimersManager.SetPaused(UIManager.Instance.timeCount, false);
 }
Пример #15
0
 // Update is called once per frame
 void Update()
 {
     //Debug.Log(healthBarDefineTransform.position);
     healthBarTransform.position = Camera.main.WorldToScreenPoint(healthBarDefineTransform.position);
     Detect();
     if (detectedEnemyList.Count > 0)
     {
         //Debug.Log("侦测到敌人");
         if (TimersManager.GetTimerByName(AttackTimer) == null)
         {
             TimersManager.SetTimer(this, 1f, AttackTimer);
         }
     }
 }
Пример #16
0
 void AttackTimer()
 {
     if (detectedTowerList.Count > 0)
     {
         //Debug.Log("攻击一次");
         Tower detectedTowerComp      = detectedTowerList[0].GetComponent <Tower>();
         float enemyAttackPower_final = BasicInfo.calcuteAttackPower(enemyAttackPower, this.enemyAttr, detectedTowerComp.towerAttr);
         detectedTowerComp.GetAttacked(enemyAttackPower_final);
     }
     else
     {
         TimersManager.ClearTimer(AttackTimer);
     }
 }
Пример #17
0
    // Start is called before the first frame update
    void Start()
    {
        textoHp = GameObject.Find("HpP" + id).GetComponent <TextMeshProUGUI>();

        gameRef = GameObject.FindGameObjectWithTag("Game").GetComponent <Game>();

        sfxRef = GameObject.Find("SFX").GetComponent <Sfx>();

        corInicial = GetComponent <Renderer>().material.color;

        powerUp = new Timer(0.1f, (uint)(powerUpDuration / 0.1), absolutelyNotSuperStar);

        TimersManager.SetLoopableTimer(this, 5f, hpRegen);
    }
Пример #18
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.CompareTag("Bullet") || other.transform.CompareTag("Inimigo"))
        {
            Hp -= 5;
            Destroy(other.gameObject);
        }

        if (other.transform.CompareTag("PowerUp"))
        {
            powerUp = new Timer(0.1f, (uint)(powerUpDuration / 0.1), absolutelyNotSuperStar);
            TimersManager.SetTimer(this, powerUp);
            Destroy(other.gameObject);
        }
    }
Пример #19
0
 // MARK: - Timer
 public void timeCount()
 {
     if (timerCount == 0)
     {
         Debug.Log("Count finish");
         timerText.text = GameManager.Instance.timerCount.ToString();
         TimersManager.ClearTimer(timeCount);
         GameManager.Instance.gameTrigger = false;
         GameManager.Instance.turn++;
         turnText.text = GameManager.Instance.turn.ToString();
         airyUIAnimationManager.ShowMenu();
         return;
     }
     timerCount--;
     timerText.text = timerCount.ToString();
 }
Пример #20
0
    // Start is called before the first frame update
    private void Start()
    {
        Hp = maxHp;

        if (!game_ref || game_ref == null)
        {
            game_ref = GameObject.FindGameObjectWithTag("Game").GetComponent <Game>();
        }

        if (!rigidbody_ref || rigidbody_ref == null)
        {
            rigidbody_ref = GetComponent <Rigidbody2D>();
        }

        scoreTimer = Time.time;

        TimersManager.SetLoopableTimer(this, 1f, increaseScore);
    }
Пример #21
0
    // Update is called once per frame
    void Update()
    {
        textoHp.text = "HP T" + time + ": " + Hp;

        walk();

        if (powerUp.RemainingLoopsCount() <= 0)
        {
            TimersManager.ClearTimer(absolutelyNotSuperStar);
            GetComponent <Renderer>().material.color = corInicial;
            speed = speedInicial;
        }

        switch (id)
        {
        case 1:
            if (Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                shootAt();
            }
            break;

        case 2:
            if (Input.GetKeyDown(KeyCode.F))
            {
                shootAt();
            }
            break;

        case 3:
            if (Input.GetKeyDown(KeyCode.Return))
            {
                shootAt();
            }
            break;

        case 4:
            if (Input.GetKeyDown(KeyCode.F))
            {
                shootAt();
            }
            break;
        }
    }
Пример #22
0
    void Update()
    {
        if (currentSection == null)
        {
            if (!win)
            {
                TimersManager.SetTimer(this, 0.5f, delegate
                {
                    SceneManager.LoadScene("GameWin");
                });
                win = true;
            }
            return;
        }

        if (audioSource.time > currentSection.endTime)
        {
            if (nextSectionId >= level.sectionList.Count)
            {
                EndGame();
                return;
            }
            else
            {
                NextSection();
            }
        }

        if (currentSection.playStartTime <= audioSource.time && audioSource.time <= currentSection.playEndTime)
        {
            if (currentSection.GetType() == typeof(RepeatSection))
            {
                CheckInput(currentSection as RepeatSection);
            }
        }

        if ((Input.GetKeyDown(KeyCode.X)))
        {
            progressBar.DOKill();
            progressBar.value = 0;
        }
    }
Пример #23
0
    // Update is called once per frame
    void Update()
    {
        textoScore.text = "SCORE: " + pontuação;

        if (Input.GetKeyDown(KeyCode.R))
        {
            TimersManager.ClearTimer(spawnInimigo);
            TimersManager.ClearTimer(scoreRate);
            TimersManager.ClearTimer(spawnPowerUp);

            Destroy(timeManager);

            SceneManager.LoadScene(0);
        }

        if (isGameOver)
        {
            panelGameOver.SetActive(true);
        }
    }
Пример #24
0
    // Start is called before the first frame update
    void Start()
    {
        menu = GameObject.FindGameObjectWithTag("Menu").GetComponent <Menu>();
        menu.gameObject.SetActive(false);

        players = new Player[PlayerPrefs.GetInt("playerQuantity")];

        for (int i = 0; i < PlayerPrefs.GetInt("playerQuantity"); i++)
        {
            if (i >= playersPrefabs.Length)
            {
                break;
            }

            Player p = Instantiate(playersPrefabs[i], new Vector3(2 * i, (float)0.5, 0), Quaternion.identity).GetComponent <Player>();

            p.id = i + 1;

            if (PlayerPrefs.GetInt("peopleInTeamOne") > 0)
            {
                p.time = 1;
                PlayerPrefs.SetInt("peopleInTeamOne", PlayerPrefs.GetInt("peopleInTeamOne") - 1);
            }
            else
            {
                p.time = 2;
            }

            players[i] = p;
        }

        TimersManager.SetLoopableTimer(this, enemyTimeRate, spawnInimigo);
        TimersManager.SetLoopableTimer(this, scoreTimeRate, scoreRate);
        TimersManager.SetLoopableTimer(this, powerUpTimeRate, spawnPowerUp);
        //----------
        TimersManager.SetTimer(this, scoreTimer);
        TimersManager.ClearTimer(EmptyTimer);

        lastDamageTakenTime = Time.time;
    }
Пример #25
0
    void Preview(RepeatSection section)
    {
        foreach (var beat in section.previewBeatList)
        {
            if (!string.IsNullOrEmpty(beat.animationState))
            {
                float animAdvancedTime = level.animationStateAdvanceTime[level.animationStateNames.IndexOf(beat.animationState)];
                TimersManager.SetTimer(this, beat.time - audioSource.time - animAdvancedTime, delegate
                {
                    enemyUpperAnimator.Play(beat.animationState);
                });
            }

            TimersManager.SetTimer(this, beat.time - audioSource.time, delegate
            {
                audioSource.PlayOneShot(beat.audioEffect);

                Destroy(throwable);
                if (beat.randomThrowable)
                {
                    throwable = Instantiate(level.throwablePrefabList[Random.Range(0, level.throwablePrefabList.Count)], throwableRoot.transform);
                }
                else
                {
                    throwable = Instantiate(beat.throwable, throwableRoot.transform);
                }
                Debug.Log("咳嗽");
            });
        }

        section.miss            = false;
        section.currentPlayBeat = section.playBeatList[0];
        section.nextHitIndex    = 1;
        foreach (var beat in section.playBeatList)
        {
            beat.hasClicked = false;
            beat.hasHit     = false;
        }
    }
Пример #26
0
    void AttackTimer()
    {
        if (detectedEnemyList.Count > 0)
        {
            //Debug.Log("攻击一次");

            if (towerAttackScope > 0)//攻击范围大于0
            {
                List <Vector2> offList = new List <Vector2>();
                for (int i = 1; i <= towerAttackScope; ++i)
                {
                    for (int j = 0; j <= i; ++j)
                    {
                        int k = i - j;
                        if (j > 0 && k == 0)
                        {
                            offList.Add(new Vector2(j, k));
                            offList.Add(new Vector2(-j, k));
                        }
                        else if (j == 0 && k > 0)
                        {
                            offList.Add(new Vector2(j, k));
                            offList.Add(new Vector2(j, -k));
                        }
                        else if (j > 0 && k > 0)
                        {
                            offList.Add(new Vector2(j, k));
                            offList.Add(new Vector2(-j, k));
                            offList.Add(new Vector2(j, -k));
                            offList.Add(new Vector2(-j, -k));
                        }
                    }
                }
                List <Vector2> gridPosList = new List <Vector2>();
                foreach (Vector2 off in offList)
                {
                    Vector2 pos = new Vector2((float)Mathf.Floor(detectedEnemyList[0].transform.position.x) + 0.5f, (float)Mathf.Floor(transform.position.z) + 0.5f);
                    pos += off;
                    gridPosList.Add(pos);
                }

                List <Vector2>    enemyPosList = new List <Vector2>();
                List <GameObject> enemyList    = GeneralPool.get_enemyList();
                foreach (GameObject enemy in enemyList)
                {
                    Vector2 pos = new Vector2((float)Mathf.Floor(enemy.transform.position.x) + 0.5f, (float)Mathf.Floor(enemy.transform.position.z) + 0.5f);
                    enemyPosList.Add(pos);
                }

                List <GameObject> detectedEnemyList_inAttackScope = new List <GameObject>();
                detectedEnemyList_inAttackScope.Add(detectedEnemyList[0]);
                for (int i = 0; i < enemyPosList.Count; i++)
                {
                    for (int j = 0; j < gridPosList.Count; j++)
                    {
                        if (enemyPosList[i] == gridPosList[j])
                        {
                            detectedEnemyList_inAttackScope.Add(enemyList[i]);
                        }
                    }
                }
                foreach (GameObject detectedEnemy_inAttackScope in detectedEnemyList_inAttackScope)
                {
                    Enemy detectedEnemyComp_inAttackScope = detectedEnemy_inAttackScope.GetComponent <Enemy>();
                    float towerAttackPower_final          = BasicInfo.calcuteAttackPower(towerAttackPower, this.towerAttr, detectedEnemyComp_inAttackScope.enemyAttr);
                    detectedEnemy_inAttackScope.GetComponent <Enemy>().GetAttacked(towerAttackPower_final);
                }
            }
            else
            {
                Enemy detectedEnemyComp      = detectedEnemyList[0].GetComponent <Enemy>();
                float towerAttackPower_final = BasicInfo.calcuteAttackPower(towerAttackPower, this.towerAttr, detectedEnemyComp.enemyAttr);
                detectedEnemyComp.GetAttacked(towerAttackPower_final);
            }
        }
        else
        {
            TimersManager.ClearTimer(AttackTimer);
        }
    }
Пример #27
0
        private void Awake()
        {
            _button = gameObject.GetComponent <Button>();

            _timersManager = GameManager.Instance.TimersManager;
        }
Пример #28
0
 void Start()
 {
     TimersManager.SetTimer(this, 1f, 60, Timer);
     TimersManager.SetPaused(Timer, true);
 }
Пример #29
0
 public void StartTimer()
 {
     TimersManager.SetTimer(this, 1f, 60, Timer);
 }
Пример #30
0
 public void ResetTimer()
 {
     TimersManager.SetTimer(this, 1f, 60, Timer);
     TimersManager.SetPaused(Timer, true);
 }