public void PickUpHit(Transform racer, Transform other) { if(other.gameObject.tag == "PickUp") { player = racer.GetComponent<PlayerPickUp>(); thePickUp = other.GetComponent<PickUp>(); thePickUp.UseRefresh(); if(player.PickUpQueue.Length < 1) { switch(thePickUp.MyType) { case "Turbo": player.PickUpQueue = new string[1]; player.PickUpQueue[0] = "Turbo"; break; case "Forcefield": player.PickUpQueue = new string[1]; player.PickUpQueue[0] = "Forcefield"; break; default: break; } } } }
void CheckForPickUp() { Collider[] pickUpColliders = Physics.OverlapSphere(transform.position, m_InteractionRange, m_LayersToCollideWith.value); float minDistance = m_InteractionRange; PickUp inRangePickUp = null; foreach(Collider pickUpCollider in pickUpColliders) { float distance = Vector3.Distance (pickUpCollider.transform.position, transform.position); if(pickUpCollider.gameObject != gameObject && distance < minDistance) { minDistance = distance; inRangePickUp = pickUpCollider.GetComponent<PickUp>(); } } if(m_InRangePickUp && inRangePickUp != m_InRangePickUp) { m_InRangePickUp.Collect (null); } m_InRangePickUp = inRangePickUp; }
void Start() { g = GameObject.Find("Player"); HealthScript = g.GetComponent<PlayerHealth>(); PickUpScript = g.GetComponent<PickUp> (); healthText.text = "Health: " + health.ToString (); hungerText.text = "Hunger: " + hunger.ToString (); }
public void Add(PickUp pickup) { PickUp.PickUpType type = pickup.type; int oldTotal = 0; if(items.TryGetValue(type, out oldTotal)) items[type] = oldTotal + 1; else items.Add (type, 1); playerInventoryDisplay.OnChangeInventory(items); }
//-------------------- // add given 'pickup' objects to our Dictionary public void Add(PickUp pickup) { // get the type of this pickup object PickUp.PickUpType type = pickup.type; // init total to zerpo int oldTotal = 0; // IF we can find this type in the Dictionary // then set 'oldTotal' to the associated value if(items.TryGetValue(type, out oldTotal)) // add 1 to existing total (since we just picked one up) items[type] = oldTotal + 1; else // if we could not find the type key in the Dictionary // then add new item, with total 1 (since we just picked one up) items.Add (type, 1); // tell the display object to update the UI display with the new totals in 'items' Dictionary playerInventoryDisplay.OnChangeInventory(items); }
static void Main(string[] args) { Vehicles[] aVehicles = new Vehicles[6]; aVehicles[0] = new Compact(); aVehicles[1] = new DoubleBogey(); aVehicles[2] = new FreightTrain(); aVehicles[3] = new PassengerTrain(); aVehicles[4] = new PickUp(); aVehicles[5] = new SUV(); foreach (Vehicles vehicles in aVehicles) { try { IPassengerCarrier tmp = (IPassengerCarrier) vehicles; AddPassenger(tmp); } catch (Exception) { Console.WriteLine("Объект не наследует интерфейс IPassengerCarrier {0}",vehicles.ToString()); } } Console.ReadKey(); }
public void RegisterPickUp(PickUp pickUp) { outstandingPickUps.Add(pickUp); }
private void OnOxygenUseOut() { UIManager.ShowPanel <GameOverPanel>(); PickUp.OnOxygenUseOut(); IsGameOver = true; }
private void btnCrear_Click(object sender, EventArgs e) { PickUp pickUp = new PickUp(txtPatente.Text, txtModelo.Text); MessageBox.Show(pickUp.ConsultarDatos()); }
private void btnCrear_Click(object sender, EventArgs e) { PickUp pickup = new PickUp(txtPatente.Text, txtModelo.Text); MessageBox.Show(pickup.ConsultarDatos(), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); }
void Start() { drop = GameObject.Find("Player").GetComponent <PickUp>(); startPos = transform.position; startScale = transform.localScale; }
private void RegisterStates() { mStateMachin = new StateMachin(); mStateMachin.RegisterState(MousToken.Pickup, new MousState[] { MousState.Normal }, MousState.PickedUp, delegate { PickUp?.Invoke(); mTarget.SetTocken(BugToken.PickUp); }); mStateMachin.RegisterState(MousToken.Drop, new MousState[] { MousState.PickedUp }, MousState.Normal, delegate { Drop?.Invoke(); mTarget.SetTocken(BugToken.Drop); }); mStateMachin.RegisterState(MousToken.DeletBug, new MousState[] { MousState.PickedUp }, MousState.Normal, delegate { mTarget = null; }); mStateMachin.RegisterState(MousToken.EnterInfo, new MousState[] { MousState.PickedUp }, MousState.OverInfo, null); mStateMachin.RegisterState(MousToken.ExitInfo, new MousState[] { MousState.OverInfo }, MousState.PickedUp, null); mStateMachin.RegisterState(MousToken.InfoClick, new MousState[] { MousState.OverInfo }, MousState.Scaning, delegate { OpenScan?.Invoke(); mTarget.SetTocken(BugToken.OpenScan); }); mStateMachin.RegisterState(MousToken.InfoClick, new MousState[] { MousState.Scaning }, MousState.PickedUp, delegate { CloseScan?.Invoke(); mTarget.SetTocken(BugToken.CloseScan); }); }
public bool collidesWithPickup(Vector3 moverRadius, Vector3 basePoint, Vector3 velocity, PickUp collidable) { /* we cast a ray from the center of collider to the center of * collidable. if the collision time is closer (or sufficiently close) * for collidable then we're colliding */ BoundingBox otherbb = ((ICollidable)collidable).getBoundingBox(); Vector3 otherRadius = (otherbb.Max - otherbb.Min) * 0.5f, otherPos = otherbb.Min + otherRadius; //now convert everything otherESpace so that we can cast using BoundingSpheres Vector3 basePointInOtherESpace = toESpace(otherRadius, toWorldSpace(moverRadius, basePoint)), otherPointInOtherESPace = toESpace(otherRadius, otherPos); Ray r = new Ray(basePointInOtherESpace, Vector3.Normalize(otherPointInOtherESPace - basePointInOtherESpace)); Nullable <float> dist = r.Intersects(new BoundingSphere(otherPointInOtherESPace, 1)); if (dist != null) //i don't even know what dist == null means in this context //find the collisionPoint in otherESpace { Vector3 colPoint = r.Position + dist.Value * r.Direction; //convert it back to normal eSpace (of basePoint) colPoint = toESpace(moverRadius, toWorldSpace(otherRadius, colPoint)); float colDist = Vector3.Distance(colPoint, basePoint); //if the distance is < 1 + epsilon (the radius of the collider in eSpace) then we've collided if (colDist < 1 + 0.5) { float t = colDist / (float)Math.Sqrt(Vector3.Dot(velocity, velocity)); return(true); } } return(false); }
void Awake() { pickup = GetComponent <PickUp>(); }
private void OnBeerBarrelPickedUp(PickUp _, PlayerComponent __) => OnTutorialEvent(TutorialEvent.BeerBarrelPickedUp);
public override void fireProjectile() { int repeats = ModdedPlayer.RangedRepetitions(); for (int i = 0; i < repeats; i++) { bool noconsume = false; if (ModdedPlayer.instance.ReusabilityChance >= 0 && Random.value < ModdedPlayer.instance.ReusabilityChance) { noconsume = true; } if (noconsume || LocalPlayer.Inventory.RemoveItem(_ammoItemId, 1, false, true)) { Vector3 position = _ammoSpawnPos.transform.position; if (i > 0) { position += 0.5f * _ammoSpawnPos.transform.up * (i + 1) / 3; position += 0.5f * _ammoSpawnPos.transform.right * (((i - 1) % 3) - 1); } Quaternion rotation = _ammoSpawnPos.transform.rotation; if (ForestVR.Enabled) { position = _ammoSpawnPosVR.transform.position; rotation = _ammoSpawnPosVR.transform.rotation; } GameObject gameObject = Object.Instantiate(_Ammo, position, rotation); gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio; Rigidbody component = gameObject.GetComponent <Rigidbody>(); rockSound component2 = gameObject.GetComponent <rockSound>(); if ((bool)component2) { component2.slingShot = true; } if (BoltNetwork.isRunning) { BoltEntity component3 = gameObject.GetComponent <BoltEntity>(); if ((bool)component3) { BoltNetwork.Attach(gameObject); } } PickUp componentInChildren = gameObject.GetComponentInChildren <PickUp>(); if ((bool)componentInChildren) { SheenBillboard[] componentsInChildren = gameObject.GetComponentsInChildren <SheenBillboard>(); SheenBillboard[] array = componentsInChildren; foreach (SheenBillboard sheenBillboard in array) { sheenBillboard.gameObject.SetActive(false); } componentInChildren.gameObject.SetActive(false); if (base.gameObject.activeInHierarchy) { base.StartCoroutine(enablePickupTrigger(componentInChildren.gameObject)); } } Vector3 forward = _ammoSpawnPos.transform.forward; if (ForestVR.Enabled) { forward = _ammoSpawnPosVR.transform.forward; } component.AddForce(4000f * ModdedPlayer.instance.ProjectileSpeedRatio * (0.016666f / Time.fixedDeltaTime) * forward); } } }
// raycast which can overlap "soft" walls private bool SoftRayCast2D(Vector2 Start, Vector2 End, out List <RaycastHit2D> OutHit) { // seting up some variables OutHit = new List <RaycastHit2D>(); RaycastHit2D LocalRayHit; Vector2 StartPos = Start; // we break only if.. while (true) { LocalRayHit = Physics2D.Raycast(StartPos, End - StartPos, (End - StartPos).magnitude); // raycast reach finale destination if (!LocalRayHit) { return(false); } // ofcourse every hit must be in result OutHit.Add(LocalRayHit); if (LocalRayHit.transform.tag == "Bonus") { PickUp MyPU = LocalRayHit.transform.GetComponent <PickUp>(); if (MyPU != null) { MyPU.PickUpMe(gameObject); } } if (TPDamage > 0) { if (LocalRayHit.transform.tag == "Enemy") { EnemyHealth MyEH = LocalRayHit.transform.GetComponent <EnemyHealth>(); if (MyEH != null) { MyEH.TPDamage(TPDamage); } } } // or we hit not soft wall bool findLayer = false; if (TPDamage > 0 && LocalRayHit.transform.gameObject.layer == 14) { findLayer = true; } else if (WalkThroughLayers == (WalkThroughLayers | (1 << LocalRayHit.transform.gameObject.layer))) { findLayer = true; } if (!findLayer) { return(true); } // relocate start pos so next ray start incide soft wall StartPos = LocalRayHit.point + (End - Start).normalized * 0.15f; // and in the end check for some bugs (what if something will go wrong) if (OutHit.Count > 30) { print("Too much Hits!!!"); return(false); } } }
//Method to assign a child the correct item public void AssignItem(PickUp item) { correctItem = item.name; AssignTextBox(); }
private void button1_Click(object sender, EventArgs e) { PickUp pickup = new PickUp(textBox1.Text, textBox2.Text); MessageBox.Show(pickup.ConsultarDatos()); }
PickUpData CopyPickUpData(PickUp pickup){ PickUpData pu; pu.Type = pickup.Type; pu.Name = pickup.Name; return pu; }
private PickUp SpawnPickup(Level level, int index) { PickUp pickUp = new PickUp(ItemLibrary.Get().generics[index], 1); //rng.Next(1,3)); bool found = false; //enemy position while (!found) { int a = rng.Next(0, (level.structure.GetLength(0))); int b = rng.Next(0, (level.structure.GetLength(1))); if (level.structure[a, b].substance == ClipType.FLOOR) { for (int i = 0; i < level.doors.Count; i++) { if (level.doors[i].position.x == a && level.doors[i].position.y == b) { found = false; break; } } if (level.pickUps.Count > 0) { for (int i = 0; i < level.pickUps.Count; i++) { if (!(level.pickUps[i].position.x == a && level.pickUps[i].position.y == b)) { found = true; } else { found = false; break; } } } else { found = true; } if (found) { pickUp.position = new Vector2(a, b); } } } return pickUp; }
private void OnInstrumentPickedUp(PickUp _, PlayerComponent playerComponent) => OnTutorialEvent(TutorialEvent.InstrumentPickedUp);
// Start is called before the first frame update void Start() { pickUp = GameObject.FindObjectOfType <PickUp>(); }
private void OnInstrumentDropped(PickUp _, PlayerComponent __) => OnTutorialEvent(TutorialEvent.InstrumentDropped);
static void Main(string[] args) { Console.Title = "Primer Parcial"; Estacionamiento e = new Estacionamiento("UTN", 6); // Creación de Vehículos Console.WriteLine("MOTOS"); Vehiculo m1 = new Moto("ASD123", 75, 4); Console.WriteLine(m1.ConsultarDatos()); Moto m2 = new Moto("ASDaa123", 175); Console.WriteLine(m2.ConsultarDatos()); Moto m3 = new Moto("QWE312", 175, 4, 35); Console.WriteLine(m3.ConsultarDatos()); Console.WriteLine(""); Console.WriteLine("PICKUPS"); PickUp p1 = new PickUp("TYR753", "78", 51); Console.WriteLine(p1.ConsultarDatos()); PickUp p2 = new PickUp("TYR753", "Model A"); Console.WriteLine(p2.ConsultarDatos()); Console.WriteLine(""); Console.WriteLine("AUTOMOVILES"); Automovil a1 = new Automovil("POI952", ConsoleColor.Red); Console.WriteLine(a1.ConsultarDatos()); Automovil a2 = new Automovil("MNB651", ConsoleColor.DarkCyan, 23); Console.WriteLine(a2.ConsultarDatos()); Console.WriteLine("--------------------------------"); Console.WriteLine("--------------------------------"); Console.WriteLine("Estacionamiento Ingreso"); e += m1; e += p1; e += a1; e += m1; e += p1; e += a1; e += m2; e += p2; e += a2; e += m3; Console.WriteLine((string)e); Console.WriteLine("--------------------------------"); Console.WriteLine("--------------------------------"); Console.WriteLine("Estacionamiento Egreso"); Console.WriteLine(e - m1); Console.WriteLine(e - p1); Console.WriteLine(e - a1); Console.WriteLine(e - m2); Console.WriteLine(e - p2); Console.WriteLine(e - a2); Console.WriteLine(e - m3); Console.WriteLine("--------------------------------"); Console.WriteLine((string)e); Console.ReadKey(); }
private void OnWeaponPickedUp(PickUp _, PlayerComponent playerComponent) => OnTutorialEvent(TutorialEvent.WeaponPickedUp);
public CollisionPackage collides(Vector3 moverRadius, Vector3 basePoint, Vector3 velocity, ICollidable collider) { float closestCollisionTime = 1; Vector3 closestCollisionPoint = Vector3.Zero; //make colliderBoundingBox a bounding volume over the movement BoundingBox colliderBoundingBox = collider.getBoundingBox(); Vector3 worldVel = toWorldSpace(moverRadius, velocity); if (worldVel.X < 0) { colliderBoundingBox.Min.X += worldVel.X; } else if (worldVel.X > 0) { colliderBoundingBox.Max.X += worldVel.X; } if (worldVel.Y < 0) { colliderBoundingBox.Min.Y += worldVel.Y; } else if (worldVel.Y > 0) { colliderBoundingBox.Max.Y += worldVel.Y; } if (worldVel.Z < 0) { colliderBoundingBox.Min.Z += worldVel.Z; } else if (worldVel.Z > 0) { colliderBoundingBox.Max.Z += worldVel.Z; } List <PickUp> pickedUp = new List <PickUp>(); List <Vector3> eSpaceVerts = new List <Vector3>(); bool convertedVerts = false; foreach (ICollidable collidable in getCollidablesToCheck(collider, toWorldSpace(moverRadius, velocity))) { if (collidable is Agent) { continue; } BoundingBox collidableBoundingBox = collidable.getBoundingBox(); collidableBoundingBox.Min -= boundingBoxPadding; collidableBoundingBox.Max += boundingBoxPadding; if (!collidableBoundingBox.Intersects(colliderBoundingBox) || collidable == collider) { continue; } if (collidable is Brush) { Brush brush = (Brush)collidable; bool faceCollide = false; foreach (Face face in brush.faces) { if (faceCollide) { break; } convertedVerts = false; //find the normal of the face's plane in eSpace Microsoft.Xna.Framework.Plane helperPlane = new Microsoft.Xna.Framework.Plane(toESpace(moverRadius, face.plane.first), toESpace(moverRadius, face.plane.second), toESpace(moverRadius, face.plane.third)); helperPlane.Normal = -helperPlane.Normal; Vector3 N = helperPlane.Normal; N.Normalize(); float D = -helperPlane.D; if (Vector3.Dot(N, Vector3.Normalize(velocity)) >= -0.005) { continue; } float t0, t1; bool embeddedInPlane = false; if (Vector3.Dot(N, velocity) != 0) { t0 = (-1 - signedDistance(N, basePoint, D)) / Vector3.Dot(N, velocity); t1 = (1 - signedDistance(N, basePoint, D)) / Vector3.Dot(N, velocity); //swap them so that t0 is smallest if (t0 > t1) { float temp = t1; t1 = t0; t0 = temp; } if (t0 < 0 && t1 > 1) { face.DiffuseColor = new Vector3(0, 1, 0); } if (t0 > 1 || t1 < 0) { continue; } } else if (Math.Abs(signedDistance(N, basePoint, D)) < 1) { t0 = 0; t1 = 1; embeddedInPlane = true; } else //in this case we can't collide with this face { continue; } if (!embeddedInPlane) { //now we find the plane intersection point //Vector3 planeIntersectionPoint = basePoint - N + t0 * velocity; Vector3 planeIntersectionPoint = basePoint - N + t0 * velocity; //project this onto the plane //clamp [t0, t1] to [0,1] if (t0 < 0) { t0 = 0; } if (t1 < 0) { t1 = 0; } if (t0 > 1) { t0 = 1; } if (t1 > 1) { t1 = 1; } //now we find if this point lies on the face eSpaceVerts.Clear(); foreach (Vertex vert in face.vertices) { eSpaceVerts.Add(toESpace(moverRadius, vert.position)); } convertedVerts = true; if (MapEngine.pointOnFace(planeIntersectionPoint, eSpaceVerts, N)) { //float intersectionDistance = t0 * (float)Math.Sqrt(Vector3.Dot(velocity, velocity)); if (face.DiffuseColor == new Vector3(1, 1, 1)) { face.DiffuseColor = new Vector3(1, 0, 0); } if (t0 < closestCollisionTime) { closestCollisionTime = t0; closestCollisionPoint = planeIntersectionPoint; faceCollide = true; continue; } } } if (!convertedVerts) { eSpaceVerts.Clear(); foreach (Vertex vert in face.vertices) { eSpaceVerts.Add(toESpace(moverRadius, vert.position)); } convertedVerts = true; } //do sweep tests //sweep against the vertices foreach (Vector3 p in eSpaceVerts) { //calculate A, B and C that make up our quadratic equation // At^2 + Bt + C = 0 float A = Vector3.Dot(velocity, velocity), B = 2 * Vector3.Dot(velocity, basePoint - p), C = Vector3.Dot(p - basePoint, p - basePoint) - 1; //check that the equation has a solution float discriminant = B * B - 4 * A * C; //in this case we have a solution to the equation if (discriminant >= 0) { float r1 = (-B + (float)Math.Sqrt(discriminant)) / (2 * A), r2 = (-B - (float)Math.Sqrt(discriminant)) / (2 * A); /*float x1 = Math.Min(r1, r2), x2 = Math.Max(r1, r2); * if (x1 < 0) * x1 = x2;*/ if (r1 > r2) { float temp = r2; r2 = r1; r1 = temp; } float root = -1; if (r1 > 0 && r1 < closestCollisionTime) { root = r1; } else if (r2 > 0 && r2 < closestCollisionTime) { root = r2; } /* intersectionPoint = p; * intersectionDistance = x1 * (float)Math.Sqrt(Vector3.Dot( velocity, velocity )); */ if (root != -1) { closestCollisionTime = root; closestCollisionPoint = p; faceCollide = true; } } } //sweep against the edges for (int i = 0; i < eSpaceVerts.Count; i++) { //calculate A, B and C that make up our quadratic equation // At^2 + Bt + C = 0 Vector3 p1 = eSpaceVerts[i], p2 = eSpaceVerts[(i + 1) % eSpaceVerts.Count]; Vector3 edge = p2 - p1; Vector3 baseToVertex = p1 - basePoint; float A = Vector3.Dot(edge, edge) * (-Vector3.Dot(velocity, velocity)) + (float)Math.Pow(Vector3.Dot(edge, velocity), 2), B = Vector3.Dot(edge, edge) * 2 * Vector3.Dot(velocity, baseToVertex) - 2 * (Vector3.Dot(edge, velocity) * Vector3.Dot(edge, baseToVertex)), C = Vector3.Dot(edge, edge) * (1 - Vector3.Dot(baseToVertex, baseToVertex)) + (float)Math.Pow(Vector3.Dot(edge, baseToVertex), 2); //check that the equation has a solution float discriminant = B * B - 4 * A * C; //in this case we have a solution to the equation if (discriminant >= 0) { float r1 = (-B + (float)Math.Sqrt(discriminant)) / (2 * A), r2 = (-B - (float)Math.Sqrt(discriminant)) / (2 * A); if (r1 > r2) { float temp = r2; r2 = r1; r1 = temp; } float root = -1; if (r1 > 0 && r1 < closestCollisionTime) { root = r1; } else if (r2 > 0 && r2 < closestCollisionTime) { root = r2; } if (root != -1) { float f0 = (Vector3.Dot(edge, velocity) * root - Vector3.Dot(edge, baseToVertex)) / (Vector3.Dot(edge, edge)); //NEED TO DO SOMETHING HERE-------------------------------------------------------------------------- /* intersectionPoint = p1 + f0 * edge; * intersectionDistance = x1 * (float)Math.Sqrt(Vector3.Dot( velocity, velocity )); */ if (0 <= f0 && f0 <= 1) { closestCollisionTime = root; closestCollisionPoint = p1 + f0 * edge; faceCollide = true; } } } } } } // if brush else if (collider is Agent && collidable is PickUp) //otherwise we need to boundingEllipsoid collisions { PickUp p = (PickUp)collidable; if (collidesWithPickup(moverRadius, basePoint, velocity, p)) { pickedUp.Add(p); } } // if pickup } foreach (PickUp p in pickedUp) { p.pickupGen.removePickUp(); p.affect((Agent)collider); } return(new CollisionPackage(basePoint, velocity, closestCollisionTime < 1, closestCollisionPoint, closestCollisionTime * (float)Math.Sqrt(Vector3.Dot(velocity, velocity)))); }
private void OnToolPickedUp(PickUp _, PlayerComponent playerComponent) => OnTutorialEvent(TutorialEvent.RepairToolPickedUp);
public override void GetReferenceObject(Interactable interactable) { base.GetReferenceObject(interactable); pickUp = interactable.gameObject.GetComponent <PickUp>(); }
private void OnFoodPickedUp(PickUp _, PlayerComponent __) => OnTutorialEvent(TutorialEvent.FoodPickedUp);
public static void DoPickup() { if (LocalPlayer.FpCharacter.PushingSled) { return; } int minRarity = 7; for (int i = -2; i > -14; i--) { if (Player.Inventory.Instance.ItemSlots[i] == null) { minRarity = 0; break; } else { if (Player.Inventory.Instance.ItemSlots[i].Rarity < minRarity) { minRarity = Player.Inventory.Instance.ItemSlots[i].Rarity; } } } RaycastHit[] hit = Physics.SphereCastAll(LocalPlayer.Transform.position, radius, Vector3.one, radius + 1); for (int i = 0; i < hit.Length; i++) { PickUp pu = hit[i].transform.GetComponent <PickUp>(); if (pu != null) { Debug.Log("Found pickup in original object"); } if (pu == null) { pu = hit[i].transform.GetComponentInParent <PickUp>(); if (pu != null) { Debug.Log("Found pickup in parent"); } } if (pu == null) { pu = hit[i].transform.GetComponentInChildren <PickUp>(); if (pu != null) { Debug.Log("Found pickup in child"); } } if (pu != null) { if (pu._itemId == 57 || pu._itemId == 54 || pu._itemId == 53 || pu._itemId == 42 || pu._itemId == 37 || pu._itemId == 36 || pu._itemId == 33 || pu._itemId == 31 || pu._itemId == 83 || pu._itemId == 91 || pu._itemId == 99 || pu._itemId == 67 || pu._itemId == 89 || pu._itemId == 280 || pu._itemId == 41 || pu._itemId == 56 || pu._itemId == 49 || pu._itemId == 43 || pu._itemId == 262 || pu._itemId == 83 || pu._itemId == 94 || pu._itemId == 99 || pu._itemId == 98 || pu._itemId == 97 || pu._itemId == 178 || pu._itemId == 177 || pu._itemId == 109 || pu._itemId == 307 || pu._itemId == 181 || pu._itemId == 82) { if (LocalPlayer.Inventory.AddItem(pu._itemId, pu._amount, true, false, pu._properties)) { GameObject.Destroy(pu._destroyTarget); } } } else { var customPickup = hit[i].transform.gameObject.GetComponent <ItemPickUp>(); if (customPickup != null) { if (customPickup.item.Rarity >= minRarity) { customPickup.PickUp(); } } } } }
private PickUp SpawnPickup(Vector2 pos, int i) { Random rng = new Random(); PickUp pickUp = new PickUp(ItemLibrary.Get().generics[i], 1); //rng.Next(1,3)); pickUp.position = pos; return pickUp; }
public void ClearSlot() { imagePlayerWithItem.sprite = null; pickUp = null; isFull = false; }
//Add item to list public void AddItem(PickUp item) { inventory.Add(item); }
public void CollectPickUp(PickUp pickUp) { outstandingPickUps.Remove(pickUp); pickUpsCollected++; General.Instance.OnPickUpCollected(); }
//To combine items void CombineItems(PickUp obj1, PickUp obj2, PickUp newObj) { RemoveItem(obj1); RemoveItem(obj2); AddItem(newObj); }
/*--------------------------------------------------- * load the Inspector icons, and GameObject Sprites when item selected in Hierarchy * * get copy of 'target' object details into 'pickupObject' * * retrieve current value of 'type' */ void OnEnable() { iconHealth = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/icon_heart_32.png", typeof(Texture)) as Texture; iconKey = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/icon_key_green_32.png", typeof(Texture)) as Texture; iconStar = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/icon_star_32.png", typeof(Texture)) as Texture; spriteHealth100 = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/healthheart.png", typeof(Sprite)) as Sprite; spriteKey100 = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/icon_key_green_100.png", typeof(Sprite)) as Sprite; spriteStar100 = AssetDatabase.LoadAssetAtPath("Assets/EditorSprites/star.png", typeof(Sprite)) as Sprite; pickupObject = (PickUp)target; pickUpType = serializedObject.FindProperty ("type"); }
public void Ignite(Vector3 worldBurnPosition, int generation = 0) { if (this.isBurning) { return; } this.burnGeneration = generation; this.spreadTimer = 0f; this.isBurning = true; FireDamagePoint fireDamagePoint = this.FindClosestFirePoint(base.transform.InverseTransformPoint(worldBurnPosition)); if (fireDamagePoint != null) { this.BurnPoint(fireDamagePoint); this.UpdateSizeParameter(); } if (this.BurnMaterial && !this.Structure) { Renderer component = base.GetComponent <Renderer>(); if (component.sharedMaterial != this.BurnMaterial) { this.OriginalMaterial = component.sharedMaterial; component.sharedMaterial = this.BurnMaterial; } } for (int i = 0; i < this.AdditionalBurnMaterials.Length; i++) { if (this.AdditionalBurnMaterials[i].renderer.sharedMaterial != this.AdditionalBurnMaterials[i].material) { this.AdditionalBurnMaterials[i].originalMaterial = this.AdditionalBurnMaterials[i].renderer.sharedMaterial; this.AdditionalBurnMaterials[i].renderer.sharedMaterial = this.AdditionalBurnMaterials[i].material; } } if (this.DestroyWhenComplete) { IEnumerator enumerator = base.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; PickUp component2 = transform.GetComponent <PickUp>(); if (component2) { component2._destroyTarget = component2.gameObject; if (component2._myPickUp) { UnityEngine.Object.Destroy(component2._myPickUp); } if (component2._sheen) { UnityEngine.Object.Destroy(component2._sheen); } UnityEngine.Object.Destroy(component2.gameObject); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } }
void RayCast() { { int layerMask = 100; int x = Screen.width / 2; int y = Screen.height / 2; Camera Cam = CameraObject.GetComponent <Camera>(); Ray ray = Cam.ScreenPointToRay(new Vector3(x, y)); RaycastHit hit; if (Physics.Raycast(ray, out hit, layerMask)) { PickUp p = hit.collider.GetComponent <PickUp>(); if (p != null) { if (Input.GetMouseButtonDown(0)) { if (UseGun(FreezeChargeCost)) { p.FreezeObject(); //AudioPlayer.clip = TM_Effect; //print("Freeze Object"); //if (CurrentCharge < 20f) //{ //vignette.color.value = new Color(0, 217, 255, 5); //vignette.color.value = Color.black; // vignette.intensity.value = 0.268f; // vignette.color.Interp(Color.black, new Color(0, 217, 255, 5), 0.01f); // } } } else if (hit.distance < 8f && Input.GetMouseButtonDown(1)) { //if (UseGun(PickupChargeCost)) //{ print("Pickup Object"); p.PickupObject(); ArbiterHolder.Play("Fire"); //} } else if (Input.GetMouseButtonDown(2)) { //if (UseGun(PickupChargeCost)) //{ if (savedVelocity == new Vector3(0, 0, 0)) { savedVelocity = p.VelocityTake(); } else { p.VelocityApply(savedVelocity); savedVelocity = new Vector3(0, 0, 0); } //} } return; } else { print(hit.collider.tag); CubeSpawner CS = hit.collider.GetComponent <CubeSpawner>(); if (CS != null) { if (Input.GetMouseButtonDown(0)) { CS.RespawnCube(); } return; } SwitchToggle ST = hit.collider.GetComponent <SwitchToggle>(); if (ST != null) { // print("1"); if (Input.GetMouseButtonDown(1)) { //print("2"); UseGun(ST.Toggle()); } else { if (ST.resetable) { UseGun(ST.Reset()); } } return; } PowerSource PS = hit.collider.GetComponent <PowerSource>(); if (PS != null & Input.GetMouseButtonDown(1)) { // print("1"); if (Input.GetMouseButtonDown(1)) { //print("2"); if (PS.Use()) { CurrentCharge = MaxCharge; } } return; } } UseGun(0); AudioSource.PlayOneShot(Miss); } } }
public async Task <JsonResult> Create_Shipment_Order([FromBody] Shipment obj) { bool shipment_status = false; var result = new Models.DataProvider.DbResult(); var cart = await _shop_repo.Shopping_Cart_Tracking_Get_By_Id(obj.Cart_Id); if (!cart.Status.Equals("Pending")) { result.Message = "Order already created."; return(Json(result)); } var addr = await _addr_repo.Get_By_Id(cart.Shipping_Address_Id); cart.ShippingAddress = addr; string mobile = string.IsNullOrEmpty(addr.Mobile) ? string.Empty : addr.Mobile.StartsWith("+") ? addr.Mobile : string.Format("+{0}{1}", addr.ISDCode, addr.PhoneNumber); if (cart.CartType == "Shopping") { var dorship = new Dorship(cart.Id, obj.PaymentType); var order_rec = new Receiver_Data(addr.Full_Name, mobile, cart.Email, addr.Country, addr.State, addr.City, addr.Address_Line, addr.ZipCode); order_rec.Street_Two = addr.Address_Line2; order_rec.Street_Three = addr.Address_Line3; dorship.Receiver_Data = order_rec; var packages = new List <Package_Data>(); foreach (var x in cart.ShopingCart) { decimal price = (obj.PaymentType == "cc") ? 0 : x.TotalPrice; var package = new Package_Data(x.SKU, price, x.Product_Name); packages.Add(package); } dorship.Package_Data = packages; var shipment = await _fetchr.Create_Order_For_Shipment(dorship); if (shipment.Success) { if (shipment.Data.Success) { result.Message = "Order created successfully."; result.Success = shipment_status = true; foreach (var x in shipment.Data.Dorship.Package_Data) { var abc = _shop_repo.Update_Shipment_Id(x.Tracking_No, shipment.Data.Dorship.Order_Reference, x.Package_Reference); abc.Wait(); } var ord = await _shop_repo.Shopping_Cart_Tracking_Update_Order_Status(obj.Cart_Id, shipment_status, obj.PaymentType, "Order Created"); var invoice_template = _emailSender.GetMailTemplate(cart, "invoice.cshtml"); var file = Utility.Create_Invoice(invoice_template, cart.Id); var invoice_path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Resources", "Invoice", string.Format("{0}.pdf", cart.Id)); var html_template = _emailSender.GetMailTemplate(cart, "order-confirmation.cshtml"); var mailResult = await _emailSender.Send_Email_With_Attachement(cart.Name, cart.Email, "Order Confirmation", html_template, invoice_path); } } else { result.Message = shipment.Content; await ExceptionGateway.AddExceptionAsync(new ExceptionLog(new Exception(string.Format("Error: Create_Order_For_Shipment, Id: {0}", obj.Cart_Id)), shipment.Content)); } } if (cart.CartType == "Selling") { var pickup = new PickUp(); var pickup_data = new PickUp_Data { Email = cart.Email, Phone_Number = mobile, Name = addr.Full_Name }; pickup_data.Address = string.Format("{0}, {1}", addr.Address_Line, addr.Area); pickup_data.City = addr.City; pickup_data.Country = addr.Country; pickup_data.Order_Reference = cart.Id; foreach (var item in cart.SellingCart) { pickup_data.Product_Items.Add(new PickUp_Product { Product_Description = string.Format("{0}, {1} ({2})", item.Product_Name, item.Product_TypeName, item.Product_Type) }); } pickup.Data.Add(pickup_data); var shipment = await _fetchr.Create_PickUp_Order(pickup); if (shipment.Success) { if (shipment.Data.Success) { var resp = shipment.Data; result.Message = "Order created successfully."; result.Success = shipment_status = resp.Success; if (shipment_status) { var abc = _shop_repo.Update_Shipment_Id_Pickup(resp.Tracking_Id, resp.Order_Reference); abc.Wait(); var payment = await _pay_repo.Get(); await _credit_repo.Add_New(new Credit { Amount = cart.Total_Sum *payment.Credit_Ratio, IsBlocked = true, Trancaction_Id = obj.Cart_Id, Transaction_Type = "CREDIT", Transaction_For = "Selling", UserId = cart.UserId, Comments = string.Format("Added Credit for Order #{0}", obj.Cart_Id) }); var ord = await _shop_repo.Shopping_Cart_Tracking_Update_Order_Status(obj.Cart_Id, shipment_status, obj.PaymentType, "Order Created"); var invoice_template = _emailSender.GetMailTemplate(cart, "invoice.cshtml"); var file = Utility.Create_Invoice(invoice_template, cart.Id); var invoice_path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Resources", "Invoice", string.Format("{0}.pdf", cart.Id)); var html_template = _emailSender.GetMailTemplate(cart, "order-confirmation.cshtml"); var mailResult = await _emailSender.Send_Email_With_Attachement(cart.Name, cart.Email, "Order Confirmation", html_template, invoice_path); } } } else { result.Message = shipment.Content; await ExceptionGateway.AddExceptionAsync(new ExceptionLog(new Exception(string.Format("Error: Create_Order_For_Shipment, Id: {0}", obj.Cart_Id)), shipment.Content)); } } return(Json(result)); }