コード例 #1
0
 public ObjPosReturn(int Row, int Col, ObjType otype, Objcolor color = Objcolor.NONE)
 {
     objtype    = otype;
     this.Row   = Row;
     this.Col   = Col;
     this.color = color;
 }
コード例 #2
0
ファイル: grid.cs プロジェクト: VitorOrtiz/WizardColor
    GridObj SpawnObj(GridObj obj, int row, int col, bool CanDrag, Objcolor color = Objcolor.NONE)
    {
        if (panellist[row, col].Wall)
        {
            Debug.Log("Panel has Wall in: " + row + " " + col);
            return(null);
        }
        Vector3 newobjpos = panellist[row, col].transform.position;

        newobjpos.y += .5f;
        GridObj newobj = Instantiate(obj, newobjpos, Quaternion.identity, newLevel.transform);

        if (newobj.objtype == ObjType.TARGET)
        {
            targets.Add(newobj);
            if (color != Objcolor.NONE)
            {
                newobj.ChangeColor(color);
            }
        }
        newobj.CanDrag      = CanDrag;
        newobj.GridPosition = new Vector2(row, col);
        panellist[row, col].SetItem(newobj);
        return(newobj);
    }
コード例 #3
0
 Gradient SetLineColor(Objcolor color)
 {
     return(color == Objcolor.RED? RedGradient:
            color == Objcolor.GREEN? GreenGradient:
            color == Objcolor.BLUE? BlueGradient:
            color == Objcolor.CYAN? CyanGradient:
            color == Objcolor.MAGENTA? MagGradient:
            color == Objcolor.YELLOW? YellowGradient:
            NewGradient);
 }
コード例 #4
0
    Objcolor mixColor(Objcolor curColor, Objcolor secondColor)
    {
        if (curColor == secondColor)
        {
            return(curColor);
        }
        switch (curColor)
        {
        case Objcolor.RED:
            if (secondColor == Objcolor.BLUE)
            {
                return(Objcolor.MAGENTA);
            }
            else if (secondColor == Objcolor.GREEN)
            {
                return(Objcolor.YELLOW);
            }
            else
            {
                return(secondColor);
            }

        case Objcolor.GREEN:
            if (secondColor == Objcolor.BLUE)
            {
                return(Objcolor.CYAN);
            }
            else if (secondColor == Objcolor.RED)
            {
                return(Objcolor.YELLOW);
            }
            else
            {
                return(secondColor);
            }

        case Objcolor.BLUE:
            if (secondColor == Objcolor.RED)
            {
                return(Objcolor.MAGENTA);
            }
            else if (secondColor == Objcolor.GREEN)
            {
                return(Objcolor.CYAN);
            }
            else
            {
                return(secondColor);
            }
        }
        return(secondColor);
    }
コード例 #5
0
 void SelectColor(Objcolor color, Image SelectedImage)
 {
     CurColor = color;
     if (this.SelectedImage != null)
     {
         this.SelectedImage.transform.localScale = new Vector3(1, 1, 1);
     }
     if (SelectedImage != null)
     {
         this.SelectedImage = SelectedImage;
         this.SelectedImage.transform.localScale = new Vector3(2, 2, 1);
     }
 }
コード例 #6
0
ファイル: GridObj.cs プロジェクト: VitorOrtiz/WizardColor
    // Start is called before the first frame update
    public void ChangeColor(Objcolor TarColor)
    {
        switch (TarColor)
        {
        case Objcolor.RED:
            mat.material.SetColor("_BaseColor", redMat);
            mat.material.SetColor("_EmissionColor", redMat);
            break;

        case Objcolor.GREEN:
            mat.material.SetColor("_BaseColor", GreenMat);
            mat.material.SetColor("_EmissionColor", GreenMat);
            break;

        case Objcolor.BLUE:
            mat.material.SetColor("_BaseColor", BlueMat);
            mat.material.SetColor("_EmissionColor", BlueMat);
            break;

        case Objcolor.CYAN:
            mat.material.SetColor("_BaseColor", CyanMat);
            mat.material.SetColor("_EmissionColor", CyanMat);
            break;

        case Objcolor.MAGENTA:
            mat.material.SetColor("_BaseColor", MagMat);
            mat.material.SetColor("_EmissionColor", MagMat);
            break;

        case Objcolor.YELLOW:
            mat.material.SetColor("_BaseColor", YellowMat);
            mat.material.SetColor("_EmissionColor", YellowMat);
            break;

        default:
            mat.material = defmat;
            mat.material.SetColor("_BaseColor", Color.white);
            mat.material.SetColor("_EmissionColor", Color.white);
            break;
        }
        oColor = TarColor;
    }
