public virtual void ReMoveSceneObj(SceneObj go) { if (null != go && m_listSceneObj.Contains(go)) { m_listSceneObj.Remove(go); } }
public virtual void AddSceneObj(SceneObj go) { if (null != go && !m_listSceneObj.Contains(go)) { m_listSceneObj.Add(go); } }
private IEnumerator IELoad(ObjData obj) { SceneObj sceneObj = new SceneObj(obj); sceneObj.status = SceneObjStatus.Loading; ActiveObjDic.Add(obj.sUid, sceneObj); GameObject resObj = null; ResourcesObj resourceObj; if (ResourcesObjDic.TryGetValue(obj.resPath, out resourceObj)) { resObj = resourceObj.obj; resourceObj.CreateIns(); } else { ResourceRequest request = Resources.LoadAsync <GameObject>(obj.resPath); yield return(request); resObj = request.asset as GameObject; } CreateObj(resObj, sceneObj); sceneObj.status = SceneObjStatus.New; }
public void Load(ObjData obj) { if (CheckIsActive(obj.sUid) != null) { return; } if (!MoveToActive(obj)) { SceneObj sceneObj = new SceneObj(obj); sceneObj.status = SceneObjStatus.New; GameObject resObj = null; ResourcesObj resourceObj; if (ResourcesObjDic.TryGetValue(obj.resPath, out resourceObj)) { resObj = resourceObj.obj; resourceObj.CreateIns(); } else { resObj = Resources.Load <GameObject>(obj.resPath); } CreateObj(resObj, sceneObj); ActiveObjDic.Add(obj.sUid, sceneObj); } }
public Model(SceneObj objData) { Name = objData.name; Position = objData.transform.position; EulerRot = objData.transform.eulerAngles; Scale = objData.transform.localScale; }
public override void OnMouseUp(SceneObj objScene) { if (m_objTouchDown == objScene) { OnClick(m_objTouchDown); } m_objTouchDown = null; }
public void OnMouseDown(SceneObj obj) { var newObj = Object.Instantiate(obj); newObj.name = obj.name; newObj.transform.position += (newObj.transform.localScale.magnitude * 2 * Vector3.back); GameEvents.OnSceneObjAdd(newObj); }
public void OnClick(SceneObj objScene) { if (objScene is BlockObj) { BlockObj bobj = objScene as BlockObj; bobj.OnClick(); } }
public void Dead(SceneObj _object) { isDied = true; if (_object) { _object.SendMessage("OnPickup", this); } Spawner.instance.DespawnDrop(this); }
// Start is called before the first frame update void Start() { mSpR = this.GetComponent <SpriteRenderer>(); mSceneObj = this.GetComponent <SceneObj>(); mStage = 0; isResolve = false; mSceneObj.relatedQuiz = mQuizComputer; }
public void OnMouseDown(SceneObj obj) { _gameObject = obj.gameObject; if (_actualTextureSelected != null) { ChangeTexture(_actualTextureSelected); } ChangeColor(_actualColorSelected); }
void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Scene") { SceneObjScript = other.transform.gameObject.GetComponent <SceneObj>(); SceneObjScript.ISOpacity = false; SceneObjScript.SetOpacity(SceneObjScript.ISOpacity); // Debug.Log(other + "out"); } }
public void displayScene(SceneObj scene) { //If the flags aren't set, switch to fallback scene if (checkCondition(scene) == false) { if (scene.fallback == null) { Debug.LogError("NO FALLBACK FROUND FOR SCENE " + SceneID); } ChangeScene(scene.fallback); return; } //Run run scene script if (scene.script != null) { if (sm != null) { sm.SendMessage(scene.script); } } if (scene.end) { return; } //set the current scene and display options currentScene = scene; text.text = getWriting(scene.text); int optionsCount; if (scene.options == null) { optionsCount = 0; } else { optionsCount = scene.options.Length; } for (int i = 0; i < 3; ++i) { GameObject obj = buttons[i].gameObject; //Only shows buttons up to optionsCount obj.SetActive(i < optionsCount); if (i < optionsCount) { obj.GetComponentInChildren <TextMeshPro>().text = getWriting(scene.options[i].text); } } }
private SceneObj jsonToScene(SceneJson scene) { SceneObj obj = new SceneObj(); obj.conditions = scene.conditions; obj.fallback = scene.fallback; obj.script = scene.script; obj.text = scene.text; obj.options = scene.options; obj.end = scene.end; return(obj); }
public void AddObject(SceneObj obj, ObjShowStyle s) { if (s == ObjShowStyle.ShowAllTime) { this.AddObject(obj); } else if (s == ObjShowStyle.ShowInFold) { foldElement.AddObject(obj); } else if (s == ObjShowStyle.ShowInUnFold) { unfoldElement.AddObject(obj); } }
public SceneObj GetSceneObj(string name) { SceneObj sceneObj = null; foreach (SceneObj obj in m_listSceneObj) { if (obj == null) { continue; } if (obj.name == name) { sceneObj = obj; } } return(sceneObj); }
/// <summary> /// 确认是否为该功能模块 /// </summary> private bool CheckFunBlock(SceneObj obj, FunBlock block) { if (obj == null || block == FunBlock.None) { return(false); } if (block == FunBlock.Boat && obj is BoatObj) { return(true); } if (block == FunBlock.Stage && obj is StageObj) { return(true); } return(false); }
// Update is called once per frame protected virtual void Update() { OnUpdateRendered(); if (!IsRendered) { return; } if (_isMoving) { Vector3 pos = transform.position; pos = Vector3.MoveTowards(pos, _moveTarget, _moveSpeed * Time.deltaTime); pos.y = SceneObj.SampleHeight(pos); transform.position = pos; // 到达在旋转之前判断 // 若到达则无需旋转,避免零距离旋转误差可能出现的错误 Vector3 step = transform.position - _moveTarget; if (Mathf.Abs(step.x) <= 0.1f && Mathf.Abs(step.y) <= 0.1f && Mathf.Abs(step.z) <= 0.1f) { _remainIdleTime = GetNewIdleTime(); StopMove(); } else { Vector3 dir = _moveTarget - transform.position; dir.y = 0; Quaternion dirRot = Quaternion.LookRotation(dir); Quaternion rot = transform.rotation; rot = Quaternion.RotateTowards(rot, dirRot, _rotateSpeed * Time.deltaTime); transform.rotation = rot; } } else { _remainIdleTime -= Time.deltaTime; if (_remainIdleTime < 0) { _moveTarget = _posFinder.GetNewTarget(); _moveTarget.y = SceneObj.SampleHeight(_moveTarget); StartMove(); } } }
public bool checkCondition(SceneObj scene) { if (scene.conditions == null) { return(true); } bool ret; foreach (string flag in scene.conditions) { if (flags.TryGetValue(flag, out ret) == false) { return(false); } } return(true); }
private Vector2 m_vtotalmouseDelta; //记录手指按下后的屏幕移动总和,可用于判断移动和捏合操作 public override void OnMouseDown(SceneObj objScene) { RaycastHit hit; if (!WndManager.IsHitNGUI(out hit)) { m_vtotalmouseDelta = Vector3.zero; m_objTouchDown = objScene; if (SystemInfo.deviceType == DeviceType.Desktop) { m_vposLastTouchMove = Input.mousePosition; } else { m_vposLastTouchMove = Input.GetTouch(0).position; } } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Scene") { Vector3 V1, V2; V1 = other.transform.position - MainCam.transform.position; V2 = Player.transform.position - MainCam.transform.position; if (Vector3.Distance(other.transform.position, MainCam.transform.position) < Vector3.Distance(Player.transform.position, MainCam.transform.position)) { SceneObjScript = other.transform.gameObject.GetComponent <SceneObj>(); SceneObjScript.ISOpacity = true; SceneObjScript.SetOpacity(SceneObjScript.ISOpacity); // Debug.Log(other + "in"); } } // else // Debug.Log(other); }
private void TraverseChildNode(Transform root) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); MeshRenderer mr = child.GetComponent <MeshRenderer>(); if (mr != null) { var obj = new SceneObj(); obj.parentnames = new List <string>(); GetParentNames(child, ref obj.parentnames); if (mr.transform.childCount > 0) { UnityEngine.Debug.LogError("MeshRender has childs ,is error :" + obj.parentnames); continue; } obj.name = child.name; obj.positionX = child.localPosition.x; obj.positionT = child.localPosition.y; obj.positionZ = child.localPosition.z; obj.rotationX = child.transform.localEulerAngles.x; obj.rotationY = child.transform.localEulerAngles.y; obj.rotationZ = child.transform.localEulerAngles.z; obj.scaleX = child.transform.localScale.x; obj.scaleY = child.transform.localScale.y; obj.scaleZ = child.transform.localScale.z; obj.lightmapIndex = mr.lightmapIndex; obj.lightmapScaleOffsetx = mr.lightmapScaleOffset.x; obj.lightmapScaleOffsety = mr.lightmapScaleOffset.y; obj.lightmapScaleOffsetz = mr.lightmapScaleOffset.z; obj.lightmapScaleOffsetw = mr.lightmapScaleOffset.w; m_config.objs.Add(obj); UnityEngine.Object.DestroyImmediate(mr.gameObject); } else { TraverseChildNode(child); } } }
public virtual void Start() { if (SceneObj == null) { return; } _originalPos = transform.position; _originalPos.y = SceneObj.SampleHeight(_originalPos); transform.position = _originalPos; _isMoving = false; _remainIdleTime = GetNewIdleTime(); _renderers = gameObject.GetComponentsInChildren <Renderer>(); foreach (var item in _renderers) { item.receiveShadows = false; } _posFinder = new AIWanderPosFinder(this, _wanderRadius * 0.2f, _wanderRadius * 0.5f); cacheTrans = transform; StopMove(); }
public void RefreshStatus() { DelKeysList.Clear(); foreach (var pair in ActiveObjDic) { SceneObj sceneObj = pair.Value; if (sceneObj.status == SceneObjStatus.Old) { DelKeysList.Add(pair.Key); } else if (sceneObj.status == SceneObjStatus.New) { sceneObj.status = SceneObjStatus.Old; } } for (int i = 0; i < DelKeysList.Count; ++i) { MoveToInActive(ActiveObjDic[DelKeysList[i]].data); } }
/////////////////////////////////////////////////////////////////////////////// // auxiliary /////////////////////////////////////////////////////////////////////////////// IEnumerator AttractTo_Coroutine(SceneObj _object) { float timer = 0.0f; float duration = attractDuration; Vector3 start = transform.position; while ( timer <= duration ) { if (_object == null) yield break; float ratio = timer / duration; Vector3 end = _object.transform.position + new Vector3( 0.0f, 1f, 0.0f ); Vector3 pos = Vector3.Lerp(start, end, ratio); transform.position = pos; // timer += Time.deltaTime; yield return 0; } this.Dead(_object); }
private void LoadObjsMenu(SceneObj obj) { var button = Instantiate(objBtnPrefab, objPanel.transform, false); button.menuManager = this; button.gameObject.SetActive(true); onSelectChange += button.OnChangeSelectMode; var objTexture = _manager.objsTextures.First(y => y.Name == obj.name).Textures; var objColors = new Color[objTexture.Length]; for (var i = 0; i < objTexture.Length; i++) { var value = Random.Range(0, 1f); var color = Color.HSVToRGB(value, 1, 1); objColors[i] = color; } button.text.text = obj.name; button.objGuidRef = obj.guid; button.LoadTexture(objTexture); button.LoadColors(objColors); }
/// <summary> /// 获取资源 /// </summary> /// <param name="resType">资源文件类型号1-12</param> /// <param name="type">资源类型</param> /// <param name="index">资源索引号</param> /// <returns>资源对象,不存在则返回</returns> public ResBase GetRes(int resType, int type, int index) { ResBase rtn = null; int offset = GetDataOffset(resType, type, index); //TODO 超过索引的资源直接不处理??? if (offset != -1 && offset < _data.Length) { switch (resType) { case RES_GUT: rtn = new ResGut(Context); break; case RES_MAP: rtn = new ResMap(Context); break; case RES_ARS: switch (type) { case 1: // 玩家角色 rtn = new PlayerCharacter(Context); break; case 2: // NPC角色 rtn = new NPC(Context); break; case 3: // 敌人角色 rtn = new Monster(Context); break; case 4: // 场景对象 rtn = new SceneObj(Context); break; default: rtn = null; break; } break; case RES_MRS: rtn = InternalGetMagic(type, index); break; case RES_SRS: rtn = new ResSrs(Context); break; case RES_GRS: rtn = InternalGetGoods(type, index); break; case RES_TIL: case RES_ACP: case RES_GDP: case RES_GGJ: case RES_PIC: rtn = new ResImage(Context); break; case RES_MLR: if (type == 1) { rtn = new ResMagicChain(Context); } else if (type == 2) { rtn = new ResLevelupChain(Context); } break; } rtn.SetData(_data, offset); } else { // 资源不存在 //Log.e("Context.LibData.GetRes", "resType:" + resType + " type:" + type + " index:" + index + " not found."); } return(rtn); }
public virtual bool Hurt(SceneObj _object, object _param) {
/////////////////////////////////////////////////////////////////////////////// // public /////////////////////////////////////////////////////////////////////////////// public void AttractTo(SceneObj _object) { attracted = true; StartCoroutine(AttractTo_Coroutine(_object)); }
private void OnMouseDown(SceneObj obj) => _currentEvent.OnMouseDown(obj);
public void OnMouseDown(SceneObj obj) { _gameObject = obj.gameObject; }
public virtual void OnMouseUp(SceneObj objScene) { }
public virtual void OnMouseDown(SceneObj objScene) { }
private void ObjSceneAdd(SceneObj obj) { objsScene.Add(obj); }