Beispiel #1
0
    private void OnTriggerExit(Collider other)
    {
        if (gameMode.isGameOver)
        {
            return;
        }

        if (other.gameObject.tag.Equals("GravityField"))
        {
            GameObstacle obstacleObj = SharedUtilities.GetInstance().GetFirstComponentInParentWithTag <GameObstacle>(other.gameObject, "Obstacle");
            gravityFieldsGens.Remove(obstacleObj);
        }
        else if (other.gameObject.tag.Equals("DangerZone"))
        {
            if (dangerZoneCount == 1 && !skillManager.isAntiGravityActive)
            {
                movementManager.GravitySling();
            }
            dangerZoneCount = dangerZoneCount > 0 ? dangerZoneCount - 1 : 0;

            if (dangerZoneCount == 0)
            {
                hudManagerInstance.EnableHighGravityFieldPanel(false);
            }
        }
        if (other.gameObject.tag.Equals("Margins"))
        {
            directionArrow.gameObject.SetActive(false);
        }
    }
Beispiel #2
0
 void Start()
 {
     go        = GetComponent <GameObstacle> ();
     startTime = Time.time;
     waitTime  = Random.Range(minTimeBeforeSwitch, maxTimeBeforeSwitch);
     color     = startColor;
     go.SetColor(color);
 }
Beispiel #3
0
    //Collision and triggers
    private void OnCollisionEnter(Collision collision)
    {
        if (gameMode.isGameOver)
        {
            return;
        }

        if (collision.collider.tag == "Obstacle")
        {
            movementManager.ResetMovementSpeed();
            dangerZoneCount--;
            GameObstacle obstacle = collision.gameObject.GetComponent <GameObstacle>();
            gravityFieldsGens.Remove(obstacle);

            if (dangerZoneCount == 0)
            {
                hudManagerInstance.EnableHighGravityFieldPanel(false);
            }

            CameraShaker.Instance.ShakeOnce(shakeMagnitude, shakeRoughness, shakeFadeInTime, shakeFadeOutTime);

            if (!extraManager.isShielded)
            {
                float damage = 0;
                switch (obstacle.type)
                {
                case Obstacle.ObstacleType.PLANET:
                    damage = 60f;
                    break;

                case Obstacle.ObstacleType.STAR:
                    damage = 80f;
                    break;

                case Obstacle.ObstacleType.WHITE_DWARF:
                    damage = 120f;
                    break;

                case Obstacle.ObstacleType.NEUTRON_STAR:
                    damage = 160f;
                    break;
                }
                TakeDamage(damage);
            }
            else
            {
                extraManager.DestroyShield();
                gameMode.BonusScore(GameplayMath.GetInstance().GetBonusPointsFromObstacleMass(obstacle.mass));
                skillManager.sessionObstaclesDestroyed++;
            }
            sessionObstaclesHit++;
        }
    }
Beispiel #4
0
 void Update()
 {
     if (go == null)
     {
         go = GetComponent <GameObstacle> ();
     }
     if (Mathf.Floor(color.r * 100) == Mathf.Floor(nextColor.r * 100))
     {
         nextColor = new Color(Random.Range(0.2f, 0.8f), Random.Range(0.2f, 0.8f), Random.Range(0.2f, 0.8f), 1f);
     }
     color = Color.Lerp(color, nextColor, 0.1f);
     go.SetColor(color);
 }
Beispiel #5
0
 public void OnCollisionDefault(Collider2D other)
 {
     if (other.CompareTag("Obstacle"))
     {
         GameObstacle go = other.gameObject.GetComponent <GameObstacle> ();
         if (go.GetColor() != mr.material.color)
         {
             if (onDeath != null)
             {
                 onDeath();
             }
         }
     }
 }
Beispiel #6
0
    public float GetGravityTd(GameObject player, GameObstacle obstacle)
    {
        float intern = (float)(1f - ((Td_constant * obstacle.mass) / Vector3.Magnitude(player.transform.position - obstacle.transform.position)));
        float result;

        if (intern <= 0.10f)
        {
            return(4f);
        }
        else
        {
            result = (1f / Mathf.Sqrt(intern));
        }
        return(result);
    }
Beispiel #7
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.CompareTag("Obstacle"))
     {
         GameObstacle go = collider.gameObject.GetComponent <GameObstacle> ();
         if (go.GetColor() != mr.material.color)
         {
             GameObject explPrefab = Resources.Load <GameObject> ("PowerIcons/ExploDeath");
             if (onDeath != null)
             {
                 GameObject g = Instantiate(explPrefab) as GameObject;
                 g.transform.position = transform.position;
                 onDeath();
             }
         }
     }
 }
Beispiel #8
0
 void Update()
 {
     if (go == null)
     {
         go = GetComponent <GameObstacle> ();
     }
     if (go.GetColor() != color)
     {
         go.SetColor(color);
     }
     if (Time.time - startTime >= waitTime)
     {
         startTime = Time.time;
         waitTime  = Random.Range(minTimeBeforeSwitch, maxTimeBeforeSwitch);
         color     = color.r == 0f ? Color.white : Color.black;
         go.SetColor(color);
     }
 }
Beispiel #9
0
    private void OnTriggerEnter(Collider other)
    {
        if (gameMode.isGameOver)
        {
            return;
        }

        if (other.gameObject.tag.Equals("GravityField"))
        {
            GameObstacle obstacleObj = SharedUtilities.GetInstance().GetFirstComponentInParentWithTag <GameObstacle>(other.gameObject, "Obstacle");
            if (!gravityFieldsGens.Contains(obstacleObj))
            {
                gravityFieldsGens.Add(obstacleObj);
            }
        }

        else if (other.gameObject.tag.Equals("DangerZone"))
        {
            dangerZoneCount++;
            hudManagerInstance.EnableHighGravityFieldPanel(true);
        }
    }
Beispiel #10
0
 void Awake()
 {
     instance = this;
 }
Beispiel #11
0
 private void OnEnable()
 {
     script          = (GameObstacle)target;
     so              = new SerializedObject(script);
     stringsProperty = so.FindProperty("materialsPool");
 }
Beispiel #12
0
    public float GetObstacleMass(GameObstacle obstacle)
    {
        float radius = obstacle.targetScale / 2f;

        return((radius * radius * radius) * (4 / 3f) * Mathf.PI * obstacle.density);
    }