Exemplo n.º 1
0
        /*public Dictionary<GameObject, worldProp> worldProps {
         *      get { return _worldProps; }
         * }*/

        #endregion

        #region PublicMethods

        public void init()
        {
            _levelPropDefs = new List <propDef> ();

            PropsList propList = Resources.Load <PropsList> ("Data/" + Globals.propListName);
            int       i, len = propList.props.Count;

            for (i = 0; i < len; ++i)
            {
                PropDefinition propDef = propList.props [i];
                if (propDef.prefab != null)
                {
                    propDef p = new propDef();
                    p.id          = propDef.id;
                    p.name        = propDef.propName;
                    p.prefab      = propDef.prefab;
                    p.useCollider = propDef.isUsingCollider;
                    p.useGravity  = propDef.isUsingGravity;

                    _levelPropDefs.Add(p);
                }
            }

            _iSelectedItem = 0;

            //_worldProps = new Dictionary<GameObject, worldProp> ();
        }
        public propDef getPropDefForGameObject(GameObject go)
        {
            propDef p = new propDef();

            p.id = -1;

            if (_worldProps.ContainsKey(go))
            {
                p = PropsManager.Instance.getPropDefForId(_worldProps [go].id);
            }

            return(p);
        }
        public void placeIt(Vector3 v3Pos)
        {
            string sName = _goCurProp.name + "_" + _levelEditor.curLevelChunk.trfmProps.childCount;

            propDef prop = PropsManager.Instance.getSelectedPropDef();

            GameObject goNew = PropsManager.Instance.createProp(prop, v3Pos, sName, _levelEditor.curLevelChunk.trfmProps, prop.useCollider, prop.useGravity);

            goNew.transform.forward = _goCurProp.transform.forward;

            _levelEditor.curLevelChunk.addWorldProp(prop.id, goNew);

            _levelEditor.resetUndoActions();
            _levelEditor.addUndoAction(AppState.Props, goNew);
        }
Exemplo n.º 4
0
        //
        public propDef getPropDefForId(int id)
        {
            propDef p = new propDef();

            p.id = -1;

            int i, len = _levelPropDefs.Count;

            for (i = 0; i < len; ++i)
            {
                if (_levelPropDefs [i].id == id)
                {
                    p = _levelPropDefs [i];
                    break;
                }
            }

            return(p);
        }
Exemplo n.º 5
0
        //
        public void newPropSelected()
        {
            if (AppController.Instance.appState == AppState.Null)
            {
                return;
            }

            if (propAim != null)
            {
                if (_goCurProp != null)
                {
                    Destroy(_goCurProp);
                    _goCurProp = null;
                }
                propDef prop = PropsManager.Instance.getSelectedPropDef();
                _goCurProp = PropsManager.Instance.createProp(prop, Vector3.zero, prop.name, propAim.transform, false, false);
                _goCurProp.transform.localPosition = Vector3.zero;
            }

            if (_curEditorTool != null)
            {
                _curEditorTool.resetProp();
            }
        }
Exemplo n.º 6
0
        //

        /*public propDef getPropDefForGameObject(GameObject go)
         * {
         *      propDef p = new propDef();
         *      p.id = -1;
         *
         *      if (_worldProps.ContainsKey (go)) {
         *              p = getPropDefForId(_worldProps [go].id);
         *      }
         *
         *      return p;
         * }*/

        //
        public GameObject createProp(propDef prop, Vector3 v3Pos, string name, Transform parent, bool useCollider = true, bool useGravity = true)
        {
            GameObject goNew = GameObject.Instantiate(prop.prefab);

            goNew.transform.SetParent(parent);
            goNew.transform.localPosition = v3Pos;
            goNew.name = name;

            Collider collider = goNew.GetComponent <Collider> ();

            if (collider != null)
            {
                collider.enabled = useCollider;
            }

            Rigidbody rigidBody = goNew.GetComponent <Rigidbody> ();

            if (rigidBody != null)
            {
                rigidBody.useGravity = useGravity;
            }

            return(goNew);
        }