public virtual void Release() { _isDead = true; for (int i = 0; i < _components.Count; i++) { _components[i].Release(); } _components.Clear(); SnakerNode node = _head; while (node != null) { // release node... node.Release(); node = node.NextNode; } _head = null; _tail = null; hitNode = null; enegy = 0; _ownerPlayer = null; _view = null; }
public Snaker(PlayerData player, Vector3 initPos, float initSpeed = 0f) { _ownerPlayer = player; // load table _data = CSVTableLoader.GetTableContainer("Snaker").GetRow(player.snakerData.id.ToString()); _head = new SnakerHead(); _head.InitData(_data["Head"].IntValue, 0, this, initPos); _tail = new SnakerTail(); _tail.InitData(_data["Tail"].IntValue, 0, this, initPos); _head.SetNextNode(_tail); _tail.SetPrevNode(_head); _components = new List <SnakerComponent>(); if (_ownerPlayer.aiID > 0) { SnakerAI ai = new SnakerAI(this, _ownerPlayer.aiID); _components.Add(ai); } _isDead = false; // input _moveSpeed = initSpeed; _inputDirection = new Vector3(); _moveDirection = new Vector3(0f, 1f, 0f); enegy = 0; pre_length = -1; pre_count = 0; hitNode = null; // init snaker nodes AddNode(InitLength, initPos); }