void Start()
 {
     text = GetComponent<Text> ();
     originalColor = text.color;
     collisionDetection.OnHit += triggerChangeColor;
     state = idle;
 }
 public void changeColor(Color col, bool rand = false, float transition = 0.1f)
 {
     state = decreasing;
     transOut = transition;
     if (rand)
         transOut += Random.Range(-transition* (2f/3f), transition * 2);
     trans = 1;
 }
 void stopping()
 {
     counter -= Time.deltaTime;
     if (counter <= 0) {
         main.animation.Stop ();
         state = idle;
     }
 }
Beispiel #4
0
    void decreasing()
    {
        trans -= transOut;
        Color transColor = Color.Lerp (originalColor, ColorManager.instance.hitCol, trans);
        image.color = transColor;

        if (trans <= 0)
            state = idle;
    }
Beispiel #5
0
    void decreasing()
    {
        trans -= transOut;
        Color transColor = Color.Lerp (originalColor, currentColor, trans);
        renderer.material.color = transColor;

        if (trans <= 0)
            state = idle;
    }
Beispiel #6
0
 public void changeColor(Color col, float transition, bool rand)
 {
     state = decreasing;
     currentColor = col;
     transOut = transition;
     if (rand)
         transOut += Random.Range(-transition* (2f/3f), transition * 2);
     trans = 1;
 }
    void decreasing()
    {
        trans -= transOut;
        Color transColor = Color.Lerp (originalColor, hitColor, trans);
        text.color = transColor;

        if (trans <= 0)
            state = idle;
    }
 void moving()
 {
     if (Input.GetAxis("Mouse X") == 0) {
         state = decelerating;
         decelerating ();
         return;
     }
     speed = Input.GetAxis ("Mouse X") * sensitivityX;
     transform.Rotate(0, speed, 0);
 }
Beispiel #9
0
    void fire()
    {
        GameObject barInst = GameObject.Instantiate (bar, currentTile.transform.position, currentTile.transform.rotation) as GameObject;
        currentBarComp = barInst.GetComponent<Bar> ();
        float magnitude = getScale (scaleCoords [currentWall, stateIndex]);
        currentBarComp.maxDist = magnitude * tileLen;
        barInst.transform.localScale = new Vector3 (tileLen, tileLen * magnitude, tileLen);
        barInst.transform.Translate (new Vector3 (0, -magnitude/2f * tileLen, 0));

        currentBarComp.onDone += switchBackToMoving;
        movementState = idle;
    }
Beispiel #10
0
    void decelerating()
    {
        if (Input.GetAxis("Mouse X") != 0) {
            state = moving;
            moving ();
            return;
        }
        speed *= deceleration;
        speed = Mathf.Clamp (speed, 0, speed);
        transform.Rotate(0, speed, 0);
        Debug.Log (speed);

        if (speed == 0)
            state = moving;
    }
Beispiel #11
0
    public void activate()
    {
        counter = 0f;
        float minValint = (float.Parse(minVal));

        if (minValint <= 0 || minValint == null)
        {
            state = idle;
            return;
        }
        float minsInDay = 60 * 24;

        increment = minsInDay / minValint;
        goal      = minsInDay;
        on        = true;
        state     = running;
    }
Beispiel #12
0
    void show()
    {
        hideCounter = whenToHide;

        if (state == hidden || state == null) {
            toEnable.SetActive (true);
            state = shown;
            if (timedHiders.Count + 1 > maxAmount) { //the ui lags a lot so it has to be limited
                TimedHider timedHider = timedHiders[0];
                if (timedHider != null)
                    timedHider.hide();
                timedHiders.Remove(timedHider);

            }
            timedHiders.Add(this);
        }
    }
Beispiel #13
0
    void firing()
    {
        float move = speed * Time.deltaTime;
        transform.Translate (new Vector3 (0, move, 0));
        distTraveled += move;
        speed *= acceleration;
        damage = Point.instance.value;

        if (distTraveled >= maxDist) {
            Vector3 movementToEnd = new Vector3(0, maxDist-distTraveled,0);
            transform.Translate(movementToEnd);
            speed = initSpeed;
            distTraveled = 0;
            state = pause;
            damage = Point.instance.value;
        }
    }
