Пример #1
0
        protected override void OnRemovePart(BodyPartSlot slot, SharedBodyPartComponent part)
        {
            base.OnRemovePart(slot, part);

            _partContainer.ForceRemove(part.Owner);
            part.Owner.RandomOffset(0.25f);
        }
Пример #2
0
 public static (INDX INDX, BNAM BNAM, CNAM CNAM) EquipementBodyPart(BodyPartSlot bodyPartSlot, string maleBodyPartId = "", string femaleBodyPartId = "")
 {
     return
         (
         new INDX {
         Type = bodyPartSlot
     },
         string.IsNullOrEmpty(maleBodyPartId) ? null : new BNAM {
         MalePartName = maleBodyPartId
     },
         string.IsNullOrEmpty(femaleBodyPartId) ? null : new CNAM {
         FemalePartName = femaleBodyPartId
     }
         );
 }
Пример #3
0
    private void Update()
    {
        if (character == null)
        {
            return;
        }

        freeSpaceText.text = character.inventory.FreeSpace + "/" + character.inventory.maxSize;
        itemCountText.text = character.inventory.ItemCount.ToString();

        foreach (Item item in character.inventory.Items)
        {
            if (!displayedItems.Contains(item))
            {
                ItemSlot itemSlot = Instantiate(itemSlotPrefab, Vector3.zero, Quaternion.identity, inventoryGrid.transform);
                itemSlot.Item = item;
                displayedItems.Add(item);
                itemSlots.Add(itemSlot);
            }
        }

        itemSlots.RemoveAll(item => item == null);
        foreach (ItemSlot itemSlot in itemSlots)
        {
            if (!character.inventory.Contains(itemSlot.Item) || itemSlot.Item == null)
            {
                displayedItems.Remove(itemSlot.Item);
                Destroy(itemSlot.gameObject);
            }
        }

        foreach (BodyPart bodyPart in character.body.bodyParts)
        {
            if (bodyPart.slot != Slot.None && !displayedBodyParts.Contains(bodyPart))
            {
                BodyPartSlot bodyPartSlot = Instantiate(bodyPartSlotPrefab, Vector3.zero, Quaternion.identity, equipmentGrid.transform);
                bodyPartSlot.bodyPart = bodyPart;
                displayedBodyParts.Add(bodyPart);
            }
        }
    }
Пример #4
0
        protected override void OnAddPart(BodyPartSlot slot, SharedBodyPartComponent part)
        {
            base.OnAddPart(slot, part);

            _partContainer.Insert(part.Owner);
        }
Пример #5
0
        public INDX(byte[] rawData) : base(rawData)
        {
            var reader = new ByteReader();

            Type = reader.ReadBytes <BodyPartSlot>(base.Data);
        }
Пример #6
0
    //TODO: force the player to pick more than one type
    //TODO: no duplicate choice
    private IEnumerator GeneratePlayerBody()
    {
        DontDestroyOnLoad(this.gameObject);
        BodyPart.Init();
        Stack <BodyPartSlot> frontier = new Stack <BodyPartSlot>();

        m_bodySlot.GetComponent <BodyPartSlot> ().m_depth = 0;
        frontier.Push(m_bodySlot.GetComponent <BodyPartSlot>());

        HashSet <BodyPart.ElementType> elements = new HashSet <BodyPart.ElementType>();

        while (frontier.Count > 0)
        {
            m_NahButton.SetActive(false);
            BodyPartSlot slot = frontier.Pop();


            bool isHead = slot.GetBodyPartType() == BodyPartSlot.BodyPartType.Head;


            if (slot.m_depth > 5 && isHead == false)
            {
                continue;
            }



            BodyPartSlot.BodyPartType bodyPartSlotType = slot.GetBodyPartType();
            //TODO:pick three bodyparts
            HashSet <BodyPart.ElementType> types = new HashSet <BodyPart.ElementType>();
            List <GameObject> parts;
            if (m_body == null)
            {
                parts = BodyPart.GetUsableParts(slot.GetBodyPartType(), true, null);
            }
            else
            {
                parts = BodyPart.GetUsableParts(slot.GetBodyPartType(), true, m_body.CountTypes(ref types));
            }

            if (slot.m_depth >= 1 && isHead == false && frontier.Count - elements.Count >= Mathf.Max(PlayerPrefs.GetInt("Level", 0) / 3, 6))
            {
                m_NahButton.SetActive(true);
            }

            bool shouldContinue = false;

            foreach (BodyPartDisplay display in m_bodyPartDisplays)
            {
                BodyPart bp = null;
                if (parts.Count > 0)
                {
                    bp = parts [Random.Range(0, parts.Count)].GetComponent <BodyPart> ();
                }
                if (bp == null)
                {
                    display.Display(null, 0, 0);
                    shouldContinue = true;
                }
                else
                {
                    display.Display(bp.gameObject, bp.MinRotation(), bp.MaxRotation());
                }
            }

            if (shouldContinue)
            {
                continue;
            }

            m_spawnIndicator.transform.position = slot.transform.position;
            m_choice = null;
            //TODO:Let the player choose one
            while (m_choice == null && !(skip == true && slot.GetBodyPartType() != BodyPartSlot.BodyPartType.Body))
            {
                yield return(new WaitForEndOfFrame());
            }
            if (skip == true)
            {
                skip = false;
                continue;
            }

            BodyPart.RemoveConflicts(m_choice);

            m_choice.transform.localScale *= .25f;

            //TODO:Add the choice to the body
            m_audioSource.PlayOneShot(m_audioClip);
            m_choice = slot.AddPart(m_choice, slot.m_parentPart);

            elements.Add(m_choice.GetElementType());


            if (m_body == null)
            {
                m_body = m_choice;
            }

            foreach (BodyPartSlot s in m_choice.GetSlots())
            {
                s.m_parentPart = m_choice;
                s.m_depth      = slot.m_depth + 1;
                frontier.Push(s);
            }

            yield return(new WaitForEndOfFrame());
        }

        Destroy(m_spawnIndicator);

        m_body.CalculateScore(ref m_typeScores);
        CacheIfMatchProfile();

        m_body.transform.parent = this.transform;

        //TODO: go to the next scene
        Fader.Instance.FadeIn().LoadLevel("PrototypeScene").FadeIn(3.0f).FadeOut(3.0f);
    }