Esempio n. 1
0
    private void PlayerMoveByIndex(int index)
    {
        //TODO : When selected answer True or False
        //if (mgamemanager.mplayerselected_brain && mgamemanager != null)
        //{
        //    if (mmovenum[index] != -1)
        //    {
        //        mcurrentwaypointid[index]++;
        //    }
        //    mmovenum[index]++;

        //}

        if (mPathHolderID[index] < 3 && mMoveNum[index] > -1)
        {
            // TODO : Not yet to test
            DifferentMoveForEachPlayer(index);

            PathPoints pathPoint         = mMoveOnPath[mPathHolderID[index]];
            Transform  pathPointPosition = pathPoint.mPath_Objs[mCurrentWayPointID[index]];

            // float distance = Vector3.Distance(pathPointPosition.position, transform.position);
            transform.position = Vector3.MoveTowards(transform.position, pathPointPosition.position, Time.deltaTime * mSpeed);

            var rotation = Quaternion.LookRotation(pathPointPosition.position - transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * mRotateSpeed);
        }
    }
Esempio n. 2
0
        public LapPathGroup(dynamic bymlNode)
        {
            if (bymlNode is Dictionary <string, dynamic> )
            {
                Prop = (Dictionary <string, dynamic>)bymlNode;
            }
            else
            {
                throw new Exception("Not a dictionary");
            }

            int index = 0;

            foreach (var point in this["PathPt"])
            {
                PathPoints.Add(new LapPathPoint(point)
                {
                    Name = $"Point [{index++}]"
                });
            }

            index = 0;
            foreach (var point in this["ReturnPoints"])
            {
                ReturnPoints.Add(new ReturnPoint(point)
                {
                    Name = $"Point [{index++}]"
                });
            }
        }
Esempio n. 3
0
 public override void Update(Point currentLocation)
 {
     if (ToMove && currentLocation == NextPosition)
     {
         PathPoints.RemoveAt(0);
     }
 }
Esempio n. 4
0
    public static PathPoints Create()
    {
        PathPoints asset = ScriptableObject.CreateInstance <PathPoints>();

        AssetDatabase.CreateAsset(asset, "Assets/PathPoints.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 void Awake()
 {
     dimension     = (int)Mathf.Pow(2, level);
     points        = new List <Point>();
     objPos        = new List <Vector3>();
     gridPositions = new List <Vector3>();
     pathPoints    = new PathPoints(Vector3.zero, Vector3.zero);
 }
Esempio n. 6
0
 public void MakePlayerReadyToMove(PathPoints[] pathPointsToMoneOn_)
 {
     isReady                   = true;
     transform.position        = pathPointsToMoneOn_[0].transform.position;
     numberOfStepsAlreadyMoved = 1;
     previousPathPoint         = pathPointsToMoneOn_[0];
     currentPathPoint          = pathPointsToMoneOn_[0];
     GameManager.gm.AddPathPoint(currentPathPoint);
 }
Esempio n. 7
0
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         pathPoints = AssetDatabase.LoadAssetAtPath(objectPath, typeof(PathPoints)) as PathPoints;
     }
     SceneView.onSceneGUIDelegate += OnSceneGUI;
 }
Esempio n. 8
0
 public void RemovePathPoint(PathPoints pathPoint_)
 {
     if (playerOnPathPointsList.Contains(pathPoint_))
     {
         playerOnPathPointsList.Remove(pathPoint_);
     }
     else
     {
         Debug.Log("PP Removed");
     }
 }
Esempio n. 9
0
 public void CyclePoint()
 {
     if (PathPoints.ContainsKey(TargetPoint + 1))
     {
         TargetPoint++;
     }
     else
     {
         TargetPoint = 0;
     }
 }
