Exemplo n.º 1
0
	void Start(){
		localGrid = GameObject.FindGameObjectWithTag("MainGrid").GetComponent<CreatePlayGrid>();
		if(isLocalPlayer){
			Cmd_SetObjNameServer(Player.Instance.playerName);
			Player.Instance.thisPlayersNetworkHelper = this;
		}
		Player.Instance.workingOnline = true;
		if(isServer)
			InvokeRepeating("checkAllIfAllClientsAreReadyToAct", 2f, 0.1f);
	}
Exemplo n.º 2
0
	public AIGrid(CreatePlayGrid grid) {
		this.grid = grid;

		closestDist = new int[teamCount, grid.gridSize, grid.gridSize]; 
		closestDistHead = new int[teamCount, grid.gridSize, grid.gridSize];
		closestUnit = new UnitScript[teamCount, grid.gridSize, grid.gridSize]; 
		closestUnitHead = new UnitScript[teamCount, grid.gridSize, grid.gridSize];
		dist = new int[teamCount, grid.gridSize, grid.gridSize];
		distHead = new int[teamCount, grid.gridSize, grid.gridSize];
	}
Exemplo n.º 3
0
	/// <summary>
	/// Sets the grid connection.
	/// This must be set when the unit is created.
	/// </summary>
	/// <param name="playGrid">Play grid.</param>
	public void setGridConection(CreatePlayGrid playGrid){
		grid = playGrid;
	}
Exemplo n.º 4
0
	/// <summary>
	/// Called when the grid block creates the unit.
	/// </summary>
	/// <param name="startLocation">Start location.</param>
	public virtual void spawnUnit(CreatePlayGrid gm, GridBlock startLocation, Team t){
		grid = gm;
		blockList = new LinkedList<GridBlock>();
		//set base unit stats so they can be adjusted at runtime
		maxProgramLength = unitInfo.maxLength;
		maximumMovment = unitInfo.maxMove;
		movmentActionsRemaning = maximumMovment;
		currentMaxPosibleAttackActions = unitInfo.maxAttackActions;
		currentAttacksRemaning = currentMaxPosibleAttackActions;
		currentAttackPower = unitInfo.attackPow;
		team = t;
		team.addAlly(this);
		team.addSpawn();

		blockList.AddLast(startLocation);
		float spawnTime = spawnAnimation();
		Invoke("checkAllDisplay", spawnTime);
		timerStartup();
		Invoke("startTimerTick", spawnTime);
	}
	// All sprite layers are created on load to minimize the impact of changing sprites
	/// <summary>Start this instance.</summary>
	void Start(){ 
		spriteInfo = GetComponentInParent<CreatePlayGrid>();
		attachedGridBlock = GetComponent<GridBlock>();

		//Initialize unit sprite.
		unitSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		unitSprite.transform.SetParent(transform);
		unitSprite.transform.localPosition = new Vector3(0, 0, 0.1f);
		unitSprite.name = "Unit Sprite";

		//Initialize unit head sprite.
		headSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		headSprite.transform.SetParent(transform);
		headSprite.transform.localPosition = new Vector3(0, 0, 0.2f);
		headSprite.name = "Head Sprite";

		//Initialize action sprites and use state.
		actionSprites = new SpriteControler[MAX_ACTIONS_ON_THIS_BLOCK];
		actionUsed = new bool[MAX_ACTIONS_ON_THIS_BLOCK];
		for(int x = 0; x < MAX_ACTIONS_ON_THIS_BLOCK; x++){
			actionSprites[x] = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
			actionSprites[x].transform.SetParent(transform);
			actionSprites[x].transform.localPosition = new Vector3(0, 0, 0.3f + x * 0.05f);
			actionSprites[x].name = "Action Sprite " + x;
		}

		//Initialize movement directions.
		movementDirections = new SpriteControler[4];
		string[] directionNames = { "up", "right", "down", "left" };
		for(int x = 0; x < 4; x++){
			movementDirections[x] = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
			movementDirections[x].transform.SetParent(transform);
			movementDirections[x].transform.localPosition = new Vector3(0, 0, 2.5f);

			//Rotating each movement arm.
			Quaternion rot = movementDirections[x].transform.localRotation;
			rot.eulerAngles = new Vector3(0.0f, 0.0f, 90.0f * x); //UNDONE check to see if rotation is correct
			movementDirections[x].transform.localRotation = rot;

			movementDirections[x].name = "Movment Direction " + directionNames[x];
			// Sprites for this controller are always the same.
			movementDirections[x].setSprite(spriteInfo.spritesAndColors.sprite_moveLine);
			//The color for this sprite is Alpha only.
			movementDirections[x].setColor(Color.clear);
		}

		//Initialize movement circle.
		movementCircle = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		movementCircle.transform.SetParent(transform);
		movementCircle.transform.localPosition = new Vector3(0, 0, 2.5f);
		movementCircle.name = "Movement Circle";

		//Initialize right connection.
		rightConnection = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		rightConnection.transform.SetParent(transform);
		rightConnection.transform.localPosition = new Vector3(conectionLocation, 0, 0.1f);
		rightConnection.name = "Right Conection";

		//Initialize above connection.
		aboveConnection = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		aboveConnection.transform.SetParent(transform);
		aboveConnection.transform.localPosition = new Vector3(0, -conectionLocation, 0.1f);
		aboveConnection.transform.Rotate(0f, 0f, 90f);
		aboveConnection.name = "Above Conection";

		//Initialize move sprite.
		moveSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		moveSprite.transform.SetParent(transform);
		moveSprite.transform.localPosition = new Vector3(0, 0, 0.2f);
		moveSprite.name = "Move Sprite";

	}