Inheritance: MonoBehaviour
コード例 #1
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    void Awake()
    {
        //Get the managers requiered to spawn balls.
        levelManager     = GameObject.FindGameObjectWithTag("LevelManager");
        ballManager      = levelManager.GetComponent <BallManager>();
        maxNumberOfBalls = ballManager.maxNumberOfBalls;

        //Get the players health.
        player       = GameObject.FindGameObjectWithTag("Player").transform;
        playerHealth = player.GetComponent <PlayerHealth>();

        //Get the player range detector from the child. It is this big cos is uses the same behavior as EnemyMovement so GetComponentInChildren can't guarantee getting the right instance of the code for
        //the behavior desiered.
        GameObject PlayerFiringRange = transform.Find("PlayerFiringRange").gameObject;

        if (PlayerFiringRange != null)
        {
            Debug.Log("PlayerFiringRange was found");
            PlayerFiringRangeCode = PlayerFiringRange.GetComponent <EnemyPlayerDetector>();
            if (PlayerFiringRangeCode != null)
            {
                Debug.Log("PlayerFiringRangeCode obtained");
            }
        }

        //Set the timer and start invokeing the method to spawn balls.
        spawnTimer = Random.Range(20, 40) / 10;
        InvokeRepeating("CreateBall", spawnTimer, spawnTimer);
    }
コード例 #2
0
 void Start()
 {
     //The only way that I find out to access to the components is by tags or GameObject.Find...
     ball = GameObject.FindGameObjectWithTag("Ball").GetComponent <BallManager>();
     p1   = GameObject.FindGameObjectWithTag("Left").GetComponent <PaddleController>();
     p2   = GameObject.FindGameObjectWithTag("Right").GetComponent <PaddleController>();
 }
コード例 #3
0
    // Created: River
    // Date: 1/9/2016
    // Time: 3:40
    void Start()
    {
        obj = GameObject.FindGameObjectWithTag("Timer");

        if (obj != null)
        {
            tmr = obj.GetComponent <Timer>();
        }

        GameObject temp = GameObject.FindGameObjectWithTag("GameController");

        if (temp != null)
        {
            m_ballManagerManager = temp.GetComponent <BallManager>();

            if (m_ballManagerManager == null)
            {
                Debug.Log("Missing BallManager on GameController");
            }
        }
        else
        {
            Debug.Log("Missing Gamecontroller make sure gamecontroller is tagged as GameController");
        }
    }
コード例 #4
0
 private void Start()
 {
     soundsManager   = GameObject.Find("SoundsManager").GetComponent <SoundsManager>();
     lightsManager   = GameObject.Find("LightsManager").GetComponent <LightsManager>();
     _ballManager    = FindObjectOfType <BallManager>();
     _missionManager = FindObjectOfType <MissionManager>();
 }
コード例 #5
0
 // Start is called before the first frame update
 void Start()
 {
     if (ballManagerInstance == null)
     {
         ballManagerInstance = this;
     }
 }
コード例 #6
0
ファイル: Buttons.cs プロジェクト: UnverOnal/JumpingBall
 private void Start()
 {
     mainCanvas          = FindObjectOfType(typeof(Canvas)) as Canvas;
     uiManager           = UiManager.Instance;
     ballManager         = BallManager.Instance;
     touchControlManager = TouchControlManager.Instance;
 }
コード例 #7
0
 /// <summary>
 /// Start is called before the first frame update.
 /// </summary>
 void Start()
 {
     levelManager     = GameObject.FindGameObjectWithTag("LevelManager");
     ballManager      = levelManager.GetComponent <BallManager>();
     maxNumberOfBalls = ballManager.maxNumberOfBalls;
     InvokeRepeating("CreateBall", spawnTimer, spawnTimer);
 }
コード例 #8
0
    //makes next level configurations
    public void ContinueToNextLevel(BallManager ballManager, GameDatas gameDatas)
    {
        //makes enable level passed element
        levelPassedScreen.SetActive(true);

        //doesn't allow the collider of the last ring's slices collide
        ballManager.canCollide = false;

        //pauses the game
        Time.timeScale = 0f;

        //save level count
        gameDatas.LevelCount += 1;
        SaveLoad.gameDatas    = gameDatas;
        SaveLoad.Save();

        //save platform count
        if (gameDatas.PlatformCount < maxPlatformCount)
        {
            gameDatas.PlatformCount += 1;
            SaveLoad.gameDatas       = gameDatas;
            SaveLoad.Save();
        }

        StartCoroutine(DissapearLevelPassedScreen(ballManager));
    }
