public void Init(PlanerCore parent, int range) { GraphNode x = parent.GetNode(); gameObject.SetActive(true); int direction = parent.Direction; int i = range; while (i > 0) { if (GraphTagMachine.GetDirections(x)[direction]!=WayStatus.Blocked) { x = x.GetNodeByDirection(direction); i--; if (x.HasObjectOfType(typeof(IPlanerLike))) i = -1; } else { i = -1; } } //placed = true; Node = x; (m_visualiser.GetComponent<WebCatapultVisualiser>()).Push(parent); }
public static MineController GetMineController(int[] mines, PlanerCore planer) { MineController newController=ScriptableObject.CreateInstance<MineController>(); newController.Init(planer); newController.RenewObjectList(mines); return newController; }
public static void Save(PlanerCore planer, GraphNode node, int direction, bool onPlaySave) { //Debug.Log("OnSave"); //PlayerPrefs.DeleteAll(); PlayerPrefs.SetInt("MineCount", planer.MineController.Mines.Count); //Debug.Log(Application.loadedLevelName); string currentLevel = Application.loadedLevelName; if (currentLevel == "GlobalMap") currentLevel = Creator.PreviousLevel; PlayerPrefs.SetString("CurrentLevel", currentLevel); for (int i = 0; i < planer.MineController.Mines.Count; i++) { PlayerPrefs.SetInt("Mine" + i, Armory.WeaponIndex(planer.MineController.Mines[i].GetType().Name)); } if (onPlaySave) { PlayerPrefs.SetInt("XCoord", node.X); PlayerPrefs.SetInt("YCoord", node.Y); PlayerPrefs.SetInt("IndexCoord", node.Index); PlayerPrefs.SetInt("LevelCoord", node.Level); if(direction<0) direction=planer.Direction; PlayerPrefs.SetInt("Direction", direction); } }
public void Initialize(PlanerCore planer, MoveParameters parameters) { Agility = parameters.agility; m_direction = parameters.direction; m_planer = planer; m_planer.transform.rotation = Quaternion.identity; m_planer.transform.Rotate(new Vector3(0, -60 * m_direction, 0)); }
public void Init(PlanerCore parent) { //Destroy(GetComponent<CustomObjectEditorSupply>()); Node = parent.Node; gameObject.SetActive(true); (m_visualiser.GetComponent<BasicMineVisualiser>()).OnInstall(parent); }
public void Init(PlanerCore planer, int index) { m_parentPlaner = planer; Activated = false; if (planer == Creator.Player) { m_index = index; InitGUI(index); m_hasGUI = true; } }
public void Activate(PlanerCore planer) { m_planer = planer; m_firefly =(Instantiate(fireflyPrefab) as GameObject).GetComponent<RedFirefly>(); defaultPlanerMaterial =new Material( m_planer.Visualiser.body.GetComponent<Renderer>().material); m_planer.Visualiser.body.GetComponent<Renderer>().material.color = Color.red; planer.AddUpdateFunc(UpdatePlaner); planer.State=1; planer.CutInterface(); planer.Interact = OnInteract; AddButtons(); }
public void Push(PlanerCore parent) { Vector3 targetVector = transform.position - parent.Visualiser.transform.position; float dist = targetVector.magnitude / transform.parent.localScale.x; transform.parent.rotation = Quaternion.identity; transform.parent.localScale = transform.parent.localScale * dist; transform.localScale = transform.localScale / dist; float angle = Vector3.Angle(targetVector, Vector3.forward); //Debug.Log(angle); if (targetVector.x < 0) angle = -angle; transform.parent.Rotate(new Vector3(0, angle, 0)); GetComponent<Animation>().Play("Push"); //m_visualiser.animation.localBounds }
public void Init(PlanerCore planer) { //Debug.Log("init"); m_planer = planer; m_mines = new List<ButtonObject>(); int i = 0; foreach(string x in planer.Upgrades) { //Debug.Log(x); ButtonObject obj = ScriptableObject.CreateInstance(x) as ButtonObject; obj.Init(planer, i); m_mines.Add(obj); i++; //Debug.Log(i); } }
public void OnInstall(PlanerCore parent) { //Debug.Log(parent); Vector3 targetVector = transform.position - parent.Visualiser.transform.position; float dist = targetVector.magnitude / transform.parent.localScale.x; if (dist == 0) return; transform.parent.rotation = Quaternion.identity; transform.parent.localScale = transform.parent.localScale * dist; transform.localScale = transform.localScale / dist; float angle = Vector3.Angle(targetVector, Vector3.forward); //Debug.Log(angle); if (targetVector.x < 0) angle = -angle; transform.parent.Rotate(new Vector3(0, angle, 0)); //animation.GetClip("InstallMine").localBounds=new Bounds(Vector3.zero, new Vector3(dist,0,dist)); GetComponent<Animation>().Play("InstallMine"); //Debug.Log(angle); //Debug.Log(targetVector); //Debug.Log(parent.Visualiser.transform.position); //Debug.Break(); }
public void Init(PlanerCore parent) { m_parentPlaner = parent; }
public void Start() { if (m_init) return; basicFixedTime = Time.fixedDeltaTime; if (!(testBuild && Application.isEditor)) { foreach (UnityEngine.Object x in Resources.FindObjectsOfTypeAll(typeof(CustomObject))) { if (!(x).name.Contains("Prefab")) { if (x as EmptyObject != null) continue; Destroy((x as CustomObject).gameObject); } } } if (m_player == null) { m_player = (Instantiate(playerPrefab) as GameObject).GetComponent<PlanerCore>(); m_player.Init(); m_player.name = "Player"; } m_player.Hidden = false; Camera.main.GetComponent<CameraControls>().Init(); string levelName = "SafeHouse"; if (testBuild && Application.isEditor) { levelName = SceneName; m_energy = -1; m_addObjects = new HashSet<CustomObject>(); foreach (UnityEngine.Object x in Resources.FindObjectsOfTypeAll(typeof(CustomObject))) { if (!(x).name.Contains("Prefab") && !(x.name == "InstrumentObject")) { m_addObjects.Add(x as CustomObject); } } UpdateObjectList(); } else { LoadLevel(levelName); } LoadGame(); m_init = true; AddObject(m_player); SwitchLevel(); GraphNode.InteractAll(); m_turnTime = levels[m_energy].SelectionPhaseDuration; }
public static bool SetPlanerData(PlanerCore planer, bool firstLoad) { planer.InitInterface(); EnterPortal(planer); if (!PlayerPrefs.HasKey("CurrentLevel")) { return true; } planer.prevNode = planer.Node.GetNodeByDirection((planer.Direction + 3) % 6); planer.m_visualiser.transform.position=planer.transform.position; int[] mines = GetMines(); ScriptableObject.Destroy(planer.MineController); planer.MineController = MineController.GetMineController(mines, planer); return true; }
static void EnterPortal(PlanerCore planer) { IPortalExit enter = Creator.creator.defaultPortal; if (Creator.creator.testBuild && Application.isEditor ) { if(Creator.creator.testEnter != null) enter = Creator.creator.testEnter; planer.EnteredPortal = true; } planer.OnEnterPortal(enter.GetNode(), enter.Direction); }