private void CreateNode(Vector3 v) { _lastCheckPos = _unit.transform.position; Vector3 p = new Vector3(v.z, 0, -v.x); VectorHelper.ResizeVector(ref p, _unit.unit.dataUnit.GetRadius() - 0.7f); VectorHelper.ResizeVector(ref v, -(_unit.unit.dataUnit.GetRadius() - 1f)); Vector3 p1 = _unit.transform.position - p + v; Vector3 p2 = _unit.transform.position + p + v; float rotationY = -Mathf.Atan2(v.z, v.x) / Mathf.PI * 180; int tileIndex1 = UnitTrackControl.QueryTrackTile(); int tileIndex2 = UnitTrackControl.QueryTrackTile(); UnitTrackControl.SetTrackTile(tileIndex1, p1, rotationY); UnitTrackControl.SetTrackTile(tileIndex2, p2, rotationY); Node node1 = new Node(); node1.tileIndex = tileIndex1; node1.timestamp = TimeHelper.GetCurrentTimestampScaled(); _nodes.Add(node1); Node node2 = new Node(); node2.tileIndex = tileIndex2; node2.timestamp = TimeHelper.GetCurrentTimestampScaled(); _nodes.Add(node2); }
private void UpdateNodes() { long ct = TimeHelper.GetCurrentTimestampScaled(); int n = _nodes.Count; for (int i = n - 1; i >= 0; --i) { Node node = _nodes[i]; bool fadeout = _unit.isDead || (i < n - TRACK_RESERVE_COUNT); if (!fadeout) { node.timestamp = ct; } else { float dt = ct - node.timestamp; float alpha = 1 - dt / TRACK_DURATION_MS; if (alpha <= 0) { UnitTrackControl.ReturnTrackTile(node.tileIndex); _nodes.RemoveAt(i); } else { if (alpha - node.alpha < -0.05f) { UnitTrackControl.SetTileAlpha(node.tileIndex, alpha); node.alpha = alpha; } } } } }
// Use this for initialization void Start() { Assert.assert(_instance == null); _instance = this; if (AppConfig.DEBUGGING) { new MyTest(); } CreateBattleData(); // SceneBattle _camera = GameObject.FindGameObjectWithTag(AppConfig.TAB_MAIN_CAMERA); //todo, use define in mission _unitGroup = new UnitGroup(); _mapGrid = new MapGrid(InstancePlayer.instance.battle.dataMap); _mapAStar = new MapAStar(_mapGrid); _mapCamera = new MapCamera(); _gameEntering = new BattleGameEntering(this); _mouseContorl = new MouseControl(this); _gameSkill = new GameSkill(); _gameSkillControl = new GameSkillControl(this); // MapAStar.PATH path = _mapAStar.Calc (5, 2, 15, 2); // _mapGrid.AddPath (path); AudioGroup.Play(GetComponent <AudioGroup> ().music, _camera, AudioGroup.TYPE.MUSIC); UnitTrackControl.ClearTrackTiles(); BattleGameHelper.PreloadAssets(); }