Пример #1
0
 public void UnbindEntity(Tapestry_Entity e)
 {
     hasBoundEntity = false;
     GetComponent <Rigidbody>().isKinematic = true;
     e.transform.SetParent(null);
     e.GetComponent <Rigidbody>().isKinematic = false;
     e.isPushing = false;
 }
Пример #2
0
    public void BindEntityForPush(Tapestry_Entity e)
    {
        hasBoundEntity = true;
        GetComponent <Rigidbody>().isKinematic   = false;
        e.GetComponent <Rigidbody>().isKinematic = true;
        e.transform.SetParent(this.transform);
        e.isPushing = true;
        GameObject closest      = null;
        float      shortestDist = float.MaxValue;

        foreach (GameObject point in GetAttachPoints())
        {
            float thisDist = Vector3.Distance(point.transform.position, e.attachPoint.transform.position);
            if (thisDist < shortestDist)
            {
                closest      = point;
                shortestDist = thisDist;
            }
        }
        e.transform.rotation = closest.transform.rotation;
        Vector3 offset = closest.transform.position - e.attachPoint.transform.position;

        e.transform.position = e.transform.position + offset;
        activeAttachPoint    = closest;

        int score = e.attributeProfile.GetScore(Tapestry_Config.pushLiftAttribute);

        if (score > pushClumsy)
        {
            if (score > pushImpressive)
            {
                score = pushImpressive;
            }
            float prog = (float)(score - pushClumsy) / (float)(pushImpressive - pushClumsy);
            if (gridAligned)
            {
                pushSpeed = (pushSpeedCurve.Evaluate(prog) * (pushSpeedMax - pushSpeedMin)) + pushSpeedMin;
            }
            else
            {
                float
                    min = Tapestry_Config.BaseEntityWalkSpeed * pushSpeedMin,
                    max = Tapestry_Config.BaseEntityWalkSpeed * pushSpeedMax;
                pushSpeed = (pushSpeedCurve.Evaluate(prog) * (max - min)) + min;
            }
        }
    }