士兵列阵 - -

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了士兵列阵 - -相关的知识,希望对你有一定的参考价值。

using UnityEngine;
using System.Collections;

public class duilie : MonoBehaviour
{

    object[] objs;
    public ArrayList DL;
    public void Start()
    {
        DL = new ArrayList();
        objs = GameObject.FindSceneObjectsOfType(typeof(Transform));
        foreach (Transform tr in objs)
        {
            if (tr.GetComponent<SphereCollider>())
            {
                DL.Add(tr);
            }
        }
        Debug.Log((DL[0] as Transform).name);
        Debug.Log((DL[1] as Transform).name);
    }

    void Update()
    {

      
            
        
        if (Input.GetKeyDown(KeyCode.D))//一字长蛇阵
        {
            StopAllCoroutines();
            for (int i = 1; i < DL.Count; i++)
            {
                GameObject obj = (DL[i] as Transform).gameObject;
                Debug.Log(obj.name);
                Vector3 _begin = obj.transform.position;
                Vector3 _end = (DL[0] as Transform).position + new Vector3(2, 0, 0) * i;
                StartCoroutine(Z_TWEEN.TweenPosition(obj, _begin, _end, 1));
            }
        }

        if (Input.GetKeyDown(KeyCode.F))//雁行阵
        {
            StopAllCoroutines();
            for (int i = 1; i <= DL.Count / 2; i++)
            {
                GameObject obj_zuo = (DL[i] as Transform).gameObject;
                GameObject obj_you = (DL[DL.Count - i] as Transform).gameObject;

                Vector3 _begin1 = obj_zuo.transform.position;
                Vector3 _end1 = (DL[0] as Transform).position + new Vector3(2, 2, 0) * i;

                Vector3 _begin2 = obj_you.transform.position;
                Vector3 _end2 = (DL[0] as Transform).position + new Vector3(2, -2, 0) * i;

                StartCoroutine(Z_TWEEN.TweenPosition(obj_zuo, _begin1, _end1, 1));
                StartCoroutine(Z_TWEEN.TweenPosition(obj_you, _begin2, _end2, 1));

            }
        }
        if (Input.GetKeyDown(KeyCode.A)) //龟甲阵
        {
            StopAllCoroutines();
            float jiaodu = 2*Mathf.PI / (DL.Count-1);
            Debug.Log(jiaodu);
            float x, y;


            for (int i = 1; i < DL.Count; i++)
            {
                GameObject obj = (DL[i] as Transform).gameObject;

                Vector3 _begin = obj.transform.position;
                x = Mathf.Sin(jiaodu * (i-2)) * 5;
                y = Mathf.Cos(jiaodu * (i-2)) * 5;
                Vector3 _end = new Vector3(x, y, 0)+(DL[0]as Transform).position;
                print(Mathf.Sin(-90f/3.1415926f));
                StartCoroutine(Z_TWEEN.TweenPosition(obj, _begin, _end, 1));
            }
        }
        if (Input.GetKeyDown(KeyCode.S))//箭矢阵
        {
            StopAllCoroutines();
            for (int i = 1; i < DL.Count ; i++)
            {
                if (i <= 2)
                {
                    GameObject obj_zuo = (DL[i] as Transform).gameObject;
                    GameObject obj_you = (DL[DL.Count - i] as Transform).gameObject;

                    Vector3 _begin1 = obj_zuo.transform.position;
                    Vector3 _end1 = (DL[0] as Transform).position + new Vector3(1, 1, 0) * i;

                    Vector3 _begin2 = obj_you.transform.position;
                    Vector3 _end2 = (DL[0] as Transform).position + new Vector3(1, -1, 0) * i;

                    StartCoroutine(Z_TWEEN.TweenPosition(obj_zuo, _begin1, _end1, 1));
                    StartCoroutine(Z_TWEEN.TweenPosition(obj_you, _begin2, _end2, 1));
                }
                else if(i>2&&i<=DL.Count-3)
                {
                    GameObject obj = (DL[i] as Transform).gameObject;
                    Debug.Log(obj.name);
                    Vector3 _begin = obj.transform.position;
                    Vector3 _end = (DL[0] as Transform).position + new Vector3(2, 0, 0) * (i-2);
                    StartCoroutine(Z_TWEEN.TweenPosition(obj, _begin, _end, 1));
                }
            }  
        }
      
    }

}

 

以上是关于士兵列阵 - -的主要内容,如果未能解决你的问题,请参考以下文章

RAID独立冗余磁盘列阵

巴西列阵

磁盘冗余列阵Raid技术知识与实践

#yyds干货盘点#算法给小码农归并排序列阵

《士兵:二战英雄》怎样修改士兵无敌?

c_cpp 一队士兵在操场上排成一列,士兵总数为N,士兵按照队伍从前往后的顺序从1到Ñ依次编号。每个士兵有各自的身高,第I个士兵的身高为AI。士兵列队完毕后,将军走到队列的最前面。因为身高不