Ejemplo n.º 1
0
 private void Start()
 {
     cachedTransform = transform;
     cachedRigidbody = GetComponent <Rigidbody>();
     cachedCollider  = GetComponent <SphereCollider>();
     data            = Resources.Load <BallData>(BALL_FOLDER + ballType.ToString());
     hp            = data.hp;
     ballSpeed     = data.speed;
     rotationSpeed = data.rotationSpeed;
 }
Ejemplo n.º 2
0
        public string DrawBall(DrawType drawType)
        {
            SetStats();
            if (isFreeDraw == true)
            {
                drawType = DrawType.Free;
            }

            if (drawType == DrawType.Paid)
            {
                if (alottedCredit > drawCost && leftRounds > 0)
                {
                    alottedCredit -= drawCost;
                    spentCredit   += drawCost;
                    leftRounds    -= 1;
                    drawnBall      = CalculateProbablityNextBall();

                    var query = entities.DrawGameStats.SingleOrDefault(x => x.GameID == gameID);
                    if (query != null)
                    {
                        query.CreditAlotted = alottedCredit;
                        query.SpentCredit   = spentCredit;
                        query.LeftRounds    = leftRounds;
                        entities.SaveChanges();
                    }
                    CheckDrawResult(drawnBall);
                    return(drawnBall.ToString());
                }
                else
                {
                    return(OnGameOver());
                }
            }
            else
            {
                isFreeDraw = false;
                var query = entities.DrawGameStats.SingleOrDefault(x => x.GameID == gameID);
                if (query != null)
                {
                    query.FreeDraw = isFreeDraw.ToString();
                    entities.SaveChanges();
                }
                drawnBall = CalculateProbablityNextBall();
                CheckDrawResult(drawnBall);
                return(drawnBall.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ボールプレハブをインスタンス化し生成する
        /// </summary>
        private BallController generateBall(BallType ballType, Point point)
        {
            /// BoardPointの数値から、具体的な座標を計算し、生成する
            var newBallPos = convertPointToPos(point);

            var newBall = Instantiate(BallPrefab, newBallPos, Quaternion.identity);

            newBall.name = ballType.ToString();
            /// コントローラーセットアップ
            var ballContorller = newBall.GetComponent <BallController>();

            if (ballContorller != null)
            {
                ballContorller.setSprite(selectBallSprite(ballType));
                ballContorller.ballType   = ballType;
                ballContorller.boardPoint = point;
            }

            return(ballContorller);
        }
Ejemplo n.º 4
0
        public void AddBall(object t)
        {
            BallType type = (BallType)t;
            string   name = type.ToString();

            GameObject o = Instantiate((GameObject)Resources.Load(name)) as GameObject;

            o.transform.SetParent(m_CustomBallRoot.transform);
            o.transform.localRotation = Quaternion.identity;
            //o.transform.localPosition = new Vector3(-7.6f, -2.3f, 0);

            Texture2D   tex  = Resources.LoadAssetAtPath <Texture2D>("Assets/Images/EditorTextures/" + name + ".png");
            Rect        rect = new Rect(backgroundHitPoint.x, backgroundHitPoint.y, m_GridSize * 2, m_GridSize * 2);
            TouchObject to   = new TouchObject()
            {
                transform = o.transform, id = o.GetInstanceID(), texture = tex, type = type, rect = rect
            };

            m_Balls.Add(to.id, to);

            //GetBallObjectsRect();
        }
Ejemplo n.º 5
0
        private void Start()
        {
            Up = Vector3.up;

            //Set up drifty smoke
            smoke            = Instantiate(prefabs.Smoke);
            smoke.target     = this;
            smoke.DriftAudio = sounds.Brake;


            //Grab reference to Rigidbody
            rb = GetComponent <Rigidbody>();
            //Set angular velocity (This is necessary for fast)
            rb.maxAngularVelocity = 1000f;

            //Set object name
            gameObject.name = type.ToString() + " - " + nickname;

            //Set character
            if (CharacterId >= 0 && CharacterId < ActiveData.Characters.Length)
            {
                SetCharacter(ActiveData.Characters[CharacterId]);
            }

            //Set up speed effect
            speedFire = Instantiate(prefabs.SpeedFire);
            speedFire.Init(this);

            //Crimbus
            DateTime now = DateTime.Now;

            if (now.Month == 12 && now.Day > 20 && now.Day <= 31)
            {
                hatPrefab = ActiveData.ChristmasHat;
            }

            if (ActiveData.GameSettings.eSportsReady)
            {
                hatPrefab = ActiveData.ESportsHat;
            }

            //Spawn hat
            if (hatPrefab)
            {
                GameObject hat = Instantiate(hatPrefab);
                hat.transform.SetParent(transform, false);
            }

            //Create objects and components based on ball type
            if (type == BallType.Player)
            {
                if (ctrlType != ControlType.None)
                {
                    IBallCamera camera;
                    //Create camera
                    if (ActiveData.GameSettings.useOldControls)
                    {
                        camera = Instantiate(prefabs.OldCamera);
                        ((PivotCamera)camera).UseMouse = ctrlType == ControlType.Keyboard;
                    }
                    else
                    {
                        camera = Instantiate(prefabs.Camera);
                    }
                    camera.Target   = rb;
                    camera.CtrlType = ctrlType;

                    if (CameraCreated != null)
                    {
                        CameraCreated(this, new CameraCreationArgs(camera));
                    }
                }
            }
            if (type == BallType.LobbyPlayer)
            {
                //Make the lobby camera follow this ball
                var cam = FindObjectOfType <LobbyCamera>();
                if (cam)
                {
                    cam.AddBall(this);
                }
            }
            if ((type == BallType.Player || type == BallType.LobbyPlayer) && ctrlType != ControlType.None)
            {
                //Create input component
                input = gameObject.AddComponent <BallControlInput>();
            }
            if (type == BallType.AI)
            {
                //Create AI component
                gameObject.AddComponent <BallControlAI>();
            }
        }