Beispiel #14
0
    void OnEnable()
    {
        WallManager.instance.onNewDimensions += updateDim;
        WallBuilder.instance.OnNewWall += updateWallParams;
        tileLen = WallManager.instance.tileLen;
        normalColor = WallManager.instance.normalColor;
        activeColor = WallManager.instance.activeColor;

        delay = delayVal;
        counter = counterLimit;
        fireCounter = fireCounterLimit;
        xAmt = WallManager.instance.xAmt;
        yAmt = WallManager.instance.yAmt;
        zAmt = WallManager.instance.zAmt;

        directions = new Vector3[4,3]
        {{new Vector3 (0,1,0), new Vector3 (1,0,0), new Vector3 (1,0,0)},
            {new Vector3 (0,0,1), new Vector3 (0,0,1), new Vector3 (0,-1,0)},
            {new Vector3 (0,-1,0), new Vector3 (-1,0,0), new Vector3 (-1,0,0)},
            {new Vector3 (0,0,-1), new Vector3 (0,0,-1), new Vector3 (0,1,0)}};

        scaleCoords = new int[4,3]
        {{2,2,1},
         {1,0,0},
         {2,2,1},
         {1,0,0}};

        position = new Vector3 (0, 0, 0);
        currentWall = 0;
        setConversionValues (currentWall);
        stateHandler path = randomizePath (YPath, XPath);
        path ();
        movementState = moving;
    }
Beispiel #15
0
 // Use this for initialization
 void Start()
 {
     originalColor = renderer.material.color;
     WallManager.instance.OnNewColor += changeColor;
     state = idle;
 }
Beispiel #16
0
 public void stop()
 {
     on    = false;
     state = idle;
 }
Beispiel #17
0
 void Start()
 {
     state = idle;
 }
Beispiel #18
0
    void moving()
    {
        counter -= Time.deltaTime;
        fireCounter -= Time.deltaTime;
        delay -= Time.deltaTime;
        if (delay >= 0)
            return;

        delay = delayVal;

        move ();

        if (counter <= 0) {
            counter = counterLimit;
            switchDirection(currentWall);
        }

        if (fireCounter <= 0) {
            fireCounter = fireCounterLimit;
            movementState = fire;
        }

        lastTile = currentTile;
        //=====color code=====
        currentTile = currentPath [currentWall] [(int)(position2D.x), (int)(position2D.y)];
        //currentTile.renderer.material.color = activeColor;
        if (currentTile != lastTile)
            currentTileComp = currentTile.GetComponent<StaticTile>();
        currentTileComp.changeColor (activeColor, 0.012f, false);
    }
Beispiel #19
0
 void ZPath()
 {
     pathState = ZPath;
     stateIndex = 2;
     direction = directions [currentWall, stateIndex];
     currentPath = WallManager.instance.pathAroundZ;
 }
Beispiel #20
0
 void YPath()
 {
     pathState = YPath;
     stateIndex = 1;
     direction = directions [currentWall, stateIndex];
     currentPath = WallManager.instance.pathAroundY;
 }
Beispiel #21
0
    void XPath()
    {
        //path around x axis

        pathState= XPath;
        stateIndex = 0;
        direction = directions [currentWall, stateIndex];
        currentPath = WallManager.instance.pathAroundX;
    }
Beispiel #22
0
 void pause()
 {
     counter -= Time.deltaTime;
     if (counter <= 0)
         state = moveBack;
 }
Beispiel #23
0
 void Start()
 {
     speed = 10;
     initSpeed = speed;
     acceleration = 1.1f;
     counter = 2; //seconds
     renderer.material.color = WallManager.instance.activeColor;
     state = firing;
 }
Beispiel #24
0
 void OnEnable()
 {
     collisionDetection.OnHit += triggerChangeColor;
     state = idle;
 }
Beispiel #25
0
 // Use this for initialization
 void Start()
 {
     counter = counterVal;
     state = idle;
 }
Beispiel #26
0
 stateHandler randomizePath(stateHandler firstState, stateHandler secondState)
 {
     if (Random.Range(0,100) < 50)
         return firstState;
     else
         return secondState;
 }
Beispiel #27
0
 void switchBackToMoving()
 {
     movementState = moving;
     currentBarComp.onDone -= switchBackToMoving;
 }
Beispiel #28
0
    void Start()
    {
        // Make the rigid body not change rotation
        if (GetComponent<Rigidbody>())
            GetComponent<Rigidbody>().freezeRotation = true;

        Screen.lockCursor = true;
        state = moving;
    }
Beispiel #29
0
 public void hide()
 {
     toEnable.SetActive (false);
     state = hidden;
 }