Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
 public void RemoveSilkIfAny()
 {
     if (_silk != null)
     {
         _silk.Remove();
         _silk          = null;
         _currentHangOn = null;
     }
 }
Exemplo n.º 3
0
Arquivo: Worm.cs Projeto: stv1024/IWAW
 public void BreakUpHeldSilk()
 {
     Debug.Log("BreakUpHeldSilk");
     if (!SilkInMouth)
     {
         return;
     }
     SilkInMouth.BreakUp();
     SilkInMouth = null;
 }
Exemplo n.º 4
0
    /// <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;
    }
Exemplo n.º 5
0
 private void Awake()
 {
     if (!RenderedSilk)
     {
         RenderedSilk = GetComponent <Silk>();
     }
     if (!RenderedSilk)
     {
         Debug.LogWarning("no silk to render!");
         enabled = false;
     }
 }
Exemplo n.º 6
0
    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);
    }
Exemplo n.º 7
0
    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);
    }
Exemplo n.º 8
0
Arquivo: Worm.cs Projeto: stv1024/IWAW
 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);
     }
 }
Exemplo n.º 9
0
 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));
         }
     }
 }
Exemplo n.º 10
0
 public SilkPoint(Silk silk)
 {
     MySilk = silk;
 }
Exemplo n.º 11
0
 public void SetSilk(Silk silk)
 {
     _silk = silk;
 }