Exemple #1
0
 public GenerateBalls(BallPoint sizePole, MiningSceneViewDescription miningViewDescription, BallPool ballPool)
 {
     _sizeGamePole          = sizePole;
     _typeBallResource      = miningViewDescription.TypeBallResource;
     _countColor            = miningViewDescription.Balls.Count;
     _percentageResources   = miningViewDescription.PercentageResources;
     _resources             = new ResourcesCount(miningViewDescription.TypeResources, miningViewDescription.CountResource);
     _miningViewDescription = miningViewDescription;
     _ballPool = ballPool;
 }
Exemple #2
0
 public Sprite GetSprite(TypeBall typeBall, bool isOre)
 {
     if (isOre)
     {
         return(_spritesOre[typeBall]);
     }
     else
     {
         return(_spritesWithoutOre[typeBall]);
     }
 }
Exemple #3
0
 public BallController(BallView ballView, int xPositinon, int yPosition, TypeBall typeBall, ResourcesCount typeResources)
 {
     _ballView      = ballView;
     _xPositinon    = xPositinon;
     _yPosition     = yPosition;
     _typeBall      = typeBall;
     _typeResources = typeResources;
     _moveAnimator  = _ballView.MoveAnimator;
     _ballView.PointerObject.BallMoveSide += PointerObject_BallMoveSide;
     _ballView.MoveAnimator.EndAnimation  += OnEndAnimation;
     _isChanged = true;
 }
Exemple #4
0
    void Shooting()
    {
#if UNITY_EDITOR
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            GameObject       oGame     = (GameObject)Instantiate(ChildBullet, ChildBullet.transform.position, ChildBullet.transform.rotation);
            CircleCollider2D cCollider = oGame.GetComponent <CircleCollider2D>();
            TypeBall         T         = oGame.GetComponent <TypeBall>();
            T.enabled         = true;
            cCollider.enabled = true;
            Rigidbody2D rigitInst      = oGame.GetComponent <Rigidbody2D>();
            Vector2     velocity       = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
            float       velocityLength = Vector2.Distance(Camera.main.ScreenToWorldPoint(Input.mousePosition), transform.position);
            oGame.transform.parent = transform.parent;
            rigitInst.velocity     = velocity * Speed / velocityLength;
            GameObject Previous = ChildBullet;
            ChildBullet = (GameObject)Instantiate(Balls[NextObjectIndex], ChildBullet.transform.position, ChildBullet.transform.rotation);
            ChildBullet.transform.parent = Previous.transform.parent;
            NextObjectIndex   = (byte)Random.Range(0, Balls.Length - 0.0001f);
            spriteBall.sprite = Sprite_Balls[NextObjectIndex];

            Destroy(Previous);
        }
#elif UNITY_ANDROID
        if (Input.touchCount > 0)
        {
            foreach (Touch touch in Input.touches)
            {
                if (touch.phase == TouchPhase.Ended)
                {
                    GameObject       oGame     = (GameObject)Instantiate(ChildBullet, ChildBullet.transform.position, ChildBullet.transform.rotation);
                    CircleCollider2D cCollider = oGame.GetComponent <CircleCollider2D>();
                    TypeBall         T         = oGame.GetComponent <TypeBall>();
                    T.enabled         = true;
                    cCollider.enabled = true;
                    Rigidbody2D rigitInst      = oGame.GetComponent <Rigidbody2D>();
                    Vector2     velocity       = Camera.main.ScreenToWorldPoint(touch.position) - transform.position;
                    float       velocityLength = Vector2.Distance(Camera.main.ScreenToWorldPoint(touch.position), transform.position);
                    oGame.transform.parent = transform.parent;
                    rigitInst.velocity     = velocity * Speed / velocityLength;
                    GameObject Previous = ChildBullet;
                    ChildBullet = (GameObject)Instantiate(Balls[NextObjectIndex], ChildBullet.transform.position, ChildBullet.transform.rotation);
                    ChildBullet.transform.parent = Previous.transform.parent;
                    NextObjectIndex   = (byte)Random.Range(0, Balls.Length - 0.0001f);
                    spriteBall.sprite = Sprite_Balls[NextObjectIndex];

                    Destroy(Previous);
                }
            }
        }
#endif
    }
Exemple #5
0
 void fPutBall(Collider2D coll, TypeBall ColorBall)
 {
     ColorBall.Delete = false;
     Destroy(coll.gameObject.GetComponent <Rigidbody2D>());
     coll.gameObject.GetComponent <CircleCollider2D>().enabled = false;
     for (int i = 0; i < coll.gameObject.transform.childCount; i++)
     {
         coll.gameObject.transform.GetChild(i).gameObject.SetActive(false);
     }
     coll.transform.position = PositionBall.position;
     coll.transform.rotation = PositionBall.rotation;
     IsFilling = true;
     coll.gameObject.transform.parent = transform;
 }
Exemple #6
0
        public BallController GenerateRandomBall(BallPoint position)
        {
            List <TypeBall> ballsTypes = GetTypesBall();
            var             indexColor = _rand.Next(0, ballsTypes.Count);
            TypeBall        typeBall   = ballsTypes[indexColor];
            ResourcesCount  resources  = null;

            if (typeBall == _typeBallResource)
            {
                float chance = _rand.Next(0, 100) / 100F;
                if (chance < _percentageResources)
                {
                    resources = _resources;
                }
            }
            return(new BallController(_ballPool.FreeBall, position, typeBall, resources));
        }
Exemple #7
0
        public BallController GenerateBall(List <TypeBall> ballsTypes)
        {
            var      indexColor = _rand.Next(0, ballsTypes.Count);
            TypeBall typeBall   = ballsTypes[indexColor];

            ballsTypes.Remove(typeBall);
            ResourcesCount resources = null;

            if (typeBall == _typeBallResource)
            {
                float chance = _rand.Next(0, 100) / 100F;
                if (chance < _percentageResources)
                {
                    resources = _resources;
                }
            }
            return(new BallController(_ballPool.FreeBall, _generatePosition, typeBall, resources));
        }
Exemple #8
0
    IEnumerator WaitAndDestroy(float wait, Ring r)
    {
        yield return(new WaitForSeconds(wait));

        TypeBall ball = r.gameObject.GetComponentInChildren <TypeBall>();

        r.gameObject.GetComponent <SpriteRenderer>().enabled = false;
        CircleCollider2D circle = r.gameObject.GetComponentInChildren <CircleCollider2D>();

        particleSystem.SetActive(true);
        circle.enabled = false;

        Anim.SetInteger("On", 1);

        if (ball.gameObject)
        {
            Destroy(ball.gameObject);
        }
    }
Exemple #9
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        TypeBall ColorBall = coll.gameObject.GetComponent <TypeBall>();

        if (ColorBall)
        {
            if (!IsFilling)
            {
                if (ColorBall.typeBall == typeRing)
                {
                    fPutBall(coll, ColorBall);
                    ObjectBall = coll.gameObject;
                    fFusionBalls();
                }
                else
                {
                }
            }
            else
            {
                Destroy(coll);
            }
        }
    }
Exemple #10
0
 public BallController(BallView ballView, BallPoint position, TypeBall typeBall, ResourcesCount typeResources) : this(ballView, position.X, position.Y, typeBall, typeResources)
 {
 }
Exemple #11
0
 public Color GetColor(TypeBall typeBall)
 {
     return(_colors[typeBall]);
 }