Beispiel #1
0
 void StopGrapple()   {                                                     // l
     dray.enabled = true; drayColld.enabled = true;
     // Check for unsafe tile     
     int tileNum  =  TileCamera.GET_MAP(p0.x, p0.y);
     if (mode  ==  eMode.gInHit  &&  unsafeTiles.IndexOf(tileNum)   !=   - 1)   {
         // We landed on an unsafe tile        
         dray.ResetInRoom( unsafeTileHealthPenalty );
     }
     grapHead.SetActive(false);
     mode  =  eMode.none;
 }
Beispiel #2
0
    void FixedUpdate()
    {
        switch (mode)
        {
        case eMode.gOut:     // Grappler shooting out                        // i
            p1 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            grapHead.transform.position = p1;
            grapLine.SetPosition(1, p1);

            // Check to see whether the grapple hit anything
            int tileNum = TileCamera.GET_MAP(p1.x, p1.y);
            if (grappleTiles.IndexOf(tileNum) != -1)
            {
                // We've hit a grappleable tile!
                mode = eMode.gInHit;
                break;
            }
            if ((p1 - p0).magnitude >= grappleLength)
            {
                // The grapple reached its end and didn't hit anything
                mode = eMode.gInMiss;
            }
            break;

        case eMode.gInMiss:     // Grappler missed; return at double speed   // j
            p1 -= directions[facing] * 2 * grappleSpd * Time.fixedDeltaTime;
            if (Vector3.Dot((p1 - p0), directions[facing]) > 0)
            {
                // The grapple is still in front of Dray
                grapHead.transform.position = p1;
                grapLine.SetPosition(1, p1);
            }
            else
            {
                StopGrapple();
            }
            break;

        case eMode.gInHit:     // Grappler hit, pulling Dray to wall         // k
            float dist = grappleInLength + grappleSpd * Time.fixedDeltaTime;
            if (dist > (p1 - p0).magnitude)
            {
                p0 = p1 - (directions[facing] * grappleInLength);
                transform.position = p0;
                StopGrapple();
                break;
            }
            p0 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            transform.position = p0;
            grapLine.SetPosition(0, p0);
            grapHead.transform.position = p1;
            break;
        }
    }
Beispiel #3
0
    void FixedUpdate()
    {
        switch (mode)
        {
        case eMode.gOut:     // Grappler shooting out                        // i
                                p1 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            grapHead.transform.position = p1;
            grapLine.SetPosition(1, p1);

            // Check to see whether the grapple hit anything
            int tileNum = TileCamera.GET_MAP(p1.x, p1.y);
            if (grappleTiles.IndexOf(tileNum) != -1)
            {
                // We've hit a grappleable tile!
                mode = eMode.gInHit;
                break;
            }
            if ((p1 - p0).magnitude >= grappleLength)
            {
                // The grapple reached its end and didn't hit anything
                mode = eMode.gInMiss;
            }
            break;

        case eMode.gInMiss:     // Grappler missed; return at double speed   // j
                                p1 -= directions[facing] * 2 * grappleSpd * Time.fixedDeltaTime;
            if (Vector3.Dot((p1 - p0), directions[facing]) > 0)
            {
                // The grapple is still in front of Dray
                grapHead.transform.position = p1;
                grapLine.SetPosition(1, p1);
            }
            else
            {
                StopGrapple();
            }
            break;

        case eMode.gInHit:     // Grappler hit, pulling Dray to wall         // k
                            float dist = grappleInLength + grappleSpd * Time.fixedDeltaTime;
            if (dist > (p1 - p0).magnitude)
            {
                p0 = p1 - (directions[facing] * grappleInLength);
                transform.position = p0;
                StopGrapple();
                break;
            }
            p0 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            transform.position = p0;
            grapLine.SetPosition(0, p0);
            grapHead.transform.position = p1;
            break;
        }
    }
