예제 #1
0
파일: ObjectSpawner.cs 프로젝트: IkonOne/CV
    // Use this for initialization
    void Start()
    {
        _elapsed   = 0;
        gameBounds = GameObject.FindObjectOfType <GameBounds>();

        prefab.CreatePool();
    }
예제 #2
0
    private void SetPosition()
    {
        _currentPos += _dir * _deltaPos;
        _deltaPos.Set(0f, 0f, 0f);

        if (_config != null && _config.BlockedOnScreen)
        {
            GameBounds.ClampsThisPosition(ref _currentPos);
            _trans.position = _currentPos;
        }
        else
        {
            if (GameBounds.IsOnDeathArea(_currentPos))
            {
                if (OnOutOfBounds != null)
                {
                    OnOutOfBounds();
                }
            }
            else
            {
                _trans.position = _currentPos;
            }
        }
    }
예제 #3
0
 void Update()
 {
     _rb.MovePosition(_rb.position + transform.forward * Time.deltaTime * Speed);
     if (!GameBounds.IsWithinBounds(transform.position))
     {
         GameObject.Destroy(gameObject);
     }
 }
예제 #4
0
    private void Awake()
    {
        GameBounds gb = FindObjectOfType <GameBounds>();

        if (gb)
        {
            bounds = gb.bounds;
        }
    }
예제 #5
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
예제 #6
0
    void Update()
    {
        var speed = Mathf.Lerp(Speed.x, Speed.y, _difficulty);

        _rb.MovePosition(_rb.position + Vector3.back * Time.deltaTime * speed);
        if (!GameBounds.IsWithinBounds(transform.position))
        {
            GameObject.Destroy(gameObject);
        }

        //_hull.Fire(true); // TODO: FIRE
    }
예제 #7
0
    void FixedUpdate()
    {
        //Movement och sånt
        var horizontal = Input.GetAxis("Horizontal");
        var vertical   = Input.GetAxis("Vertical");

        _movementVector = Vector3.Lerp(_movementVector, new Vector3(horizontal, 0, vertical).normalized, Time.deltaTime * SpeedEase);
        var moveVec        = new Vector3(_movementVector.x * Speed.x, 0f, _movementVector.z * Speed.y);
        var wantedPosition = GameBounds.ClampToBounds(_rb.position + (moveVec * Time.deltaTime));

        _rb.MovePosition(Vector3.Lerp(_rb.position, wantedPosition, Time.deltaTime * SpeedEase));
    }
예제 #8
0
    protected override void Awake()
    {
        base.Awake();

        GameBounds gb = FindObjectOfType <GameBounds>();

        if (gb)
        {
            movementBounds = gb.bounds;
        }

        rigidbody = GetComponent <Rigidbody>();
    }
예제 #9
0
    void Update()
    {
        _difficultyTimer += Time.deltaTime / DifficultyTime;

        _timer -= Time.deltaTime;
        if (_timer < 0)
        {
            var curveValue    = DifficultyCurve.Evaluate(_difficultyTimer);
            var randomIndex   = GetRandomEnemyToSpawn();
            var enemySettings = Enemies[randomIndex];
            var enemy         = GameObject.Instantiate(enemySettings.Prefab, GameBounds.GetRandomSpawnPosition(), Quaternion.identity, transform).GetComponent <Enemy>();
            enemy.SetDifficulty(curveValue);
            var spawnTimer = Mathf.Lerp(SpawnTimer.x, SpawnTimer.y, curveValue);
            _timer = 1f / spawnTimer;
        }
    }
예제 #10
0
	// Use this for initialization
	void Start () {

        sBounds = this;

    }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     sBounds = this;
 }