コード例 #9
0
 //this occurs after Start
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
コード例 #10
0
ファイル: PopBall.cs プロジェクト: mirkomantovani/BubbleVR
    //divide due to effect of bomb
    public void Divide()
    {
        float bullVelX = 0.1f;
        float bullVelZ = 0.1f;

        float norm = (float)Math.Sqrt(bullVelX * bullVelX + bullVelZ * bullVelZ);

        bullVelZ = bullVelZ * 5;
        bullVelX = bullVelX * 5;

        Transform trans = gameObject.transform;

        DestroyBall(gameObject);
        float velY = ComputeInitialYVelocity(trans.position.y);

        //Debug.Log(velY);

        trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z);
        GameObject newBall = (GameObject)Instantiate(ball2, trans.position, trans.rotation);

        BallManager.AddBall(newBall);
        newBall.GetComponent <Rigidbody>().velocity = new Vector3(-bullVelZ, 0, bullVelX);

        newBall.GetComponent <AudioSource>().Play();

        trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z);
        GameObject newBall2 = (GameObject)Instantiate(ball2, trans.position, trans.rotation);

        BallManager.AddBall(newBall2);
        newBall2.GetComponent <Rigidbody>().velocity = new Vector3(bullVelZ, 0, -bullVelX);
    }
コード例 #11
0
ファイル: Classical.cs プロジェクト: mirkomantovani/BubbleVR
    private void StartNewLevel()
    {
        if (!playing)
        {
            return;
        }

        BallManager.ExplodeBalls();
        BallManager.ExplodeBalls();
        BallManager.ExplodeBalls();

        Level += 1;
        GameModeText.SetText("Classical : Level " + Level);
        CancelAllInvokes();
        StartRecursiveRandomBallGenerator(GenerateTimingFromLevel());

        if (Level != 1)
        {
            SpawnRandomSpecialItem();
        }

        if (playing)
        {
            Invoke("StartNewLevel", 60);
        }
    }
コード例 #12
0
    protected override void SetupBall(int index)
    {
        // Retrieve the proper position of the ball according to the provided index
        Vector3 position = Utils.GetBallPosition(index, true);

        // Create the ball
        Transform ts_Ball = Instantiate(this.go_Ball.transform, position, Quaternion.identity);
        Ball      ball    = ts_Ball.GetComponent <Ball>();

        // Attach the ball to the opponent row parent
        ball.transform.parent = this.transform;

        // Select a random color
        int random_index = Random.Range(0, 8);

        BallManager.Color color = BallManager.GetColor(random_index);

        // Setup the ball
        ball.SetIndex(index);
        ball.SetColor(color);
        ball.SetParentRow(this);
        ball.SetIsOpponent(true);

        // Add the current ball to the record
        this.m_balls.Add(ball);
    }
コード例 #13
0
 // Use this for initialization
 void Start()
 {
     _gameManager  = GameObject.Find("GameCtrl").GetComponent <GameManager>();
     _ballManager  = _gameManager._ballManager;
     _blockManager = _gameManager._blockManager;
     myType        = Const.ItemType.NONE;
 }
コード例 #14
0
ファイル: MouseManager.cs プロジェクト: Zalarox/unity-sorting
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 mouseWorldPos3D = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mousePos2D      = new Vector2(mouseWorldPos3D.x, mouseWorldPos3D.y);
            Vector2 dir             = Vector2.zero;

            RaycastHit2D hit = Physics2D.Raycast(mousePos2D, dir);             // if we don't hit anything, it will be null

            if (hit.collider != null && !hit.collider.GetComponent <BallManager>().hasEntered)
            {
                // hit has a reference to collider, which has reference to all collider objects including this
                if (hit.collider.GetComponent <Rigidbody2D>() != null)
                {
                    // technically it doesn't involve any sort of motion/forces so it went here instead of fixedupdate, and that's okay.
                    // it means, on the next physics tick (whenever), apply/make sure this is so.
                    oGrabbedObject             = hit.collider.GetComponent <BallManager>();
                    grabbedObject              = hit.collider.GetComponent <Rigidbody2D>();       // we just grabbed it.
                    grabbedObject.gravityScale = 0;
                    lineDrag.enabled           = true;
                }
            }
        }

        if (Input.GetMouseButtonUp(0) && grabbedObject != null)            // when i lift up the mouse button, don't keep my object glued to it.
        {
            grabbedObject.gravityScale = 1;
            grabbedObject    = null;
            lineDrag.enabled = false;
        }
    }
