public SilkMidPoint(Silk silk, int indexOnSilk, Vector2 nearerPoint, Vector2 myPos, Vector2 fartherPoint) : base(silk) { _indexOnSilk = indexOnSilk; var f = fartherPoint - myPos; var n = nearerPoint - myPos; _hand = (f.x * n.y - f.y * n.x) > 0 ? HandType.Right : HandType.Left; }
public void RemoveSilkIfAny() { if (_silk != null) { _silk.Remove(); _silk = null; _currentHangOn = null; } }
public void BreakUpHeldSilk() { Debug.Log("BreakUpHeldSilk"); if (!SilkInMouth) { return; } SilkInMouth.BreakUp(); SilkInMouth = null; }
/// <summary> /// 创建时必须手动立即执行这个,相当于构造器,但是Awake()不能填参数 /// </summary> /// <param name="mySilk"></param> /// <param name="indexOnSilk"></param> public void Initialize(Silk mySilk, int indexOnSilk) { MySilk = mySilk; IndexOnSilk = indexOnSilk; var center = MySilk.transform.InverseTransformPoint((FarPoint.Position + NearPoint.Position) * 0.5f); LastLine.x = NearPoint.Position.x; LastLine.y = NearPoint.Position.y; LastLine.z = FarPoint.Position.x; LastLine.w = FarPoint.Position.y; }
private void Awake() { if (!RenderedSilk) { RenderedSilk = GetComponent <Silk>(); } if (!RenderedSilk) { Debug.LogWarning("no silk to render!"); enabled = false; } }
public SilkEnd(Silk silk) : base(silk) { TempMass = new GameObject("End TempMass(ERROR:NO NAME)", typeof(Rigidbody2D)); TempMass.layer = LayerManager.Layer.Silk; TempMass.transform.parent = silk.transform;//使用时再放出来 var rigidbody = TempMass.GetComponent <Rigidbody2D>(); rigidbody.mass = Silk.TempMass; rigidbody.drag = 0f; rigidbody.centerOfMass = Vector3.zero; rigidbody.inertia = 0.1f; //rigidbody.gravityScale = 1f; 不需有重力,仅当Free时才会有重力 TempMass.SetActive(false); }
public Silk CreateSilk(Transform pointA, Transform pointB) { if (!CanSilk(pointA, pointB)) { return(null); } _climbedOnTop = false; RemoveSilkIfAny(); _silk = new Silk(silkWidth); DoCreateSilk(pointA, pointB); _currentHangOn = pointB.gameObject; return(_silk); }
public void Spit(Vector2 dir) { if (dir.x == 0 && dir.y == 0) { Debug.LogError("dir == 0"); return; } if (SilkInMouth)//嘴里有丝 { } else//嘴里无丝 { var go = Instantiate(SilkPrefab); go.transform.ResetAs(SilkPrefab.transform); //var go = new GameObject("Silk " + Time.frameCount); SilkInMouth = go.GetComponent <Silk>(); SilkInMouth.NewSpit( transform.TransformPoint(MouthPosLocal).ToVector2(), dir.normalized * ShootSpeed, this, ShootRange); } }
public void Silking(Transform destination) { if (_silkManager.CanSilk(transform, destination)) { // CreateSilk will make old silk go away, so make sure // spider is not at the child of any silk transform.SetParent(_savedParent); Silk silk = _silkManager.CreateSilk(transform, destination); if (silk != null) { List <GameObject> chains = silk.GetChains(); Debug.Log("chains # " + chains.Count); if (_spiderClimbCoroutine != null) { StopCoroutine(_spiderClimbCoroutine); _state = State.Floating; transform.SetParent(_savedParent); _spiderClimbCoroutine = null; } _spiderClimbCoroutine = StartCoroutine(ClimbUp(chains)); } } }
public SilkPoint(Silk silk) { MySilk = silk; }
public void SetSilk(Silk silk) { _silk = silk; }