Ejemplo n.º 1
0
 /// <summary> Update the minimap to the direction the hero went. </summary>
 /// <param name="direction"> The direction the hero moved in. </param>
 public void UpdateMiniMap(Util.Enums.Direction direction)
 {
     if (this.grid == null)
     {
         return;
     }
     this.grid[(int)this.current.x, (int)this.current.y] = 2;
     if (direction == Util.Enums.Direction.Up)
     {
         this.current = new Vector2(this.current.x - 1, this.current.y);
     }
     if (direction == Util.Enums.Direction.Down)
     {
         this.current = new Vector2(this.current.x + 1, this.current.y);
     }
     if (direction == Util.Enums.Direction.Left)
     {
         this.current = new Vector2(this.current.x, this.current.y - 1);
     }
     if (direction == Util.Enums.Direction.Right)
     {
         this.current = new Vector2(this.current.x, this.current.y + 1);
     }
     this.grid[(int)this.current.x, (int)this.current.y] = 3;
     UpdateMapState();
 }
        private IEnumerator SwitchRooms(Door current)
        {
            this.overlay.FadeIn();
            GameState.Instance.State = Util.Enums.GameState.Tranisioning;
            floorMap.transform.parent.gameObject.SetActive(false);
            Room    next;
            Vector2 postion;

            Util.Enums.Direction directionMoved = Util.Enums.Direction.None;
            if (current.Parent.upperDoor == current)
            {
                next           = current.Parent.Up;
                postion        = new Vector2(0, -7);
                directionMoved = Util.Enums.Direction.Up;
            }
            else if (current.Parent.lowerDoor == current)
            {
                next           = current.Parent.Down;
                postion        = new Vector2(0, 7);
                directionMoved = Util.Enums.Direction.Down;
            }
            else if (current.Parent.leftDoor == current)
            {
                next           = current.Parent.Left;
                postion        = new Vector2(7, 0);
                directionMoved = Util.Enums.Direction.Left;
            }
            else
            {
                next           = current.Parent.Right;
                postion        = new Vector2(-7, 0);
                directionMoved = Util.Enums.Direction.Right;
            }

            if (this.miniMap != null)
            {
                this.miniMap.UpdateMiniMap(directionMoved);
                yield return(0);
            }

            RemoveMoney();

            this.hero.gameObject.transform.position = postion;
            next.transform.localPosition            = Vector3.zero;
            this.cameraTracker.ResetPosition();
            current.Parent.Deactivate();
            yield return(0);

            next.Activate(this.floorMap);
            this.overlay.FadeOut();
            GameState.Instance.State = Util.Enums.GameState.Playing;
            yield break;
        }
Ejemplo n.º 3
0
        public void changeSpot()
        {
            //anim.SetTrigger("MoveBegin");
            mdec = (Util.Enums.Direction)Random.Range(0, 3);

            if (mdec == Util.Enums.Direction.Up)
            {
                //If we're randomly going up
                if (currentNode.panelAllowed(Util.Enums.Direction.Up, Type) || currentNode.Right.Occupied)
                {
                    currentNode.clearOccupied();//Say we aren't here
                    currentNode = currentNode.Up;//Say we're there
                    currentNode.Owner = (this);//Tell the place we own it.
                }
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Right, Type) || currentNode.Right.Occupied)
            {
                currentNode.clearOccupied();//Say we aren't here
                currentNode = currentNode.Right;//Say we're there
                currentNode.Owner = (this);//Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Left, Type) || currentNode.Right.Occupied)
            {
                currentNode.clearOccupied();//Say we aren't here
                currentNode = currentNode.Left;//Say we're there
                currentNode.Owner = (this);//Tell the place we own it.

            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Down, Type) || currentNode.Right.Occupied)
            {
                //If we're randomly going down
                if (currentNode.Up.Occupied == false)
                {
                    currentNode.clearOccupied();//Say we aren't here
                    currentNode = currentNode.Down;//Say we're there
                    currentNode.Owner = (this);//Tell the place we own it.
                }
            }
            anim.SetTrigger("MoveEnd");
            transform.position = currentNode.transform.position;
            turn++;
        }
