コード例 #1
0
    static void AddDialogue()
    {
        Debug.Log("adding Dialogue...");
        GameObject dialoguePF = AssetDatabase.LoadAssetAtPath("Assets/Zyndo/Prefabs/Dialogue.prefab", typeof(GameObject)) as GameObject;

        for (int i = 0; i < Selection.gameObjects.Count(); i++)
        {
            GameObject panel = GameObject.Instantiate(dialoguePF) as GameObject;
            panel.transform.SetParent(Selection.gameObjects [i].transform);
            panel.name = "Dialogue";
            PathMagic pm = panel.transform.parent.GetComponentInChildren <PathMagic> ();
            if (pm != null)
            {
                panel.transform.SetSiblingIndex(pm.transform.GetSiblingIndex());
            }

            var dialogue = panel.GetComponent <DialogueText>();
            dialogue.internal_id = dialogue.SetInternalID();

            Transform[] rectTrans = panel.GetComponentsInChildren <RectTransform> ();
            foreach (Transform rect in rectTrans)
            {
                rect.localPosition = Vector3.zero;
                rect.localScale    = Vector3.one;
            }
        }
    }
コード例 #2
0
 public void StartCrawling(GameObject crawler)
 {
     this.crawler     = crawler;
     pathMagic        = GetComponent <PathMagic>();
     pathMagic.Target = crawler.transform;
     pathMagic.waypoints[pathMagic.waypoints.Length - 1].reached.AddListener(crawler.GetComponent <CrawlerAI>().AttackPortal);
     pathMagic.Play();
 }
コード例 #3
0
    public void StartFlying(GameObject fly)
    {
        this.fly         = fly;
        pathMagic        = GetComponent <PathMagic>();
        pathMagic.Target = fly.transform;

        Transform globalTarget = GameObject.FindGameObjectWithTag("Portal").transform;

        pathMagic.globalLookAt = globalTarget;

        fly.GetComponent <FlyDroneAIPath>().SetPath(this);
        pathMagic.Play();
    }
コード例 #4
0
        /// <summary>
        /// Creates A new instance of Road in the Hierarchy view.
        /// </summary>
        /// <param name="menuCommand">Menu command.</param>
        public static void CreateNewTorus(MenuCommand menuCommand)
        {
            // Create a custom game object
            GameObject go = new GameObject("Road");

            go.transform.rotation = Quaternion.Euler(0f, 00f, 0f);
            // Ensure it gets reparented if this was a context click (otherwise does nothing)
            GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);

            PathMagic path = go.AddComponent <PathMagic> ();

            Waypoint wp1 = new Waypoint();

            wp1.Position          = Vector3.zero;
            wp1.InTangent         = Vector3.back;
            wp1.OutTangent        = Vector3.forward;
            wp1.SymmetricTangents = true;

            Waypoint wp2 = new Waypoint();

            wp2.Position          = new Vector3(0, 0, 10);
            wp2.InTangent         = Vector3.back;
            wp2.OutTangent        = Vector3.forward;
            wp2.SymmetricTangents = true;

            path.Waypoints = new Waypoint[] {
                wp1,
                wp2
            };

            path.Loop             = false;
            path.GlobalFollowPath = true;

            PathMagicRoad road = go.AddComponent <PathMagicRoad> ();

            road.path       = path;
            road.closeFront = true;
            road.closeBack  = true;
            road.Generate();

            MeshRenderer mr = road.GetComponent <MeshRenderer> ();

            mr.materials = new Material[] { new Material(Shader.Find("Standard")),
                                            new Material(Shader.Find("Standard")),
                                            new Material(Shader.Find("Standard")) };

            // Register the creation in the undo system
            Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);

            Selection.activeObject = go;
        }
コード例 #5
0
    /// <summary>
    /// Computes the position for a specific waypoint. This implementation takes account of the effective
    /// distances from waypoints. The implementation takes also account of the fact that the path is
    /// pre-sampled or not.
    /// </summary>
    /// <returns>The position for waypoint.</returns>
    /// <param name="waypoint">Waypoint.</param>
    public float ComputePosForWaypoint(PathMagic pm, int waypoint)
    {
        float pos  = 0f;
        float step = 0.0001f;

        if (!pm.presampledPath)
        {
            // Compute the pos to the minWaypoint in non-pre-sampled path
            pos = CalcPosForWaypointIndex(pm, waypoint);
        }
        else
        {
            // Compute the pos to the minWaypoint in pre-sampled path
            int i = 0;
            while (pm.WaypointSamples [i] != waypoint)
            {
                pos += pm.SamplesDistances [i++];
            }

            pos /= pm.TotalDistance;

            float      p = pos;
            Vector3    position;
            Quaternion rotation;
            float      vel;
            int        wp;
            float      lastDistanceFromWaypoint;

            pm.sampledPositionAndRotationAndVelocityAndWaypointAtPos(p, out position, out rotation, out vel, out wp);

            do
            {
                lastDistanceFromWaypoint = Vector3.Distance(position, pm.Waypoints [waypoint].Position);

                p += step;
                if (p > 1f)
                {
                    p = 1f;
                }

                pm.sampledPositionAndRotationAndVelocityAndWaypointAtPos(p, out position, out rotation, out vel, out wp);
            } while(Vector3.Distance(position, pm.Waypoints [waypoint].Position) <= lastDistanceFromWaypoint && p < 1);

            pos = p;
        }

        return(pos);
    }
コード例 #6
0
ファイル: FishngManager.cs プロジェクト: Oksanny/Aquarium
    void SelectPath()
    {
        List <int> numberFishingPath = new List <int>();

        for (int i = 0; i < FishingPaths.Count; i++)
        {
            numberFishingPath.Add(i);
        }
        int currentNumber = Random.Range(0, numberFishingPath.Count);

        CurrentPath = FishingPaths[numberFishingPath[currentNumber]];
        for (int i = 0; i < Fishs.Count; i++)
        {
            Fishs[i].FishingPath = CurrentPath;
            Fishs[i].Hook        = Hook;
        }
    }
コード例 #7
0
        /// <summary>
        /// Awake this instance. Get the connected instance of type PathMagic or PathMagicAnimator.
        /// </summary>
        void Awake()
        {
            PathMagic pm = GetComponent <PathMagic> ();

            if (pm != null)
            {
                pathMagic         = pm;
                pathMagicAnimator = null;
            }
            else
            {
                PathMagicAnimator pma = GetComponent <PathMagicAnimator> ();
                if (pma != null)
                {
                    pathMagicAnimator = pma;
                    pathMagic         = null;
                }
            }
        }
コード例 #8
0
 /// <summary>
 /// Calculates the float position ([0..1])of a waypoint related to the whole path. This implementation
 /// does not take account of effective distances from waypoints but only waypoints number.
 /// </summary>
 /// <returns>The position for waypoint index.</returns>
 /// <param name="index">The reference index.</param>
 private float CalcPosForWaypointIndex(PathMagic pm, int index)
 {
     return((float)index / (pm.waypoints.Length - (pm.loop ? 0f : 1f)));
 }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     pathMagic         = GetComponent <PathMagic> ();
     requestedWaypoint = 0;
 }