当前位置: 首页>>代码示例>>C#>>正文


C# Field.getSuccessor方法代码示例

本文整理汇总了C#中Field.getSuccessor方法的典型用法代码示例。如果您正苦于以下问题:C# Field.getSuccessor方法的具体用法?C# Field.getSuccessor怎么用?C# Field.getSuccessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Field的用法示例。


在下文中一共展示了Field.getSuccessor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    // Use this for initialization
    void Start ()
    {

        // Initiate Enemy

        RaycastHit raycastHit;
        if (Physics.Raycast(new Ray(transform.position, Physics.gravity), out raycastHit))
        {

            GameObject gameObject = raycastHit.transform.gameObject;
            if (gameObject)
            {

                Field field = gameObject.GetComponent<Field>();
                if (field)
                {

                    currField = field;
                    nextField = currField.getSuccessor();
                    endDirection = nextField.transform.position - currField.transform.position;
                    startDirection = endDirection; //wartosc umowna, moze wymyslimy lepiej z poprzednika;
                    endPosition = (currField.transform.position + nextField.transform.position)
                                  * 0.5f + new Vector3(0f, offsetY, 0f);
                    startPosition = endPosition - endDirection;
                    currentPercentOfField = 0.5f;

                }

            }

        }

        previousStepPhyramidHeight = Pyramid.singleton.transform.position.y;

	}
开发者ID:sawickiap,项目名称:GGJ2016,代码行数:36,代码来源:Enemy.cs

示例2: Update

	// Update is called once per frame
	void Update ()
    {

        if (this.currField.onPyramid)
        {

            Vector3 delta = new Vector3(0.0f, Pyramid.singleton.transform.position.y
                                              - previousStepPhyramidHeight, 0.0f);
            startPosition = startPosition + delta;
            endPosition = endPosition + delta;
            previousStepPhyramidHeight = Pyramid.singleton.transform.position.y;

        }

        previousStepPhyramidHeight = Pyramid.singleton.transform.position.y;

        float deltaPercentOfPole = speed * Time.deltaTime;

        if (currField.isStairs)
        {
            deltaPercentOfPole *= 0.5f;
        }

        currentPercentOfField += deltaPercentOfPole;

        if (currentPercentOfField > 1.0f)
        {

            currentPercentOfField = currentPercentOfField - 1.0f;
            startDirection = endDirection;
            startPosition = endPosition;
            currField = nextField;
            nextField = currField.getSuccessor();
            endPosition = (currField.transform.position + nextField.transform.position) * 0.5f
                          + new Vector3(0f, offsetY, 0f);
            endDirection = nextField.transform.position - currField.transform.position;

            if (nextField.isStairs) //jesli to schody
            {
                endPosition.y = startPosition.y;
                //endDirection.y = 0.0f;
            }
            else if (currField.isStairs)
            {
                endPosition.y = nextField.transform.position.y + 0.75f;
                //startDirection = endPosition - startPosition;
                endDirection = endPosition - startPosition;
            }

        }

        Vector3 currentDirection;
        if (!this.currField.isStairs)
        {

            Vector3 midPoint = startPosition + startDirection * 0.5f;
            Vector3 newPosition =
                startPosition * (1f - currentPercentOfField) * (1f - currentPercentOfField) +
                midPoint * 2f * (1f - currentPercentOfField) * currentPercentOfField +
                endPosition * currentPercentOfField * currentPercentOfField;

            if (this.isHumanoid)
            {
                newPosition.y = Mathf.Lerp(startPosition.y, endPosition.y, currentPercentOfField);
            }

            this.transform.position = newPosition;

        }
        else
        {
            this.transform.position = Vector3.Lerp(startPosition,endPosition,currentPercentOfField);
        }

        currentDirection = Vector3.Lerp(startDirection, endDirection, currentPercentOfField);

        if (nextField.isStairs)
        {

            currentDirection.y = startDirection.y;
            const float threshold = 0.6f;

            if(currentPercentOfField > threshold)
            {
                currentDirection.y = Mathf.Lerp(startDirection.y, endDirection.y,
                    (currentPercentOfField - threshold) / (1f - threshold));
            }

        }

        if (this.isHumanoid)
        {
            currentDirection.y = 0.0f;
        }

        this.transform.LookAt(this.transform.position + currentDirection);
//        this.transform.position = startPosition + startDirection*
//            Vector3.Lerp(startPosition, endPosition, currentPercentOfPole);//startPosition + Vector3.Lerp(startDirection, endDirection, currentPercentOfPole);

//.........这里部分代码省略.........
开发者ID:sawickiap,项目名称:GGJ2016,代码行数:101,代码来源:Enemy.cs


注:本文中的Field.getSuccessor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。