コード例 #1
0
ファイル: CheckPointsMainCS.cs プロジェクト: lovigame/alalei
 /*
  *	FUNCTION: Get the CP gameobjects of the currently active patches.
  *	USED BY:	PatchesRandomizer.Start()
  *				PatchesRandomizer.Start()
  */
 public void setChildGroups()
 {
     foreach (Transform child in hPatchesRandomizerCS.getCurrentPatch().transform)
     {
         if (child.name.Contains("CheckPoints"))
         {
             goCPsGroup = child.gameObject;
         }
     }
     foreach (Transform child in hPatchesRandomizerCS.getNextPatch().transform)
     {
         if (child.name.Contains("CheckPoints"))
         {
             goNextCPsGroup = child.gameObject;
         }
     }
 }
コード例 #2
0
ファイル: MoveForwardCS.cs プロジェクト: lovigame/alalei
    // Use this for initialization
    void Start()
    {
        bMoving = false;

        hCheckPointsMainCS   = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS));
        hPatchesRandomizerCS = (PatchesRandomizerCS)GameObject.Find("Player").GetComponent(typeof(PatchesRandomizerCS));
        if (this.transform.parent.parent == null)
        {
            hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.GetComponentInChildren(typeof(PathLineDrawerCS));
            patch             = this.transform.parent.gameObject;
        }
        else
        {
            hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.parent.GetComponentInChildren(typeof(PathLineDrawerCS));
            patch             = this.transform.parent.parent.gameObject;
        }

        fSpeedPercent = fSpeed / hPathLineDrawerCS.fPathLength;

        isNext  = patch == hPatchesRandomizerCS.getNextPatch();
        isFirst = patch == hPatchesRandomizerCS.getCurrentPatch();
        Vector3 pos;

        if (isNext)
        {
            pos    = hCheckPointsMainCS.getNextWSPointBasedOnPercent(fPercent);
            fAngle = hPatchesRandomizerCS.getNextPatch().transform.eulerAngles.y;
        }
        else
        {
            pos    = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent);
            fAngle = hPatchesRandomizerCS.getCurrentPatch().transform.eulerAngles.y;
        }

        offset = this.transform.position - pos;
    }
コード例 #3
0
ファイル: MoveForwardCS.cs プロジェクト: lovigame/alalei
    // Update is called once per frame
    void Update()
    {
        if (isStoped)
        {
            return;
        }

        if (bMoving)
        {
            fPercent -= fSpeedPercent;

            Vector3 pos;
            if (fPercent <= 0)
            {
                if (isNext)
                {
                    isNext    = false;
                    fPercent += 1f;
                }
                else
                {
                    Destroy(this.gameObject);
                    return;
                }
            }

            if (isNext)
            {
                if (patch == hPatchesRandomizerCS.getNextPatch())
                {
                    pos = hCheckPointsMainCS.getNextWSPointBasedOnPercent(fPercent);
                    //this.transform.localEulerAngles = new Vector3(this.transform.rotation.x, hCheckPointsMainCS.getNextAngle(fPercent),this.transform.rotation.y);
                }
                else if (patch == hPatchesRandomizerCS.getCurrentPatch())
                {
                    pos = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent);
                    //this.transform.localEulerAngles = new Vector3(this.transform.rotation.x, hCheckPointsMainCS.getCurrentAngle(fPercent),this.transform.rotation.y);
                }
                else
                {
                    Destroy(this.gameObject);
                    return;
                }
            }
            else
            {
                if (isFirst)
                {
                    if (patch == hPatchesRandomizerCS.getCurrentPatch())
                    {
                        pos = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent);
                        //this.transform.localEulerAngles = new Vector3(this.transform.rotation.x, hCheckPointsMainCS.getCurrentAngle(fPercent),this.transform.rotation.y);
                    }
                    else
                    {
                        Destroy(this.gameObject);
                        return;
                    }
                }
                else
                {
                    if (patch == hPatchesRandomizerCS.getCurrentPatch())
                    {
                        Destroy(this.gameObject);
                        return;
                    }
                    pos = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent);
                    //this.transform.localEulerAngles = new Vector3(this.transform.rotation.x, hCheckPointsMainCS.getCurrentAngle(fPercent) - (fAngle-hPatchesRandomizerCS.getCurrentPatch().transform.eulerAngles.y),this.transform.rotation.y);
                }
            }

            Vector3 dir   = (pos + offset) - this.transform.position;
            float   angle = PosAngleofVector(dir);
            if (angle > 180.0f)
            {
                angle = angle - 360.0f;
            }

            this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, -angle + 180, this.transform.eulerAngles.z);

            //this.transform.Translate(pos+offset - this.transform.position);
            this.transform.position = pos + offset;
        }
        else
        {
            if (Vector3.Distance(GameObject.Find("Player").transform.position, this.transform.position) <= fStartDistance)
            {
                bMoving = true;
            }
        }
    }