protected void Awake() { directional = GetComponent <Directional>(); directional.OnDirectionChange.AddListener(OnDirectionChange); SpriteHandler = GetComponentInChildren <SpriteHandler>(); if (CustomNetworkManager.Instance._isServer == false) { return; } SpriteHandler.SetSpriteSO(GhostSpritesSOs.PickRandom()); }
protected virtual void Awake() { simpleAnimal = GetComponent <SimpleAnimal>(); mobFollow = GetComponent <MobFollow>(); mobExplore = GetComponent <MobExplore>(); mobFlee = GetComponent <MobFlee>(); health = GetComponent <LivingHealthBehaviour>(); directional = GetComponent <Directional>(); mobSprite = GetComponent <MobSprite>(); cnt = GetComponent <CustomNetTransform>(); registerObject = GetComponent <RegisterObject>(); uprightSprites = GetComponent <UprightSprites>(); }
//Editor only syncing public void EditorDirectionChange() { directional = GetComponent <Directional>(); spriteRenderer = GetComponentInChildren <SpriteRenderer>(); spriteRendererLightOn = GetComponentsInChildren <SpriteRenderer>().Length > 1 ? GetComponentsInChildren <SpriteRenderer>()[1] : GetComponentsInChildren <SpriteRenderer>()[0]; var state = mountStatesMachine.LightMountStates[LightMountState.On]; spriteRenderer.sprite = state.SpritesDirectional.GetSpriteInDirection(directional.CurrentDirection.AsEnum()); spriteRendererLightOn.sprite = spritesStateOnEffect.GetSpriteInDirection(directional.CurrentDirection.AsEnum()); RefreshBoxCollider(); }
private void EnsureInit() { if (playerScript != null) { return; } playerScript = GetComponent <PlayerScript>(); uprightSprites = GetComponent <UprightSprites>(); playerDirectional = GetComponent <Directional>(); playerDirectional.ChangeDirectionWithMatrix = false; uprightSprites.spriteMatrixRotationBehavior = SpriteMatrixRotationBehavior.RemainUpright; spriteRenderers = GetComponentsInChildren <SpriteRenderer>(); }
private void Start() { //for changing direction on click playerDirectional = gameObject.GetComponent <Directional>(); playerMove = GetComponent <PlayerMove>(); objectBehaviour = GetComponent <ObjectBehaviour>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); //Do not include the Default layer! Assign your object to one of the layers below: layerMask = LayerMask.GetMask("Furniture", "Walls", "Windows", "Machines", "Unshootable Machines", "Players", "Items", "Door Open", "Door Closed", "WallMounts", "HiddenWalls", "Objects", "Matrix", "Floor", "NPC"); }
private void Start() { upVectorForRotation = transform.up; child = transform.GetChild(0); directional = GetComponent <Directional>(); spriteRenderers = GetComponentsInChildren <SpriteRenderer>(); foreach (SpriteRenderer renderer in spriteRenderers) { //don't add it if it already exists var existingRenderer = renderer.GetComponent <WallmountSpriteBehavior>(); if (existingRenderer == null) { renderer.gameObject.AddComponent <WallmountSpriteBehavior>(); } } }
/// <summary> /// This will spawn a contagion spot with the specific sickness in it /// at the player position and in the 3 spots in front of him. /// Like so: /// o /// xo /// o /// </summary> /// <param name="symptomManifestation"></param> private void SpawnContagion(SymptomManifestation symptomManifestation) { Vector3Int position = symptomManifestation.PlayerHealth.gameObject.RegisterTile().WorldPositionServer; Directional playerDirectional = symptomManifestation.PlayerHealth.PlayerMove.PlayerDirectional; // Player position SpawnContagionSpot(symptomManifestation, position); // In front SpawnContagionSpot(symptomManifestation, position + playerDirectional.CurrentDirection.Vector); // Front left SpawnContagionSpot(symptomManifestation, position + (Quaternion.Euler(0, 0, -45) * playerDirectional.CurrentDirection.Vector)); // Front Right SpawnContagionSpot(symptomManifestation, position + (Quaternion.Euler(0, 0, 45) * playerDirectional.CurrentDirection.Vector)); }
/// <summary> /// Initiate this progress bar's behavior on server side. Assumes position is already set to where the progress /// bar should appear. /// </summary> /// <param name="progressAction">progress action being performed</param> /// <param name="timeForCompletion">how long in seconds the action should take</param> /// <param name="progressEndAction">callback for when action completes or is interrupted</param> /// <param name="player">player performing the action</param> public void ServerStartProgress(ProgressAction progressAction, float timeForCompletion, IProgressEndAction progressEndAction, GameObject player) { done = true; playerDirectional = player.GetComponent <Directional>(); progress = 0f; lastSpriteIndex = 0; timeToFinish = timeForCompletion; completedEndAction = progressEndAction; facingDirectionCache = playerDirectional.CurrentDirection; registerPlayer = player.GetComponent <RegisterPlayer>(); playerSync = player.GetComponent <PlayerSync>(); this.progressAction = progressAction; id = GetInstanceID(); //check if something is in hand so we can interrupt if it's dropped var usedItemObj = player.Player().Script.playerNetworkActions.GetActiveHandItem(); if (usedItemObj != null) { usedItem = usedItemObj.GetComponent <Pickupable>(); if (usedItem != null) { usedItem.OnDropServer.AddListener(ServerInterruptOnDrop); } } if (player != PlayerManager.LocalPlayer) { //server should not see clients progress bar spriteRenderer.enabled = false; } else { spriteRenderer.enabled = true; } spriteRenderer.sprite = progressSprites[0]; CommonStartProgress(); //Start the progress for the player: //note: using transform position for the offset, because progress bar has no register tile and //otherwise it would give an incorrect offset if player is on moving matrix ProgressBarMessage.SendCreate(player, 0, (transform.position - player.transform.position).To2Int(), id); }
protected void Awake() { directional = GetComponent <Directional>(); livingHealthBehaviour = GetComponent <LivingHealthBehaviour>(); foreach (ClothingItem c in GetComponentsInChildren <ClothingItem>()) { clothes[c.name] = c; // add listener in case clothing was changed c.OnClothingEquipped += OnClothingEquipped; } AddOverlayGameObjects(); directional.OnDirectionChange.AddListener(OnDirectionChange); livingHealthBehaviour.OnClientFireStacksChange.AddListener(OnClientFireStacksChange); OnClientFireStacksChange(livingHealthBehaviour.FireStacks); }
private void Awake() { playerScript = GetComponent <PlayerScript>(); PlayerDirectional = gameObject.GetComponent <Directional>(); registerPlayer = GetComponent <RegisterPlayer>(); pna = gameObject.GetComponent <PlayerNetworkActions>(); playerScript.registerTile.AddStatus(this); //Aren't these set up with sync vars? Why are they set like this? //They don't appear to ever get synced either. if (PlayerScript.IsGhost == false) { RunSpeed = 1; WalkSpeed = 1; CrawlSpeed = 0f; } }
public Directional GetWeakestDirectionalOfVector(Vector3 vector) { vector = Vector3Absolute(vector); Directional newDirectional = Directional.X; if (vector.y < vector.x && vector.y < vector.z) { newDirectional = Directional.Y; } if (vector.z < vector.x && vector.z < vector.y) { newDirectional = Directional.Z; } return(newDirectional); }
protected void Awake() { directional = GetComponent <Directional>(); playerHealth = GetComponent <PlayerHealthV2>(); foreach (var clothingItem in GetComponentsInChildren <ClothingItem>()) { clothes.Add(clothingItem.Slot, clothingItem); } AddOverlayGameObjects(); directional.OnDirectionChange.AddListener(OnDirectionChange); //TODO: Need to reimplement fire stacks on players. playerHealth.OnClientFireStacksChange.AddListener(OnClientFireStacksChange); var healthStateController = GetComponent <HealthStateController>(); OnClientFireStacksChange(healthStateController.FireStacks); }
private void ManipulationStart(RaycastHit hit) { editToolMode = EditToolMode.Manipulating; manipulationBlockDirectional = Directional.Unspecified; manipulationPointStart = hit.point; manipulationSelectionPosInitial = selectionPos; manipulationSelectionPosCurrent = manipulationSelectionPosInitial; // Adjust Manipulator Planes manipulatorPlaneX.transform.position = hit.point; manipulatorPlaneY.transform.position = hit.point; manipulatorPlaneZ.transform.position = hit.point; if (selectionType == SelectionType.Face) { if (selectionFaceNormalA.x != 0) { manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(true); } else if (selectionFaceNormalA.y != 0) { manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(true); } else if (selectionFaceNormalA.z != 0) { manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(false); } } else { manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(true); } }
public void DirectionalStuff() { int[,] values = new int[, ] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, }; var d = new Directional <int>(values); Assert.AreEqual(0, d.TopLeft); Assert.AreEqual(1, d.TopCenter); Assert.AreEqual(2, d.TopRight); Assert.AreEqual(3, d.MiddleLeft); Assert.AreEqual(4, d.Center); Assert.AreEqual(5, d.MiddleRight); Assert.AreEqual(6, d.BottomLeft); Assert.AreEqual(7, d.BottomCenter); Assert.AreEqual(8, d.BottomRight); }
private void DrawEntrance(Directional entrance, ref Texture2D2 texture) { BuildingModule module = GameObject.FindObjectOfType <BuildingModule>(); if (entrance.direction == Direction.North) { MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_north); } else if (entrance.direction == Direction.East) { MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_east); } else if (entrance.direction == Direction.South) { MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_south); } else { MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_west); } }
private void DrawWindow(Directional window, ref Texture2D2 texture) { BuildingModule module = GameObject.FindObjectOfType <BuildingModule>(); if (window.direction == Direction.North) { MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_north); } else if (window.direction == Direction.East) { MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_east); } else if (window.direction == Direction.South) { MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_south); } else { MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_west); } }
/// <summary> /// Initiate this progress bar's behavior on server side. Assumes position is already set to where the progress /// bar should appear. /// </summary> /// <param name="progressAction">progress action being performed</param> /// <param name="timeForCompletion">how long in seconds the action should take</param> /// <param name="progressEndAction">callback for when action completes or is interrupted</param> /// <param name="player">player performing the action</param> public void ServerStartProgress(ProgressAction progressAction, float timeForCompletion, IProgressEndAction progressEndAction, GameObject player) { done = true; playerDirectional = player.GetComponent <Directional>(); progress = 0f; lastSpriteIndex = 0; timeToFinish = timeForCompletion; completedEndAction = progressEndAction; facingDirectionCache = playerDirectional.CurrentDirection; registerPlayer = player.GetComponent <RegisterPlayer>(); playerSync = player.GetComponent <PlayerSync>(); this.progressAction = progressAction; id = GetInstanceID(); //interrupt if hand contents are changed var activeSlot = player.Player().Script.ItemStorage.GetActiveHandSlot(); activeSlot.OnSlotContentsChangeServer.AddListener(ServerInterruptOnInvChange); this.usedSlot = activeSlot; if (player != PlayerManager.LocalPlayer) { //server should not see clients progress bar spriteRenderer.enabled = false; } else { spriteRenderer.enabled = true; } spriteRenderer.sprite = progressSprites[0]; CommonStartProgress(); //Start the progress for the player: //note: using transform position for the offset, because progress bar has no register tile and //otherwise it would give an incorrect offset if player is on moving matrix ProgressBarMessage.SendCreate(player, 0, (transform.position - player.transform.position).To2Int(), id); }
void InitController() { var slot = GamepadManager.GetSlot(ControllerId); if (!slot.IsConnected) { return; } if (SnesController.IsMatch(slot)) { var snes = new SnesController(slot); Jump = snes.B; Attack = snes.Y; Dodge = snes.R; ActivateUpgrade = snes.X; Guard = snes.L; Start = snes.Start; Direction = snes.Dpad; } else if (Xbox360Controller.IsMatch(slot)) { var xbox = new Xbox360Controller(slot); Jump = xbox.A; Attack = xbox.X; Dodge = xbox.RB; ActivateUpgrade = xbox.Y; Guard = xbox.LB; Start = xbox.Start; Direction = xbox.LeftStick; } else { throw new Exception("invalid controller woh"); } }
/// <summary> /// This will spawn a contagion spot with the specific sickness in it /// at the player position and in the 3 spots in front of him. /// Like so: /// o /// xo /// o /// </summary> /// <param name="symptomManifestation"></param> private void SpawnContagion(SymptomManifestation symptomManifestation) { Vector3Int position = symptomManifestation.MobHealth.gameObject.RegisterTile().WorldPositionServer; Directional directional = symptomManifestation.MobHealth.GetComponent <Directional>(); // Player position SpawnContagionSpot(symptomManifestation, position); if (directional == null) { return; } // In front SpawnContagionSpot(symptomManifestation, position + directional.CurrentDirection.Vector); // Front left SpawnContagionSpot(symptomManifestation, position + (Quaternion.Euler(0, 0, -45) * directional.CurrentDirection.Vector)); // Front Right SpawnContagionSpot(symptomManifestation, position + (Quaternion.Euler(0, 0, 45) * directional.CurrentDirection.Vector)); }
protected void Awake() { if (ENGULFED_BURNING_OVERLAY_PREFAB == null) { ENGULFED_BURNING_OVERLAY_PREFAB = Resources.Load <GameObject>("EngulfedBurningPlayer"); PARTIAL_BURNING_OVERLAY_PREFAB = Resources.Load <GameObject>("PartialBurningPlayer"); } if (engulfedBurningOverlay == null) { engulfedBurningOverlay = GameObject.Instantiate(ENGULFED_BURNING_OVERLAY_PREFAB, transform) .GetComponent <BurningDirectionalOverlay>(); engulfedBurningOverlay.enabled = true; engulfedBurningOverlay.StopBurning(); partialBurningOverlay = GameObject.Instantiate(PARTIAL_BURNING_OVERLAY_PREFAB, transform) .GetComponent <BurningDirectionalOverlay>(); partialBurningOverlay.enabled = true; partialBurningOverlay.StopBurning(); } livingHealthBehaviour = GetComponent <LivingHealthBehaviour>(); livingHealthBehaviour.OnClientFireStacksChange.AddListener(OnClientFireStacksChange); OnClientFireStacksChange(livingHealthBehaviour.FireStacks); //StaticSpriteHandler directional = GetComponent <Directional>(); directional.OnDirectionChange.AddListener(OnDirectionChange); foreach (ClothingItem c in GetComponentsInChildren <ClothingItem>()) { clothes[c.name] = c; // add listner in case clothing was changed c.OnClothingEquiped += OnClothingEquipped; } SetupBodySprites(); }
public void build() { DestroyRenderAreaTexture(); texture = new Texture2D(200, 200); GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture; vp = new ViewPlane(texture.width, texture.height, 1.0f, 1); vp.max_depth = 5; background_color = Constants.white; tracer_ptr = new Whitted(this); Jittered jit = new Jittered(1); AmbientOccluder ambocl = new AmbientOccluder(); ambocl.scale_radiance(1.0f); ambocl.set_color(Constants.white); ambocl.set_minAmount(Constants.black); ambocl.SetSampler(jit); set_ambient_light(ambocl); PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera(); pinhole_ptr1.set_eye(new Vector3(0, 0, 500)); pinhole_ptr1.set_lookat(Vector3.zero); pinhole_ptr1.set_view_distance(600.0f); pinhole_ptr1.compute_uvw(); set_camera(pinhole_ptr1); Directional directional = new Directional(); directional.set_color(new Color(1, 1, 1, 1)); directional.set_direction(new Vector3(-1, -1, 0)); directional.cast_shadows = true; directional.scale_radiance(3.0f); add_light(directional); Dielectric mat_ptr = new Dielectric(); mat_ptr.set_eta_in(0.8f); mat_ptr.set_eta_in(1.2f); mat_ptr.set_cf_in(new Color(0.0f, 1.0f, 0.8f, 1)); mat_ptr.set_cf_out(new Color(0.75f, 1.0f, 0.4f, 1)); mat_ptr.set_ks(0.5f); mat_ptr.set_exp(100.0f); mat_ptr.set_ior(1.2f); Sphere sph = new Sphere(); sph.sphereCenter = Vector3.zero; sph.sphereRad = 1.0f; sph.set_material(mat_ptr); Instance sphInst = new Instance(sph); sphInst.set_material(mat_ptr); add_object(sphInst); sphInst.set_identity(); sphInst.Scale(40, 40, 1); sphInst.Translate(0.0f, 0.0f, -60); Dielectric mat_ptr1 = new Dielectric(); mat_ptr.set_eta_in(0.2f); mat_ptr.set_eta_in(0.4f); mat_ptr1.set_cf_in(new Color(0.0f, 1.0f, 0.0f, 1)); mat_ptr1.set_cf_out(new Color(0.75f, 1.0f, 0.0f, 1)); mat_ptr1.set_ks(0.8f); mat_ptr1.set_exp(100.0f); mat_ptr1.set_ior(1.52f); Rectangle rect1 = new Rectangle(Vector3.zero, new Vector3(1, 0, 0), new Vector3(0, 1, 0)); rect1.set_material(mat_ptr1); Instance rect1Inst = new Instance(rect1); rect1Inst.set_material(mat_ptr1); add_object(rect1Inst); rect1Inst.set_identity(); rect1Inst.Scale(80, 80, 1); rect1Inst.Translate(-40, -40, 0.0f); render_scene(); }
public DirectionalFrame(Directional directional, bool push, int timestamp) { this.directional = directional; this.push = push; this.timestamp = timestamp; }
public void addDirectional(Directional directional, int duration, bool isBlocking = false) { sequence.Add(new DirectionalFrame(directional, true, sequenceDuration++)); sequence.Add(new DirectionalFrame(directional, false, sequenceDuration++ + duration)); if (isBlocking) { addWait(duration); } }
private void ManipulationContinue() { RaycastHit hitX; RaycastHit hitY; RaycastHit hitZ; Vector3 manipulationDeltaX = Vector3.zero; Vector3 manipulationDeltaY = Vector3.zero; Vector3 manipulationDeltaZ = Vector3.zero; Directional manipulationDirectional = GetManipulationDirectional(); Directional cameraWeakestDirectional = GetWeakestDirectionalOfVector(lvlEditor.cam.gameObject.transform.forward); Vector3 cameraAbsolute = Vector3Absolute(lvlEditor.cam.gameObject.transform.forward); if (selectionType == SelectionType.Block) { // Block Selection (Show 2 Manipulator Planes) if (manipulationBlockDirectional == Directional.Unspecified) { switch (cameraWeakestDirectional) { case (Directional.X): manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(true); break; case (Directional.Y): manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(true); break; case (Directional.Z): manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(false); break; } } else { switch (manipulationDirectional) { case (Directional.X): manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(false); break; case (Directional.Y): manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(false); break; case (Directional.Z): manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(true); break; } } } else { // Face Selection (Show 1 Manipulator Plane) switch (manipulationDirectional) { case (Directional.X): manipulatorPlaneX.gameObject.SetActive(true); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(false); break; case (Directional.Y): manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(true); manipulatorPlaneZ.gameObject.SetActive(false); break; case (Directional.Z): manipulatorPlaneX.gameObject.SetActive(false); manipulatorPlaneY.gameObject.SetActive(false); manipulatorPlaneZ.gameObject.SetActive(true); break; } } if (manipulatorPlaneX.gameObject.activeSelf) { if (CheckMouseColliderRaycast(manipulatorPlaneX, out hitX)) { manipulationDeltaX = hitX.point - manipulationPointStart; } } if (manipulatorPlaneY.gameObject.activeSelf) { if (CheckMouseColliderRaycast(manipulatorPlaneY, out hitY)) { manipulationDeltaY = hitY.point - manipulationPointStart; } } if (manipulatorPlaneZ.gameObject.activeSelf) { if (CheckMouseColliderRaycast(manipulatorPlaneZ, out hitZ)) { manipulationDeltaZ = hitZ.point - manipulationPointStart; } } manipulationDeltaX = Vector3Round(manipulationDeltaX); manipulationDeltaY = Vector3Round(manipulationDeltaY); manipulationDeltaZ = Vector3Round(manipulationDeltaZ); if (selectionType == SelectionType.Face) { manipulationDeltaX = Vector3.Project(manipulationDeltaX, selectionFaceNormalA); manipulationDeltaY = Vector3.Project(manipulationDeltaY, selectionFaceNormalA); manipulationDeltaZ = Vector3.Project(manipulationDeltaZ, selectionFaceNormalA); } else if (selectionType == SelectionType.Block && manipulationBlockDirectional != Directional.Unspecified) { Vector3 normal = Vector3.zero; if (manipulationBlockDirectional == Directional.X) { normal = new Vector3(1, 0, 0); } else if (manipulationBlockDirectional == Directional.Y) { normal = new Vector3(0, 1, 0); } else if (manipulationBlockDirectional == Directional.Z) { normal = new Vector3(0, 0, 1); } manipulationDeltaX = Vector3.Project(manipulationDeltaX, normal); manipulationDeltaY = Vector3.Project(manipulationDeltaY, normal); manipulationDeltaZ = Vector3.Project(manipulationDeltaZ, normal); } Vector3 manipulationDeltaFinal = manipulationDeltaX; if (manipulationDeltaY.magnitude > manipulationDeltaFinal.magnitude) { manipulationDeltaFinal = manipulationDeltaY; } if (manipulationDeltaZ.magnitude > manipulationDeltaFinal.magnitude) { manipulationDeltaFinal = manipulationDeltaZ; } // Make sure delta only has 1 direction if (manipulationDeltaFinal.x != 0) { manipulationDeltaFinal.y = 0; manipulationDeltaFinal.z = 0; manipulationDeltaFinal.x = Mathf.Sign(manipulationDeltaFinal.x); } else if (manipulationDeltaFinal.y != 0) { manipulationDeltaFinal.x = 0; manipulationDeltaFinal.z = 0; manipulationDeltaFinal.y = Mathf.Sign(manipulationDeltaFinal.y); } else if (manipulationDeltaFinal.z != 0) { manipulationDeltaFinal.x = 0; manipulationDeltaFinal.y = 0; manipulationDeltaFinal.z = Mathf.Sign(manipulationDeltaFinal.z); } // Manipulate! if (manipulationDeltaFinal.magnitude > 0) { Debug.DrawRay(manipulationPointStart, manipulationDeltaFinal, Color.red, 0.125f); manipulationPointStart += manipulationDeltaFinal; selectionPos += manipulationDeltaFinal; manipulationSelectionPosCurrent += manipulationDeltaFinal; // If this is block selection and manipulation directional is unspecified, specify it! if (manipulationBlockDirectional == Directional.Unspecified && selectionType == SelectionType.Block) { if (manipulationDeltaFinal.x != 0) { manipulationBlockDirectional = Directional.X; } else if (manipulationDeltaFinal.y != 0) { manipulationBlockDirectional = Directional.Y; } else if (manipulationDeltaFinal.z != 0) { manipulationBlockDirectional = Directional.Z; } } } Vector3 manipulationDeltaTotal = (manipulationSelectionPosCurrent - manipulationSelectionPosInitial); Vector3 manipulationVisualPositionStart = manipulationSelectionPosInitial + (Vector3Multiply(manipulationDeltaTotal.normalized, -selectionScale) * 0.5f); Vector3 manipulationVisualPositionEnd = manipulationVisualPositionStart + manipulationDeltaTotal; Vector3 manipulationVisualPos = (manipulationVisualPositionStart + manipulationVisualPositionEnd) * 0.5f; Vector3 manipulationVisualScale = new Vector3((manipulationDeltaTotal.x == 0 ? selectionScale.x : manipulationDeltaTotal.x), (manipulationDeltaTotal.y == 0 ? selectionScale.y : manipulationDeltaTotal.y), (manipulationDeltaTotal.z == 0 ? selectionScale.z : manipulationDeltaTotal.z)); Vector3 uiSelectionFramePosOffset = (selectionType == SelectionType.Block ? Vector3.zero : selectionFaceNormalA * 0.0125f); FormWiredCube(manipulationVisualPos + uiSelectionFramePosOffset, manipulationVisualScale, uiManipulationFramePiecesInnerSolid, -0.025f); FormWiredCube(manipulationVisualPos + uiSelectionFramePosOffset, manipulationVisualScale, uiManipulationFramePiecesInnerTransparent, -0.025f); //Debug.DrawRay(manipulationVisualPositionStart, Vector3.one * 0.25f, Color.magenta); Debug.DrawLine(manipulationVisualPositionStart, manipulationVisualPositionEnd, Color.magenta); }
private void Awake() { registerTile = GetComponent <RegisterTile>(); directional = GetComponent <Directional>(); }
private Directional(Directional other) : base(other) { }
public DirectionalPair(Directional first, Directional second) { this.first = first; this.second = second; }
public void tapDirectional(Directional directional, int milliseconds = 30, int variance = 5) { holdDirectional(directional); System.Threading.Thread.Sleep(getTapLength(milliseconds, variance)); releaseDirectional(); }
protected override void Awake() { base.Awake(); directional = GetComponent <Directional>(); }
public ControllerSelect(MenuWorld parent, int playerSlot, int joyId) { var font = Library.GetFont("fonts/Laffayette_Comic_Pro.ttf"); changing = false; this.parent = parent; Height = FP.Height - 20; Width = 250; this.JoyId = joyId; this.PlayerSlot = playerSlot; Image = new Image(Library.GetTexture("menu.png")); Image.Color = new Color(Color = colors[PlayerSlot]); pressStart = new Text("PRESS START"); pressStart.Font = font; pressStart.X -= 80; pressStart.Y = Height - 100; pressStart.Size = 20; pressStart.Color = new Color(0); check = new Image(Library.GetTexture("ready.png")); check.CenterOO(); check.Y = Height * 0.75f; check.ScaleY = 0; OriginX = Width / 2; Image.OriginX = Image.Width / 2; var slot = GamepadManager.GetSlot(joyId); if (SnesController.IsMatch(slot)) { var snes = new SnesController(slot); confirm = new Image(Library.GetTexture("Snes_1.png")); Cursor = snes.Dpad; Start = snes.Start; Back = snes.A; Confirm = snes.B; } else if (Xbox360Controller.IsMatch(slot)) { var xbox = new Xbox360Controller(slot); confirm = new Image(Library.GetTexture("Xbox_1.png")); Cursor = xbox.LeftStick; Start = xbox.Start; Confirm = xbox.A; Back = xbox.B; } else { throw new Exception("Invalid gamepad type, sorry D:"); } AddComponent(Image); AddComponent(pressStart); if (wins.ContainsKey(JoyId)) { var score = new Text(wins[joyId].ToString("Wins: 0")); score.Font = font; score.Color = new Color(0); score.Size = 20; score.X = pressStart.X + 32; score.Y = pressStart.Y + score.Size; AddComponent(score); } }
public virtual void Awake() { registerTile = GetComponent <RegisterTile>(); directional = GetComponent <Directional>(); }
List <Path> Walk(int fromIndex, Directional directional, Path path) { debugLevel++; int row = fromIndex / Settings.FieldWidth; int col = fromIndex - row * Settings.FieldWidth; switch (directional) { case Directional.Down: DebugPath("Down", debugLevel); row++; if (row == Settings.FieldHeight) { debugLevel--; return(null); } break; case Directional.Left: DebugPath("Left", debugLevel); col--; if (col == -1) { debugLevel--; return(null); } break; case Directional.Right: DebugPath("Right", debugLevel); col++; if (col == Settings.FieldWidth) { debugLevel--; return(null); } break; case Directional.Up: DebugPath("Up", debugLevel); row--; if (row == -1) { debugLevel--; return(null); } break; } int index = col + Settings.FieldWidth * row; if (path.Contains(index)) { DebugPath("-Double", debugLevel); debugLevel--; return(null); } List <Path> temp = new List <Path>(); if (SecondSelect != -1 && SecondSelect == index) { DebugPath("-Find OK", debugLevel); path.Add(index); if (path.NumAngle <= 2) { temp.Add(path); debugLevel--; return(temp); } } else if (SecondSelect == -1 && Settings.Grid[FirstSelect] == Settings.Grid[index]) { path.Add(index); if (path.NumAngle <= 2) { SecondSelect = index; temp.Add(path); debugLevel--; return(temp); } } if (Settings.Grid[index] == -1) { path.Add(index); if (path.NumAngle > 2) { //Debug.WriteLine("--- Angle > 2 break"); DebugPath("- Angle > 2", debugLevel); debugLevel--; return(null); } List <Path> tempList = Walk(index, Directional.Down, path.Copy()); if (tempList != null) { foreach (var item in tempList) { temp.Add(item); } //для увеличения скорости, найдем первый путь и все if (temp.Count > 0) { return(temp); } //debugLevel--; //return temp; } tempList = Walk(index, Directional.Left, path.Copy()); if (tempList != null) { foreach (var item in tempList) { temp.Add(item); } if (temp.Count > 0) { return(temp); } //debugLevel--; //return temp; } tempList = Walk(index, Directional.Right, path.Copy()); if (tempList != null) { foreach (var item in tempList) { temp.Add(item); } if (temp.Count > 0) { return(temp); } //debugLevel--; //return temp; } tempList = Walk(index, Directional.Up, path.Copy()); if (tempList != null) { foreach (var item in tempList) { temp.Add(item); } if (temp.Count > 0) { return(temp); } //debugLevel--; //return temp; } debugLevel--; return(temp); } //Debug.WriteLine("NO PATH"); debugLevel--; return(null); }
private void Awake() { directional = GetComponent <Directional>(); }
public void holdDirectional(Directional directional) { vjoy.SetDiscPov((int)directional, vjoyID, dpadID); }