Exemplo n.º 1
0
    private void SpawnFirstCharacter()
    {
        GameObject newCharacter = Instantiate(m_characterPrefab);

        newCharacter.transform.parent = transform;
        float randomX = Random.Range(m_xMin, m_xMax);
        float randomY = Random.Range(m_yMin, m_yMax);

        newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f);

        List <Item> topList  = m_itemsDatabase.GetItems(Item.ItemType.Top);
        int         topIndex = Random.Range(0, topList.Count);
        TopItem     top      = (TopItem)topList[topIndex];

        newCharacter.GetComponent <Character>().AssignTop(top);

        List <Item> bottomList  = m_itemsDatabase.GetItems(Item.ItemType.Bottom);
        int         bottomIndex = Random.Range(0, bottomList.Count);
        BottomItem  bottom      = (BottomItem)bottomList[bottomIndex];

        newCharacter.GetComponent <Character>().AssignBottom(bottom);

        AssignHead(Item.ItemType.Head, newCharacter);
        AssignFace(Item.ItemType.Face, newCharacter);
        AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter);
        AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter);

        newCharacter.GetComponent <Character>().InitOrders();
        newCharacter.GetComponentInChildren <SuspectController>().IsTarget = true;

        m_characters.Add(newCharacter);
        m_zManager.m_playersAndObstacles.Add(newCharacter);
    }
Exemplo n.º 2
0
    GameObject CreateItem(int width, float posX)
    {
        GameObject tempObj = Instantiate(templateBottomItem) as GameObject;

        tempObj.SetActive(true);
        tempObj.transform.parent     = objParent.transform;
        tempObj.transform.localScale = Vector3.one;
        //tempObj.transform.localPosition = Vector3.zero;
        //tempObj.GetComponent<UISprite>().width = width;
        tempObj.transform.localPosition = new Vector3(posX, -420.0f, 0.0f);

        BottomItem bottomItem = tempObj.GetComponent <BottomItem>();

        bottomItem.SetBridge(width);
        objList.Add(bottomItem);

//		//是否带苹果
//		if (curScore >= 1) {
//			if(Random.Range(1,11) >= 5){
//				//生成水果
//				//bottomItem.fruitControl.gameObject.SetActive(true);
//				if(desDis >= 200){
//					bottomItem.enermyControl.gameObject.SetActive(true);
//				}
//			}
//		}
        return(tempObj);
    }
Exemplo n.º 3
0
 public void AssignBottom(BottomItem _bottom)
 {
     m_bottom = _bottom;
     m_hipsAnchor.GetComponent <SpriteRenderer>().sprite          = m_bottom.m_hipsSprite;
     m_bottomLegTopLAnchor.GetComponent <SpriteRenderer>().sprite = m_bottom.m_bottomLegTopLSprite;
     m_bottomLegTopRAnchor.GetComponent <SpriteRenderer>().sprite = m_bottom.m_bottomLegTopRSprite;
     m_bottomLegBotLAnchor.GetComponent <SpriteRenderer>().sprite = m_bottom.m_bottomLegBotLSprite;
     m_bottomLegBotRAnchor.GetComponent <SpriteRenderer>().sprite = m_bottom.m_bottomLegBotRSprite;
     m_shoesLAnchor.GetComponent <SpriteRenderer>().sprite        = m_bottom.m_shoesLSprite;
     m_shoesRAnchor.GetComponent <SpriteRenderer>().sprite        = m_bottom.m_shoesRSprite;
 }
Exemplo n.º 4
0
    private void SpawnCharacterV3(List <ItemClue> _defClues)
    {
        GameObject newCharacter = Instantiate(m_characterPrefab);

        newCharacter.transform.parent = transform;
        float randomX = Random.Range(m_xMin, m_xMax);
        float randomY = Random.Range(m_yMin, m_yMax);

        newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f);

        List <Item> topList  = m_itemsDatabase.GetItems(Item.ItemType.Top);
        int         topIndex = Random.Range(0, topList.Count);
        TopItem     top      = (TopItem)topList[topIndex];

        newCharacter.GetComponent <Character>().AssignTop(top);

        List <Item> bottomList  = m_itemsDatabase.GetItems(Item.ItemType.Bottom);
        int         bottomIndex = Random.Range(0, bottomList.Count);
        BottomItem  bottom      = (BottomItem)bottomList[bottomIndex];

        newCharacter.GetComponent <Character>().AssignBottom(bottom);

        AssignHead(Item.ItemType.Head, newCharacter);
        AssignFace(Item.ItemType.Face, newCharacter);
        AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter);
        AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter);

        newCharacter.GetComponent <Character>().InitOrders();

        if (m_characters.Count > 0 && newCharacter.GetComponent <Character>().RespectClues(_defClues))
        {
            // same as the bad guy
            // Debug.Log("Duplicate");
        }
        else
        {
            m_characters.Add(newCharacter);
            m_zManager.m_playersAndObstacles.Add(newCharacter);
        }
    }
Exemplo n.º 5
0
    private void SpawnCharacterWithConstraints(List <Constraint> _constraints)
    {
        GameObject newCharacter = Instantiate(m_characterPrefab);

        newCharacter.transform.parent = transform;
        float randomX = Random.Range(m_xMin, m_xMax);
        float randomY = Random.Range(m_yMin, m_yMax);

        newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f);

        TopItem itemTop = HasTopConstraint(_constraints);

        if (itemTop == null)
        {
            List <Item> topList  = m_itemsDatabase.GetItems(Item.ItemType.Top);
            int         topIndex = Random.Range(0, topList.Count);
            TopItem     top      = (TopItem)topList[topIndex];
            newCharacter.GetComponent <Character>().AssignTop(top);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignTop(itemTop);
        }

        BottomItem itemBottom = HasBottomConstraint(_constraints);

        if (itemBottom == null)
        {
            List <Item> bottomList  = m_itemsDatabase.GetItems(Item.ItemType.Bottom);
            int         bottomIndex = Random.Range(0, bottomList.Count);
            BottomItem  bottom      = (BottomItem)bottomList[bottomIndex];
            newCharacter.GetComponent <Character>().AssignBottom(bottom);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignBottom((BottomItem)itemBottom);
        }

        Item itemHead = HasConstraint(_constraints, Item.ItemType.Head);

        if (itemHead == null)
        {
            AssignHead(Item.ItemType.Head, newCharacter);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignHead((SimpleItem)itemHead);
        }

        Item itemFace = HasConstraint(_constraints, Item.ItemType.Face);

        if (itemFace == null)
        {
            AssignFace(Item.ItemType.Face, newCharacter);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignFace((SimpleItem)itemFace);
        }

        Item itemHeadAccessory = HasConstraint(_constraints, Item.ItemType.HeadAccessory);

        if (itemHeadAccessory == null)
        {
            AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignHeadAccessory((SimpleItem)itemHeadAccessory);
        }

        Item itemFaceAccessory = HasConstraint(_constraints, Item.ItemType.FaceAccessory);

        if (itemFaceAccessory == null)
        {
            AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter);
        }
        else
        {
            newCharacter.GetComponent <Character>().AssignFaceAccessory((SimpleItem)itemFaceAccessory);
        }

        newCharacter.GetComponent <Character>().InitOrders();

        m_characters.Add(newCharacter);
        m_zManager.m_playersAndObstacles.Add(newCharacter);
    }
Exemplo n.º 6
0
 public bool IsSameItem(BottomItem _bottomItem)
 {
     return(m_hipsSprite == _bottomItem.m_hipsSprite);
 }