Exemple #1
0
    public void PlaceObj(int _index, Point _gridPos, GameObject _originObj)
    {
        originObj = _originObj;
        originSys = originObj.GetComponent <SystemScript> ();

        if (originObj == gameObject)
        {
            isOrigin        = true;
            pwrIndicatorSpr = powerIndicator.GetComponent <SpriteRenderer> ();
        }

        if (this.gameObject == originObj)
        {
            //string _string = (objStr + ",1," + gridPos.X.ToString () + "," + gridPos.Y.ToString ());
            saveStr = (objStr + ",1," + _gridPos.X.ToString() + "," + _gridPos.Y.ToString());
            LevelManager.Instance.parameterList.Add(saveStr);
        }

        //gridPos = _gridPos;
        gridPos = new Point(_gridPos.X + Mathf.RoundToInt(nextPos.x * 2), _gridPos.Y + Mathf.RoundToInt(nextPos.y), _gridPos.Z);


        subSysSlot.SetActive(hasSubSysSlot);


        tile = LevelManager.Instance.Tiles [gridPos];
        hScr = gameObject.GetComponent <HealthScript> ();


        transform.position = tile.transform.position;
        //Quaternion.identity = tile.Quaternion.identity;

        transform.SetParent(tile.transform.GetChild(1));

        //Debug.Log ("yaya");

        DoBool();

        GameManager.Instance.Buy();

        //subSysSlot.SetActive (hasSubSysSlot);

        if (!last)
        {
            //creates next component of obj

            //combinig nextPos with point to get the true next gridPos
            //Point _point = new Point (_gridPos.X + Mathf.RoundToInt (nextPos.x * 2), _gridPos.Y + Mathf.RoundToInt (nextPos.y), _gridPos.Z);
            //TileScript _tile = LevelManager.Instance.Tiles [_point];

            thisNextObj = (GameObject)Instantiate(nextObj);
            thisNextSys = thisNextObj.GetComponent <SystemScript> ();

            IPlacable _placable = thisNextObj.GetComponent <IPlacable> ();
            _placable.PlaceObj(_index, gridPos, originObj);

            hScr.NextHScr = thisNextObj.GetComponent <HealthScript> ();
        }
    }
Exemple #2
0
    private void PlaceObj(string _objStr, int _type = 10)
    {
        GameObject _obj      = (GameObject)Instantiate(LevelManager.Instance.ObjDict [_objStr], transform.position, Quaternion.identity);
        IPlacable  _placable = _obj.GetComponent <IPlacable> ();

        _placable.PlaceObj(0, this.GridPosition, _obj);

        if (_type < 10)
        {
            //HScrDict.Add (_type, _obj.GetComponent <HealthScript> ()); //SHITFUCK DIS IS DA ONE!!! TWATS CAUSING ME ALL THIS TROUBLE

            //Debug.Log ("type: " + _type);
        }
    }
Exemple #3
0
    //only called on server
    public GameObject RemoteCouchCrew(string _objStr)
    {
        GameObject _obj      = (GameObject)Instantiate(LevelManager.Instance.ObjDict [_objStr], transform.position, Quaternion.identity);
        IPlacable  _placable = _obj.GetComponent <IPlacable> ();

        _placable.PlaceObj(0, this.GridPosition, _obj);

        //CasheScript.Instance.AssignController (_obj.GetComponent <CouchCrewScript> ());

        /*
         * if (GridPosition.Z == NetManager.Instance.localPlayerID) {
         *      //isLocal = true;
         *
         *      //couchCrewSetup is called by this as well...
         *      CasheScript.Instance.AssignController (_obj.GetComponent <CouchCrewScript> ());
         * }
         *
         * Debug.LogError ("crewPos: " + GridPosition.Z + ", netID: " + NetManager.Instance.localPlayerID);
         */

        return(_obj);
    }