コード例 #15
0
    // Start is called before the first frame update
    void Start()
    {
        //add initial movement
        rB2D = GetComponent <Rigidbody2D>();

        //get information about paddle
        paddle           = GameObject.FindGameObjectWithTag("Paddle");
        paddleDimensionY = paddle.GetComponent <BoxCollider2D>().size.y;

        //Define Ball manager
        ballManager = GameObject.FindGameObjectWithTag("BallManager").GetComponent <BallManager>();

        //Add a timer
        initialTimer = gameObject.AddComponent <Timer>();
        deadTimer    = gameObject.AddComponent <Timer>();

        //Setting timer of 1 second
        initialTimer.Duration = 1;
        initialTimer.Run();

        //settiing dead timer
        deadTimer.Duration = ConfigurationUtils.BallDeadTime; /*RANDOM TIME*/
        deadTimer.Run();

        //setup listener for the speedupEffect
        speedupEffectTimer = gameObject.AddComponent <Timer>();
        EventManager.AddSpeedupListener(SpeedupBall);

        //speedup effect support timer
        speedupEffectTimer.AddFinishedTimeListener(SpeedupEffect);

        //play ball spawn clip
        AudioManager.Play(AudioClipName.BallSpawn);
    }
コード例 #16
0
 // Use this for initialization
 void Start()
 {
     startingPosition = ball.transform.position;
     gameManager      = GameObject.Find("GameManager").GetComponent <GameManager>();
     ballManager      = GameObject.Find("BallManager").GetComponent <BallManager>();
     audioSource      = GetComponent <AudioSource>();
 }
コード例 #17
0
 void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
コード例 #18
0
ファイル: BallManager.cs プロジェクト: AlexeyInc/Balls_game
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #19
0
 void Start()
 {
     soundsManager   = GameObject.Find("SoundsManager").GetComponent <SoundsManager>();
     _missionManager = GameObject.Find("MissionManager").GetComponent <MissionManager>();
     _lockedBalls    = new Queue <Rigidbody>();
     _ballManager    = FindObjectOfType <BallManager>();
 }
コード例 #20
0
    private void TurnLight(bool on)
    {
        if (!on)
        {
            if (!this.GetComponent <Light>())
            {
                return;
            }
        }
        if (on)
        {
            if (this.GetComponent <Light>())
            {
                return;
            }
        }

        if (on)
        {
            BallManager.AddBallLight(this);
        }
        else
        {
            Destroy(this.GetComponent <Light>());
        }
    }
コード例 #21
0
ファイル: Ball.cs プロジェクト: zeninja/JugglerRedux
 void Awake()
 {
     ballManager     = BallManager.GetInstance();
     rb              = GetComponent <Rigidbody2D> ();
     ballArtManager  = GetComponent <BallArtManager> ();
     ballInfo        = GetComponent <BallInfo> ();
     rb.gravityScale = 0;
 }
コード例 #22
0
 // Use this for initialization
 void Start()
 {
     _ballManager  = FindObjectOfType <BallManager>();
     soundsManager = GameObject.Find("SoundsManager").GetComponent <SoundsManager>();
     _text         = GetComponent <TextMeshProUGUI>();
     _oldCount     = _ballManager.BallsLeftCount() - 1;
     _text.text    = _oldCount.ToString();
 }
コード例 #23
0
 /// <summary>
 /// Adds the invoker to the reduce ball left event
 /// </summary>
 /// <param name="invoker"></param>
 public static void ReduceBallsLeftInvoker(BallManager invoker)
 {
     reduceBallsLeftInvoker = invoker;
     if (reduceBallsLeftListener != null)
     {
         reduceBallsLeftInvoker.ReduceBallsLeftListener(reduceBallsLeftListener);
     }
 }
コード例 #24
0
ファイル: PlayerManager.cs プロジェクト: swixi/Banjo
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "ball")
     {
         attachedBall = collision.collider.GetComponent <BallManager>();
         attachedBall.SetAttachedPlayer(this);
     }
 }
コード例 #25
0
    void Awake()
    {
        if (instance != null) {
            Debug.LogError("Instance already created!");
        }

        instance = this;
    }
コード例 #26
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            ballManager         = new BallManager();
            this.IsMouseVisible = true;

            base.Initialize();
        }