Ejemplo n.º 4
0
        public void changeSpot()
        {
            //anim.SetTrigger("MoveBegin");
            mdec = (Util.Enums.Direction)Random.Range(0, 3);

            if (mdec == Util.Enums.Direction.Up)
            {
                //If we're randomly going up
                if (currentNode.panelAllowed(Util.Enums.Direction.Up, Type) || currentNode.Right.Occupied)
                {
                    currentNode.clearOccupied();                   //Say we aren't here
                    currentNode       = currentNode.Up;            //Say we're there
                    currentNode.Owner = (this);                    //Tell the place we own it.
                }
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Right, Type) || currentNode.Right.Occupied)
            {
                currentNode.clearOccupied();               //Say we aren't here
                currentNode       = currentNode.Right;     //Say we're there
                currentNode.Owner = (this);                //Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Left, Type) || currentNode.Right.Occupied)
            {
                currentNode.clearOccupied();               //Say we aren't here
                currentNode       = currentNode.Left;      //Say we're there
                currentNode.Owner = (this);                //Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Down, Type) || currentNode.Right.Occupied)
            {
                //If we're randomly going down
                if (currentNode.Up.Occupied == false)
                {
                    currentNode.clearOccupied();                   //Say we aren't here
                    currentNode       = currentNode.Down;          //Say we're there
                    currentNode.Owner = (this);                    //Tell the place we own it.
                }
            }
            anim.SetTrigger("MoveEnd");
            transform.position = currentNode.transform.position;
            turn++;
        }
Ejemplo n.º 5
0
        public void SwitchRooms(Door current)
        {
            Room    next;
            Vector2 postion;

            Util.Enums.Direction directionMoved = Util.Enums.Direction.None;
            if (current.Parent.upperDoor == current)
            {
                next           = current.Parent.Up;
                postion        = new Vector2(0, -10);
                directionMoved = Util.Enums.Direction.Up;
            }
            else if (current.Parent.lowerDoor == current)
            {
                next           = current.Parent.Down;
                postion        = new Vector2(0, 4);
                directionMoved = Util.Enums.Direction.Down;
            }
            else if (current.Parent.leftDoor == current)
            {
                next           = current.Parent.Left;
                postion        = new Vector2(7, -3);
                directionMoved = Util.Enums.Direction.Left;
            }
            else
            {
                next           = current.Parent.Right;
                postion        = new Vector2(-7, -3);
                directionMoved = Util.Enums.Direction.Right;
            }


            if (this.miniMap != null)
            {
                this.miniMap.UpdateMiniMap(directionMoved);
            }

            FindObjectOfType <Character.Hero.HeroBehavior>().gameObject.transform.position = postion;
            current.Parent.Deactivate();
            next.Activate();
            FindObjectOfType <Util.CameraTracker>().ResetPosition();
        }
Ejemplo n.º 6
0
        public void returnToField()
        {
            currentNode = grid[rowStart, colStart];
            mdec        = (Util.Enums.Direction)Random.Range(0, 3);

            if (mdec == Util.Enums.Direction.Up)
            {
                //If we're randomly going up
                if (currentNode.panelAllowed(Util.Enums.Direction.Up, Type))
                {
                    currentNode.clearOccupied();        //Say we aren't here
                    currentNode       = currentNode.Up; //Say we're there
                    currentNode.Owner = (this);         //Tell the place we own it.
                }
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Right, Type))
            {
                currentNode.clearOccupied();           //Say we aren't here
                currentNode       = currentNode.Right; //Say we're there
                currentNode.Owner = (this);            //Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Left, Type))
            {
                currentNode.clearOccupied();          //Say we aren't here
                currentNode       = currentNode.Left; //Say we're there
                currentNode.Owner = (this);           //Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Down, Type))
            {
                //If we're randomly going down
                if (currentNode.Up.Occupied == false)
                {
                    currentNode.clearOccupied();          //Say we aren't here
                    currentNode       = currentNode.Down; //Say we're there
                    currentNode.Owner = (this);           //Tell the place we own it.
                }
            }
            transform.position = currentNode.transform.position;
        }
Ejemplo n.º 7
0
        protected void spawnObjectUsingPrefabAsModel(int damage, int distance, float deathTime, bool piercing, Util.Enums.Direction direction, float speed, int timesCanPierce, bool isFlying, Grid.GridNode spawnPosition, Player.Character actor)
        {
            Weapons.Hitbox temp  = MonoBehaviour.Instantiate(hitbox);
            GameObject     model = MonoBehaviour.Instantiate(prefab);

            model.transform.parent = temp.transform;
            temp.Damage            = damage;
            temp.Distance          = distance == 0 ? 1 : distance;
            temp.DeathTime         = deathTime;
            temp.Piercing          = piercing;
            temp.Direction         = direction;
            temp.Speed             = speed;
            temp.TimesCanPierce    = timesCanPierce;
            temp.IsFlying          = isFlying;
            temp.Owner             = actor.gameObject;
            temp.Element           = element;
            Util.AddElement.AddElementByEnum(model, element, true);
            temp.CurrentNode        = spawnPosition;
            temp.transform.position = spawnPosition.transform.position;
        }
Ejemplo n.º 8
0
        public void returnToField()
        {
            currentNode = grid[rowStart, colStart];
            mdec = (Util.Enums.Direction)Random.Range(0, 3);

            if (mdec == Util.Enums.Direction.Up)
            {
                //If we're randomly going up
                if (currentNode.panelAllowed(Util.Enums.Direction.Up, Type))
                {
                    currentNode.clearOccupied();//Say we aren't here
                    currentNode = currentNode.Up;//Say we're there
                    currentNode.Owner = (this);//Tell the place we own it.
                }
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Right, Type))
            {
                currentNode.clearOccupied();//Say we aren't here
                currentNode = currentNode.Right;//Say we're there
                currentNode.Owner = (this);//Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Left, Type))
            {
                currentNode.clearOccupied();//Say we aren't here
                currentNode = currentNode.Left;//Say we're there
                currentNode.Owner = (this);//Tell the place we own it.
            }

            else if (currentNode.panelAllowed(Util.Enums.Direction.Down, Type))
            {
                //If we're randomly going down
                if (currentNode.Up.Occupied == false)
                {
                    currentNode.clearOccupied();//Say we aren't here
                    currentNode = currentNode.Down;//Say we're there
                    currentNode.Owner = (this);//Tell the place we own it.
                }
            }
            transform.position = currentNode.transform.position;
        }
Ejemplo n.º 9
0
        protected void spawnObjectUsingPrefabAsModel(int damage, int distance, float deathTime, bool piercing, Util.Enums.Direction direction, float speed, int timesCanPierce, bool isFlying, Grid.GridNode spawnPosition, Player.Character actor, bool changeMaterial = false)
        {
            Weapons.Hitbox temp  = MonoBehaviour.Instantiate(hitbox);
            GameObject     model = MonoBehaviour.Instantiate(prefab);

            if (actor.Direction == Util.Enums.Direction.Left)
            {
                model.transform.localScale = new Vector3(model.transform.localScale.x, -model.transform.localScale.y, model.transform.localScale.z);
            }
            model.transform.parent = temp.transform;
            temp.Damage            = damage;
            temp.Distance          = distance == 0 ? 1 : distance;
            temp.DeathTime         = deathTime;
            temp.Piercing          = piercing;
            temp.Direction         = direction;
            temp.Speed             = speed;
            temp.TimesCanPierce    = timesCanPierce;
            temp.IsFlying          = isFlying;
            temp.Owner             = actor.gameObject;
            temp.Element           = element;
            Util.AddElement.AddElementByEnum(temp.gameObject, element, changeMaterial);
            temp.CurrentNode        = spawnPosition;
            temp.transform.position = spawnPosition.transform.position;
        }