コード例 #1
0
    void SpawnBall()
    {
        if (!shouldSpawn)
        {
            return;
        }

        if (totalSpawned >= maxBallsToSpawn)
        {
            return;
        }

        int totalBalls = balls.Count;

        if (totalBalls >= maxConcurrentBallsInArena)
        {
            return;
        }

        //Debug.Log("total balls: " + totalBalls + ", totalSpawned" + totalSpawned);

        Ball.BallType ballTypeToSpawn = NextBallType();
        //Debug.Log("creating " + ballTypeToSpawn);

        // spawn ball
        GameObject ballGameObjectToSpawn = GetBallPFByType(ballTypeToSpawn);

        if (ballGameObjectToSpawn != null)
        {
            GameObject spawnedBall = Instantiate(ballGameObjectToSpawn, spawnVec, Quaternion.identity) as GameObject;
            spawnedBall.GetComponent <Rigidbody>().AddForce(Vector3.forward * force, ForceMode.Acceleration);
            balls.Add(spawnedBall);
            totalSpawned++;
        }
    }
コード例 #2
0
ファイル: Ball.cs プロジェクト: tnn112710/lines98
    public PrepareBall(GameConfig config)
    {
        float rnd1 = UnityEngine.Random.Range(0f, 1f);

        if (rnd1 < config.GhostChance)
        {
            if (config.CanSpawnGhost)
            {
                Type = Ball.BallType.Ghost;
            }
            else
            {
                Type = Ball.BallType.Normal;
            }
        }
        else if (rnd1 < config.GhostChance + config.RainbowChance)
        {
            if (config.CanSpawnRainbow)
            {
                Type = Ball.BallType.Rainbow;
            }
            else
            {
                Type = Ball.BallType.Normal;
            }
        }
        else if (rnd1 < config.GhostChance + config.RainbowChance + config.BombChance)
        {
            if (config.CanSpawnBomb)
            {
                Type = Ball.BallType.Bomb;
            }
            else
            {
                Type = Ball.BallType.Normal;
            }
        }
        else if (rnd1 < config.GhostChance + config.RainbowChance + config.BombChance + config.StoneChance)
        {
            if (config.CanSpawnStone)
            {
                Type = Ball.BallType.Stone;
            }
            else
            {
                Type = Ball.BallType.Normal;
            }
        }
        else
        {
            Type = Ball.BallType.Normal;
        }

        if (Type == Ball.BallType.Normal)
        {
            int rnd2 = UnityEngine.Random.Range(0, (int)Ball.BallColor.Count);
            this.Color = (Ball.BallColor)rnd2;
        }
    }
コード例 #3
0
    void Start()
    {
        gameController = GameObject.FindGameObjectWithTag("GameController");

        if (GameMaster.instance.g_coop == false)
        {
            brickType = Ball.BallType.Grey;
            GetComponent <SpriteRenderer>().sprite = greyBrick;
        }
    }
コード例 #4
0
    public void InstallGlasses()
    {
        var ballIndex = 0;

        for (int i = 0; i < glassCount; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                Ball.BallType tempValue = (Ball.BallType)ballColor[ballIndex];
                Glasses[i].transform.GetChild(j).GetComponent <Ball>().ballType = tempValue;
                ballIndex++;
            }
        }
    }
コード例 #5
0
    private Ball.BallType NextBallType()
    {
        if (typesStack.Count() == 0)
        {
            NewBallTypesStack();
        }

        // generate next ball type randomly by weight
        Random.InitState(System.DateTime.Now.Millisecond); // make randow seem more random
        int randomIndex = Random.Range(0, typesStack.Count());

        Ball.BallType ballType = typesStack[randomIndex];
        typesStack.RemoveAt(randomIndex);

        return(ballType);
    }
コード例 #6
0
 public void CheckSwipe(Ball.BallType type)
 {
     if (_activeBall.Type == type)
     {
         HandleStar();
         StartCoroutine(DestroyBall());
     }
     else
     {
         LivesLeftCounter.text = (--_livesLeft).ToString();
         _incorrectSwipes++;
         if (_livesLeft <= 0)
         {
             LevelFailed();
         }
     }
 }
コード例 #7
0
    //private Ball.BallType NextBallType()
    //{
    //    // generate next ball type randomly by weight
    //    Random.seed = System.DateTime.Now.Millisecond; // make randow seem more random
    //    int randomWeight = Random.Range(1, totalWeight+1); // returns 1-total
    //    int currentWeight = 0;

    //    foreach (WeightBallType wbt in weights)
    //    {
    //        currentWeight += wbt.weight;

    //        if (randomWeight <= currentWeight)
    //        {
    //            return wbt.ballType;
    //        }
    //    }

    //    return Ball.BallType.green; // we should not get here
    //}

    //private int GetNumBallsByType(Ball.BallType ballType)
    //{
    //    int val = balls.Where(ball => ball.GetComponent<Ball>().ballType == ballType).Count();
    //    Debug.Log("total " + ballType + ":" + val);
    //    return val;
    //}

    private GameObject GetBallPFByType(Ball.BallType ballType)
    {
        Ball val = ballTypes.Where(ball => ball.ballType == ballType).First();

        return(val.gameObject);
    }
コード例 #8
0
 public WeightBallType(int weight, Ball.BallType ballType) : this()
 {
     this.weight   = weight;
     this.ballType = ballType;
 }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: dezet98/Billiards
 private void AssignBallToPlayer(Ball.BallType ballType)
 {
     playersBalls[playerTurn]           = ballType;
     playersBalls[(playerTurn + 1) % 2] = ballType == Ball.BallType.Solid ? Ball.BallType.Stripe : Ball.BallType.Solid;
 }