Пример #1
0
 // Use this for initialization
 void Start()
 {
     selector.onMouseButtonUp.AddListener(() =>
     {
         die.SetLEDsToColor(ColorSelector.GetColor());
     });
 }
Пример #2
0
    void Update()
    {
        brushColor = ColorSelector.GetColor();  //Updates our painted color with the selected color
        if (Input.GetMouseButton(0))
        {
            DoAction();
        }
        UpdateBrushCursor();

        if (!FullPaint)          //Benim ekledigim kod blogu. Asset'e ait degil.
        {
            //1000'de 10
            //100'de x
            paintPercent          = (PlayerPrefs.GetInt("paintPercent") * 25) / 1000;
            paintPercentText.text = "% " + paintPercent;
            if (paintPercent == 100)
            {
                foreach (Transform child in brushContainer.transform)
                {                //Clear brushes
                    Destroy(child.gameObject);
                }
                brushCursor.SetActive(false);
                saving    = true;
                FullPaint = true;
            }
        }
    }
Пример #3
0
 public void SetColor()
 {
     if (die != null)
     {
         die.SetLEDsToColor(ColorSelector.GetColor());
     }
 }
Пример #4
0
    public void ChangeColorCloth(int TapNum)
    {
        switch (TapNum)
        {
        case 1:
            BodyColor.color = ColorSelector.GetColor();
            break;

        case 2:
            RightColor.color = ColorSelector.GetColor();
            LeftColor.color  = ColorSelector.GetColor();
            break;

        case 3:
            //LeftColor.color = ColorSelector.GetColor();
            break;

        case 4:
            SkirtColor.color = ColorSelector.GetColor();
            break;

        default:
            break;
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        Color32 c = (Color32)ColorSelector.GetColor();

        R.text = c.r.ToString();
        G.text = c.g.ToString();
        B.text = c.b.ToString();
    }
Пример #6
0
 void Update()
 {
     brushColor = ColorSelector.GetColor();          //Updates our painted color with the selected color
     if (Input.GetMouseButton(0))
     {
         DoAction();
     }
     UpdateBrushCursor();
 }
Пример #7
0
    bool saving = false;                           //Bool pour vérifier si nous sauvegardons la texture


    void Update()
    {
        brushColor = ColorSelector.GetColor();          //Met à jour notre couleur peinte avec la couleur sélectionnée
        if (Input.GetMouseButton(0))
        {
            DoAction();
        }
        UpdateBrushCursor();
    }
Пример #8
0
    private void Shoot()
    {
        if (attackTracker != AttackTracker.IDLE)
        {
            return;
        }
        // Get mouse position
        Vector3 mousePos = Input.mousePosition;

        mousePos.z = 0;
        // Convert to world position
        Vector3 worldMouse = mainCamera.ScreenToWorldPoint(mousePos);

        // Create Burst Attack
        GameObject firedShot  = Instantiate(burst);
        int        burstColor = (int)ColorSelector.GetColor();

        firedShot.GetComponent <Explode>().burstProperties = burstTypes[burstColor];
        firedShot.transform.position = transform.position;

        firedShot.tag = ColorSelector.GetColor().ToString();

        // Color changes
        Color color          = new Color();
        Color highlightColor = new Color();

        ColorUtility.TryParseHtmlString(ColorScheme.primaryColors[burstColor], out color);
        ColorUtility.TryParseHtmlString(ColorScheme.highlightColors[burstColor], out highlightColor);
        firedShot.GetComponent <SpriteRenderer>().color = color;
        firedShot.transform.GetComponent <TrailRenderer>().startColor = highlightColor;
        firedShot.transform.GetComponent <TrailRenderer>().endColor   = highlightColor;

        PhysicsMaterial2D physMat = new PhysicsMaterial2D();

        physMat.bounciness = burstTypes[burstColor].bounciness;
        physMat.friction   = burstTypes[burstColor].friction;
        firedShot.GetComponent <Rigidbody2D>().sharedMaterial = physMat;
        firedShot.GetComponent <Rigidbody2D>().drag           = burstTypes[burstColor].drag;

        firedShot.transform.localScale = new Vector2(burstTypes[burstColor].size, burstTypes[burstColor].size);

        // Force Calculations + Launch
        float angle = Mathf.Atan2(worldMouse.y - transform.position.y, worldMouse.x - transform.position.x);

        //float distance = Mathf.Sqrt(Mathf.Pow(worldMouse.x - transform.position.x, 2) + Mathf.Pow(worldMouse.y - transform.position.y, 2));
        firedShot.GetComponent <Rigidbody2D>().AddForce(new Vector2(maxForce * Mathf.Cos(angle) * Mathf.Clamp(Mathf.Abs(worldMouse.x - transform.position.x) / maxDistance, 0, 1), maxForce * Mathf.Sin(angle) * Mathf.Clamp(Mathf.Abs(worldMouse.y - transform.position.y) / maxDistance, 0, 1)));



        // Resets player to Reload atttack state
        attackTracker = AttackTracker.RELOAD;
    }
Пример #9
0
        private void Update()
        {
            if (Input.GetMouseButton(0))
            {
                brush.Color = ColorSelector.GetColor();
                ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
                bool success = true;
                if (Physics.Raycast(ray, out hitInfo))
                {
                    var paintObject = hitInfo.transform.GetComponent <InkCanvas>();
                    if (paintObject != null)
                    {
                        switch (useMethodType)
                        {
                        case UseMethodType.RaycastHitInfo:
                            success = erase ? paintObject.Erase(brush, hitInfo) : paintObject.Paint(brush, hitInfo);
                            break;

                        case UseMethodType.WorldPoint:
                            success = erase ? paintObject.Erase(brush, hitInfo.point) : paintObject.Paint(brush, hitInfo.point);
                            break;

                        case UseMethodType.NearestSurfacePoint:
                            success = erase ? paintObject.EraseNearestTriangleSurface(brush, hitInfo.point) : paintObject.PaintNearestTriangleSurface(brush, hitInfo.point);
                            break;

                        case UseMethodType.DirectUV:
                            if (!(hitInfo.collider is MeshCollider))
                            {
                                Debug.LogWarning("Raycast may be unexpected if you do not use MeshCollider.");
                            }
                            success = erase ? paintObject.EraseUVDirect(brush, hitInfo.textureCoord) : paintObject.PaintUVDirect(brush, hitInfo.textureCoord);
                            break;
                        }
                    }
                    if (!success)
                    {
                        Debug.LogError("Failed to paint.");
                    }

                    if (lastPoint == Vector3.zero)
                    {
                        lastPoint = hitInfo.point;
                        return;
                    }
                    float distance = Vector3.Distance(hitInfo.point, lastPoint);


                    if (distance > brush.Scale)
                    {
                        Vector3 direction = (hitInfo.point - lastPoint).normalized;
                        int     num       = (int)(distance / (brush.Scale));
                        //Accoring your computer cpu, my cpu is 6700K,it is accptable~!!
                        //But in the i5 4210U(computer with touchScreen),it is look like set to 8;
                        //Chang the for loop i+=2 to i+=8;
                        for (int i = 0; i <= num - 1; i += 2)
                        {
                            Vector3 lerpPoint = lastPoint + direction * (i + 1) * (brush.Scale);
                            Ray     mRay      = new Ray(ray.origin, (lerpPoint - ray.origin).normalized);
                            Debug.DrawLine(mRay.origin, lerpPoint);
                            RaycastHit newHitInfo;
                            if (Physics.Raycast(mRay, out newHitInfo))
                            {
                                if (newHitInfo.transform.GetComponent <InkCanvas>())
                                {
                                    success = erase ? paintObject.Erase(brush, newHitInfo) : paintObject.Paint(brush, newHitInfo);
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        if (!success)
                        {
                            Debug.LogError("Failed lerp to point");
                        }
                    }
                    lastPoint = hitInfo.point;
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                lastPoint = Vector3.zero;
            }
        }
Пример #10
0
    public void UpdateTP()
    {
        brushColor = ColorSelector.GetColor();          //Updates our painted color with the selected color

        UpdateBrushCursor();

        if (smoothBrush != null)
        {
            smoothBrush.UpdateCursorPos(brushPos, brushSize);
            cpTimer += Time.deltaTime;
            if (cpTimer > CP_TIME)
            {
                smoothBrush.AddCP(brushPos, brushSize);
                cpTimer = 0;
            }
            smoothBrush.UpdateStroke();

            if (drip == null)
            {
                if (dripTimer > 0)
                {
                    if (DripScript.IsInRange(lastCoords, brushPos, lastPaintableObject.texScale))
                    {
                        dripTimer += Time.deltaTime;
                        if (dripTimer > timeToDrip)
                        {
                            drip = MakeDrip(lastPaintableObject, brushPos, brushSize).GetComponent <DripScript> ();
                            drip.Init(brushPos, lastPaintableObject);
                            dripTimer = 0;
                        }
                    }
                    else
                    {
                        dripTimer = 0;
                    }
                }
                else
                {
                    lastCoords = brushPos;
                    dripTimer += Time.deltaTime;
                }
            }
            else
            {
                if (drip.IsInRange(brushPos))
                {
                    drip.IncAmt();
                }
                else
                {
                    drip = null;
                }
            }
        }

        if (lastPaintableObject != null)
        {
            if (smoothBrush != null && !PlayerInput.singleton.isTriggerHeld)
            {
                EndPaint();
            }
            else
            {
                RenderCanvas(lastPaintableObject, true);
            }
        }
    }