コード例 #7
0
    IEnumerator CreateBeam(GridPanel initialPanel, Direction InitialDir, Vector3 InitialPosition)
    {
        ResetCounters();
        float time                    = 0;
        bool  HasLineOpen             = true;
        List <lightBeamSeg> newLines  = new List <lightBeamSeg>();
        List <lightBeamSeg> Openlines = new List <lightBeamSeg>();

        Direction CurrentDir = InitialDir;
        int       CurRow     = (int)initialPanel.position.x;
        int       CurCol     = (int)initialPanel.position.y;

        lightBeamSeg CurrentLine = new lightBeamSeg(AvailableLines[0], CurrentDir);

        CurrentLine.line.transform.position = InitialPosition;
        Vector3[] oldpos = new Vector3[CurrentLine.line.positionCount];

        CurrentLine.line.GetPositions(oldpos);
        CurrentLine.points.Add(new GridValue {
            Row = CurRow, Col = CurCol
        });
        List <Vector3> positions = new List <Vector3>(oldpos);

        Openlines.Add(CurrentLine);
        AvailableLines.RemoveAt(0);
        Vector3Int nextPos = Vector3Int.zero;

        while (HasLineOpen)
        {
            GridPanel obj = lineCheck(CurRow, CurCol, CurrentDir);
            if (obj.HasItem)
            {
                switch (obj.item.objtype)
                {
                case ObjType.REFLECTOR:
                    nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                    AddPositiontoLine(CurrentLine.line, nextPos);
                    Direction newDir = Reflector.returnnewDirection(obj.item.DirRot, CurrentDir);
                    Debug.Log(newDir + " " + CurrentDir);
                    CurCol = (int)obj.position.y;
                    CurRow = (int)obj.position.x;
                    if (newDir == Direction.INVALID)
                    {
                        Openlines.Remove(CurrentLine);
                        newLines.Add(CurrentLine);
                    }

                    CurrentDir = newDir;
                    break;

                case ObjType.DOUBLE:

                    Direction newRaydir = Reflector.returnnewDoubleDirection(obj.item.DirRot, CurrentDir);
                    nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                    AddPositiontoLine(CurrentLine.line, nextPos);
                    CurCol = (int)obj.position.y;
                    CurRow = (int)obj.position.x;
                    if (newRaydir != Direction.INVALID)
                    {
                        CurrentDir      = newRaydir;
                        CurrentLine.dir = CurrentDir;
                        lightBeamSeg newseg = new lightBeamSeg(AvailableLines[0],
                                                               Reflector.ReturnReverseDirection(newRaydir));
                        AvailableLines.RemoveAt(0);
                        Vector3 newraypos = obj.transform.position;
                        newraypos.y = CurrentLine.line.transform.position.y;
                        newseg.line.transform.position = newraypos;
                        newseg.lineColor          = CurrentLine.lineColor;
                        newseg.line.colorGradient = SetLineColor(CurrentLine.lineColor);
                        newseg.points.Add(new GridValue {
                            Row = CurRow, Col = CurCol
                        });
                        Openlines.Add(newseg);
                    }
                    else
                    {
                        Openlines.Remove(CurrentLine);
                        newLines.Add(CurrentLine);
                    }

                    break;

                case ObjType.GLASS:
                    lightBeamSeg seg = new lightBeamSeg(AvailableLines[0], CurrentDir);
                    // Openlines.Add(seg);
                    AvailableLines.RemoveAt(0);
                    Vector3 newpos = obj.transform.position;
                    newpos.y = CurrentLine.line.transform.position.y;
                    seg.line.transform.position = newpos;
                    nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                    AddPositiontoLine(CurrentLine.line, nextPos);
                    Objcolor newcolor = mixColor(CurrentLine.lineColor, obj.item.oColor);
                    seg.line.colorGradient = SetLineColor(newcolor);
                    seg.lineColor          = newcolor;
                    CurCol = (int)obj.position.y;
                    CurRow = (int)obj.position.x;
                    newLines.Add(CurrentLine);
                    Openlines.Remove(CurrentLine);
                    seg.points.Add(new GridValue {
                        Row = CurRow, Col = CurCol
                    });
                    if (CurrentLine.points[0].Row != CurRow || CurrentLine.points[0].Col != CurCol)
                    {
                        Openlines.Add(seg);
                    }
                    particles.Add(CreateGlassParticle(obj.item.GetColor(), newpos, seg.dir).gameObject);
                    break;

                case ObjType.WALL:
                    nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                    AddPositiontoLine(CurrentLine.line, nextPos);
                    Openlines.Remove(CurrentLine);
                    newLines.Add(CurrentLine);
                    Vector3 pos = obj.transform.position;
                    pos.y = CurrentLine.line.transform.position.y;
                    particles.Add(CreateWallParticle(pos, CurrentLine.dir));
                    break;

                case ObjType.TARGET:
                    nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                    AddPositiontoLine(CurrentLine.line, nextPos);
                    Openlines.Remove(CurrentLine);
                    newLines.Add(CurrentLine);
                    if (CurrentLine.lineColor == obj.item.oColor)
                    {
                        obj.item.LightUP();
                    }
                    break;

                case ObjType.OTHER:
                    break;

                case ObjType.PRESSURE:
                    CurCol = (int)obj.position.y;
                    CurRow = (int)obj.position.x;
                    break;
                }
            }
            else
            {
                Debug.Log(obj.position + " " + CurRow + " " + CurCol);
                nextPos += new Vector3Int((int)obj.position.x - CurRow, 0, (int)obj.position.y - CurCol);
                AddPositiontoLine(CurrentLine.line, nextPos);
                Debug.Log("No item Found");
                Openlines.Remove(CurrentLine);
                newLines.Add(CurrentLine);
            }
            Debug.Log("Running");
            if (Openlines.Count <= 0)
            {
                HasLineOpen = false;
            }
            else if (!Openlines.Contains(CurrentLine))
            {
                CurrentLine = Openlines[0];
                CurrentDir  = CurrentLine.dir;
                nextPos     = Vector3Int.zero;
                oldpos      = new Vector3[CurrentLine.line.positionCount];
                CurrentLine.line.GetPositions(oldpos);
                positions = new List <Vector3>(oldpos);
                CurRow    = CurrentLine.points[0].Row;
                CurCol    = CurrentLine.points[0].Col;
            }
            time += Time.deltaTime;
            yield return(null);
        }
        Segments = new List <lightBeamSeg>(newLines);
        Debug.Log(time);
    }