Beispiel #1
0
    public void turnOn(bool hasEffect = false)
    {
        bgSprite.color    = onColor;
        currentPointState = pointState.isOn;
        unlockEffect.gameObject.SetActive(true);

        //scale up the point a bit and back
        TweenHelper.scaleLocal(this.gameObject, new Vector3(1.5f, 1.5f, 1.5f), 0.1f, iTween.EaseType.easeOutCubic, "scalePointBack", this.gameObject);

        if (hasEffect)
        {
            Instantiate(unlockEffect, this.transform.position, Quaternion.identity);
        }
    }
Beispiel #2
0
    //Constructor
    //vLoc is points location
    //cIndex is the index in the world grid
    //pointState is the state of the point ( open spot, no land, obstacle)
    public Point(Vector3 vLoc, Index cIndex, pointState pointState, Point parent = null)
    {
        state     = pointState;
        controlSt = controlState.grey;

        redInfluence  = 0;
        blueInfluence = 0;

        loc         = vLoc;
        parentPoint = parent;
        index       = cIndex;

        //initialize these to zero for now
        f = 0;
        g = 0;
        h = 0;
    }
Beispiel #3
0
    //Method - creates the 2D grid, which accounts for varying terrain heights
    void BuildGrid()
    {
        Vector3 above = new Vector3(0, 2, 0);

        //cycle through th points on the grid
        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                //the origin of the grid
                Vector3 worldPoint = transform.position - Vector3.right * gridSize.x / 2 - Vector3.forward * gridSize.y / 2;
                worldPoint   += Vector3.right * (x * d + r) + Vector3.forward * (y * d + r);
                worldPoint.y += 5;
                //the state at any location on the grid
                pointState state = pointState.space;

                //add point to grid
                grid[x, y] = new Point(worldPoint, new Index(x, y), state);
            }
        }
        GenerateInfluenceMap();
    }
	// Use this for initialization
	void Start ()
	{
		mainstate = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameController> ();
		//curcol = GetComponent<BoxCollider2D> ();

		// Just in case check.
		transform.position = Vector2.zero;

		/*// Show Line Renderer in 2D by bringing it to foreground
		cur = GetComponent<LineRenderer> ();
		cur.sortingLayerName = "Obstacles";
		*/

		// Camera details
		campos = Camera.main.transform.position;
		//xDist = Camera.main.aspect * Camera.main.orthographicSize;
		yDist = Camera.main.orthographicSize;
		//xMax = campos.x + xDist;
		yMax = campos.y + yDist;
		yMin = campos.y - yDist;
		endpos = new Vector2 (campos.x, yMin - 0.25f);
		startpos = new Vector2 (campos.x, yMax + 0.25f);

		/*/Set length of line
		cur.SetPosition (0, new Vector3 (xDist, 0, 0));
		cur.SetPosition (1, new Vector3 (-xDist, 0, 0));*/

		/* Set Collider size
		curcol.size = new Vector2 (xDist * 2, 0.2f);*/

		// Main camera height and width
		camheight = Camera.main.orthographicSize * 2;
		camwidth = camheight * Camera.main.aspect;
		
		// Line sprite components
		tempsr = transform.GetChild (2).GetComponent<SpriteRenderer> ();
		temps = tempsr.sprite;
		
		// How big line is in world units
		unitWidth = temps.textureRect.width / temps.pixelsPerUnit;
		unitHeight = temps.textureRect.height / temps.pixelsPerUnit;
		
		// Adjust line scale
		transform.localScale = new Vector3 (camwidth / (unitWidth * 4f), camheight / (unitHeight * 70));

		// Set position above camera
		transform.position = startpos;

		LineAnim = GetComponent<Animator> ();

		curState = pointState.Stall;
		StartCoroutine (pointGo ());

		curpoints = 0;
	}
	// Determines when the point goes down screen
	IEnumerator pointGo ()
	{
		while (mainstate.curState == GameController.gameState.Start) {
			yield return null;
		}
		while (mainstate.curState != GameController.gameState.End) {
			yield return new WaitForSeconds (5f);
			if (mainstate.curState != GameController.gameState.End) {
				transform.position = startpos;
				curState = pointState.Go;
				inside = false;
			} else {
				yield return null;
			}
		}
		yield break;
	}
	// Update is called once per frame
	void Update ()
	{
		// Point goes down screen
		if (curState == pointState.Go) {
			movePoint ();
			if (transform.position.y <= endpos.y) {
				curState = pointState.Stall;
				LineAnim.SetBool ("Gained", false);
			}
		}
	}
Beispiel #7
0
 public void turnError()
 {
     bgSprite.color    = errorColor;
     currentPointState = pointState.isError;
 }
Beispiel #8
0
 public void turnOff()
 {
     bgSprite.color    = offColor;
     currentPointState = pointState.isOff;
     //unlockEffect.gameObject.SetActive(false);
 }