コード例 #1
0
    private void updateObjectPosition()
    {
        int iDistance = (int)distance_;
        //Debug.Log("Update Obj Position  : " + iDistance.ToString());
        Vector3 curPostionVector = new Vector3();

        //foreach(MapObjectStruct obj in objectList_)
        for (int i = 0; i < objectList_.Count; ++i)
        {
            //if (obj.object_.activeSelf == true)
            //{
            //	if (iDistance > obj.distance_ + Constant.Distance_ObjectDisappear)
            //	{
            //		obj.object_.SetActive(false);
            //		continue;
            //	}
            //}
            MapObjectStruct mapObj = objectList_[i];
            //너무 멀리 있는 오브젝트도 패스
            if (iDistance < mapObj.distance_ - Constant.Distance_ObjectAppear_)
            {
                break;
            }
            if (iDistance > mapObj.distance_ + Constant.Distance_ObjectDisappear &&
                mapObj.object_ != null)
            {
                //objectList_[i].SetReady(false);
                mapObj.object_.SetActive(false);
                mapObj.object_ = null;
                continue;
            }
            // 거리에 들어왔는데
            //if (objectList_[i].bReady_ == false)
            //{

            //}
            //if (obj.object_.activeSelf == false)
            //{
            //    Debug.Log("Obj Activatie : " + obj.objectType_.ToString() + " " + obj.distance_.ToString());
            //}
            // 여기서부턴 거리에 들어와있는 오브젝트들
            if (mapObj.object_ == null)
            {
                mapObj.object_
                    = GameObject.FindGameObjectWithTag(
                          "GameController").GetComponent <GameManagerScript>().GetMapObjectInstance(mapObj.objectType_);
                if (mapObj.object_ == null)
                {
                    continue;
                }
                mapObj.object_.SetActive(true);
            }



            curPostionVector.x = calcObjectXPos(mapObj.objectType_, mapObj.horizonalPosition_, mapObj.distance_);
            curPostionVector.y = calcObjectYPos(mapObj.objectType_, mapObj.distance_);
            curPostionVector.z = calcObjectZpos(mapObj.objectType_, mapObj.distance_);
            mapObj.object_.transform.position = curPostionVector;
            objectList_[i] = mapObj;
        }
    }
コード例 #2
0
    public bool addObject(int distance, string objectType, int hPos)
    {
        if (stageMaxDistance_ <= 0 ||
            distance > stageMaxDistance_)
        {
            return(false);
        }

        // 오브젝트 생성(실제생성은 나중에)
        MapObjectStruct obj = new MapObjectStruct();

        ///////////////////////////////////////////////////////////////
        if (objectType.Equals("boss"))
        {
            obj.objectType_ = Constant.MapObjects.BOSS;
        }
        else if (objectType.Equals("crack"))
        {
            obj.objectType_ = Constant.MapObjects.CRACK;
        }
        else if (objectType.Equals("crack_upg"))
        {
            obj.objectType_ = Constant.MapObjects.CRACK_UPG;
        }
        else if (objectType.Equals("curve_end"))
        {
            obj.objectType_ = Constant.MapObjects.CURVE_END;
        }
        else if (objectType.Equals("curve_left"))
        {
            obj.objectType_ = Constant.MapObjects.CURVE_LEFT_START;
        }
        else if (objectType.Equals("curve_right"))
        {
            obj.objectType_ = Constant.MapObjects.CURVE_RIGHT_START;
        }
        else if (objectType.Equals("goal"))
        {
            obj.objectType_ = Constant.MapObjects.GOAL;
        }
        else if (objectType.Equals("heart"))
        {
            obj.objectType_ = Constant.MapObjects.HEART;
        }
        else if (objectType.Equals("large_hole"))
        {
            obj.objectType_ = Constant.MapObjects.LHOLE;
        }
        else if (objectType.Equals("large_hole_upg"))
        {
            obj.objectType_ = Constant.MapObjects.LHOLE_UPG;
        }
        else if (objectType.Equals("rock"))
        {
            obj.objectType_ = Constant.MapObjects.ROCK;
        }
        else if (objectType.Equals("shop_expensive"))
        {
            obj.objectType_ = Constant.MapObjects.SHOP_EXPENSIVE;
        }
        else if (objectType.Equals("shop_normal"))
        {
            obj.objectType_ = Constant.MapObjects.SHOP_NORMAL;
        }
        else if (objectType.Equals("shop_santa"))
        {
            obj.objectType_ = Constant.MapObjects.SHOP_SANTA;
        }
        else if (objectType.Equals("special_1"))
        {
            obj.objectType_ = Constant.MapObjects.SPECIAL_1;
        }
        else if (objectType.Equals("special_2"))
        {
            obj.objectType_ = Constant.MapObjects.SPECIAL_2;
        }
        else if (objectType.Equals("special_3"))
        {
            obj.objectType_ = Constant.MapObjects.SPECIAL_3;
        }
        else if (objectType.Equals("tree"))
        {
            obj.objectType_ = Constant.MapObjects.TREE;
        }
        else if (objectType.Equals("warp"))
        {
            obj.objectType_ = Constant.MapObjects.WARP;
        }
        else if (objectType.Equals("wing"))
        {
            obj.objectType_ = Constant.MapObjects.WING;
        }
        else
        {
            return(false);
        }
        obj.distance_          = distance;
        obj.horizonalPosition_ = hPos;
        obj.bReady_            = false;
        objectList_.Add(obj);

        return(true);
    }