public Web(Vector2 start, Vector2 end, WebPlatform target) { this.start = start; this.end = end; this.target = target; }
private void SetAutoMapElementTypes() { if (mWizard.AutoMapElementTypesList.Count == 0) { List <eElementType> UIElementsTypeList = null; switch (mAppPlatform) { case ePlatformType.Web: WebPlatform webPlatformInfo = new WebPlatform(); UIElementsTypeList = webPlatformInfo.GetPlatformUIElementsType(); break; } foreach (eElementType eET in UIElementsTypeList) { mWizard.AutoMapElementTypesList.Add(new UIElementFilter(eET, string.Empty)); } } }
IEnumerator IZip(Vector2 target) { bool loop = true; animator.SetTrigger("Fly"); while (loop) { state = State.Flying; transform.position = Vector3.MoveTowards(transform.position, target, zipSpeed * Time.deltaTime); web.SetPosition(0, this.transform.position); web.SetPosition(1, target); if ((Vector2.Distance(this.transform.position, target) > 0.25f)) { yield return(null); } else { transform.position = target; currentPlatform = currentWeb.target; web.positionCount = 0; loop = false; currentWeb = null; Debug.Log("Current Zip is Null now"); currentZip = null; yield return(true); } } }
private void Shoot() { // left click if (Input.GetMouseButtonDown(0) && currentZip == null) { state = State.Shooting; animator.SetTrigger("Fire"); RaycastHit2D[] hit = Physics2D.RaycastAll(transform.position, aimDirection, slingDist, raycastMask); web.startColor = new Color(241 / 255f, 241 / 255f, 215 / 255f); web.endColor = new Color(241 / 255f, 241 / 255f, 215 / 255f); web.SetWidth(0.05f, 0.05f); web.positionCount = 2; web.SetPosition(0, this.transform.position); bool hitTrigger = false; for (int i = 0, counti = hit.Length; i < counti; i++) { if (hit[i].collider != null) { // Spider has hit platform which is not theirs if (hit[i].transform.GetComponent <WebPlatform>() != null && hit[i].transform.GetComponent <WebPlatform>() != currentPlatform) { // grab the platform we're aiming at WebPlatform nextPlatform = hit[i].transform.gameObject.GetComponent <WebPlatform>(); // can't zip to same platform... this causes issues... if (currentWeb == null && nextPlatform != null && nextPlatform != currentPlatform) { hitTrigger = true; FMODUnity.RuntimeManager.PlayOneShot("event:/Spoder/Web_Splat"); currentWeb = new Web(this.transform.position, hit[i].point, hit[i].transform.gameObject.GetComponent <WebPlatform>()); Vector2 target = currentWeb.end; currentOrientation = currentWeb.target.Direction(); //store the current coroutine so we don't start another until it's up!.. IEnumerator kinda sucks, but game jam! Debug.Log("SETTING CURRENT ZIP"); currentZip = StartCoroutine(IZip(target)); GetComponent <FMODUnity.StudioEventEmitter>().Stop(); float dot = Vector2.Dot(hit[i].normal, Vector2.up); Debug.Log(string.Format("Surface Normal: {0}, Spider Up {1}, Dot {2}", hit[i].normal, Vector2.up, dot)); // floor if (dot <= -1) { Debug.Log("Horizontal"); Quaternion currentRot = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z); rotState = RotState.InvertHorizontal; this.transform.rotation = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, 180); } // ceiling if (dot >= 1) { Debug.Log("Horizontal"); rotState = RotState.normalHorizontal; Quaternion currentRot = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z); this.transform.rotation = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, 0); } if ((dot > 0 && dot < 1) || (dot < 0 && dot > -1)) { Debug.Log("Vertical"); Quaternion currentRot = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z); if (aimDirection.x < 0) { rotState = RotState.invertVertical; this.transform.rotation = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, -90); } else { rotState = RotState.normalVertical; this.transform.rotation = Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, 90); } } break; } } // Fly has caught spider else if (hit[i].transform.GetComponent <Fly>() && hit[i].transform.GetComponent <Fly>() != victim) { if (hit[i].transform.GetComponent <Fly>().FlyState == Fly.FlyStates.AtTable) { continue; } Debug.Log("Hit Fly"); hitTrigger = true; Fly nextFly = hit[i].transform.GetComponent <Fly>(); FMOD.Studio.EventInstance instance = FMODUnity.RuntimeManager.CreateInstance("event:/Flappy Fly/Fly_Hit"); Debug.Log(nextFly.Gender); instance.setParameterValue("Female_Fly", nextFly.Gender); instance.start(); /// i.e spider is not carrying anyone if (victim == null) { victim = nextFly; victim.Caught(); currentReel = StartCoroutine(IReelInVictim()); nextFly.GetComponent <Animator>().SetTrigger("Trapped"); } else { nextFly.Kill(); } break; } } } // no hit if (!hitTrigger) { Debug.Log("No Hit"); Debug.DrawRay(transform.position, aimDirection * slingDist, Color.yellow); web.SetPosition(1, this.transform.position + (Vector3)(aimDirection * slingDist)); } } else { if (currentZip == null && currentReel == null) { // stop slinging that web web.positionCount = 0; } } }