Ejemplo n.º 1
0
    void SetFaceDirect(FaceDirect dir)
    {
        faceDir = dir;
        float angle = (int)dir * 45f;

        transform.eulerAngles = new Vector3(0, angle, 0);
    }
Ejemplo n.º 2
0
        public void Initialize(TileType type)
        {
            switch (type)
            {
            case TileType.BoyForward:
                sex      = Sex.Boy;
                direct   = FaceDirect.Forward;
                itemType = ItemType.Face;
                break;

            case TileType.BoyLeft:
                sex      = Sex.Boy;
                direct   = FaceDirect.Left;
                itemType = ItemType.Face;
                break;

            case TileType.BoyRight:
                sex      = Sex.Boy;
                direct   = FaceDirect.Right;
                itemType = ItemType.Face;
                break;

            case TileType.GirlForward:
                sex      = Sex.Girl;
                direct   = FaceDirect.Forward;
                itemType = ItemType.Face;
                break;

            case TileType.GirlLeft:
                sex      = Sex.Girl;
                direct   = FaceDirect.Left;
                itemType = ItemType.Face;
                break;

            case TileType.GirlRight:
                sex      = Sex.Girl;
                direct   = FaceDirect.Right;
                itemType = ItemType.Face;
                break;

            case TileType.SlapLeft:
                sex      = Sex.None;
                direct   = FaceDirect.Left;
                itemType = ItemType.Item;
                break;

            case TileType.SlapRight:
                sex      = Sex.None;
                direct   = FaceDirect.Right;
                itemType = ItemType.Item;
                break;

            case TileType.Underwear:
                sex      = Sex.None;
                direct   = FaceDirect.Forward;
                itemType = ItemType.Item;
                break;
            }
        }
    // 在该位置铺设铁轨(重载1)
    void Put(GameObject rail, Vector3 new_pos, TurnDirect turnDirect)
    {
        FaceDirect new_faceDirect = NewFaceDirection(new_pos, LastRail.pos);

        if (turnDirect != TurnDirect.Straight)
        {
            CurveLastRail(turnDirect);
        }
        int rotation = (int)new_faceDirect * -90;

        PutRailModel(new_pos, rotation, rail);  //放置的铁轨必定是直行铁轨
        LastRail.pos = new_pos; LastRail.faceDirect = new_faceDirect;
    }
    // 判断是否允许铺设铁轨(重载1)
    public bool PutEnable(Vector3 new_pos, out FaceDirect new_faceDirect)
    {
        new_faceDirect = FaceDirect.Unknown;
        int lx = (int)LastRail.pos.x, lz = (int)LastRail.pos.z;
        int x = (int)new_pos.x, z = (int)new_pos.z;

        if (RailsArray[x, z] != null || Mathf.Abs(x - lx) + Mathf.Abs(z - lz) >= 2)
        {
            return(false);
        }
        new_faceDirect = NewFaceDirection(new_pos, LastRail.pos);
        return(true);
    }
Ejemplo n.º 5
0
        public void UpdateDirectBySlap(TileType type)
        {
            if (type == TileType.SlapLeft)
            {
                direct += -1;
            }
            else if (type == TileType.SlapRight)
            {
                direct += 1;
            }

            if (direct > FaceDirect.Right)
            {
                direct = FaceDirect.Left;
            }
            else if (direct < FaceDirect.Left)
            {
                direct = FaceDirect.Right;
            }
        }
    // 转向
    TurnDirect TurnDirection(FaceDirect new_faceDirect, FaceDirect old_faceDirect)
    {
        int nf = (int)new_faceDirect, lf = (int)old_faceDirect;

        if (lf == nf)
        {
            return(TurnDirect.Straight);
        }
        else if ((lf + 1) % 4 == nf)
        {
            return(TurnDirect.Left);
        }
        else if ((lf + 3) % 4 == nf)
        {
            return(TurnDirect.Right);
        }
        else
        {
            return(TurnDirect.Unknown);
        }
    }