Example #1
0
 public static void CMD_AppendNumber(GameObject obj)
 {
     IEnumerable<GameObject> objenum = null;
     if (obj.transform.GetParent() == null)
         objenum = EngineManagerViewModel.instance.CurrentGameObjects.AsEnumerable<GameObject>();
     else
     {
         Converters.CTransformListToGameObjectListConverter conv = new Converters.CTransformListToGameObjectListConverter();
         objenum = (conv.Convert(obj.transform.GetParent().children,null, null, null) as ObservableCollection<GameObject>).AsEnumerable<GameObject>();
     }
     string obj_name = obj.GetName();
     for (int i = 0; i < obj_name.Length; ++i)
     {
         if (char.IsDigit(obj_name[i]))
         {
             obj_name = obj_name.Remove(i);
             break;
         }
     }
     obj_name = obj_name.Trim();
     int index = objenum.Count(new Func<GameObject,bool>((GameObject g)=>{ return g.GetName().Contains(obj_name); }));
     obj.SetName(obj_name + " " + index.ToString());
 }
    public void OnStart()
    {
        sound = gameObject.RequireComponent<CSound>();

        consoleText = Common.GetSurveillancePlayerConsoleText().RequireComponent<CFontRenderer>();
        // consoleText.mFontSize = 60;
        // consoleText.mFontScale = 0.0024f;

        mBlinkingTimer = 0.0f;
        consoleText.mText = "";
        firstLineTextToDisplay = "";
        btmTextToDisplay = "";

        playerMouse = GetScript<Mouse>(Common.GetStealthPlayerMouse());
        player = Common.GetStealthPlayer();
        mBlinkingLight = GetScript<OcuConsoleBlinkingLight>(Common.GetConsoleBlinkingLight());

        mCenterPosForText = Common.GetConsoleCam().transform.position; // console: -10, 25
        mCenterPosForText.Z = consoleText.gameObject.transform.position.z;

        mExtraTexts = new List<GameObject>();

        if (mColorOfText == null || mColorOfText.Comp(SharpMocha.BLACK))
        {
            mColorOfText = mDColorOfText;
        }

        mHeaderTextObj = ObjectFactory.getInstance().Instantiate(Common.nameForFixedWidthText);
        mHeaderTextObj.SetName("ConsoleHeaderText");
        Vector3 headerPos = mCenterPosForText;
        headerPos.X -= 3.3f; //-13.40, 26.8
        headerPos.Y += 1.8f;
        mHeaderTextObj.transform.SetPosition(headerPos);
        mHeaderFont = mHeaderTextObj.GetComponent<CFontRenderer>();
        mHeaderFont.mText = "";
        mHeaderFont.mJustification = CFontRenderer.FONT_JUSTIFICATION.LEFT_JUSTIFIED;

        ChangeHeader(defaultHeaderText);

        mNextMessageTimer = 0.0f;
        mMessageQueue = new LinkedList<Tuple<String, float, bool> >();
        QueueMessage("System Initializing...", 0.0f, false, false);
        QueueMessage("Enabling Camera Systems.", 0.7f, false, false);
        QueueMessage("Enabling Map Systems.", 0.4f, false, false);
        QueueMessage("Enabling Door Security Systems.", 0.3f, false, false);
        QueueMessage("System Ready.", 0.7f, false, false);

        mTextToDisplay.AddFirst("> ");
        UpdateConsoleTextFromQueue();
        hasConsoleTextChanged = 0;
    }
Example #3
0
    // Adds to the camInMap, camInMapArea, and camInWorld lists
    public static void AddCameraObjectToList(GameObject inCamInWorld, out GameObject retCamInMap, out GameObject retCamInMapArea)
    {
        // Ensure they are initialized
        GetCamsInMap();
        GetCamsInMapArea();
        GetCamsInWorld();

        retCamInMap = null;
        retCamInMapArea = null;

        if (inCamInWorld.GetName().StartsWith(nameForCamInWorld))
        {
            // Sort and change name based on CamInWorld (parent)'s name
            String camIndexStr1 = inCamInWorld.transform.GetParent().gameObject.GetName();
            camIndexStr1 = camIndexStr1.Substring(nameForCamInWorldParent.Length);
            int index = Convert.ToInt32(camIndexStr1);

            inCamInWorld.SetName(nameForCamInWorld + camIndexStr1);
            //String camIndexStr = inCamInWorld.GetName().Substring(nameForCamInWorld.Length);
            //int index = Convert.ToInt32(camIndexStr);

            camInWorld.Add(inCamInWorld);
            // Sort the physical CamInWorld# by name, so [0] == CamInMap1 and so on, with StickyCamInMap being the last
            camInWorld.Sort(CompareCamInWorld);

            retCamInMapArea = null;

            retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
            retCamInMap.SetName(nameForCamInMap + index.ToString());
            for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
            {
                if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                {
                    retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                    retCamInMapArea.SetName(nameForCamInMapArea + index.ToString());
                    camInMapArea.Add(retCamInMapArea);
                    break;
                }
            }
            retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());
            camInMap.Add(retCamInMap);
            camInMap.Sort(CompareCamInMap);

            camInMapArea.Sort(CompareCamInMapArea);
        }
        else
        {
            Logger.Log("Adding camera to list: name not normal: " + inCamInWorld.GetName());

            if (inCamInWorld.GetName() == nameForStickyCamInWorld)
            {
                stickCam = inCamInWorld;
                retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
                retCamInMap.SetName(nameForStickyCamInMap);
                for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
                {
                    if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                    {
                        retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                        retCamInMapArea.SetName(nameForStickyCamInMap + "Area");
                        stickCamInMapArea = retCamInMapArea;
                        break;
                    }
                }
                retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());

                stickCamInMap = retCamInMap;
            }
            else if (inCamInWorld.GetName() == nameForRCCarCamInWorld)
            {
                rcCarCam = inCamInWorld;
                retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
                retCamInMap.SetName(nameForRCCarCamInMap);
                for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
                {
                    if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
                    {
                        retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
                        retCamInMapArea.SetName(nameForRCCarCamInMap + "Area");
                        break;
                    }
                }
                retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());

                rcCarCamInMap = retCamInMap;
            }
        }
    }