Beispiel #4
0
    void FixedUpdate()
    {
        switch (mode)
        {
        case eMode.gOut:
            p1 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            grapHead.transform.position = p1;
            grapLine.SetPosition(1, p1);
            int tileNum = TileCamera.GET_MAP(p1.x, p1.y);

            if (grappleTiles.IndexOf(tileNum) != -1)
            {
                mode = eMode.gInHit;
                break;
            }

            if ((p1 - p0).magnitude >= grappleLength)
            {
                mode = eMode.gInMiss;
            }
            break;

        case eMode.gInMiss:
            p1 -= directions[facing] * 2 * grappleSpd * Time.fixedDeltaTime;

            if (Vector3.Dot((p1 - p0), directions[facing]) > 0)
            {
                grapHead.transform.position = p1;
                grapLine.SetPosition(1, p1);
            }
            else
            {
                StopGrapple();
            }
            break;

        case eMode.gInHit:
            float dist = grappleInLength + grappleSpd * Time.fixedDeltaTime;

            if (dist > (p1 - p0).magnitude)
            {
                p0 = p1 - (directions[facing] * grappleInLength);
                transform.position = p0;
                StopGrapple();
                break;
            }
            p0 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            transform.position = p0;
            grapLine.SetPosition(0, p0);
            grapHead.transform.position = p1;
            break;
        }
    }
    private void FixedUpdate()
    {
        switch (mode)
        {
        case EMode.gOut:     // Крюк брошен
            p1 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            grapHead.transform.position = p1;
            grapLine.SetPosition(1, p1);

            // Проверить попал ли крюк  куда-нибудь
            int tileNum = TileCamera.GET_MAP(p1.x, p1.y);
            if (grappleTiles.IndexOf(tileNum) != -1)
            {
                // Крюк  попал на  плитку за  которую можно зацепиться
                mode = EMode.gInHit;
                break;
            }
            if ((p1 - p0).magnitude >= grappleLength)     // Крюк улетел на всю длину верёвки  но никуда не  попал
            {
                mode = EMode.gInMiss;
            }
            break;

        case EMode.gInMiss:     // Игрок промахнулся, вернуть крюк на удвоенной скорости
            p1 -= directions[facing] * 2 * grappleSpd * Time.fixedDeltaTime;
            if (Vector3.Dot(p1 - p0, directions[facing]) > 0)
            {
                // Крюк всё ещё  перед Дреем
                grapHead.transform.position = p1;
                grapLine.SetPosition(1, p1);
            }
            else
            {
                StopGrapple();
            }
            break;

        case EMode.gInHit:      // Крюк зацепился, поднять Дрея на стену
            float dist = grappleInLength + grappleSpd * Time.fixedDeltaTime;
            if (dist > (p1 - p0).magnitude)
            {
                p0 = p1 - (directions[facing] * grappleInLength);
                transform.position = p0;
                StopGrapple();
                break;
            }
            p0 += directions[facing] * grappleSpd * Time.fixedDeltaTime;
            transform.position = p0;
            grapLine.SetPosition(0, p0);
            grapHead.transform.position = p1;
            break;
        }
    }
Beispiel #6
0
 // Use this for initialization
 public void SetTile(int eX, int eY, int eTileNum = -1)
 {
     x = eX;
     y = eY;
     transform.localPosition = new Vector3(x, y, 0);
     gameObject.name         = x.ToString("D3") + "x" + y.ToString("D3");
     if (eTileNum == -1)
     {
         eTileNum = TileCamera.GET_MAP(x, y);
     }
     tileNum = eTileNum;
     GetComponent <SpriteRenderer>().sprite = TileCamera.SPRITES[tileNum];
 }
Beispiel #7
0
    void StopGrapple()
    {
        dray.enabled      = true;
        drayColld.enabled = true;
        int tileNum = TileCamera.GET_MAP(p0.x, p0.y);

        if (mode == eMode.gInHit && unsafeTiles.IndexOf(tileNum) != -1)
        {
            dray.ResetInRoom(unsafeTileHealthPenalty);
        }
        grapHead.SetActive(false);
        mode = eMode.none;
    }
Beispiel #8
0
    public void SetTile(int eX, int eY, int eTileNum = -1)
    {
        x = eX;
        y = eY;
        transform.localPosition = new Vector3(x, y, 0);
        gameObject.name         = x.ToString("D3") + "x" + y.ToString("D3"); // D3 = decimal, at least 3 characters

        if (eTileNum == -1)                                                  // if no eTileNum, use default tile number from GET_MAP
        {
            eTileNum = TileCamera.GET_MAP(x, y);
        }
        tileNum = eTileNum;
        GetComponent <SpriteRenderer>().sprite = TileCamera.SPRITES[tileNum];
    }
Beispiel #9
0
    public void SetTile(int _x, int _y, int _tileNum = -1)
    {
        x = _x;
        y = _y;
        transform.localPosition = new Vector3(x, y, 0);
        gameObject.name         = x.ToString("D3") + "x" + y.ToString("D3"); //вернет число в десятичной форме (3+ символа) в виде строки (для x=23 и y=5 -> "023x005")

        if (_tileNum == -1)
        {
            _tileNum = TileCamera.GET_MAP(x, y);
        }
        tileNum = _tileNum;
        GetComponent <SpriteRenderer>().sprite = TileCamera.SPRITES[tileNum];
        SetCollider();
    }