コード例 #27
0
 private void use()
 {
     //Debug.Log("object used");
     //ScoreText.SetScore(100);
     sound.Play();
     BallManager.StopBalls();
     Destroy(gameObject, 1);
 }
コード例 #28
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     levelManager  = GameObject.FindGameObjectWithTag("LevelManager");
     ballManager   = levelManager.GetComponent <BallManager>();
     ballState     = GetComponent <BallStates>();
     ballRigidbody = GetComponent <Rigidbody>();
     ballCollider  = GetComponent <Collider>();
 }
コード例 #29
0
 private void DestroyBall(GameObject ball)
 {
     popSound.Play();
     ball.GetComponent <MeshRenderer>().enabled = false;
     ball.GetComponent <Collider>().enabled     = false;
     BallManager.RemoveBall(ball);
     Destroy(ball, 1);
 }
コード例 #30
0
ファイル: GameManager.cs プロジェクト: Sylphy0052/Breakout360
 private void CreatePlayer()
 {
     player = Instantiate <GameObject>(playerPrefab);
     ball   = player.transform.FindChild("Ball").gameObject;
     pc     = player.GetComponent <PlayerController> ();
     bm     = ball.GetComponent <BallManager> ();
     cm.SetPlayer(player);
 }
コード例 #31
0
ファイル: BallManager.cs プロジェクト: raventure7/3DBalls2
 // Use this for initialization
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     balls = GameObject.Find("Balls").transform;
 }
コード例 #32
0
    void Start()
    {
        spriteRenderer = GetComponent<SpriteRenderer> ();
                //scoreHandler = GameObject.Find("ScoreHandler").GetComponent<ScoreHandler>();
                ballmanager = GameObject.Find ("BallManager").GetComponent<BallManager> ();

                ArrayNumber = 4;
                RandomSpriteGeneration ();
                targetScale = new Vector2 (0.4f, 0.4f);
                Invoke ("DestroyBubbule", 2.5f);
    }
コード例 #33
0
    void Start()
    {
        ballScript = GameObject.FindGameObjectWithTag("Player").GetComponent<BallManager> ();

        cam = GameObject.Find("FollowCamera").transform;
        oceanBeds = GameObject.Find("OceanBeds").transform;
        oceanBeds.gameObject.SetActive(false);

        RenderSettings.fogColor = new Color(0.156f, 0.27f, 0.39f);
        RenderSettings.fogDensity = 0.1f;
        RenderSettings.fog = true;
        alreadyUnderwater = true;
    }
コード例 #34
0
 void Start()
 {
     arrowHead.sizeDelta = new Vector2 (arrowHead.rect.width * ARROW_HEAD_SCALE_COEFFICIENT, arrowHead.rect.height * ARROW_HEAD_SCALE_COEFFICIENT);
     arrowTail.sizeDelta = new Vector2 (arrowTail.rect.width, arrowTail.rect.height * ARROW_TAIL_SCALE_COEFFICIENT);
     scoreKeepingScript = GameObject.Find ("World").GetComponent<ScoreKeeping> ();
     ballManagerScript = GetComponent<BallManager> ();
     cameraFollowScript = camera3D.GetComponent<CameraFollow> ();
     levelManage = GameObject.Find ("LevelManager");
     levelManagerScript = levelManage == null ? null : levelManage.GetComponent<LevelManager> ();
     arrowTailRenderer = arrowTail.GetComponent<CanvasRenderer> ();
     arrowTailRenderer.SetMaterial (arrowTailShader, null);
     distance = 0;
     arrowScalePercent = 0;
     overUI = false;
 }
コード例 #35
0
ファイル: MoveBall.cs プロジェクト: TanaySinghal/Life-Of-Ball
    void Start()
    {
        TouchControls.SetActive(false);
        mySpeed = 0f;
        myRigidbody = GetComponent<Rigidbody>();
        //cameraGO = transform.FindChild("FollowCamera");
        cameraGO = GameObject.FindGameObjectWithTag("MainCamera").transform;

        isMobile = (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer);
        if(isMobile && !useTilt) {
            TouchControls.SetActive(true);
        }
        else {
            TouchControls.SetActive(false);
        }
        BM = GetComponent<BallManager>();
    }
