/* * private void RemoveRoom () * { * GameObject _obj = transform.GetChild (0).GetChild (0).gameObject; * IPlacable _placable = _obj.GetComponent <IPlacable> (); * _placable.RemoveObj (); * } * * * private void RemoveSystem () * { * GameObject _obj = transform.GetChild (1).GetChild (0).gameObject; * IPlacable _placable = _obj.GetComponent <IPlacable> (); * _placable.RemoveObj (); * } * * * private void RemoveCrew () * { * GameObject _obj = transform.GetChild (2).GetChild (0).gameObject; * IPlacable _placable = _obj.GetComponent <IPlacable> (); * _placable.RemoveObj (); * } */ /* * private void RemoveDanger () * { * //Debug.Log ("Danger Removed at " + GridPosition.X + ", " + GridPosition.Y); * * LevelManager.Instance.parameterList.Remove (localDanger); * * //meyhap need to redet DangerID... * * //GameObject obj = (GameObject)this.GetComponent<GameObject> ().activeInHierarchy; * //GameObject obj = transform.Find("Fire(Clone)").gameObject; * * GameObject _obj = transform.GetChild (3).GetChild (0).gameObject; * * //obj.SetActive (false); * Destroy (_obj); * * OnFire = false; * * //probably needs to be replaced * PlacementManager.Instance.Price = 10; * * GameManager.Instance.Sell (); * } */ private void RemoveSubSystem() { GameObject _obj = transform.GetChild(6).GetChild(0).gameObject; IPlacable _placable = _obj.GetComponent <IPlacable> (); _placable.RemoveObj(); }
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> (); } }
private static int ComputeColumnSpan(int columnCount, IPlacable placable, CellPosition pos) { //先看整个格子够不够放 if (placable.ColumnSpan <= 0) // <= 0 表示从当前位置起占满整行 { return(columnCount - pos.Column); } else { return(Math.Min(columnCount - pos.Column, placable.ColumnSpan)); } }
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); } }
private object CreateWidget(IPlacable placable) { Debug.Assert(placable != null); object widget = null; if (placable is Label) { var label = placable as Label; var labelWidget = this.widgetFactory.CreateLabelWidget(label); widget = labelWidget; } else if (placable is NewLine) { widget = null; } else if (placable is HorizontalLine) { var hl = placable as HorizontalLine; widget = this.widgetFactory.CreateHorizontalLineWidget(hl); } else if (placable is Notebook) { var nb = placable as Notebook; widget = this.widgetFactory.CreateNotebookWidget(nb); foreach (Page page in nb.Pages) { var le = new LayoutEngine(this.widgetFactory); var pageContent = le.BuildLayout(page); var pageWidget = this.widgetFactory.CreatePageWidget(page, widget, pageContent); } } else if (placable is Button) { var button = placable as Button; widget = this.widgetFactory.CreateButtonWidget(button); } else if (placable is Input) { var field = placable as Input; widget = this.widgetFactory.CreateInputWidget(field); } else { throw new NotSupportedException("不支持的控件类型:" + placable.GetType().FullName); } return(widget); }
private void RemoveObj(int _objType) { //GameObject _obj = transform.GetChild (0).GetChild (0).gameObject; if (_objType != 7) { GameObject _obj = transform.GetChild(_objType).GetChild(0).gameObject; IPlacable _placable = _obj.GetComponent <IPlacable> (); _placable.RemoveObj(); } else if (_objType == 7) { GameObject _obj = transform.GetChild(0).gameObject; IPlacable _placable = _obj.GetComponent <IPlacable> (); _placable.RemoveObj(); } }
//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); }
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> (); }