Пример #1
0
    public void OnTriggerEnter2D(Collider2D collider)
    {
        PlayerMoveControler player = collider.GetComponent <PlayerMoveControler>();

        player.Hit(-2, new Vector2(0.0f, 0.0f));

        int        i            = Random.Range(0, Weapons.Length);
        BaseWeapon weaponToGrab = Weapons[i];

        if (weaponToGrab.id == player.weapon.id)
        {
            if (i == Weapons.Length - 1)
            {
                weaponToGrab = Weapons[(i - 1)];
            }
            else
            {
                weaponToGrab = Weapons[(i + 1)];
            }
        }

        player.SetWeapon(weaponToGrab);
        SoundManager.instance.PlaySound(soundToPlay);
        GameObject.Destroy(gameObject, 0.1f);
    }
Пример #2
0
    private IEnumerator StartGameCoroutine()
    {
        AsyncOperation loadOp = SceneManager.LoadSceneAsync("Loader", LoadSceneMode.Additive);

        while (loadOp.isDone == false)
        {
            yield return(new WaitForEndOfFrame());
        }
        GameObject uiRoot = GameObject.FindGameObjectWithTag("UI");

        m_uiroot             = uiRoot.GetComponent <UIRoot>();
        m_uiroot.group.alpha = 0;

        m_ChangerPanel = GameObject.FindGameObjectWithTag("LoaderPanel").GetComponent <SceneChanger>();
        m_ChangerPanel.GameOver.GetComponent <CanvasGroup>().alpha = 0;
        Player = GameObject.Instantiate(Resources.Load <PlayerMoveControler>("Player"));
        Player.transform.parent = Instance.transform;
        m_uiroot.InitialiseUI(Player);
        MoneyManager.instance.currentScore = 0;
        Player.SetAlive(false);

        //yield return new WaitForSeconds(10);
        LoadNextScene(0, "Title");

        SoundManager.instance.PlayMusic(1);
    }
Пример #3
0
    void Update()
    {
        if (player == null)
        {
            GameObject go = GameObject.FindGameObjectWithTag("Player");
            if (go != null)
            {
                player          = go.GetComponent <PlayerMoveControler>();
                playerTransform = go.transform;
            }
        }

        if (playerTransform == null || player == null || player.isAlive == false)
        {
            return;
        }

        recup = false;
        int numParticles = pSystem.GetParticles(particles);

        for (int i = 0; i < numParticles; i++)
        {
            if (particles[i].startLifetime - particles[i].remainingLifetime < delayBeforeAttract)
            {
                return;
            }

            Vector3 dir          = playerTransform.position - particles[i].position;
            float   sqrMagnitude = dir.sqrMagnitude;

            if (sqrMagnitude < attractRange * attractRange)
            {
                particles[i].position = Vector3.Lerp(particles[i].position, playerTransform.position, Time.deltaTime * attractForce);

                if (sqrMagnitude < grabRange)
                {
                    particles[i].remainingLifetime = 0.0f;
                    currentScore += 1;
                    recup         = true;
                }
            }

            pSystem.SetParticles(particles, numParticles);

            if (recup == true)
            {
                recupSound.pitch = Random.Range(recupSoundRandomPitch.x, recupSoundRandomPitch.y);
                recupSound.Play();
            }
        }
    }
Пример #4
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (isAlive == false)
        {
            return;
        }

        PlayerMoveControler player = collision.collider.GetComponent <PlayerMoveControler>();

        if (player != null)
        {
            player.Hit(1, Vector2.zero);
        }
    }
Пример #5
0
    public void StartScene(int difficulty)
    {
        if (player == null)
        {
            player = SceneControler.Instance.Player;
        }
        if (Type == LevelType.Random)
        {
            List <Vector3> allSpawnPos = new List <Vector3>();
            for (int i = 0; i < SpawnerRoot.transform.childCount; i++)
            {
                allSpawnPos.Add(SpawnerRoot.transform.GetChild(i).position);
            }
            for (int i = 0; i < difficulty / 2; i++)
            {
                int index = (int)(allSpawnPos.Count * Random.value);

                if (allSpawnPos.Count == 0)
                {
                    break;
                }

                Vector3    spawnPos            = allSpawnPos[index];
                GameObject PrefadToInstanciate = TraderPrefab;
                if (difficulty > 4)
                {
                    PrefadToInstanciate = Random.value > 0.5f ? ShooterPrefab : TraderPrefab;
                }
                if (difficulty > 8 && i == 0)
                {
                    PrefadToInstanciate = DonaldPrefab;
                }
                Instantiate(PrefadToInstanciate, MobeRoot.transform).transform.position = spawnPos;

                allSpawnPos.RemoveAt(index);
            }

            foreach (Spawner spawner in MiniSpawerRoot.GetComponentsInChildren <Spawner>())
            {
                difficulty          = Mathf.Min(difficulty, 9);
                spawner.randomDelay = new Vector2(8.0f - difficulty * 0.5f, 24 - difficulty * 2.0f);
                spawner.StartSpawn();
            }
        }
        MobeRoot.SetActive(true);

        m_BaseMobs = MobeRoot.GetComponentsInChildren <BaseAI>().ToList();
        State      = LevelState.Play;
    }
Пример #6
0
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        trsf = transform;

        GameObject go = GameObject.FindGameObjectWithTag("Player");

        if (go != null)
        {
            player          = go.GetComponent <PlayerMoveControler>();
            playerTransform = go.transform;
        }

        currentScore = 0;
        particles    = new ParticleSystem.Particle[pSystem.main.maxParticles];
        recup        = false;
    }
Пример #7
0
 public void InitialiseUI(PlayerMoveControler player)
 {
     player.LifeGauge = Gauge;
 }
Пример #8
0
 private void Start()
 {
     playerMoveControler = GetComponent <PlayerMoveControler>();
     playerAnimationStateMachineBehavior = animator.GetBehaviour <PlayerAnimationStateMachineBehavior>();
 }