Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        //_speed = 50;
        //_rotation_speed = 90;
        _maxSpeed = 3;

        maxWidth = calculateMaxWidth();
        maxHeight = calculateMaxHeight();

        shipVelocity = new Vector2(0,0);
        shipAngle = 0;
        //Debug.Log ("ShipComponentLength0: "+ shipMap.GetLength(0) + ", shipcomponentLength1: "+ shipMap.GetLength(1));

        //Debug.Log ("MaxWidth: " + maxWidth + ", maxHeight: " + maxHeight);

        componentArray = new GameObject[7, 5];

        int xPosition = -100;
        int yPosition = 100;

        circuitBoardScript = GetComponent("CircuitBoard") as CircuitBoard;

        for(int i = 0; i < shipMap.GetLength(0); ++i)
        {
            xPosition = -300;
            for(int j = 0; j < shipMap.GetLength(1); ++j)
            {

                int val = shipMap[i,j];
                switch(val)
                {
                case 1:
                {
                    componentArray[i,j] = (GameObject)Instantiate(passthroughPrefab,
                                                                  new Vector3(xPosition, yPosition, 0), Quaternion.identity);
                    break;
                }
                case 2:
                {
                    componentArray[i,j] = (GameObject)Instantiate(powersupplyPrefab,
                                                                  new Vector3(xPosition, yPosition, 0), Quaternion.identity);

                    break;
                }
                case 3:
                {
                    componentArray[i,j] = (GameObject)Instantiate(thrusterPrefab,
                                                                  new Vector3(xPosition, yPosition, 0), Quaternion.identity);

                    break;
                }
                case 4:
                {
                    componentArray[i,j] = (GameObject)Instantiate(gunPrefab,
                                                                  new Vector3(xPosition, yPosition, 0), Quaternion.identity);

                    break;
                }
                default:
                {
                    break;
                }
                }
                xPosition += tileX;
            }
            yPosition -= tileY;
        }

        circuitBoardScript.setGameObjectArray(ref shipMap, ref maxWidth, ref maxHeight);

        //this.transform.position = new Vector2(1.736f, -125.52f);
        followship = Camera.main.GetComponent("FollowShip") as FollowShip;
        followship.player = this.transform;
        followship.circuitBoardScript = circuitBoardScript;
        followship.enabled = true;
        //FollowShip temp = Camera.main.GetComponent("FollowShip") as FollowShip;
        //temp.player = this.transform;
        //temp.circuitBoardScript = circuitBoardScript;
        //temp.enabled = true;

        centerofMass = computeCenterOfMass();
    }
Esempio n. 2
0
 void Start()
 {
     targetPosition = transform.position;
     msInstance     = this;
 }