Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select a unit #98

Open
JammieDodgers opened this issue Nov 29, 2016 · 3 comments
Open

Select a unit #98

JammieDodgers opened this issue Nov 29, 2016 · 3 comments
Assignees

Comments

@JammieDodgers
Copy link
Contributor

No description provided.

@JammieDodgers JammieDodgers self-assigned this Nov 29, 2016
@JammieDodgers
Copy link
Contributor Author

using UnityEngine;
using System.Collections;

public class Interactive : MonoBehaviour {

private bool _Selected = false;

public bool Selected { get { return _Selected; } }

public bool Swap = false;

public void Select()
{
	_Selected = true;
	foreach (var selection in GetComponents<Interaction>()) {
		selection.Select();
	}
}

public void Deselect()
{
	_Selected = false;
	foreach (var selection in GetComponents<Interaction>()) {
		selection.Deselect();
	}
}

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
	if (Swap) {
		Swap = false;
		if (_Selected) Deselect();
		else Select ();
	}
}

}

@JammieDodgers
Copy link
Contributor Author

using UnityEngine;
using System.Collections;

public class Highlight : Interaction {

public GameObject DisplayItem;

public override void Deselect ()
{
	DisplayItem.SetActive (false);
}

public override void Select ()
{
	DisplayItem.SetActive (true);
}

// Use this for initialization
void Start () {
	DisplayItem.SetActive (false);
}

}

@JammieDodgers
Copy link
Contributor Author

using UnityEngine;
using System.Collections;

public abstract class Interaction : MonoBehaviour {

public abstract void Select();
public abstract void Deselect();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant