Example #1
0
    void ChangeDirection(int amount)
    {
        direction += amount;
        if (direction > direction_t.WEST)
        {
            direction = 0;
        }
        else if (direction < 0)
        {
            direction = direction_t.WEST;
        }
        switch (direction)
        {
        case direction_t.NORTH:
            transform.localRotation = Quaternion.AngleAxis(270, Vector3.up);
            break;

        case direction_t.EAST:
            transform.localRotation = Quaternion.AngleAxis(0, Vector3.up);
            break;

        case direction_t.SOUTH:
            transform.localRotation = Quaternion.AngleAxis(90, Vector3.up);
            break;

        case direction_t.WEST:
            transform.localRotation = Quaternion.AngleAxis(180, Vector3.up);
            break;
        }
    }
 void ChangeDirection(int amount)
 {
     direction += amount;
     if (direction > direction_t.WEST){
         direction = 0;
     }
     else if (direction < 0){
         direction = direction_t.WEST;
     }
     switch (direction){
     case direction_t.NORTH:
         transform.localRotation = Quaternion.AngleAxis(270, Vector3.up);
         break;
     case direction_t.EAST:
         transform.localRotation = Quaternion.AngleAxis(0, Vector3.up);
         break;
     case direction_t.SOUTH:
         transform.localRotation = Quaternion.AngleAxis(90, Vector3.up);
         break;
     case direction_t.WEST:
         transform.localRotation = Quaternion.AngleAxis(180, Vector3.up);
         break;
     }
 }
Example #3
0
 public static extern herr_t walk
     (hid_t estack_id, direction_t direction, walk_t func,
     IntPtr client_data);
Example #4
0
 public void SetDirection(direction_t to)
 {
     direction = to;
     ChangeDirection(0);
 }
Example #5
0
 // Use this for initialization
 void Start()
 {
     direction = direction_t.EAST;
     GetParticleSystem();
     particleSystem.startLifetime = 0.3f * range;
 }
 // Use this for initialization
 void Start()
 {
     direction = direction_t.EAST;
     GetParticleSystem();
     particleSystem.startLifetime = 0.3f*range;
 }
 public void SetDirection(direction_t to)
 {
     direction = to;
     ChangeDirection(0);
 }
Example #8
0
 public static extern herr_t walk
     (hid_t estack_id, direction_t direction, walk_t func,
     IntPtr client_data);
Example #9
0
 public static extern hid_t get_native_type
     (hid_t dtype_id, direction_t direction);
    /// <summary>
    /// Imports the map from the given map path and populates the mapHolder and propHolder parents - returns success value
    /// </summary>
    /// <returns>
    /// The map.
    /// </returns>
    /// <param name='mapPath'>
    /// Where to stream the map from
    /// </param>
    /// <param name='mapHolder'>
    /// MapHolder transform to put the tiles into
    /// </param>
    /// <param name='propHolder'>
    /// PropHolder transform to put the props into
    /// </param>
    public static bool ImportMap(string mapPath, Transform mapHolder, Transform propHolder)
    {
        TextReader r = new StreamReader(mapPath);

        if (r == null)
        {
            return(false);
        }
        bool tileMode = true;         //indicates what mode we are on - tiles or props

        while (true)
        {
            string line = r.ReadLine();
            if (line != null)
            {
                if (line.Equals("PROPS"))
                {
                    tileMode = false;
                }
                //tile mode
                else if (tileMode)
                {
                    string[] text = line.Split(new char[] { '\t' });
                    //GET TILE POSITION AND ADD TO PARENT
                    Vector3 position   = new Vector3(float.Parse(text[0]), float.Parse(text[1]), float.Parse(text[2]));
                    string  objectType = text[3];
                    string  objectTag  = null;
                    if (text.Length > 4)
                    {
                        objectTag = text[4];
                    }
                    GameObject gameObject;
                    if (objectType.Contains("Tile"))
                    {
                        gameObject = Resources.Load(tilePath + objectType) as GameObject;
                    }
                    else
                    {
                        gameObject = Resources.Load(hazardPath + objectType) as GameObject;
                    }

                    gameObject = MonoBehaviour.Instantiate(gameObject, position, Quaternion.identity) as GameObject;
                    gameObject.transform.parent = mapHolder;
                    if (objectTag != null)
                    {
                        gameObject.tag = objectTag;
                    }
                    //IF Object HAS ANY SPECIFIC PROPERTIES - ADD THEM HERE
                    //if hint tile - add hint to it
                    if (gameObject.tag.Equals("HintTile"))
                    {
                        Tile tile = gameObject.GetComponent <Tile>();
                        tile.hintEnabled = true;
                        tile.hint        = r.ReadLine();
                    }

                    //if moving tile - add patrol coordinates to it - they are on the next line
                    if (objectType.Equals("MovingTile"))
                    {
                        MovingTile newMovingTile = gameObject.GetComponent <MovingTile>();
                        line = r.ReadLine();
                        text = line.Split(new char[] { '\t' });
                        for (int i = 0; i < text.Length; i++)
                        {
                            string   vector  = text[i];
                            string[] xyz     = vector.Split(new char[] { ',' });
                            Vector3  patrolP = new Vector3(float.Parse(xyz[0]), float.Parse(xyz[1]), float.Parse(xyz[2]));
                            newMovingTile.patrolPoints.Add(patrolP);
                        }
                    }
                    //If this is a wind hazard
                    else if (objectType.Equals("Wind"))
                    {
                        Wind wind = gameObject.GetComponent <Wind>();
                        line = r.ReadLine();
                        text = line.Split(new char[] { ',' });
                        int range;
                        if (!int.TryParse(text[0], out range))
                        {
                            Debug.Log("Error parsing wind hazard range info");
                        }
                        direction_t dir = (direction_t)System.Enum.Parse(typeof(direction_t), text[1]);
                        wind.SetRange(range);
                        wind.SetDirection(dir);
                    }
                }
                //prop mode
                else
                {
                    string[] text = line.Split(new char[] { '\t' });
                    //GET PROP POSITION,ROTAION AND SCALE AND ADD TO PARENT
                    Vector3 position = new Vector3(float.Parse(text[0]), float.Parse(text[1]), float.Parse(text[2]));
                    Vector3 rotation = new Vector3(float.Parse(text[3]), float.Parse(text[4]), float.Parse(text[5]));
                    Vector3 scale    = new Vector3(float.Parse(text[6]), float.Parse(text[7]), float.Parse(text[8]));
                    string  propType = text[9];

                    GameObject propObject;
                    Quaternion rot = Quaternion.identity;
                    rot.eulerAngles                 = rotation;
                    propObject                      = Resources.Load("2DAsset") as GameObject;
                    propObject                      = MonoBehaviour.Instantiate(propObject, position, rot) as GameObject;
                    propObject.transform.parent     = propHolder;
                    propObject.transform.localScale = scale;
                    propObject.name                 = propType;
                }
            }
            else
            {
                break;
            }
        }

        r.Close();
        r = null;
        Debug.Log("Map successfuly imported");
        return(true);
    }