Beispiel #1
0
    void Start()
    {
        boxCollider = GetComponent <BoxCollider>();
        boxMin      = boxCollider.bounds.min;
        boxMax      = boxCollider.bounds.max;
        for (int i = 0; i < sphereAmount; i++)
        {
            SetSpherePosition();
            GameObject spawnSphere = Instantiate(sphere, spawnPos, Quaternion.identity, transform);
            GameSphere gameSphere  = spawnSphere.GetComponent <GameSphere>();
            if (i == 0)
            {
                gameSphere.sphereStats.PowerUpUI.PowerUp = PowerUp.speedUp;
            }
            if (i == 1)
            {
                gameSphere.sphereStats.PowerUpUI.PowerUp = PowerUp.shield;
            }
            if (i == 2)
            {
                gameSphere.sphereStats.PowerUpUI.PowerUp = PowerUp.reinforcements;
            }
        }

        boxCollider.enabled = false;
    }
Beispiel #2
0
    public void CopyWithReflection()
    {
        copyingFrom = this;
        Type sphereType = typeof(GameSphere);

        FieldInfo[] sphereFields = sphereType.GetFields(BindingFlags.Public | BindingFlags.Instance);
        fields = sphereFields;
    }
Beispiel #3
0
    public void ResetPowerUp()
    {
        buttonClock.color = Color.white;
        PowerUpPreset POPreset = SphereManager.Instance.powerUpPresets.Where(item => item.button == button)
                                 .FirstOrDefault();

        ResetButton(POPreset);

        GameSphere SphereReset = SphereManager.Instance.spheres.Where(item => item.sphereStats.PowerUpUI.PowerUp == powerUp)
                                 .FirstOrDefault();

        ResetSphere(SphereReset);
    }
Beispiel #4
0
 private void OnTriggerEnter(Collider collision)
 {
     if (origin != null)
     {
         if (collision.tag == "Shield" && originOwner == SphereOwner.opponent)
         {
             gameObject.SetActive(false);
         }
         else if (collision.gameObject == target)
         {
             GameSphere sphere = collision.GetComponent <GameSphere>();
             if (originOwner == SphereOwner.player)
             {
                 if (sphere.sphereStats.SphereOwner == SphereOwner.player)
                 {
                     sphere.sphereStats.Points++;
                 }
                 else
                 {
                     sphere.sphereStats.Points--;
                     if (sphere.sphereStats.Points < 0)
                     {
                         sphere.sphereStats.SphereOwner = SphereOwner.player;
                         sphere.sphereStats.Points++;
                     }
                 }
             }
             else
             {
                 if (originOwner == SphereOwner.opponent)
                 {
                     if (sphere.sphereStats.SphereOwner == SphereOwner.opponent)
                     {
                         sphere.sphereStats.Points++;
                     }
                     else
                     {
                         sphere.sphereStats.Points--;
                         if (sphere.sphereStats.Points < 0)
                         {
                             sphere.sphereStats.SphereOwner = SphereOwner.opponent;
                             sphere.sphereStats.Points++;
                         }
                     }
                 }
             }
             gameObject.SetActive(false);
         }
     }
 }
Beispiel #5
0
 public void SetOrigin(GameSphere sphereOrigin)
 {
     this.origin  = sphereOrigin.gameObject;
     originSphere = sphereOrigin;
     originOwner  = originSphere.sphereStats.SphereOwner;
     if (originOwner == SphereOwner.opponent)
     {
         trail.colorGradient = SphereManager.Instance.gameData.player2Points;
     }
     else
     {
         trail.colorGradient = SphereManager.Instance.gameData.player1Points;
     }
 }
Beispiel #6
0
        private IEnumerator TransferPointsRoutine(GameSphere fromSphere, GameSphere toSphere)
        {
            if (fromSphere == toSphere)
            {
                yield return(null);
            }
            int halfPoints = fromSphere.sphereStats.Points / 2;

            for (int i = 0; i < halfPoints; i++)
            {
                Vector3      spawnLocation = fromSphere.transform.position + new Vector3(Random.Range(-gameData.spawnRadius, gameData.spawnRadius), Random.Range(-gameData.spawnRadius, gameData.spawnRadius), Random.Range(-gameData.spawnRadius, gameData.spawnRadius));
                GameObject   particle      = ObjectPooler.instance.GetPooledObject(spawnLocation, Quaternion.identity);
                MoveToTarget move          = particle.GetComponent <MoveToTarget>();
                move.SetOrigin(fromSphere);
                move.SetTarget(toSphere.gameObject);
                fromSphere.sphereStats.Points--;
                yield return(new WaitForSeconds(.05f));
            }
            yield return(null);
        }
Beispiel #7
0
 private void ResetSphere(GameSphere resetSphere)
 {
     resetSphere.sphereStats.PowerUpUI.sphereClock.fillAmount = 0;
     resetSphere.sphereStats.PowerUpUI.PowerActive            = false;
 }
Beispiel #8
0
 /// <summary>
 /// send particles from sphere to sphere
 /// </summary>
 /// <param name="fromSphere">can be multiple spheres</param>
 /// <param name="toSphere">can be only one sphere</param>
 public void TransferPoints(GameSphere fromSphere, GameSphere toSphere)
 {
     StartCoroutine(TransferPointsRoutine(fromSphere, toSphere));
 }
Beispiel #9
0
 public void DeleteSelectedSphere(GameSphere gameSphere)
 {
     var tempSphere = selectedSpheres.Where(item => item == gameSphere).Select(item => selectedSpheres.Remove(item));
 }