コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <HitBoxScript>())
        {
            _hitBox = other.GetComponent <HitBoxScript>();

            Damage();
        }
    }
コード例 #2
0
 private void OnTriggerStay(Collider other)
 {
     _hitBox = other.GetComponentInParent <HitBoxScript>();
     if (_hitBox.BoxTeam != this.BoxTeam)
     {
         if (_timer <= 0)
         {
             Damage();
             HitEffects();
         }
         else
         {
             _timer -= Time.deltaTime;
         }
     }
 }
コード例 #3
0
 protected void Awake()
 {
     animator     = GetComponent <Animator>();
     hitBoxScript = gameObject.GetComponentInChildren <HitBoxScript>();
 }
コード例 #4
0
ファイル: LevelCreator.cs プロジェクト: moSeSthe7th/BoomBalls
    private void CreateLevel()
    {
        levelData.LoadLevelData(DataScript.currentLevel);

        colorScript.ColorizeTheLevel(levelData.levelStyle);

        rotatingObjects   = levelData.rotatingObjects;
        boxes             = levelData.boxes;
        whirlwinds        = levelData.whirlwinds;
        obstaclePositions = levelData.obstaclePositions;

        DataScript.ballCount = levelData.ballCount;
        counterScript.SetInGameBallCounter();

        cameraScale = levelData.cameraScale;
        cameraScaler.SetCameraScale(cameraScale);
        DataScript.screenTopCenter = FindTopOfTheScreen();

        if (levelData.isLevelReversed)
        {
            Camera.main.transform.rotation = reversedCameraQuaternion;
        }

        for (int i = 0; i < whirlwinds.Count; i++)
        {
            GameObject      currentWhirlwind = Instantiate(whirlwind, whirlwinds[i].position, Quaternion.identity);
            WhirlwindScript whirlwindScript  = currentWhirlwind.GetComponent <WhirlwindScript>();
            StartCoroutine(whirlwindScript.InitializeWhirlWind(whirlwinds[i].isRotatingClockwise, whirlwinds[i].rotatingSpeed, whirlwinds[i].delay));
        }

        for (int i = 0; i < boxes.Count; i++)
        {
            DataScript.boxCountInLevel += 1;

            GameObject        currentBox        = Instantiate(box, boxes[i].position, box.transform.rotation);
            HitBoxScript      hitBoxScript      = currentBox.GetComponent <HitBoxScript>();
            HitBoxMoverScript hitBoxMoverScript = currentBox.GetComponent <HitBoxMoverScript>();

            hitBoxScript.count = boxes[i].count;
            Text text = currentBox.GetComponentInChildren <Text>();
            text.text = boxes[i].count.ToString();

            if (boxes[i].isMovingHorizontal)
            {
                StartCoroutine(hitBoxMoverScript.HitBoxOscillator(true, 0.05f, 0.01f));
            }
            else if (boxes[i].isMovingVertical)
            {
                StartCoroutine(hitBoxMoverScript.HitBoxOscillator(false, 0.05f, 0.01f));
            }

            //currentBox.transform.rotation = new Quaternion(0f, 180f, 0f,0f);
        }

        for (int i = 0; i < rotatingObjects.Count; i++)
        {
            GameObject currentRotatingObj = Instantiate(rotatingObject, rotatingObjects[i].position, Quaternion.identity);
            currentRotatingObj.transform.localScale = rotatingObjects[i].scale;
            currentRotatingObj.GetComponent <RotatingObjectScript>().isTrampoline         = rotatingObjects[i].isTrampoline;
            currentRotatingObj.GetComponent <RotatingObjectScript>().isTrampolinedToRight = rotatingObjects[i].isTrampolinedRight;
        }

        for (int i = 0; i < obstaclePositions.Count; i++)
        {
            Instantiate(obstacle, obstaclePositions[i], Quaternion.identity);
        }
    }