Beispiel #10
0
    void StopGrapple()
    {
        dray.enabled      = true;
        drayColld.enabled = true;

        // Проверить безопасность плитки
        int tileNum = TileCamera.GET_MAP(p0.x, p0.y);

        if (mode == EMode.gInHit && unsafeTiles.IndexOf(tileNum) != -1)  // Дрей попал на небезопасную плитку
        {
            dray.ResetInRoom(unsafeTileHealthPenalty);
        }

        grapHead.SetActive(false);

        mode = EMode.none;
    }
Beispiel #11
0
 void FixedUpdate()   {
     switch (mode)
     {
         case eMode.gOut:// Grappler shooting out                        // i    
         p1  +=  directions[facing]   *  grappleSpd  *  Time.fixedDeltaTime;
         grapHead.transform.position  =  p1;
         grapLine.SetPosition(1, p1);
         // Check to see whether the grapple hit anything     
         int tileNum  =  TileCamera.GET_MAP(p1.x, p1.y);
         if ( grappleTiles.IndexOf( tileNum )   !=   - 1 )
         {                         // We've hit a grappleable tile!   
             mode  =  eMode.gInHit;
             break;
         }
         if ( (p1 - p0).magnitude  >=  grappleLength )   {
             // The grapple reached its end and didn't hit anything  
             mode  =  eMode.gInMiss;
         }
         break;
         case eMode.gInMiss:
         // Grappler missed; return at double speed   // j        
         p1  -=  directions[facing]   *  2  *  grappleSpd  *  Time.fixedDeltaTime;
         if ( Vector3.Dot( (p1 - p0),  directions[facing]  )   >  0 )   {
             // The grapple is still in front of Dray       
             grapHead.transform.position  =  p1;
             grapLine.SetPosition(1, p1);
         }  else  {
             StopGrapple();
         }
         break;
         case eMode.gInHit:// Grappler hit, pulling Dray to wall         // k   
         float dist  =  grappleInLength  +  grappleSpd  *  Time.fixedDeltaTime;
         if (dist  >  (p1 - p0).magnitude)   {
             p0  =  p1  -  ( directions[facing]   *  grappleInLength );
             transform.position  =  p0;
             StopGrapple();
             break;
         }
         p0  +=  directions[facing]   *  grappleSpd  *  Time.fixedDeltaTime;
         transform.position  =  p0;
         grapLine.SetPosition(0, p0);
         grapHead.transform.position  =  p1;
         break;
     }
 }
Beispiel #12
0
    public void SetTile(int eX, int eY, int eTileNum = -1)
    {                 // a
        x = eX;
        y = eY;
        transform.localPosition = new Vector3(x, y, 0);
        gameObject.name         = x.ToString("D3") + "x" + y.ToString("D3");    // b

        if (eTileNum == -1)
        {
            eTileNum = TileCamera.GET_MAP(x, y);                             // c
        }
        else
        {
            TileCamera.SET_MAP(x, y, eTileNum); // Replace if non-default tileNum
        }
        tileNum = eTileNum;
        GetComponent <SpriteRenderer>().sprite = TileCamera.SPRITES[tileNum]; // d
        SetCollider();
    }
Beispiel #13
0
    void StopGrapple()
    {
                                                             // l
                dray.enabled = true;

        drayColld.enabled = true;

        // Check for unsafe tile
        int tileNum = TileCamera.GET_MAP(p0.x, p0.y);

        if (mode == eMode.gInHit && unsafeTiles.IndexOf(tileNum) != -1)
        {
            // We landed on an unsafe tile
            dray.ResetInRoom(unsafeTileHealthPenalty);
        }

        grapHead.SetActive(false);

        mode = eMode.none;
    }
Beispiel #14
0
    public void SetTile(int eX, int eY, int eTileNum = -1)
    {
        x = eX;
        y = eY;
        transform.localPosition = new Vector3(x, y, 0);
        gameObject.name         = x.ToString("D3") + "x" + y.ToString("D3");

        if (eTileNum == -1)
        {
            eTileNum = TileCamera.GET_MAP(x, y);
        }
        else
        {
            TileCamera.SET_MAP(x, y, eTileNum); // Заменить плитку если необходимо
        }
        tileNum = eTileNum;
        GetComponent <SpriteRenderer>().sprite = TileCamera.SPRITES[tileNum];

        SetCollider();
    }
Beispiel #15
0
 private void Awake()
 {
     Instance = this;
 }