Exemple #4
0
    public void PlaceObj(int _index, Point _gridPos, GameObject _originObj)
    {
        thisCol = gameObject.GetComponent <BoxCollider2D> ();
        if (CasheScript.Instance.GameMode == 0)
        {
            thisCol.enabled = false;
        }
        else
        {
            thisCol.enabled = true;
        }

        originObj = _originObj;
        //necessary since placeObj needs to be generic
        originScr = originObj.GetComponent <RoomScript>();

        if (this.gameObject == originObj)
        {
            isOrigin = true;

            _trueOriginPos = _gridPos;

            saveStr = (objStr + ",0," + _gridPos.X.ToString() + "," + _gridPos.Y.ToString());
            LevelManager.Instance.parameterList.Add(saveStr);

            //adds the origin to the roomList for ICR (InitialContentReferencing)
            LevelManager.Instance.roomList.Add(this);

            //healthbar!
            //healthBarBase = healthBar.transform.parent.gameObject;
        }

        //gridPos = _gridPos;
        gridPos = new Point(_gridPos.X + Mathf.RoundToInt(nextPos.x * 2), _gridPos.Y + Mathf.RoundToInt(nextPos.y), _gridPos.Z);
        Debug.Log("gridPos: " + gridPos.X + ", " + gridPos.Y + ", " + gridPos.Z);


        //set tweens walkable

        /*
         * if (true) {
         *      Point _point = new Point (gridPos.X + 1, gridPos.Y, gridPos.Z);
         *      LevelManager.Instance.Tiles [_point].Walkable = true;
         * }
         */

        tile = LevelManager.Instance.Tiles [gridPos];         //-> ye fucktard! that's what's caused the issue s******d! //?
        hScr = gameObject.GetComponent <HealthScript> ();
        //transform.parent.parent.GetComponent <TileScript> ();

        //this causes roomPlacement hickups! -> not properly removed!
        tile.HScrDict.Add(0, hScr);


        /*
         * //important for dmg
         * if (this.gameObject != originObj) {
         *      tile.LocalObjDict.Add (0, gameObject.GetComponent <HealthScript> ());
         * }
         */

        transform.position = tile.transform.position;
        //Quaternion.identity = tile.Quaternion.identity;

        transform.SetParent(tile.transform.GetChild(0));

        if (HasDoorSlot)
        {
            if (isLeftBorder)
            {
                Point      _point         = new Point(gridPos.X - 2, gridPos.Y, gridPos.Z);
                TileScript _neighbourTile = LevelManager.Instance.Tiles [_point];
                if (!_neighbourTile.IsEmpty && _neighbourTile.HasDoorSlot)
                {
                    //if (!tile.IsEmpty && tile.HasDoorSlot) {
                    //place door
                    //Debug.Log ("doorPLaced left");
                    PlaceDoor(tile);
                }
            }

            if (isRightBorder)
            {
                Point      _point         = new Point(gridPos.X + 2, gridPos.Y, gridPos.Z);
                TileScript _neighbourTile = LevelManager.Instance.Tiles [_point];
                if (!_neighbourTile.IsEmpty && _neighbourTile.HasDoorSlot)
                {
                    //place door
                    //Debug.Log ("doorPlaced Right");
                    PlaceDoor(_neighbourTile);
                }
            }
        }

        //Debug.Log ("yaya");
        DoBool();

        GameManager.Instance.Buy();


        if (!last)
        {
            //creates next component of obj

            //combinig nextPos with point to get the true next gridPos
            //Point _point = new Point (_gridPos.X + Mathf.RoundToInt (nextPos.x * 2), _gridPos.Y + Mathf.RoundToInt (nextPos.y), _gridPos.Z);
            //TileScript _tile = LevelManager.Instance.Tiles [_point];

            thisNextObj = (GameObject)Instantiate(nextObj);

            IPlacable _placable = thisNextObj.GetComponent <IPlacable> ();
            _placable.PlaceObj(_index, gridPos, originObj);

            //Debug.Log ("nextHScr set!");
            hScr.NextHScr = thisNextObj.GetComponent <HealthScript> ();
        }

        sprRenderer = gameObject.GetComponent <SpriteRenderer> ();
    }