Exemple #1
0
    /// onAwake allows for each inheritance to get all the functionality and still implement other useful functionalities
    void Awake()
    {
        //Get Outside References
        boundary    = GameObject.Find("Game Master").GetComponent <ObjBoundary>();
        colorSwatch = GameObject.Find("Game Master").GetComponent <ColorSwatches>();

        //Controls  
        rightBound = (Camera.main.pixelWidth / 2.0f);
        leftBound  = (Camera.main.pixelWidth / 2.0f);
        canRotate  = true;

        //DO STUFF!
        this.gameObject.tag = "Paddle";
        PopulateSides();
        CanMove();
        CalcDegreeAngle();
        teleportToStartPos();
        if (numSides > 1)
        {
            DestroyOldPaddle();
        }
        colorSwatch.PickNewColor();

        //Get the paddle's boundaries from the Boundary class
        CalcBounds(sides[0]);
        ySpawn = boundary.getPaddleYAxis();
        speed  = 25f;
    }
    protected void SetSize()
    {
        bounds = GameObject.Find("Game Master").GetComponent <ObjBoundary>();
        Vector3 oldSize = this.transform.localScale;
        float   s       = bounds.getCamSize();

        this.transform.localScale = new Vector3(bounds.getScreenWidth() / s * oldSize.x, bounds.getScreenWidth() / s * oldSize.y, 1);
    }
Exemple #3
0
    // Use this for initialization
    void Awake()
    {
        cam = GameObject.Find("Main Camera").GetComponent <Camera>();
        this.GetComponent <Canvas>().worldCamera = cam;
        bounds  = GameObject.Find("Game Master").GetComponent <ObjBoundary>();
        message = this.transform.GetChild(0).GetComponent <Text>();

        this.transform.position = new Vector3(0, 0 + (bounds.getScreenHeight() / 3), 1);
    }
Exemple #4
0
    // Use this for initialization
    void Awake()
    {
        gm              = GameObject.Find("Game Master").GetComponent <GameMaster>();
        bm              = GameObject.Find("Game Master").GetComponent <BallMaster>();
        bounds          = gm.GetComponent <ObjBoundary>();
        cam             = this.GetComponent <Camera>(); //reference to camera
        targetTransform = cam.GetComponent <Transform>();

        //SET CAM TO STD POS&ORTHO
        targetTransform.position = stdPos;
        cam.orthographicSize     = stdOrtho;
        bounds.SetNewBounds();
    }
Exemple #5
0
    protected void InitBall()
    {
        //Initialize References
        gm         = GameObject.Find("Game Master");
        boundary   = gm.GetComponent <ObjBoundary>();
        bounceAnim = Resources.Load <GameObject>("Bounce");

        //Set Attributes
        this.gameObject.tag = "Ball";

        //Set the Boundaries
        CalcBounds(this.gameObject);
        ySpawn = boundary.getBallYAxis();

        //Components
        ballTransform = this.GetComponent <Transform>();
        ballRend      = this.GetComponent <SpriteRenderer>();

        //initialize all attributes and physics values
        isActive = true;
        SetSize();
        ChooseBallStartPos();
    }
 // Use this for initialization
 void Start()
 {
     rb       = GetComponent <Rigidbody2D>();
     boundary = GameObject.Find("Game Master").GetComponent <ObjBoundary>();
     SetSize();
 }
 protected void CalcBounds(GameObject obj)
 {
     bounds = GameObject.Find("Game Master").GetComponent <ObjBoundary>();
     xMin   = bounds.getxMin(obj);
     xMax   = bounds.getxMax(obj);
 }