public static bool IsIgnoring(Collider.Collider c1, Collider.Collider c2) { ReactType reaction1 = c1.GetReaction(c2.GetCollisionChanell()); ReactType reaction2 = c2.GetReaction(c1.GetCollisionChanell()); return(reaction1 == ReactType.Ignore || reaction2 == ReactType.Ignore); }
void IPostBusinessLogic.PatchReact(PostPatchReactDto postPatchReact) { PostReact postReact = postReactRepository.GetByFilter( pr => pr.UserId == postPatchReact.CreatorId && pr.PostId == postPatchReact.Id); ReactType type = (ReactType)System.Enum.Parse(typeof(ReactType), postPatchReact.Type); int deltaUpvotes = 0, deltaDownvotes = 0; if (postReact == null) { postReact = new PostReact { PostId = postPatchReact.Id, UserId = postPatchReact.CreatorId, Type = type }; postReactRepository.Insert(postReact); postReactRepository.SaveChanges(); ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, ReactType.None); } else { if (type == ReactType.None) { ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, postReact.Type); postReactRepository.Delete(postReact.Id); postReactRepository.SaveChanges(); } else if (type != postReact.Type) { ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, postReact.Type); postReact.Type = type; postReactRepository.Update(postReact); postReactRepository.SaveChanges(); } } if (deltaUpvotes != 0 || deltaDownvotes != 0) { Post post = postRepository.GetById(postPatchReact.Id); post.Upvotes += deltaUpvotes; post.Downvotes += deltaDownvotes; postRepository.Update(post); postRepository.SaveChanges(); } }
void ICommentBusinessLogic.PatchReact(CommentPatchReactDto commentPatchReact) { CommentReact commentReact = commentReactRepository.GetByFilter( cr => cr.UserId == commentPatchReact.CreatorId && cr.CommentId == commentPatchReact.Id); ReactType type = (ReactType)Enum.Parse(typeof(ReactType), commentPatchReact.Type); int deltaUpvotes = 0, deltaDownvotes = 0; if (commentReact == null) { commentReact = new CommentReact { CommentId = commentPatchReact.Id, UserId = commentPatchReact.CreatorId, Type = type }; commentReactRepository.Insert(commentReact); commentRepository.SaveChanges(); ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, ReactType.None); } else { if (type == ReactType.None) { ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, commentReact.Type); commentReactRepository.Delete(commentReact.Id); commentReactRepository.SaveChanges(); } else if (type != commentReact.Type) { ReactsUtils.UpdateDeltas(ref deltaUpvotes, ref deltaDownvotes, type, commentReact.Type); commentReact.Type = type; commentReactRepository.Update(commentReact); commentReactRepository.SaveChanges(); } } if (deltaUpvotes != 0 || deltaDownvotes != 0) { Comment comment = commentRepository.GetById(commentPatchReact.Id); comment.Upvotes += deltaUpvotes; comment.Downvotes += deltaDownvotes; commentRepository.Update(comment); commentRepository.SaveChanges(); } }
private int parseDynamicReaction(ReactType type) { switch (type) { case ReactType.Gravity: return(1); case ReactType.Flux: return(2); case ReactType.Positive: return(3); case ReactType.Negative: return(4); default: return(0); } }
public void setReaction(int type) { switch (type) { case 0: reaction = ReactType.Gravity; break; case 1: reaction = ReactType.Negative; break; case 2: reaction = ReactType.Positive; break; case 3: reaction = ReactType.Flux; break; } }
public static void UpdateDeltas(ref int deltaUpvotes, ref int deltaDownvotes, ReactType type, ReactType oldReactType) { switch (type) { case ReactType.Like: ++deltaUpvotes; if (oldReactType == ReactType.Dislike) { --deltaDownvotes; } break; case ReactType.Dislike: ++deltaDownvotes; if (oldReactType == ReactType.Like) { --deltaUpvotes; } break; case ReactType.None: if (oldReactType == ReactType.Like) { --deltaUpvotes; } else if (oldReactType == ReactType.Dislike) { --deltaDownvotes; } break; } }
public void SetReaction(CollisionChanell channel, ReactType reaction) { this.reaction[channel] = reaction; }
// Update is called once per frame void FixedUpdate() { try { mActiveForces = FindObjectOfType <Beam>().GetComponent <Beam>().GetActiveForces(); } catch (System.Exception) { mActiveForces = new List <GameObject>(); Debug.Log("There is no beam!"); } reactType = GetComponent <DynamicProperties>().reaction; currentX = transform.position.x; currentY = transform.position.y; foreach (GameObject i in mActiveForces) { try { switch (i.GetComponent <Properties>().type) { case ForceType.Graviton: gravDistanceX.Add((float)i.transform.position.x); gravDistanceY.Add((float)i.transform.position.y); break; case ForceType.Electron: elecDistanceX.Add((float)i.transform.position.x); elecDistanceY.Add((float)i.transform.position.y); break; case ForceType.Fluxion: fluxDistanceX.Add((float)i.transform.position.x); fluxDistanceY.Add((float)i.transform.position.y); break; default: break; } } catch (System.Exception) { } } elecForce = Electrostatic(elecDistanceX, elecDistanceY, reactType == ReactType.Positive || reactType == ReactType.Negative); fluxForce = Flux(fluxDistanceX, fluxDistanceY, reactType == ReactType.Flux); gravForce = Gravity(gravDistanceX, gravDistanceY, reactType == ReactType.Gravity); resultant = gravForce + elecForce + fluxForce; rb.AddForce(resultant, ForceMode2D.Impulse); gravDistanceX.Clear(); gravDistanceY.Clear(); elecDistanceX.Clear(); elecDistanceY.Clear(); fluxDistanceX.Clear(); fluxDistanceY.Clear(); }
public void click(bool hasSize) { if (hasSize) //only scaleing objects like walls, goals and mirrors { Instantiate(element, new Vector3(0, 0, 0), Quaternion.identity); close.GetComponent <ClosePannel>().Close(); } else //only point objects like forces { if (element.tag == "Wormhole") { close.GetComponent <ClosePannel>().Close(); int id = findFirstID(); if (id != -1) { for (int i = 0; i < 2; i++) { //spawns two connected wormholes Transform temp; mousePos = ConvertToWorldUnits(Input.mousePosition); //finds mouse position temp = Instantiate(element, mousePos, rotation); //creates the wormholes temp.GetComponent <Wormhole>().id = id; //sets their ids if (i == 1) { temp.GetComponent <DragAndDrop>().OnMouseDown(); //initiates dragging via DragAndDrop Script } } setAvailableID(id, false); } } else if (element.tag == "Beam") { } else if (element.tag == "DynamicForce") { validCombo = true; ForceType production = GameObject.Find("Dynamic Force Panel").GetComponentInChildren <DynamicProperties>().production; ReactType reaction = GameObject.Find("Dynamic Force Panel").GetComponentInChildren <DynamicProperties>().reaction; //Checks to see if the production and reaction of the dynamic force are the same, which isn't a valid game state. switch (production) { case ForceType.Graviton: if (reaction == ReactType.Gravity) { validCombo = false; } break; case ForceType.Electron: if (reaction == ReactType.Positive || reaction == ReactType.Negative) { validCombo = false; } break; case ForceType.Fluxion: if (reaction == ReactType.Flux) { validCombo = false; } break; default: Debug.Log("Unknown ForceType!"); validCombo = false; break; } if (validCombo) { close.GetComponent <ClosePannel>().Close(); Transform temp; mousePos = ConvertToWorldUnits(Input.mousePosition); //finds mouse position temp = Instantiate(element, mousePos, rotation); //creates the force temp.GetComponent <DynamicProperties>().production = production; temp.GetComponent <DynamicProperties>().reaction = reaction; } } else { close.GetComponent <ClosePannel>().Close(); Transform temp; mousePos = ConvertToWorldUnits(Input.mousePosition); //finds mouse position temp = Instantiate(element, mousePos, rotation); //creates the force temp.GetComponent <Properties> ().setType(type); //sets its type temp.GetComponent <DragAndDrop> ().OnMouseDown(); //initiates dragging via DragAndDrop Script } } }