public void EquipmentEffects(Drop_scr drop, int sign) { /* * public int MaxHealth = 100; * public int Health = 100; * public int Stamina = 20; * public int MaxStamina = 20; * public int RegenHP = 0; * public int RegenSTM = 1; * public float speed = 3f; // сорость бега * public float ShiftSpeed = 2f; // + скорость с зажатым LeftShift * public float JumpStrengh = 3000f; * public int JumpWaste = 5; * public int Armor = 0; */ MaxHealth += sign * drop.MaxHealth; Health += sign * drop.Health; Stamina += sign * drop.Stamina; MaxStamina += sign * drop.MaxStamina; RegenHP += sign * drop.RegenHP; RegenSTM += sign * drop.RegenSTM; speed += sign * drop.speed; JumpStrengh += sign * drop.JumpStrengh; JumpWaste += sign * drop.JumpWaste; Armor += sign * drop.Armor; if (Health > MaxHealth) { Health = MaxHealth; } if (Stamina > MaxStamina) { Stamina = MaxStamina; } }
public void DealDamage(Drop_scr item) { if (CanMove) { int dmg = item.DMG; } }
public void Set(GameObject item, int count) { Drop_scr drop = item.GetComponent <Drop_scr>(); Name.text = drop.supertype; Count.text += count.ToString(); sprite.sprite = item.GetComponent <SpriteRenderer>().sprite; }
public void Show(GameObject drop) { Drop_scr DropComponent = drop.GetComponent <Drop_scr>(); Name.text = DropComponent.supertype; IncreseCount(DropComponent.count); id = DropComponent.id; sprite.sprite = drop.GetComponent <SpriteRenderer>().sprite; }
public void CursorContainerActivation(GameObject item, int count) { InActiveSlot = item.GetComponent <Drop_scr>(); InHandIndicator.SetActive(true); InHandIndicator.GetComponent <Image>().sprite = item.GetComponent <SpriteRenderer>().sprite; HandContainer = InActiveSlot.id; HandContainerCount = count; HandContainerFull = true; Cursor.SetCursor(CursorTake, Vector2.zero, CursorMode.Auto); //return true; }
// Start is called before the first frame update private void Awake() { Cursor = GameObject.Find("Cursor"); Item = Cursor.GetComponent <Cursor_scr>().InActiveSlot; damage = Item.DMG; KnockBack = Item.knockBack; player = GameObject.Find("Player"); playerComponent = player.GetComponent <Player_movement_scr>(); playerComponent.WorkInd.GetComponent <SpriteRenderer>().enabled = true; lifetime = 0.1f;//Item.ActionSpeed/3f; }
private void Awake() { fade.a = 0; inc.a = 0; Cursor = GameObject.Find("Cursor"); Item = Cursor.GetComponent <Cursor_scr>().InActiveSlot; damage = Item.DMG; KnockBack = Item.knockBack; player = GameObject.Find("Player"); playerComponent = player.GetComponent <Player_movement_scr>(); lifetime = Item.ActionSpeed; }
public bool CheckID(Drop_scr drop) { int newID = drop.id; if (newID == id) { IncreseCount(drop.count); StopCoroutine("SelfDestroy"); StartCoroutine(SelfDestroy()); return(true); } return(false); }
public void GetFromCell(int high, int width, Drop_scr InHand) { //Debug.Log(high + " " + width); if (width >= GridWidth || high >= GridHigh) { Debug.Log("Out of grid"); } else { //Debug.Log(Grid[width, high]); Grid[width, high].GetComponent <Cell_class>().GetObj(InHand); } }
public void newAsk(GameObject item) { Drop_scr Comp = item.GetComponent <Drop_scr>(); id = Comp.id; //sprite.sprite = item.GetComponent<SpriteRenderer>().sprite; Name.text = Comp.supertype; for (int i = 0; i < Comp.Recipe.Length; i++) { GameObject slot = Instantiate(ComponentPrefab, ComponentPapa.transform); slot.GetComponent <RecepiSlot_scr>().Set(Comp.Recipe[i], Comp.RecipeCount[i]); } StartCoroutine(SelfDeactivate()); }
public void CheckID(GameObject item) { Drop_scr Comp = item.GetComponent <Drop_scr>(); if (id == Comp.id) { StopCoroutine("SelfDeactivate"); StartCoroutine(SelfDeactivate()); } else { StopCoroutine("SelfDeactivate"); SlotsDeactivate(); newAsk(item); } }
public bool LastHit(Drop_scr item) { int strengh = item.Efficiency; float speed = item.ActionSpeed; health -= strengh; if (health > 0) { //Debug.Log("Left " + health); return(false); } else { StartCoroutine(WaitToDrop(speed)); //Drop(type); return(true); } }
public bool HaveRoomForThisDrop(GameObject item) { Drop_scr drop = item.GetComponent <Drop_scr>(); int count = drop.count; int id = drop.id; for (int i = 0; i < InvItemsLength; i++) { GameObject iItem = InvItems[i]; if (iItem != null && iItem.GetComponent <Drop_scr>().id.Equals(id)) { int istack = iItem.GetComponent <Drop_scr>().InStack; if (ItemsCount[i] < istack) { return(true); } } } return(false); }
public void TakeItem(Drop_scr drop) { GameObject[] component = drop.Recipe; int[] componentCount = drop.RecipeCount; for (int i = 0; i < drop.Recipe.Length; i++) { int id = component[i].GetComponent <Drop_scr>().id; for (int k = 0; k < CraftPanelSize; k++) { if (CraftItems[k] != null && id == CraftItems[k].GetComponent <Drop_scr>().id) { CraftCounts[k] -= componentCount[i]; break; } } } //SmthInHand = true; CraftSlotsCheker(); UpdateInventory(); }
public void IteractWithSlot() { Debug.Log("Click"); if (CursorComponent.HandContainerFull) // если в руках есть some { int id = CursorComponent.HandContainer; GameObject FreeHand = DropCatalog.GetGObyID(id); Drop_scr drop = FreeHand.GetComponent <Drop_scr>(); Debug.Log(drop.type.Equals(SlotType)); if (drop.type.Equals(SlotType)) { if (busy) //клетка занята { SlotBenifits(-1); CursorComponent.CursorContainerActivation(inSlot, 1); SetSlot(FreeHand); SlotBenifits(1); // } else //положить в пустую { SetSlot(FreeHand); SlotBenifits(1); CursorComponent.CursorContainerActivation(); } } else { Debug.Log("Этот предмет не подходит в этот слот"); } // InventoryComponent.PutItem(SlotNumber); } else if (busy) // руки пустые, но в клетке предмет { CursorComponent.CursorContainerActivation(inSlot, 1); SlotBenifits(-1); SetSlot(); } }
public void SetSlot(GameObject item, int CraftPossibility) { this.gameObject.SetActive(true); CraftItem = item; CraftItemComponent = item.GetComponent <Drop_scr>(); CraftItemCount = CraftItemComponent.ResultCount; if (CraftItemCount < 2) { Debug.Log(CraftItemCount); Count.GetComponent <Text>().text = CraftItemCount.ToString(); } else { Count.GetComponent <Text>().text = ""; } InvSlot.GetComponent <Image>().sprite = item.GetComponent <SpriteRenderer>().sprite; Color Alpha = InvSlot.transform.GetComponent <Image>().color; if (CraftPossibility == 1) { CanCraft = true; Alpha.a = 1f; //Debug.Log("+1 Recipe"); } else if (CraftPossibility == 3) { CanCraft = false; Alpha = Color.red; Alpha.a = 0.5f; //Debug.Log("Paint red " + item.name); } else { CanCraft = false; Alpha.a = 0.5f; //Debug.Log("+1 Allmost Recipe"); } InvSlot.transform.GetComponent <Image>().color = Alpha; }
public void GetObj(Drop_scr InHand) { GameObject Player = GameObject.Find("Player"); if (objOnIt != null) { string ObjType = objOnIt.GetComponent <ObjOnCell_scr>().ItemType; string InHandType = InHand.type; Debug.Log(ObjType); if (ObjType.Equals(InHandType)) { if (InHandType == "Axe") { Player.GetComponent <AudioManager>().PlayAudioMine(1); } else if (InHandType == "Pickaxe") { Player.GetComponent <AudioManager>().PlayAudioMine(0); } if (objOnIt.transform.GetComponent <ObjOnCell_scr>().LastHit(InHand)) { objOnIt = null; } } else { Player.GetComponent <AudioManager>().PlayAudioAttack(); } } else { Player.GetComponent <AudioManager>().PlayAudioAttack(); //Debug.Log(objOnIt); //Debug.Log("Cell is empty"); } }
public void AddItem(GameObject item) { Drop_scr drop = item.GetComponent <Drop_scr>(); int count = drop.count; int id = drop.id; for (int i = 0; i < InvItemsLength; i++) { GameObject iItem = InvItems[i]; if (iItem != null && iItem.GetComponent <Drop_scr>().id.Equals(id)) { int istack = iItem.GetComponent <Drop_scr>().InStack; if (ItemsCount[i] + count <= istack) { ItemsCount[i] += count; drop.IsEmpty(); InvSlots[i].SetCount(ItemsCount[i]); return; } else { drop.count = ItemsCount[i] + count - istack; ItemsCount[i] = istack; } } } if (!isFull) { InvItems[firstemptycell] = DropCatalog.GetGObyID(id); ItemsCount[firstemptycell] = count; InvSlots[firstemptycell].SetCount(ItemsCount[firstemptycell], InvItems[firstemptycell]); drop.IsEmpty(); UpdateInventory(); } ChangeInHandItem(); }
public void ChangeInHandItem(Drop_scr Hand) { InActiveSlot = Hand; }
void SlotBenifits(int sign) { Drop_scr drop = inSlot.GetComponent <Drop_scr>(); player.EquipmentEffects(drop, sign); }
public void CheckRecipe(GameObject[] craft, GameObject item, int[] Counts) { Drop_scr drop = item.GetComponent <Drop_scr>(); GameObject[] recipe = drop.Recipe; int Rlength = recipe.Length; if (Rlength < 1) { return; } int[] recipeCount = drop.RecipeCount; int Clength = craft.Length; int coincidences = 0; bool IdealCount = true; int[] ceckedIds = new int[Clength]; int ceckedIdsCounter = 0; for (int i = 0; i < Clength; i++) { if (craft[i] != null) { int Cid = craft[i].GetComponent <Drop_scr>().id; bool wasnt = true; for (int m = 0; m < ceckedIdsCounter; m++) { if (ceckedIds[m] == Cid) { wasnt = false; Debug.Log("ghjghjghj"); break; } } if (wasnt) { for (int k = 0; k < Rlength; k++) { if (Cid == recipe[k].GetComponent <Drop_scr>().id) { if (Counts[i] < recipeCount[k]) { IdealCount = false; } //Debug.Log("+ coincidence"); coincidences++; break; } if (k == Rlength - 1) { coincidences = -10; } } if (coincidences < 0) { return; } ceckedIds[ceckedIdsCounter] = Cid; ceckedIdsCounter++; } } } if (coincidences >= Rlength) { if (IdealCount) { CanCraftItems[CurrentCanSlot] = item; CurrentCanSlot++; return; } else { AlmostCanCraftItems[CurrentAlmostCanSlot] = item; CurrentAlmostCanSlot++; return; } } else { MayCraftItems[CurrentMaySlot] = item; CurrentMaySlot++; return; } }