private void PutOnElement(SlotElement slotElement) { if (slotElement.GameObject == null) { return; } if (!_slots_map.TryGetValue(slotElement.Placement, out Slot slot)) { UnityEngine.Debug.LogError(string.Format("Stuff model has clothes for slot {0}, but StuffPrefab doesn't have such slot", slotElement.Placement.ToString())); return; } Transform elementTransform = slotElement.GameObject.transform; Rigidbody body = slotElement.GameObject.GetComponent <Rigidbody>(); if (body != null) { body.isKinematic = true; } elementTransform.SetParent(slot.Container.transform); elementTransform.localPosition = slotElement.Position; elementTransform.localEulerAngles = slotElement.Rotation; }
// 選択したスロットを返す // 参照用 public Slot GetSelectSlot(SlotElement slot_elem, int slot_num) { // 選んだスロットから最大数を取り出す int total_obj_num = m_obj_num_list[(int)slot_elem]; Slot slot; slot.p_obj = null; slot.ground_element = GroundElement.NONE; slot.slot_element = SlotElement.NONE; slot.moisture = 0.0f; // 適合したスロットを返す switch (slot_elem) { case SlotElement.ARCH: slot = m_arch_slot_list[slot_num % total_obj_num]; break; case SlotElement.PLANT: slot = m_plant_slot_list[slot_num % total_obj_num]; break; case SlotElement.FOOD: //slot = m_food_slot_list[slot_num % total_obj_num]; break; } return(slot); }
public static SlotElement[] Result(SlotHandler[] slots, SlotElement[] elements) { SlotElement[] result = new SlotElement[slots.Length]; List <int> usedIndexes = new List <int>(); int allowedRepeats = 0; if (slots.Length > elements.Length) { allowedRepeats = slots.Length - elements.Length; } for (int i = 0; i < result.Length; i++) { int index = UnityEngine.Random.Range(0, elements.Length - 1); if (allowedRepeats < 1) { while (usedIndexes.Contains(index)) { index = UnityEngine.Random.Range(0, elements.Length); } } else if (usedIndexes.Contains(index)) { allowedRepeats -= 1; } usedIndexes.Add(index); result[i] = elements[index]; } return(result); }
public static SlotElement[] Result(SlotHandler[] slots, SlotElement[] elements) { SlotElement[] result = new SlotElement[slots.Length]; for (int i = 0; i < result.Length; i++) { int index = UnityEngine.Random.Range(0, elements.Length - 1); result[i] = elements[index]; } return(result); }
private bool TryGetSlot(SlotElement slotElement, out Slot slot) { for (int i = 0; i < slots.Length; i++) { if (slots[i].Placement != slotElement.Placement) { continue; } slot = slots[i]; return(true); } slot = null; return(false); }
public decimal CalculateWinAmount(IElementsMatrix matrix, decimal bet) { decimal winAmount = 0; for (int row = 0; row < matrix.Rows; row++) { int startColIdx = 0; SlotElement comparingElement = null; //Get first non wildcard element and its position while (startColIdx < matrix.Columns) { if (matrix.Slots[row, startColIdx].Symbol != _wildcard) { comparingElement = matrix.Slots[row, startColIdx]; break; } startColIdx++; } // Iterate to the end of the row to see if all elements are the same // and to sum up their coeficient. double coeficientSum = comparingElement?.Coeficient ?? 0; bool winningLine = true; for (int col = startColIdx + 1; col < matrix.Columns; col++) { SlotElement current = matrix.Slots[row, col]; if (comparingElement.Symbol != current.Symbol && current.Symbol != _wildcard) { winningLine = false; break; } coeficientSum += current.Coeficient; } if (winningLine) { winAmount += (decimal)coeficientSum * bet; } } return(Math.Round(winAmount, 1)); }
public SlotElement Next() { SlotElement selected = null; double diceRoll = this.random.NextDouble(); double cumulative = 0; for (int i = 0; i < this.slotElements.Count; i++) { cumulative += this.slotElements[i].Probability; if (diceRoll < cumulative) { selected = this.slotElements[i]; break; } } return(selected); }
public static SlotElement[] Result(SlotHandler[] slots, SlotElement[] elements) { SlotElement[] result = new SlotElement[slots.Length]; int bigAmmountElemIndex = UnityEngine.Random.Range(0, elements.Length - 1); int unfortuneSlotIndex = UnityEngine.Random.Range(0, slots.Length - 1); for (int i = 0; i < result.Length; i++) { if (i != unfortuneSlotIndex) { result[i] = elements[bigAmmountElemIndex]; } else { int unfortuneElemIndex = UnfortunateSlotFinder.Find(bigAmmountElemIndex, elements); result[i] = elements[unfortuneElemIndex]; } } return(result); }
private void TakeOffElement(SlotElement slotElement) { slotElement.GameObject.transform.SetParent(null); Destroy(slotElement.GameObject); }
// 最大スロット数を返す public int GetSelectMaxSlotNum(SlotElement slot_elem) { // 選んだスロットから最大数を取り出す return(m_obj_num_list[(int)slot_elem]); }