コード例 #36
0
ファイル: GameManager.cs プロジェクト: VirsixInc/CatapultKing
 void Awake()
 {
     if(GameManager.s_instance == null){
     GameManager.s_instance = this;
       }else{
     Destroy(gameObject);
       }
       ballManager = GetComponent<BallManager>();
       guiManager = transform.GetChild(0).GetComponent<GUIManager>();
       DontDestroyOnLoad(gameObject);
 }
コード例 #37
0
 // Use this for initialization
 void Start()
 {
     guiManager = GameObject.Find("Globals").GetComponent("GUIManager") as GUIManager;
     globalVals = GameObject.Find("Globals").GetComponent("GlobalValues") as GlobalValues;
     ballManager = GameObject.Find("Globals").GetComponent("BallManager") as BallManager;
 }
コード例 #38
0
ファイル: GameCore.cs プロジェクト: jericho17/BallsTestTask
 public GameCore(BallManager ballManager)
 {
     GameEnded = false;
     BallManager = ballManager;
 }
コード例 #39
0
ファイル: DeathZone.cs プロジェクト: StaNov/Small-Unity-Games
 void Start()
 {
     ballManager = BallManager.GetInstance();
 }
コード例 #40
0
ファイル: AIController.cs プロジェクト: zhangjk95/Agar3D
    void Update()
    {
        if (!isActiveAndEnabled) return;
        updateBalls();
        SmallestBallSize = 100000;
        foreach (var ball in balls) {
            if(ball.size < SmallestBallSize) {
                SmallestBallSize = ball.size;
                SmallestBall = ball;
            }
        }

        IsTargetBallsinVision = false;
        BallManager Persue;
        bool IsEscape = false;
        Persue = null;
        List<BallManager> Escape = new List<BallManager>();
        Vector3 escapeDirection = new Vector3(0, 0, 0);

        foreach (var otherball in otherballs)
        {
            if (Vector3.Distance(otherball.position, SmallestBall.position) < AIVisionField)
            {
                if (otherball.size > SmallestBall.size && otherball.radius - SmallestBall.radius > 0.5)
                {
                    Escape.Add(otherball);
                    IsTargetBallsinVision = true;
                    IsEscape = true;
                    break;
                }
            }
        }

        if (state == "normal")
        {
            if (IsEscape)
            {
                Vector3 CaliescapeDirection;
                escapeDirection = new Vector3(0, 0, 0);
                foreach (var escape in Escape)
                {
                    escapeDirection += SmallestBall.position - escape.position;
                    Debug.DrawLine(SmallestBall.position, escape.position, Color.red);
                }
                CaliescapeDirection = escapeDirection;
                if (SmallestBall.position.x + SmallestBall.radius > FloorScale / 2 || SmallestBall.position.x - SmallestBall.radius < -FloorScale / 2)
                {
                    CaliescapeDirection.x = 0;
                }
                if (SmallestBall.position.z + SmallestBall.radius > FloorScale / 2 || SmallestBall.position.z - SmallestBall.radius < -FloorScale / 2)
                {
                    CaliescapeDirection.z = 0;
                }
                if (CaliescapeDirection.x == 0 && CaliescapeDirection.z == 0)
                {
                    float MinangleH = 367, MinangleV = 367;
                    foreach (var escapeball in Escape)
                    {
                        float angleV = Vector3.Angle(new Vector3(0, 0, 1), escapeball.position - SmallestBall.position);
                        angleV = Calibrate(angleV);
                        float angleH = Vector3.Angle(new Vector3(1, 0, 0), escapeball.position - SmallestBall.position);
                        angleH = Calibrate(angleH);
                        if (angleV < MinangleV)
                        {
                            MinangleV = angleV;
                        }
                        if(angleH < MinangleH)
                        {
                            MinangleH = angleH;
                        }
                    }
                    if (MinangleV > MinangleH)
                    {
                        CaliescapeDirection.z = -escapeDirection.z * 100;
                    }
                    else
                    {
                        CaliescapeDirection.x = -escapeDirection.x * 100;
                    }
                    state = "corner";
                }
                MoveDirection = CaliescapeDirection + SmallestBall.position;
            }

            else
            {
                float MinDistance = 100000, Temp_Distance = 0;
                foreach (var otherball in otherballs)
                {
                    Temp_Distance = Vector3.Distance(otherball.position, SmallestBall.position);
                    if (Temp_Distance < AIVisionField && SmallestBall.radius - otherball.radius > 0.5 && Temp_Distance < MinDistance)
                    {
                        MinDistance = Temp_Distance;
                        Persue = otherball;
                        IsTargetBallsinVision = true;
                    }
                }
                if (Persue)
                {
                    MoveDirection = Persue.position;
                    if (Persue.size < SmallestBall.size / 2)
                    {
                        if (Vector3.Distance(Persue.position, SmallestBall.position) < SplitRange)
                        {
                            AIJudgeTimer += Time.deltaTime;
                            if (AIJudgeTimer > AIJudgeTime)
                            {
                                Vector3 ForecastSplitPoint = new Ray(SmallestBall.position, Persue.position - SmallestBall.position).GetPoint(2 * SmallestBall.radius);
                                if (!checkShelterCollision(ForecastSplitPoint).HasValue)
                                {
                                    Split(Persue.position);
                                }
                                AIJudgeTimer = 0;
                            }
                        }
                        else
                        {
                            AIJudgeTimer = 0;
                        }
                    }
                }
                else
                {
                    Pickups = GameObject.FindGameObjectsWithTag("Pick Up");
                    IsPickUpinVision = false;
                    foreach (var Pickup in Pickups)
                    {
                        if (Vector3.Distance(SmallestBall.position, Pickup.transform.position) < AIVisionField)
                        {
                            MoveDirection = Pickup.transform.position;
                            IsPickUpinVision = true;
                        }
                    }

                }
            }
        }
        else if (state == "corner")
        {
            escapeDirection = new Vector3(0, 0, 0);
            bool EjectorAlive = false;
            foreach (var escape in Escape)
            {
                escapeDirection += SmallestBall.position - escape.position;
                EjectorAlive = true;
                Debug.DrawLine(SmallestBall.position, escape.position, Color.red);
            }
            if (Vector3.Dot(MoveDirection - SmallestBall.position, escapeDirection) > 0) {
                state = "normal";
            }
            if(!EjectorAlive) {
                state = "normal";
            }
        }

        MovementTimer += Time.deltaTime;
        if (!IsPickUpinVision && !IsTargetBallsinVision) {
            if (MovementTimer > Random.Range(27, 34) / 10)
            {
                MoveDirection = new Vector3(Random.Range(-FloorScale / 2, FloorScale / 2), 0, Random.Range(-FloorScale / 2, FloorScale / 2));
                MovementTimer = 0;
            }
        }

        Debug.DrawLine(MoveDirection, SmallestBall.position, Color.yellow);

        Vector3 ForecastPoint = new Ray(SmallestBall.position, MoveDirection - SmallestBall.position).GetPoint(2 * SmallestBall.radius);
        if (checkShelterCollision(ForecastPoint).HasValue) {
            Vector3 shelterPosition = checkShelterCollision(ForecastPoint).Value;
            int avoidsign = -1;
            if (Vector3.Cross (MoveDirection, shelterPosition).y < 0) {
                avoidsign = 1;
            }
            Debug.Log (avoidsign);
            int totalrotation = 0;
            while (checkShelterCollision(ForecastPoint).HasValue) {
                Vector3 AvoidDirection = MoveDirection - SmallestBall.position;
                Quaternion rotation = Quaternion.AngleAxis (avoidsign * 2, new Vector3 (0, 1, 0));
                totalrotation +=2;
                if(totalrotation > 180) {
                    break;
                }
                AvoidDirection = rotation * AvoidDirection;
                MoveDirection = SmallestBall.position + AvoidDirection;
                ForecastPoint = new Ray(SmallestBall.position, MoveDirection - SmallestBall.position).GetPoint( SmallestBall.radius);
            }
        }

        Move (MoveDirection, 100f);
        Debug.DrawLine(MoveDirection, SmallestBall.position);
    }
コード例 #41
0
 // Use this for initialization
 void Start()
 {
     ballManager = GameObject.FindObjectOfType<BallManager>();
 }
コード例 #42
0
    private void SetGameInternal(GameType type, bool hasEnvironment)
    {
        var TextureContainer = new TextureContainer ();
        var BallFactory = new BallFactory (TextureContainer);
        var BallManager = new BallManager (BallFactory);
        var GameCore = new GameCore (BallManager);
        var EventFactory = new EventFactory (GameCore);
        var GameController = MakeController (type, GameCore, EventFactory);
        var Environment = new Environment (GameController, EventFactory);

        _container = new GameContainer (GameCore, GameController, Environment, hasEnvironment);
        HasErrors = false;
        Initialized = true;
    }
コード例 #43
0
 public void Start()
 {
     ballManager = mainBall.GetComponent<BallManager>();
 }