private void OnTryWearShell() { if (_shell != null) { shell = null; Debug.Log("Had a shell, dropped"); return; } List <ShellParent> shells = FindObjectsOfType <ShellParent>().ToList(); shells = shells.OrderBy( x => Vector3.Distance(this.transform.position, x.transform.position) ).ToList(); foreach (ShellParent currentShell in shells) { float distance = (transform.position - currentShell.transform.position).magnitude; Debug.Log("Shell at " + distance); if (distance <= SHELL_GRAB_RANGE) { shell = currentShell; } return; } }
void Start() { shell = shell; //lol main = this; healthBar = GameObject.Find("HealthBar").GetComponent <Image>(); //crabAnimations = GetComponent<Animator>(); _rb = GetComponent <Rigidbody>(); restartButton = GameObject.Find("Restart").GetComponent <UnityEngine.UI.Button>(); restartButton.gameObject.SetActive(false); }
private void OnWearShell(ShellParent newShell) { if (newShell != null) { newShell.Attach(transform); } if (_shell != null) { _shell.Drop(); } _shell = newShell; UpdateShellGraphic(); }
private void DropShell() { shell = null; }
public Sprite GetShellSprite(ShellParent shellObj) { int shellIndex = (shellObj == null) ? 0 : ((int)shellObj.type + 1); return(shellSprites[shellIndex]); }