Esempio n. 10
0
        public void Dispose()
        {
            PathPoints?.Clear();
            Paths?.Clear();
            SpriteBank?.Clear();

            Paths      = null;
            PathPoints = null;
            Sprite     = null;
            SpriteBank = null;
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 12
0
 public void ResetToken(PlayerPiece _p, PathPoints pathPoints)
 {
     print("Pathpoint " + pathPoints);
     pathPoints.RemovePlayerPiece(_p);
     _p.transform.localPosition = _p._base.localPosition;
     //_p.currentPathPoint.RemovePlayerPiece(_p);
     pathPoints.RemovePlayerPiece(_p);
     _p.isReady = false;
     _p.canMove = false;
     _p.numberOfStepsAlreadyMoved = 0;
     return;
 }
Esempio n. 13
0
 void CreateNewItemList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex  = 0;
     pathPoints = PathPointsCreator.Create();
     if (pathPoints)
     {
         pathPoints.pointsList = new List <PathPoint>();
         string relPath = AssetDatabase.GetAssetPath(pathPoints);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Esempio n. 14
0
        public EnemyPathGroup(dynamic bymlNode)
        {
            if (bymlNode is Dictionary <string, dynamic> )
            {
                Prop = (Dictionary <string, dynamic>)bymlNode;
            }
            else
            {
                throw new Exception("Not a dictionary");
            }

            foreach (var point in this["PathPt"])
            {
                PathPoints.Add(new EnemyPathPoint(point));
            }
        }
Esempio n. 15
0
    void OpenItemList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Path List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            pathPoints = AssetDatabase.LoadAssetAtPath(relPath, typeof(PathPoints)) as PathPoints;
            if (pathPoints.pointsList == null)
            {
                pathPoints.pointsList = new List <PathPoint>();
            }
            if (pathPoints)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
        public void DrawTunnelPath(GraphicsDevice graphicsDevice)
        {
            if (PathPoints.Count > 0)
            {
                VertexPositionColor[] vectors = new VertexPositionColor[PathPoints.Count];

                for (int i = 0; i < PathPoints.Count; i++)
                {
                    if (i % 2 == 0)
                    {
                        vectors[i] = new VertexPositionColor(PathPoints.ElementAt(i), Color.Red);
                    }
                    else
                    {
                        vectors[i] = new VertexPositionColor(PathPoints.ElementAt(i), Color.Gold);
                    }
                }
                graphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, vectors, 0, vectors.Count() - 1);
            }
        }
        private PathPoints[] getPoints(Path path)
        {
            PathPoints[] pointArray = new PathPoints[100];
            PathMeasure  pm         = new PathMeasure(path, false);
            float        length     = pm.Length;
            float        distance   = 0f;
            float        speed      = length / 100;
            int          counter    = 0;

            float[] aCoordinates = new float[2];

            while ((distance < length) && (counter < 100))
            {
                // get point from the pathMoon
                pm.GetPosTan(distance, aCoordinates, null);
                pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
                counter++;
                distance = distance + speed;
            }

            return(pointArray);
        }
        // Used to fetch points from given path.
        private PathPoints[] getPoints(Path p)
        {
            //Size of 1000 indicates that, 1000 points
            // would be extracted from the path
            var pointArray   = new PathPoints[1000];
            var pm           = new PathMeasure(p, false);
            var length       = pm.Length;
            var distance     = 0f;
            var speed        = length / 1000;
            var counter      = 0;
            var aCoordinates = new float[2];

            while ((distance < length) && (counter < 1000))
            {
                pm.GetPosTan(distance, aCoordinates, null);
                pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
                counter++;
                distance = distance + speed;
            }

            return(pointArray);
        }
Esempio n. 19
0
    IEnumerator MoveSteps_Enum(PathPoints[] pathPointsToMoneOn_)
    {
        yield return(new WaitForSeconds(0.25f));

        int numOfStepsToMove = GameManager.gm.numOfStepsToMove;

        if (canMove)
        {
            previousPathPoint.RescaleAndReposAllPlayerPieces();
            for (int i = numberOfStepsAlreadyMoved; i < (numberOfStepsAlreadyMoved + numOfStepsToMove); i++)
            {
                if (isPathPointsAvailableToMove(numOfStepsToMove, numberOfStepsAlreadyMoved, pathPointsToMoneOn_))
                {
                    transform.position = pathPointsToMoneOn_[i].transform.position;
                    yield return(new WaitForSeconds(0.5f));
                }
            }
        }
        movementDone = true;

        GameManager.gm.State(this);
        if (isPathPointsAvailableToMove(numOfStepsToMove, numberOfStepsAlreadyMoved, pathPointsToMoneOn_))
        {
            numberOfStepsAlreadyMoved += numOfStepsToMove;

            GameManager.gm.RemovePathPoint(previousPathPoint);
            previousPathPoint.RemovePlayerPiece(this);
            currentPathPoint = pathPointsToMoneOn_[numberOfStepsAlreadyMoved - 1];
            currentPathPoint.AddPlayerPiece(this);
            GameManager.gm.AddPathPoint(currentPathPoint);
            previousPathPoint = currentPathPoint;
        }
        if (moveSteps_Coroutine != null)
        {
            StopCoroutine(moveSteps_Coroutine);
        }
    }
Esempio n. 20
0
 public void AddPathPoint(PathPoints pathPoint_)
 {
     playerOnPathPointsList.Add(pathPoint_);
 }